From bf6d9629d4512b0f870e2593b95890a6a78d2420 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Tue, 30 Jun 2020 18:35:42 +0200 Subject: [PATCH] Frontend: Re-add download file action #356 Signed-off-by: Michael Mayer --- frontend/src/dialog/photo/files.vue | 5 ++++- frontend/src/model/file.js | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/frontend/src/dialog/photo/files.vue b/frontend/src/dialog/photo/files.vue index 19db01737..c0624b8c4 100644 --- a/frontend/src/dialog/photo/files.vue +++ b/frontend/src/dialog/photo/files.vue @@ -61,7 +61,7 @@ Name - {{ file.Name }} + {{ file.Name }} @@ -172,6 +172,9 @@ openFile(file) { this.$viewer.show([Thumb.fromFile(this.model, file)], 0); }, + download(file) { + file.download(); + }, ungroup(file) { this.model.ungroupFile(file.UID); }, diff --git a/frontend/src/model/file.js b/frontend/src/model/file.js index ba23ace3e..6cf1b4bca 100644 --- a/frontend/src/model/file.js +++ b/frontend/src/model/file.js @@ -112,6 +112,18 @@ export class File extends RestModel { return "/api/v1/dl/" + this.Hash + "?t=" + config.downloadToken(); } + download() { + if (!this.Hash) { + console.warn("no file hash found for download", this); + return; + } + + let link = document.createElement("a"); + link.href = this.getDownloadUrl() + link.download = this.baseName(this.Name); + link.click(); + } + thumbnailSrcset() { const result = [];