chore: update frontend configuration
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
<template>
|
||||
<main class="container mx-auto px-6 py-8 space-y-8">
|
||||
|
||||
|
||||
<DocumentPreviewModal
|
||||
:document="previewDocument"
|
||||
:visible="previewVisible"
|
||||
@@ -20,7 +18,7 @@
|
||||
type="search"
|
||||
placeholder="Nom du document, type, site, machine..."
|
||||
class="input input-bordered w-full"
|
||||
/>
|
||||
>
|
||||
</div>
|
||||
|
||||
<div class="w-full md:w-1/3">
|
||||
@@ -28,19 +26,29 @@
|
||||
<span class="label-text">Filtrer par rattachement</span>
|
||||
</label>
|
||||
<select v-model="attachmentFilter" class="select select-bordered w-full">
|
||||
<option value="all">Tous</option>
|
||||
<option value="site">Sites</option>
|
||||
<option value="machine">Machines</option>
|
||||
<option value="composant">Composants</option>
|
||||
<option value="piece">Pièces</option>
|
||||
<option value="all">
|
||||
Tous
|
||||
</option>
|
||||
<option value="site">
|
||||
Sites
|
||||
</option>
|
||||
<option value="machine">
|
||||
Machines
|
||||
</option>
|
||||
<option value="composant">
|
||||
Composants
|
||||
</option>
|
||||
<option value="piece">
|
||||
Pièces
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="divider my-0"></div>
|
||||
<div class="divider my-0" />
|
||||
|
||||
<div v-if="loading" class="flex flex-col items-center justify-center py-16 text-sm text-gray-500">
|
||||
<span class="loading loading-spinner loading-lg mb-3"></span>
|
||||
<span class="loading loading-spinner loading-lg mb-3" />
|
||||
Chargement des documents...
|
||||
</div>
|
||||
|
||||
@@ -58,7 +66,9 @@
|
||||
<th>Taille</th>
|
||||
<th>Rattaché à</th>
|
||||
<th>Date</th>
|
||||
<th class="text-right">Actions</th>
|
||||
<th class="text-right">
|
||||
Actions
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -73,8 +83,12 @@
|
||||
/>
|
||||
</span>
|
||||
<div>
|
||||
<div class="font-semibold">{{ document.name }}</div>
|
||||
<div class="text-xs text-gray-500">{{ document.filename }}</div>
|
||||
<div class="font-semibold">
|
||||
{{ document.name }}
|
||||
</div>
|
||||
<div class="text-xs text-gray-500">
|
||||
{{ document.filename }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
@@ -124,7 +138,6 @@ import { formatFrenchDate } from '~/utils/date'
|
||||
import DocumentPreviewModal from '~/components/DocumentPreviewModal.vue'
|
||||
import IconLucideFileSearch from '~icons/lucide/file-search'
|
||||
|
||||
|
||||
const { documents, loading, loadDocuments } = useDocuments()
|
||||
|
||||
const searchTerm = ref('')
|
||||
@@ -148,9 +161,9 @@ const filteredDocuments = computed(() => {
|
||||
(filter === 'composant' && document.composantId) ||
|
||||
(filter === 'piece' && document.pieceId)
|
||||
|
||||
if (!matchesFilter) return false
|
||||
if (!matchesFilter) { return false }
|
||||
|
||||
if (!term) return true
|
||||
if (!term) { return true }
|
||||
|
||||
const searchable = [
|
||||
document.name,
|
||||
@@ -159,7 +172,7 @@ const filteredDocuments = computed(() => {
|
||||
document.site?.name,
|
||||
document.machine?.name,
|
||||
document.composant?.name,
|
||||
document.piece?.name,
|
||||
document.piece?.name
|
||||
]
|
||||
.filter(Boolean)
|
||||
.map(value => value.toLowerCase())
|
||||
@@ -169,18 +182,18 @@ const filteredDocuments = computed(() => {
|
||||
})
|
||||
|
||||
const formatSize = (size) => {
|
||||
if (size === undefined || size === null) return '—'
|
||||
if (size === 0) return '0 B'
|
||||
if (size === undefined || size === null) { return '—' }
|
||||
if (size === 0) { return '0 B' }
|
||||
const units = ['B', 'KB', 'MB', 'GB']
|
||||
const index = Math.min(units.length - 1, Math.floor(Math.log(size) / Math.log(1024)))
|
||||
const formatted = size / Math.pow(1024, index)
|
||||
return `${formatted.toFixed(1)} ${units[index]}`
|
||||
}
|
||||
|
||||
const documentIcon = (doc) => getFileIcon({ name: doc.filename || doc.name, mime: doc.mimeType })
|
||||
const documentIcon = doc => getFileIcon({ name: doc.filename || doc.name, mime: doc.mimeType })
|
||||
|
||||
const downloadDocument = (doc) => {
|
||||
if (!doc?.path) return
|
||||
if (!doc?.path) { return }
|
||||
|
||||
if (doc.path.startsWith('data:')) {
|
||||
const link = document.createElement('a')
|
||||
@@ -194,7 +207,7 @@ const downloadDocument = (doc) => {
|
||||
}
|
||||
|
||||
const openPreview = (doc) => {
|
||||
if (!canPreviewDocument(doc)) return
|
||||
if (!canPreviewDocument(doc)) { return }
|
||||
previewDocument.value = doc
|
||||
previewVisible.value = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user