@@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, watch, onMounted } from 'vue';
|
import {ref, computed, watch, onMounted, onUnmounted} from 'vue';
|
||||||
import DocumentDisplayModal from "~/components/DocumentDisplayModal.vue";
|
import DocumentDisplayModal from "~/components/DocumentDisplayModal.vue";
|
||||||
import DocumentUploadModal from "~/components/DocumentUploadModal.vue";
|
import DocumentUploadModal from "~/components/DocumentUploadModal.vue";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
@@ -11,7 +11,7 @@ const router = useRouter()
|
|||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const modal = useModal()
|
const modal = useModal()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
const { $api } = useNuxtApp()
|
const {$api} = useNuxtApp()
|
||||||
const files = useFiles()
|
const files = useFiles()
|
||||||
|
|
||||||
// --- State ---
|
// --- State ---
|
||||||
@@ -23,14 +23,14 @@ const loadingDocs = ref(true)
|
|||||||
const loaded = ref(false)
|
const loaded = ref(false)
|
||||||
const displayMode = ref("list")
|
const displayMode = ref("list")
|
||||||
const displayModes = [
|
const displayModes = [
|
||||||
{ label: 'Liste', key: 'list', icon: 'i-heroicons-list-bullet' },
|
{label: 'Liste', key: 'list', icon: 'i-heroicons-list-bullet'},
|
||||||
{ label: 'Kacheln', key: 'rectangles', icon: 'i-heroicons-squares-2x2' }
|
{label: 'Kacheln', key: 'rectangles', icon: 'i-heroicons-squares-2x2'}
|
||||||
]
|
]
|
||||||
|
|
||||||
const createFolderModalOpen = ref(false)
|
const createFolderModalOpen = ref(false)
|
||||||
const createFolderData = ref({ name: '', standardFiletype: null, standardFiletypeIsOptional: true })
|
const createFolderData = ref({name: '', standardFiletype: null, standardFiletypeIsOptional: true})
|
||||||
const renameModalOpen = ref(false)
|
const renameModalOpen = ref(false)
|
||||||
const renameData = ref({ id: null, name: '', type: '' })
|
const renameData = ref({id: null, name: '', type: ''})
|
||||||
|
|
||||||
const selectedFileIndex = ref(0)
|
const selectedFileIndex = ref(0)
|
||||||
const draggedItem = ref(null)
|
const draggedItem = ref(null)
|
||||||
@@ -72,7 +72,61 @@ const setupPage = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => setupPage())
|
// --- Global Drag & Drop (Auto-Open Upload Modal) ---
|
||||||
|
let dragCounter = 0
|
||||||
|
|
||||||
|
const handleGlobalDragEnter = (e) => {
|
||||||
|
dragCounter++
|
||||||
|
|
||||||
|
// 1. Abbrechen, wenn wir gerade intern Ordner/Dateien verschieben
|
||||||
|
if (draggedItem.value) return
|
||||||
|
|
||||||
|
// 2. Prüfen ob Files von außen kommen
|
||||||
|
if (e.dataTransfer && e.dataTransfer.types && e.dataTransfer.types.includes('Files')) {
|
||||||
|
// Modal öffnen, falls noch nicht offen (optionaler Check, useModal handhabt das meist selbst)
|
||||||
|
// Wir übergeben den aktuellen Ordner
|
||||||
|
modal.open(DocumentUploadModal, {
|
||||||
|
fileData: {folder: currentFolder.value?.id, typeEnabled: true},
|
||||||
|
onUploadFinished: () => {
|
||||||
|
setupPage()
|
||||||
|
dragCounter = 0
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleGlobalDragLeave = (e) => {
|
||||||
|
dragCounter--
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleGlobalDrop = (e) => {
|
||||||
|
dragCounter = 0
|
||||||
|
// Verhindert, dass der Browser die Datei öffnet, falls man neben das Modal droppt
|
||||||
|
e.preventDefault()
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleGlobalDragOver = (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
setupPage()
|
||||||
|
|
||||||
|
// Globale Listener registrieren
|
||||||
|
window.addEventListener('dragenter', handleGlobalDragEnter)
|
||||||
|
window.addEventListener('dragleave', handleGlobalDragLeave)
|
||||||
|
window.addEventListener('dragover', handleGlobalDragOver)
|
||||||
|
window.addEventListener('drop', handleGlobalDrop)
|
||||||
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
// Aufräumen
|
||||||
|
window.removeEventListener('dragenter', handleGlobalDragEnter)
|
||||||
|
window.removeEventListener('dragleave', handleGlobalDragLeave)
|
||||||
|
window.removeEventListener('dragover', handleGlobalDragOver)
|
||||||
|
window.removeEventListener('drop', handleGlobalDrop)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
// --- Navigation ---
|
// --- Navigation ---
|
||||||
const changeFolder = async (folder) => {
|
const changeFolder = async (folder) => {
|
||||||
@@ -86,7 +140,7 @@ const navigateUp = () => {
|
|||||||
changeFolder(parent || null)
|
changeFolder(parent || null)
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Drag & Drop ---
|
// --- Drag & Drop (Internal Sort) ---
|
||||||
const handleDragStart = (entry) => {
|
const handleDragStart = (entry) => {
|
||||||
draggedItem.value = entry
|
draggedItem.value = entry
|
||||||
}
|
}
|
||||||
@@ -99,14 +153,14 @@ const handleDrop = async (targetFolderId) => {
|
|||||||
loadingDocs.value = true
|
loadingDocs.value = true
|
||||||
try {
|
try {
|
||||||
if (draggedItem.value.type === 'file') {
|
if (draggedItem.value.type === 'file') {
|
||||||
await useEntities("files").update(draggedItem.value.id, { folder: targetFolderId })
|
await useEntities("files").update(draggedItem.value.id, {folder: targetFolderId})
|
||||||
} else {
|
} else {
|
||||||
await useEntities("folders").update(draggedItem.value.id, { parent: targetFolderId })
|
await useEntities("folders").update(draggedItem.value.id, {parent: targetFolderId})
|
||||||
}
|
}
|
||||||
toast.add({ title: 'Erfolgreich verschoben', icon: 'i-heroicons-check-circle', color: 'green' })
|
toast.add({title: 'Erfolgreich verschoben', icon: 'i-heroicons-check-circle', color: 'green'})
|
||||||
await setupPage()
|
await setupPage()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toast.add({ title: 'Fehler beim Verschieben', color: 'red' })
|
toast.add({title: 'Fehler beim Verschieben', color: 'red'})
|
||||||
} finally {
|
} finally {
|
||||||
draggedItem.value = null
|
draggedItem.value = null
|
||||||
loadingDocs.value = false
|
loadingDocs.value = false
|
||||||
@@ -115,7 +169,7 @@ const handleDrop = async (targetFolderId) => {
|
|||||||
|
|
||||||
// --- Breadcrumbs ---
|
// --- Breadcrumbs ---
|
||||||
const breadcrumbLinks = computed(() => {
|
const breadcrumbLinks = computed(() => {
|
||||||
const links = [{ label: "Home", icon: "i-heroicons-home", click: () => changeFolder(null) }]
|
const links = [{label: "Home", icon: "i-heroicons-home", click: () => changeFolder(null)}]
|
||||||
if (currentFolder.value) {
|
if (currentFolder.value) {
|
||||||
const path = []
|
const path = []
|
||||||
let curr = currentFolder.value
|
let curr = currentFolder.value
|
||||||
@@ -138,13 +192,13 @@ const renderedFileList = computed(() => {
|
|||||||
// 1. Aktuelle Ordner filtern
|
// 1. Aktuelle Ordner filtern
|
||||||
const folderList = folders.value
|
const folderList = folders.value
|
||||||
.filter(i => currentFolder.value ? i.parent === currentFolder.value.id : !i.parent)
|
.filter(i => currentFolder.value ? i.parent === currentFolder.value.id : !i.parent)
|
||||||
.map(i => ({ ...i, label: i.name, type: "folder" }))
|
.map(i => ({...i, label: i.name, type: "folder"}))
|
||||||
.sort((a, b) => a.label.localeCompare(b.label))
|
.sort((a, b) => a.label.localeCompare(b.label))
|
||||||
|
|
||||||
// 2. Aktuelle Dateien filtern
|
// 2. Aktuelle Dateien filtern
|
||||||
const fileList = documents.value
|
const fileList = documents.value
|
||||||
.filter(i => currentFolder.value ? i.folder === currentFolder.value.id : !i.folder)
|
.filter(i => currentFolder.value ? i.folder === currentFolder.value.id : !i.folder)
|
||||||
.map(i => ({ ...i, label: i.path.split("/").pop(), type: "file" }))
|
.map(i => ({...i, label: i.path.split("/").pop(), type: "file"}))
|
||||||
.sort((a, b) => a.label.localeCompare(b.label))
|
.sort((a, b) => a.label.localeCompare(b.label))
|
||||||
|
|
||||||
let combined = [...folderList, ...fileList]
|
let combined = [...folderList, ...fileList]
|
||||||
@@ -172,12 +226,12 @@ const createFolder = async () => {
|
|||||||
name: createFolderData.value.name
|
name: createFolderData.value.name
|
||||||
})
|
})
|
||||||
createFolderModalOpen.value = false
|
createFolderModalOpen.value = false
|
||||||
createFolderData.value = { name: '' }
|
createFolderData.value = {name: ''}
|
||||||
setupPage()
|
setupPage()
|
||||||
}
|
}
|
||||||
|
|
||||||
const openRenameModal = (entry) => {
|
const openRenameModal = (entry) => {
|
||||||
renameData.value = { id: entry.id, name: entry.label, type: entry.type }
|
renameData.value = {id: entry.id, name: entry.label, type: entry.type}
|
||||||
renameModalOpen.value = true
|
renameModalOpen.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,14 +240,14 @@ const updateName = async () => {
|
|||||||
loadingDocs.value = true
|
loadingDocs.value = true
|
||||||
try {
|
try {
|
||||||
if (renameData.value.type === 'folder') {
|
if (renameData.value.type === 'folder') {
|
||||||
await useEntities("folders").update(renameData.value.id, { name: renameData.value.name })
|
await useEntities("folders").update(renameData.value.id, {name: renameData.value.name})
|
||||||
} else {
|
} else {
|
||||||
const file = documents.value.find(d => d.id === renameData.value.id)
|
const file = documents.value.find(d => d.id === renameData.value.id)
|
||||||
const pathParts = file.path.split('/')
|
const pathParts = file.path.split('/')
|
||||||
pathParts[pathParts.length - 1] = renameData.value.name
|
pathParts[pathParts.length - 1] = renameData.value.name
|
||||||
await useEntities("files").update(renameData.value.id, { path: pathParts.join('/') })
|
await useEntities("files").update(renameData.value.id, {path: pathParts.join('/')})
|
||||||
}
|
}
|
||||||
toast.add({ title: 'Umbenannt', color: 'green' })
|
toast.add({title: 'Umbenannt', color: 'green'})
|
||||||
setupPage()
|
setupPage()
|
||||||
} finally {
|
} finally {
|
||||||
renameModalOpen.value = false
|
renameModalOpen.value = false
|
||||||
@@ -220,8 +274,12 @@ defineShortcuts({
|
|||||||
else if (entry.type === "up") navigateUp()
|
else if (entry.type === "up") navigateUp()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'arrowdown': () => { if (selectedFileIndex.value < renderedFileList.value.length - 1) selectedFileIndex.value++ },
|
'arrowdown': () => {
|
||||||
'arrowup': () => { if (selectedFileIndex.value > 0) selectedFileIndex.value-- }
|
if (selectedFileIndex.value < renderedFileList.value.length - 1) selectedFileIndex.value++
|
||||||
|
},
|
||||||
|
'arrowup': () => {
|
||||||
|
if (selectedFileIndex.value > 0) selectedFileIndex.value--
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const isSyncing = ref(false)
|
const isSyncing = ref(false)
|
||||||
@@ -229,7 +287,7 @@ const isSyncing = ref(false)
|
|||||||
const syncdokubox = async () => {
|
const syncdokubox = async () => {
|
||||||
isSyncing.value = true
|
isSyncing.value = true
|
||||||
try {
|
try {
|
||||||
await $api('/api/functions/services/syncdokubox', { method: 'POST' })
|
await $api('/api/functions/services/syncdokubox', {method: 'POST'})
|
||||||
|
|
||||||
toast.add({
|
toast.add({
|
||||||
title: 'Erfolg',
|
title: 'Erfolg',
|
||||||
@@ -267,30 +325,37 @@ const syncdokubox = async () => {
|
|||||||
@click="syncdokubox"
|
@click="syncdokubox"
|
||||||
class="mr-2"
|
class="mr-2"
|
||||||
/>
|
/>
|
||||||
<UInput id="searchinput" v-model="searchString" icon="i-heroicons-magnifying-glass" placeholder="Suche..." class="w-64" />
|
<UInput id="searchinput" v-model="searchString" icon="i-heroicons-magnifying-glass" placeholder="Suche..."
|
||||||
|
class="w-64"/>
|
||||||
</template>
|
</template>
|
||||||
</UDashboardNavbar>
|
</UDashboardNavbar>
|
||||||
|
|
||||||
<UDashboardToolbar class="sticky top-0 z-30 bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-800">
|
<UDashboardToolbar class="sticky top-0 z-30 bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-800">
|
||||||
<template #left>
|
<template #left>
|
||||||
<UBreadcrumb :links="breadcrumbLinks" />
|
<UBreadcrumb :links="breadcrumbLinks"/>
|
||||||
</template>
|
</template>
|
||||||
<template #right>
|
<template #right>
|
||||||
<USelectMenu v-model="displayMode" :options="displayModes" value-attribute="key" class="w-32" :ui-menu="{ zIndex: 'z-50' }">
|
<USelectMenu v-model="displayMode" :options="displayModes" value-attribute="key" class="w-32"
|
||||||
|
:ui-menu="{ zIndex: 'z-50' }">
|
||||||
<template #label>
|
<template #label>
|
||||||
<UIcon :name="displayModes.find(i => i.key === displayMode).icon" class="w-4 h-4" />
|
<UIcon :name="displayModes.find(i => i.key === displayMode).icon" class="w-4 h-4"/>
|
||||||
<span>{{ displayModes.find(i => i.key === displayMode).label }}</span>
|
<span>{{ displayModes.find(i => i.key === displayMode).label }}</span>
|
||||||
</template>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
<UButtonGroup size="sm">
|
<UButtonGroup size="sm">
|
||||||
<UButton icon="i-heroicons-document-plus" color="primary" @click="modal.open(DocumentUploadModal, { fileData: { folder: currentFolder?.id }, onUploadFinished: setupPage })">Datei</UButton>
|
<UButton icon="i-heroicons-document-plus" color="primary"
|
||||||
|
@click="modal.open(DocumentUploadModal, { fileData: { folder: currentFolder?.id }, onUploadFinished: setupPage })">
|
||||||
|
Datei
|
||||||
|
</UButton>
|
||||||
<UButton icon="i-heroicons-folder-plus" color="white" @click="createFolderModalOpen = true">Ordner</UButton>
|
<UButton icon="i-heroicons-folder-plus" color="white" @click="createFolderModalOpen = true">Ordner</UButton>
|
||||||
</UButtonGroup>
|
</UButtonGroup>
|
||||||
</template>
|
</template>
|
||||||
</UDashboardToolbar>
|
</UDashboardToolbar>
|
||||||
|
|
||||||
<UDashboardPanelContent class="p-0 overflow-y-auto">
|
<UDashboardPanelContent class="p-0 overflow-y-auto">
|
||||||
<div v-if="!loaded" class="p-10 flex justify-center"><UProgress animation="carousel" class="w-1/2" /></div>
|
<div v-if="!loaded" class="p-10 flex justify-center">
|
||||||
|
<UProgress animation="carousel" class="w-1/2"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<div v-if="displayMode === 'list'">
|
<div v-if="displayMode === 'list'">
|
||||||
@@ -327,8 +392,9 @@ const syncdokubox = async () => {
|
|||||||
{{ entry.type !== 'up' ? dayjs(entry.createdAt).format("DD.MM.YY") : '-' }}
|
{{ entry.type !== 'up' ? dayjs(entry.createdAt).format("DD.MM.YY") : '-' }}
|
||||||
</td>
|
</td>
|
||||||
<td class="px-3 text-right" @click.stop>
|
<td class="px-3 text-right" @click.stop>
|
||||||
<UDropdown v-if="entry.type !== 'up'" :items="[[{ label: 'Umbenennen', icon: 'i-heroicons-pencil-square', click: () => openRenameModal(entry) }]]">
|
<UDropdown v-if="entry.type !== 'up'"
|
||||||
<UButton color="gray" variant="ghost" icon="i-heroicons-ellipsis-horizontal" />
|
:items="[[{ label: 'Umbenennen', icon: 'i-heroicons-pencil-square', click: () => openRenameModal(entry) }]]">
|
||||||
|
<UButton color="gray" variant="ghost" icon="i-heroicons-ellipsis-horizontal"/>
|
||||||
</UDropdown>
|
</UDropdown>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -346,8 +412,10 @@ const syncdokubox = async () => {
|
|||||||
class="group relative bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-4 flex flex-col items-center hover:border-primary-500 transition-all cursor-pointer"
|
class="group relative bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-4 flex flex-col items-center hover:border-primary-500 transition-all cursor-pointer"
|
||||||
@click="entry.type === 'folder' ? changeFolder(entry) : (entry.type === 'up' ? navigateUp() : showFile(entry.id))"
|
@click="entry.type === 'folder' ? changeFolder(entry) : (entry.type === 'up' ? navigateUp() : showFile(entry.id))"
|
||||||
>
|
>
|
||||||
<UDropdown v-if="entry.type !== 'up'" :items="[[{ label: 'Umbenennen', icon: 'i-heroicons-pencil-square', click: () => openRenameModal(entry) }]]" class="absolute top-1 right-1 opacity-0 group-hover:opacity-100" @click.stop>
|
<UDropdown v-if="entry.type !== 'up'"
|
||||||
<UButton color="gray" variant="ghost" icon="i-heroicons-ellipsis-vertical" size="xs" />
|
:items="[[{ label: 'Umbenennen', icon: 'i-heroicons-pencil-square', click: () => openRenameModal(entry) }]]"
|
||||||
|
class="absolute top-1 right-1 opacity-0 group-hover:opacity-100" @click.stop>
|
||||||
|
<UButton color="gray" variant="ghost" icon="i-heroicons-ellipsis-vertical" size="xs"/>
|
||||||
</UDropdown>
|
</UDropdown>
|
||||||
<UIcon
|
<UIcon
|
||||||
:name="entry.type === 'up' ? 'i-heroicons-arrow-uturn-left' : (entry.type === 'folder' ? 'i-heroicons-folder-solid' : 'i-heroicons-document-text')"
|
:name="entry.type === 'up' ? 'i-heroicons-arrow-uturn-left' : (entry.type === 'folder' ? 'i-heroicons-folder-solid' : 'i-heroicons-document-text')"
|
||||||
@@ -363,16 +431,30 @@ const syncdokubox = async () => {
|
|||||||
<UModal v-model="createFolderModalOpen">
|
<UModal v-model="createFolderModalOpen">
|
||||||
<UCard>
|
<UCard>
|
||||||
<template #header><h3 class="font-bold">Ordner erstellen</h3></template>
|
<template #header><h3 class="font-bold">Ordner erstellen</h3></template>
|
||||||
<UFormGroup label="Name" required><UInput v-model="createFolderData.name" autofocus @keyup.enter="createFolder" /></UFormGroup>
|
<UFormGroup label="Name" required>
|
||||||
<template #footer><div class="flex justify-end gap-2"><UButton color="gray" @click="createFolderModalOpen = false">Abbrechen</UButton><UButton color="primary" @click="createFolder">Erstellen</UButton></div></template>
|
<UInput v-model="createFolderData.name" autofocus @keyup.enter="createFolder"/>
|
||||||
|
</UFormGroup>
|
||||||
|
<template #footer>
|
||||||
|
<div class="flex justify-end gap-2">
|
||||||
|
<UButton color="gray" @click="createFolderModalOpen = false">Abbrechen</UButton>
|
||||||
|
<UButton color="primary" @click="createFolder">Erstellen</UButton>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</UCard>
|
</UCard>
|
||||||
</UModal>
|
</UModal>
|
||||||
|
|
||||||
<UModal v-model="renameModalOpen">
|
<UModal v-model="renameModalOpen">
|
||||||
<UCard>
|
<UCard>
|
||||||
<template #header><h3 class="font-bold">Umbenennen</h3></template>
|
<template #header><h3 class="font-bold">Umbenennen</h3></template>
|
||||||
<UFormGroup label="Neuer Name"><UInput v-model="renameData.name" autofocus @keyup.enter="updateName" /></UFormGroup>
|
<UFormGroup label="Neuer Name">
|
||||||
<template #footer><div class="flex justify-end gap-2"><UButton color="gray" @click="renameModalOpen = false">Abbrechen</UButton><UButton color="primary" @click="updateName">Speichern</UButton></div></template>
|
<UInput v-model="renameData.name" autofocus @keyup.enter="updateName"/>
|
||||||
|
</UFormGroup>
|
||||||
|
<template #footer>
|
||||||
|
<div class="flex justify-end gap-2">
|
||||||
|
<UButton color="gray" @click="renameModalOpen = false">Abbrechen</UButton>
|
||||||
|
<UButton color="primary" @click="updateName">Speichern</UButton>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</UCard>
|
</UCard>
|
||||||
</UModal>
|
</UModal>
|
||||||
</template>
|
</template>
|
||||||
Reference in New Issue
Block a user