From 4831195bb43471530e10390ff36eaa03cfbf1469 Mon Sep 17 00:00:00 2001 From: Wajih Yassine <54372074+wajihyassine@users.noreply.github.com> Date: Fri, 23 Aug 2024 13:44:37 -0700 Subject: [PATCH] WebUI: Evidence and Worker download buttons (#1532) * Add button next to evidence name to download * Update icon add if statement * Add button to view worker logs * Update download worker logs --- .gitignore | 1 + turbinia/api/routes/logs.py | 2 +- web/src/components/TaskDetails.vue | 60 +++++++++++++++++++++++++++++- web/src/components/TaskList.vue | 2 +- web/src/utils/RestApiClient.js | 10 +++++ 5 files changed, 72 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index f0c45e519..e8419fb90 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ */_build/ /_sources/ /.tox +charts/ # And don't care about the 'egg'. /turbinia.egg-info diff --git a/turbinia/api/routes/logs.py b/turbinia/api/routes/logs.py index 8dbc96299..960eb510c 100644 --- a/turbinia/api/routes/logs.py +++ b/turbinia/api/routes/logs.py @@ -71,7 +71,7 @@ async def get_turbinia_logs( return JSONResponse(content={'detail': 'Invalid hostname'}, status_code=404) if 'NODE_NAME' in os.environ: - log_name = f'{hostname}.{os.environ["NODE_NAME"]!s}' + log_name = f'{hostname}.{os.environ["NODE_NAME"]!s}.log' else: log_name = f'{hostname}.log' log_path = Path(config.LOG_DIR, log_name) diff --git a/web/src/components/TaskDetails.vue b/web/src/components/TaskDetails.vue index b00ceb71b..31c6095f1 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 }}
@@ -123,6 +137,14 @@ limitations under the License.
N/A
+
{{ taskDetails.worker_name }}
@@ -170,7 +192,10 @@ export default { return { openGroups: ['ids', 'details'], markdownReport: '', - currentTaskID: '' + currentTaskID: '', + evidenceSnackbar: false, + notCopyable: false, + openReportDialog: false, } }, methods: { @@ -205,6 +230,39 @@ 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 + }) + }, + downloadWorkerLogs: function (worker_name) { + ApiClient.getWorkerLogs(worker_name) + .then(({ data }) => { + const downloadObj = window.URL.createObjectURL(new Blob([data])) + const link = document.createElement('a') + link.href = downloadObj + link.setAttribute('download', worker_name + '.log') + document.body.appendChild(link) + link.click() + link.remove() + }) + .catch((e) => { + console.error(e) + }) + }, }, } 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.