Speed up initial file listing
This commit is contained in:
@@ -77,7 +77,10 @@ export const useFiles = () => {
|
|||||||
const selectDocument = async (id) => {
|
const selectDocument = async (id) => {
|
||||||
let documentIds = [id]
|
let documentIds = [id]
|
||||||
if(documentIds.length === 0) return []
|
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",{
|
const res = await useNuxtApp().$api("/api/files/presigned",{
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: {
|
body: {
|
||||||
|
|||||||
@@ -63,20 +63,24 @@ watch(searchString, (val) => {
|
|||||||
const setupPage = async () => {
|
const setupPage = async () => {
|
||||||
loadingDocs.value = true
|
loadingDocs.value = true
|
||||||
try {
|
try {
|
||||||
const [fRes, dRes, tRes] = await Promise.all([
|
const [fRes, dRes] = await Promise.all([
|
||||||
useEntities("folders").select(),
|
useEntities("folders").select(),
|
||||||
files.selectDocuments(),
|
useEntities("files").select("id, path, folder, type, createdAt")
|
||||||
useEntities("filetags").select()
|
|
||||||
])
|
])
|
||||||
folders.value = fRes || []
|
folders.value = fRes || []
|
||||||
documents.value = dRes || []
|
documents.value = dRes || []
|
||||||
filetags.value = tRes || []
|
|
||||||
|
|
||||||
syncCurrentFolderFromRoute()
|
syncCurrentFolderFromRoute()
|
||||||
} finally {
|
} finally {
|
||||||
loadingDocs.value = false
|
loadingDocs.value = false
|
||||||
loaded.value = true
|
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) ---
|
// --- Global Drag & Drop (Auto-Open Upload Modal) ---
|
||||||
@@ -323,11 +327,22 @@ const updateName = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const showFile = (fileId) => {
|
const showFile = async (fileId) => {
|
||||||
modal.open(DocumentDisplayModal, {
|
loadingDocs.value = true
|
||||||
documentData: documents.value.find(i => i.id === fileId),
|
try {
|
||||||
onUpdatedNeeded: () => setupPage()
|
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 = () => {
|
const openScanModal = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user