added download to frontend

This commit is contained in:
Vito0912 2025-03-17 19:56:42 +01:00
parent 0123dacb29
commit 0a9a846a33
No known key found for this signature in database
GPG Key ID: 29A3D509FE70B237

View File

@ -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)