Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

Multi uploads feature

Smaug673915d4cadd160c
diff --git a/frontend/app/pages/dashboard/cdn/index.vue b/frontend/app/pages/dashboard/cdn/index.vue
index 31ddcfca..906d20d2 100644
--- a/frontend/app/pages/dashboard/cdn/index.vue
+++ b/frontend/app/pages/dashboard/cdn/index.vue
@@ -21,14 +21,19 @@
</div>
<span class="storage-percentage">{{ storagePercentage.toFixed(1) }}%</span>
</div>
- <AppDrop ref="dropComponent" @select="selectFile" />
+ <AppDrop ref="dropComponent" multiple :max-files="10" @select="selectFiles" />
<div style="display: flex; width: 100%; padding: 12px 0; align-items: center; flex-direction: column; gap: 10px">
- <AppButton type="primary" :disabled="!selectedFile" @click="submitFile">Upload on server</AppButton>
- <LoaderSpinner v-if="isLoading" />
+ <AppButton type="primary" :disabled="!selectedFiles.length" @click="submitFiles">
+ Upload {{ selectedFiles.length ? `${selectedFiles.length} file(s)` : '' }} on server
+ </AppButton>
+ <div v-if="isLoading" class="upload-progress">
+ <LoaderSpinner />
+ <span>Uploading {{ uploadProgress.current }} / {{ uploadProgress.total }}</span>
+ </div>
</div>
- <div v-if="fileLink" class="link-section">
- <input v-model="fileLink" type="text" readonly />
- <AppButton type="primary" @click="copyLink">Copy link</AppButton>
+ <div v-if="fileLinks.length" class="link-section">
+ <div v-text="linksText" class="links-text"></div>
+ <AppButton type="primary" @click="copyLinks">Copy {{ fileLinks.length > 1 ? 'links' : 'link' }}</AppButton>
</div>
<div v-if="filteredRessources.length" class="ressources-list">
<DataTable v-if="view === 'table'" :headers="headers" :rows="rows">
@@ -77,9 +82,10 @@ const ressourcesStore = useRessourcesStore();
const nodesStore = useNodesStore();
const view = ref<'table' | 'list'>('list');
-const selectedFile: Ref<File | undefined> = ref();
-const fileLink = ref('');
+const selectedFiles = ref<File[]>([]);
+const fileLinks = ref<string[]>([]);
const isLoading = ref(false);
+const uploadProgress = ref({ current: 0, total: 0 });
const dropComponent = ref();
const filter = ref('');
const { CDN } = useApi();
@@ -91,21 +97,44 @@ const filteredRessources = ref(nodes.value);
const totalUsedSpace = computed(() => nodes.value.reduce((acc, node) => acc + (node.size ?? 0), 0));
const storagePercentage = computed(() => Math.min((totalUsedSpace.value / MAX_STORAGE) * 100, 100));
-
-const selectFile = (file?: File) => (selectedFile.value = file);
-const copyLink = () => navigator.clipboard.writeText(fileLink.value!);
-const submitFile = async () => {
- if (!selectedFile.value) return;
+const linksText = computed(() => fileLinks.value.join('\n'));
+
+const selectFiles = (files: File | File[] | null) => {
+ if (!files) {
+ selectedFiles.value = [];
+ } else if (Array.isArray(files)) {
+ selectedFiles.value = files;
+ } else {
+ selectedFiles.value = [files];
+ }
+};
+const copyLinks = () => navigator.clipboard.writeText(fileLinks.value.join('\n'));
+const submitFiles = async () => {
+ if (!selectedFiles.value.length) return;
isLoading.value = true;
- const body = new FormData();
- body.append('file', selectedFile.value);
- selectedFile.value = undefined; // Reset selected file
- dropComponent.value.reset(); // Reset drop component
- await ressourcesStore
- .post(body)
- .then(r => (fileLink.value = `${CDN}/${(r as Node).user_id}/${(r as Node).metadata?.transformed_path as string}`))
- .catch(e => useNotifications().add({ type: 'error', title: 'Error', message: e }))
- .finally(() => (isLoading.value = false));
+ fileLinks.value = [];
+ uploadProgress.value = { current: 0, total: selectedFiles.value.length };
+
+ const filesToUpload = [...selectedFiles.value];
+ selectedFiles.value = [];
+ dropComponent.value.reset();
+
+ for (const file of filesToUpload) {
+ const body = new FormData();
+ body.append('file', file);
+ try {
+ const r = await ressourcesStore.post(body);
+ fileLinks.value.push(`${CDN}/${(r as Node).user_id}/${(r as Node).metadata?.transformed_path as string}`);
+ } catch (e) {
+ useNotifications().add({ type: 'error', title: 'Error', message: `Failed to upload ${file.name}: ${e}` });
+ }
+ uploadProgress.value.current++;
+ }
+
+ isLoading.value = false;
+ if (fileLinks.value.length) {
+ useNotifications().add({ type: 'success', title: 'Upload complete', message: `${fileLinks.value.length} file(s) uploaded successfully` });
+ }
};
const fileURL = (ressource: Node) => {
@@ -211,12 +240,33 @@ const bulkDelete = async (lines: Field[]) => {
display: flex;
align-items: center;
}
+.upload-progress {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ font-size: 14px;
+ color: var(--font-color-light);
+}
+
.link-section {
display: flex;
width: 100%;
margin: 6px 0;
flex-direction: column;
gap: 10px;
+
+ .links-text {
+ width: 100%;
+ padding: 10px;
+ border: 1px solid var(--border-color);
+ border-radius: 6px;
+ background: var(--bg-color-secondary);
+ font-family: 'JetBrains Mono', monospace;
+ font-size: 13px;
+ color: var(--font-color-dark);
+ white-space: pre-wrap;
+ word-break: break-all;
+ }
}
.bulk-actions {