π The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.
Vue dockergolangkanbanknowledge-baseknowledge-managementmarkdownnote-takingnotesnotes-appnotionnuxtnuxtjsoffline-firstoidcpwaselfhostedssovuevuejswiki
New bulk action: delete
Smaug6739622897c6982c
diff --git a/frontend/app/pages/dashboard/cdn/_modals/DeleteRessourceModal.vue b/frontend/app/pages/dashboard/cdn/_modals/DeleteRessourceModal.vueindex e7a4156c..1ecd6285 100644--- a/frontend/app/pages/dashboard/cdn/_modals/DeleteRessourceModal.vue+++ b/frontend/app/pages/dashboard/cdn/_modals/DeleteRessourceModal.vue@@ -1,7 +1,12 @@<template><div class="modal">- <h3>Delete ressource</h3>- <p>Are you sure you want to delete this ressource ?</p>+ <h3>Delete {{ ressources.length > 1 ? 'ressources' : 'ressource' }}</h3>+ <p>+ Are you sure you want to delete the selected {{ ressources.length > 1 ? 'ressources' : 'ressource' }}? <br />+ <span v-if="ressources.length > 1"+ >This action will delete <strong>{{ ressources.length }}</strong> ressources.</span+ >+ </p><p style="opacity: 0.7">This action is irreversible</p><div class="footer"><AppButton type="secondary" @click="emit('close')">Cancel</AppButton>@@ -11,16 +16,17 @@</template><script setup lang="ts">-const props = defineProps<{ ressourceId: string }>();+const props = defineProps<{ ressources: string[] }>();const emit = defineEmits(['close']);const deleteRessource = async () => {- await useRessourcesStore()- .delete(props.ressourceId)- .then(() => {- useNotifications().add({ type: 'success', title: 'Ressource deleted successfully' });- emit('close');- useRouter().push('/dashboard/cdn');- })- .catch(e => useNotifications().add({ type: 'error', title: 'Error', message: e }));+ for (const ressourceId of props.ressources) {+ await useRessourcesStore()+ .delete(ressourceId)+ .then(() => {+ emit('close');+ useRouter().push('/dashboard/cdn');+ })+ .catch(e => useNotifications().add({ type: 'error', title: 'Error', message: e }));+ }};</script>diff --git a/frontend/app/pages/dashboard/cdn/index.vue b/frontend/app/pages/dashboard/cdn/index.vueindex 93108578..92404450 100644--- a/frontend/app/pages/dashboard/cdn/index.vue+++ b/frontend/app/pages/dashboard/cdn/index.vue@@ -15,6 +15,13 @@</div><div v-if="sortedRessources.length" class="ressources-list"><DataTable v-if="view === 'table'" :headers="headers" :rows="rows">+ <template #bulk-actions="{ selected }">+ <div class="bulk-actions">+ <span class="selected-count">{{ selected.length }}</span>+ <span style="margin-left: 4px; height: 32px; border-left: 1px solid var(--border-color)"></span>+ <Icon name="delete" fill="var(--font-color-light)" class="action-btn" @click="bulkDelete(selected)" />+ </div>+ </template><template #action="{ cell }"><NuxtLink :href="`/dashboard/cdn/${(cell?.data as Node).id}/preview`" style="margin-right: 10px"><Icon name="view" /> </NuxtLink><NuxtLink :to="`/dashboard/cdn/${(cell?.data as Node).id}`"><Icon name="edit" style="margin-right: 10px" /></NuxtLink>@@ -37,25 +44,30 @@</div></template><script setup lang="ts">-import { readableFileSize } from '@/helpers/ressources';-import type { Field } from '~/components/DataTable.vue';import DeleteRessourceModal from './_modals/DeleteRessourceModal.vue';-import type { Node } from '~/stores';+import { readableFileSize } from '@/helpers/ressources';+import type { Field } from '@/components/DataTable.vue';+import type { Node } from '@/stores';+definePageMeta({ breadcrumb: 'Upload' });+const router = useRouter();const ressourcesStore = useRessourcesStore();const nodesStore = useNodesStore();+const view = ref<'table' | 'list'>('list');const selectedFile: Ref<File | undefined> = ref();const fileLink = ref('');const isLoading = ref(false);+const dropComponent = ref();++const sortedRessources = computed(() => [...nodesStore.ressources].sort((a, b) => b.created_timestamp - a.created_timestamp));+const selectFile = (file?: File) => (selectedFile.value = file);const copyLink = () => navigator.clipboard.writeText(fileLink.value!);-const dropComponent = ref();const submitFile = async () => {if (!selectedFile.value) return;isLoading.value = true;-const body = new FormData();body.append('file', selectedFile.value);selectedFile.value = undefined; // Reset selected file@@ -67,8 +79,6 @@ const submitFile = async () => {.finally(() => (isLoading.value = false));};-const sortedRessources = computed(() => [...nodesStore.ressources].sort((a, b) => b.created_timestamp - a.created_timestamp));-const fileURL = (ressource: Node) => {if ((ressource.metadata?.filetype as string)?.includes('image/')) return `${CDN}/${ressource.user_id}/${ressource.metadata?.transformed_path as string}`;return '/file_placeholder.png';@@ -81,6 +91,7 @@ const headers = [{ label: 'Date', key: 'date' },{ label: 'Action', key: 'action' },];+const color = (type: string) => (type.includes('image') ? 'green' : type.includes('video') ? 'blue' : type.includes('pdf') ? 'yellow' : 'red');const rows: ComputedRef<Field[]> = computed(() =>sortedRessources.value.map(res => {@@ -98,7 +109,11 @@ const rows: ComputedRef<Field[]> = computed(() =>);const deleteRessource = async (id: string) => {- useModal().add(new Modal(shallowRef(DeleteRessourceModal), { props: { ressourceId: id } }));+ useModal().add(new Modal(shallowRef(DeleteRessourceModal), { props: { ressources: [id] }, size: 'small' }));+};+const bulkDelete = async (lines: Field[]) => {+ const ressourcesIds = lines.map(line => (line.action?.data as Node | undefined)?.id).filter((id): id is string => !!id);+ useModal().add(new Modal(shallowRef(DeleteRessourceModal), { props: { ressources: ressourcesIds }, size: 'small' }));};</script>@@ -120,6 +135,37 @@ const deleteRessource = async (id: string) => {border-top: 5px solid var(--primary);}+.bulk-actions {+ display: flex;+ align-items: center;+ width: 100%;+ gap: 8px;+}+.action-btn {+ cursor: pointer;+ transition: background-color 0.1s;+ border-radius: 50%;+ padding: 6px;+ width: 32px;+ height: 32px;+ &:hover {+ background: var(--bg-ui);+ }+}+.selected-count {+ color: var(--font-color-light);+ font-weight: bold;+ font-family: 'Inter', sans-serif;+ font-size: 13px;+ border-radius: 4px;+ padding: 6px;+ border: 1px solid var(--border-color);+ width: 32px;+ height: 36px;+ display: flex;+ align-items: center;+ justify-content: center;+}.ressources-list {width: 100%;}