From 17717e8a1b2a34721198b54a8e69862b63576b45 Mon Sep 17 00:00:00 2001 From: flfeders Date: Sun, 9 Aug 2026 17:38:17 +0200 Subject: [PATCH] Speed up initial file listing --- frontend/composables/useFiles.ts | 5 ++++- frontend/pages/files/index.vue | 33 +++++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/frontend/composables/useFiles.ts b/frontend/composables/useFiles.ts index edc4fc0..cd61936 100644 --- a/frontend/composables/useFiles.ts +++ b/frontend/composables/useFiles.ts @@ -77,7 +77,10 @@ export const useFiles = () => { const selectDocument = async (id) => { let documentIds = [id] if(documentIds.length === 0) return [] - const fileData = await useEntities("files").selectSingle(id) + const fileData = await useEntities("files").selectSingle( + id, + "*, incominginvoice(*), project(*), vendor(*), customer(*), contract(*), plant(*), createddocument(*), vehicle(*), product(*), profile(*), check(*), inventoryitem(*)" + ) const res = await useNuxtApp().$api("/api/files/presigned",{ method: "POST", body: { diff --git a/frontend/pages/files/index.vue b/frontend/pages/files/index.vue index ee60d5a..b17aeb3 100644 --- a/frontend/pages/files/index.vue +++ b/frontend/pages/files/index.vue @@ -63,20 +63,24 @@ watch(searchString, (val) => { const setupPage = async () => { loadingDocs.value = true try { - const [fRes, dRes, tRes] = await Promise.all([ + const [fRes, dRes] = await Promise.all([ useEntities("folders").select(), - files.selectDocuments(), - useEntities("filetags").select() + useEntities("files").select("id, path, folder, type, createdAt") ]) folders.value = fRes || [] documents.value = dRes || [] - filetags.value = tRes || [] syncCurrentFolderFromRoute() } finally { loadingDocs.value = false loaded.value = true } + + useEntities("filetags").select() + .then((items) => { + filetags.value = items || [] + }) + .catch((error) => console.error("Dateitypen konnten nicht geladen werden:", error)) } // --- Global Drag & Drop (Auto-Open Upload Modal) --- @@ -323,11 +327,22 @@ const updateName = async () => { } } -const showFile = (fileId) => { - modal.open(DocumentDisplayModal, { - documentData: documents.value.find(i => i.id === fileId), - onUpdatedNeeded: () => setupPage() - }) +const showFile = async (fileId) => { + loadingDocs.value = true + try { + const documentData = await files.selectDocument(fileId) + if (!documentData) throw new Error("Datei nicht gefunden") + + modal.open(DocumentDisplayModal, { + documentData, + onUpdatedNeeded: () => setupPage() + }) + } catch (error) { + console.error(error) + toast.add({title: 'Datei konnte nicht geƶffnet werden', color: 'red'}) + } finally { + loadingDocs.value = false + } } const openScanModal = () => {