From e15686808126ed256686b5180d6947d24a2b2f08 Mon Sep 17 00:00:00 2001 From: wajihyassine Date: Tue, 13 Aug 2024 20:56:19 +0000 Subject: [PATCH 1/4] Add button next to evidence name to download --- web/src/components/TaskDetails.vue | 36 +++++++++++++++++++++++++++++- web/src/components/TaskList.vue | 2 +- web/src/utils/RestApiClient.js | 5 +++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/web/src/components/TaskDetails.vue b/web/src/components/TaskDetails.vue index b00ceb71b..6443d4360 100644 --- a/web/src/components/TaskDetails.vue +++ b/web/src/components/TaskDetails.vue @@ -99,6 +99,20 @@ limitations under the License.
N/A
+ + + Evidence output is downloading... + + + Evidence type is not supported for downloading. +
{{ taskDetails.evidence_name }}
@@ -170,7 +184,9 @@ export default { return { openGroups: ['ids', 'details'], markdownReport: '', - currentTaskID: '' + currentTaskID: '', + evidenceSnackbar: false, + notCopyable: false, } }, methods: { @@ -205,6 +221,24 @@ export default { console.error(e) }) }, + downloadEvidence: function (evidence_id) { + ApiClient.downloadEvidence(evidence_id) + .then(({ data }) => { + this.evidenceSnackbar = true + const downloadObj = window.URL.createObjectURL(new Blob([data])) + const link = document.createElement('a') + link.href = downloadObj + link.setAttribute('download', evidence_id) + document.body.appendChild(link) + link.click() + link.remove() + }) + .catch((e) => { + console.error(e) + this.evidenceSnackbar = false + this.notCopyable = true + }) + }, }, } diff --git a/web/src/components/TaskList.vue b/web/src/components/TaskList.vue index 480ed4139..1b6171ac1 100644 --- a/web/src/components/TaskList.vue +++ b/web/src/components/TaskList.vue @@ -15,7 +15,7 @@ limitations under the License.