Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebUI: Evidence and Worker download buttons #1532

Merged
merged 5 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/_build/
/_sources/
/.tox
charts/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to add this? we don't have a charts directory.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes for the skaffold dev setup to ignore that folder else shows alot of noise in your commits tab in VSCode


# And don't care about the 'egg'.
/turbinia.egg-info
Expand Down
2 changes: 1 addition & 1 deletion turbinia/api/routes/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
60 changes: 59 additions & 1 deletion web/src/components/TaskDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,20 @@ limitations under the License.
<div v-else>N/A</div>
</v-list-item>
<v-list-item title="Evidence Name:">
<template v-if="taskDetails.evidence_name" v-slot:append>
<v-tooltip location="top" text="Download Evidence output">
<template v-slot:activator="{ props: tooltip }">
<v-btn icon="mdi-magnify-plus" v-bind="tooltip" @click="downloadEvidence(taskDetails.evidence_id)">
</v-btn>
</template>
</v-tooltip>
</template>
<v-snackbar v-model="evidenceSnackbar" color="primary" location="top" height="55" timeout="2000">
Evidence output is downloading...
</v-snackbar>
<v-snackbar v-model="notCopyable" color="red" location="top" height="55" timeout="2000">
Evidence type is not supported for downloading.
</v-snackbar>
<div v-if="taskDetails.evidence_name">
{{ taskDetails.evidence_name }}
</div>
Expand All @@ -123,6 +137,14 @@ limitations under the License.
<div v-else>N/A</div>
</v-list-item>
<v-list-item title="Worker:">
<template v-if="taskDetails.worker_name" v-slot:append>
<v-tooltip location="top" text="Download Worker Logs (defaults to most recent 500 entries)">
<template v-slot:activator="{ props: tooltip }">
<v-btn icon="mdi-database-outline" v-bind="tooltip" @click="downloadWorkerLogs(taskDetails.worker_name)">
</v-btn>
</template>
</v-tooltip>
</template>
<div v-if="taskDetails.worker_name">
{{ taskDetails.worker_name }}
</div>
Expand Down Expand Up @@ -170,7 +192,10 @@ export default {
return {
openGroups: ['ids', 'details'],
markdownReport: '',
currentTaskID: ''
currentTaskID: '',
evidenceSnackbar: false,
notCopyable: false,
openReportDialog: false,
}
},
methods: {
Expand Down Expand Up @@ -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)
})
},
},
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/TaskList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
<div>
<v-list density="compact">
<v-empty-state v-if="taskList.length === 0"
text="No Tasks are available. Try adjusting your filters."
text="No Tasks are available. Try adjusting your filters.">
</v-empty-state>
<v-virtual-scroll :items="taskList" :item-height="40" :height="400" v-else>
<template v-slot:default="{ item }">
Expand Down
10 changes: 10 additions & 0 deletions web/src/utils/RestApiClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ export default {
return RestApiClient.get('/api/result/task/' + task_id, { responseType: 'blob' })
},

// Download Evidence
downloadEvidence(evidence_id) {
return RestApiClient.get('/api/evidence/download/' + evidence_id, { responseType: 'blob' })
},

// Get Worker Logs
getWorkerLogs(worker_name) {
return RestApiClient.get('/api/logs/' + worker_name)
},

// Jobs List
getAvailableJobs() {
return RestApiClient.get('/api/jobs/')
Expand Down