folder-grid: do query in timeline
Signed-off-by: Varun Patil <varunpatil@ucla.edu>pull/563/head
parent
d1c012edab
commit
558e0bf13f
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="grid" v-if="items.length">
|
<div class="grid">
|
||||||
<div class="grid-item fill-block" v-for="item of items" :key="item.fileid">
|
<div class="item fill-block" v-for="item of items" :key="item.fileid">
|
||||||
<Folder :data="item" />
|
<Folder :data="item" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -9,14 +9,10 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from "vue";
|
import { defineComponent } from "vue";
|
||||||
|
|
||||||
import axios from "@nextcloud/axios";
|
|
||||||
|
|
||||||
import UserConfig from "../mixins/UserConfig";
|
import UserConfig from "../mixins/UserConfig";
|
||||||
import Folder from "./frame/Folder.vue";
|
import Folder from "./frame/Folder.vue";
|
||||||
|
|
||||||
import * as utils from "../services/Utils";
|
|
||||||
import { IFolder } from "../types";
|
import { IFolder } from "../types";
|
||||||
import { API } from "../services/API";
|
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "ClusterGrid",
|
name: "ClusterGrid",
|
||||||
|
@ -27,46 +23,10 @@ export default defineComponent({
|
||||||
|
|
||||||
mixins: [UserConfig],
|
mixins: [UserConfig],
|
||||||
|
|
||||||
data: () => ({
|
props: {
|
||||||
items: [] as IFolder[],
|
items: {
|
||||||
path: "",
|
type: Array<IFolder>,
|
||||||
}),
|
required: true,
|
||||||
|
|
||||||
mounted() {
|
|
||||||
this.refresh();
|
|
||||||
},
|
|
||||||
|
|
||||||
watch: {
|
|
||||||
$route() {
|
|
||||||
this.items = [];
|
|
||||||
this.refresh();
|
|
||||||
},
|
|
||||||
config_showHidden() {
|
|
||||||
this.refresh();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
async refresh() {
|
|
||||||
// Get folder path
|
|
||||||
const folder = (this.path = utils.getFolderRoutePath(
|
|
||||||
this.config_foldersPath
|
|
||||||
));
|
|
||||||
|
|
||||||
// Get subfolders for this folder
|
|
||||||
const res = await axios.get<IFolder[]>(
|
|
||||||
API.Q(API.FOLDERS_SUB(), { folder })
|
|
||||||
);
|
|
||||||
if (folder !== this.path) return;
|
|
||||||
this.items = res.data;
|
|
||||||
this.$emit("load", this.items);
|
|
||||||
|
|
||||||
// Filter out hidden folders
|
|
||||||
if (!this.config_showHidden) {
|
|
||||||
this.items = this.items.filter(
|
|
||||||
(f) => !f.name.startsWith(".") && f.previews.length
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -82,7 +42,7 @@ export default defineComponent({
|
||||||
width: calc(100% - 2px); // compensation for negative margin
|
width: calc(100% - 2px); // compensation for negative margin
|
||||||
}
|
}
|
||||||
|
|
||||||
.grid-item {
|
> .item {
|
||||||
aspect-ratio: 1 / 1;
|
aspect-ratio: 1 / 1;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,10 +37,7 @@
|
||||||
>
|
>
|
||||||
</OnThisDay>
|
</OnThisDay>
|
||||||
|
|
||||||
<FolderGrid
|
<FolderGrid v-if="folders.length" :items="folders" />
|
||||||
v-if="routeIsFolders && !$route.query.recursive"
|
|
||||||
@load="scrollerManager.adjust()"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -122,7 +119,7 @@ import { showError } from "@nextcloud/dialogs";
|
||||||
import { subscribe, unsubscribe } from "@nextcloud/event-bus";
|
import { subscribe, unsubscribe } from "@nextcloud/event-bus";
|
||||||
|
|
||||||
import { getLayout } from "../services/Layout";
|
import { getLayout } from "../services/Layout";
|
||||||
import { IDay, IHeadRow, IPhoto, IRow, IRowType } from "../types";
|
import { IDay, IFolder, IHeadRow, IPhoto, IRow, IRowType } from "../types";
|
||||||
|
|
||||||
import UserConfig from "../mixins/UserConfig";
|
import UserConfig from "../mixins/UserConfig";
|
||||||
import FolderGrid from "./FolderGrid.vue";
|
import FolderGrid from "./FolderGrid.vue";
|
||||||
|
@ -169,6 +166,8 @@ export default defineComponent({
|
||||||
loading: 0,
|
loading: 0,
|
||||||
/** Main list of rows */
|
/** Main list of rows */
|
||||||
list: [] as IRow[],
|
list: [] as IRow[],
|
||||||
|
/** List of top folders */
|
||||||
|
folders: [] as IFolder[],
|
||||||
/** Computed number of columns */
|
/** Computed number of columns */
|
||||||
numCols: 0,
|
numCols: 0,
|
||||||
/** Header rows for dayId key */
|
/** Header rows for dayId key */
|
||||||
|
@ -265,7 +264,7 @@ export default defineComponent({
|
||||||
|
|
||||||
/** Nothing to show here */
|
/** Nothing to show here */
|
||||||
empty(): boolean {
|
empty(): boolean {
|
||||||
return !this.list.length && !this.routeIsFolders;
|
return !this.list.length && !this.folders.length;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -372,6 +371,7 @@ export default defineComponent({
|
||||||
this.selectionManager.clearSelection();
|
this.selectionManager.clearSelection();
|
||||||
this.loading = 0;
|
this.loading = 0;
|
||||||
this.list = [];
|
this.list = [];
|
||||||
|
this.folders = [];
|
||||||
this.heads = {};
|
this.heads = {};
|
||||||
this.currentStart = 0;
|
this.currentStart = 0;
|
||||||
this.currentEnd = 0;
|
this.currentEnd = 0;
|
||||||
|
@ -659,8 +659,42 @@ export default defineComponent({
|
||||||
return head.name;
|
return head.name;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** Fetch folders */
|
||||||
|
async fetchFolders() {
|
||||||
|
if (!this.routeIsFolders || this.$route.query.recursive) {
|
||||||
|
this.folders = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get subfolders URL
|
||||||
|
const folder = utils.getFolderRoutePath(this.config_foldersPath);
|
||||||
|
const url = API.Q(API.FOLDERS_SUB(), { folder });
|
||||||
|
|
||||||
|
// Make API call to get subfolders
|
||||||
|
try {
|
||||||
|
this.loading++;
|
||||||
|
const state = this.state;
|
||||||
|
const res = await axios.get<IFolder[]>(url);
|
||||||
|
if (state !== this.state) return;
|
||||||
|
this.folders = res.data;
|
||||||
|
} finally {
|
||||||
|
this.loading--;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter out hidden folders
|
||||||
|
if (!this.config_showHidden) {
|
||||||
|
this.folders = this.folders.filter(
|
||||||
|
(f) => !f.name.startsWith(".") && f.previews.length
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/** Fetch timeline main call */
|
/** Fetch timeline main call */
|
||||||
async fetchDays(noCache = false) {
|
async fetchDays(noCache = false) {
|
||||||
|
// Get top folders if route
|
||||||
|
await this.fetchFolders();
|
||||||
|
|
||||||
|
// Get URL an cache identifier
|
||||||
const url = API.Q(API.DAYS(), this.getQuery());
|
const url = API.Q(API.DAYS(), this.getQuery());
|
||||||
const cacheUrl = <string>this.$route.name + url;
|
const cacheUrl = <string>this.$route.name + url;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue