Speed up initial file listing

This commit is contained in:
2026-08-09 17:38:17 +02:00
parent 7d3e9a383f
commit 17717e8a1b
2 changed files with 28 additions and 10 deletions

View File

@@ -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: {

View File

@@ -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) => {
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: documents.value.find(i => i.id === fileId),
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 = () => {