From 0a9a846a332480eeb08bb8f999960e6432c16b99 Mon Sep 17 00:00:00 2001 From: Vito0912 <86927734+Vito0912@users.noreply.github.com> Date: Mon, 17 Mar 2025 19:56:42 +0100 Subject: [PATCH] added download to frontend --- client/components/app/Appbar.vue | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/client/components/app/Appbar.vue b/client/components/app/Appbar.vue index bb452526..6fd2bc3e 100644 --- a/client/components/app/Appbar.vue +++ b/client/components/app/Appbar.vue @@ -180,6 +180,15 @@ export default { action: 'rescan' }) + // The limit of 50 is introduced because of the URL length. Each id has 36 chars, so 36 * 40 = 1440 + // + 40 , separators = 1480 chars + base path 280 chars = 1760 chars. This keeps the URL under 2000 chars even with longer domains + if(this.selectedMediaItems.length <= 40) { + options.push({ + text: this.$strings.LabelDownload, + action: 'download' + }) + } + return options } }, @@ -215,6 +224,8 @@ export default { this.batchAutoMatchClick() } else if (action === 'rescan') { this.batchRescan() + } else if (action === 'download') { + this.batchDownload() } }, async batchRescan() { @@ -241,6 +252,11 @@ export default { } this.$store.commit('globals/setConfirmPrompt', payload) }, + async batchDownload() { + const libraryItemIds = this.selectedMediaItems.map((i) => i.id) + console.log('Downloading library items', libraryItemIds) + this.$downloadFile(`/api/libraries/${this.$store.state.libraries.currentLibraryId}/download?token=${this.$store.getters['user/getToken']}&ids=${libraryItemIds.join(',')}`, null, true) + }, async playSelectedItems() { this.$store.commit('setProcessingBatch', true)