Skip to content

Commit

Permalink
support view archive online (#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
iberryful authored and ib-steffen committed Jan 18, 2019
1 parent 073f277 commit 9d30645
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/api/handlers/projects/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ class ArchiveDownload(Resource):

def get(self, project_id, job_id):
filename = request.args.get('filename', None)

force_download = request.args.get('view', "false") == "false"
if not filename:
abort(404)

Expand Down Expand Up @@ -422,7 +422,7 @@ def get(self, project_id, job_id):
logger.error(key)
abort(404)

return send_file(f, as_attachment=True, attachment_filename=os.path.basename(filename))
return send_file(f, as_attachment=force_download, attachment_filename=os.path.basename(filename))

@ns.route('/<job_id>/archive')
@api.response(403, 'Not Authorized')
Expand Down
2 changes: 2 additions & 0 deletions src/dashboard-client/src/components/job/Archive.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
<md-table-row>
<md-table-head md-sort-by="filename">Filename</md-table-head>
<md-table-head md-sort-by="size">Size</md-table-head>
<md-table-head >View</md-table-head>
</md-table-row>
</md-table-header>

<md-table-body>
<md-table-row v-for="a in files" :key="a.filename">
<md-table-cell><a @click="job.downloadArchive(a.filename)">{{ a.filename }}</a></md-table-cell>
<md-table-cell>{{ Math.round(a.size / 1024) }} kb</md-table-cell>
<md-table-cell><a @click="job.downloadArchive(a.filename, 'true')">View Online</a></md-table-cell>
</md-table-row>
</md-table-body>
</md-table>
Expand Down
4 changes: 2 additions & 2 deletions src/dashboard-client/src/models/Job.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ export default class Job {
NewAPIService.openAPIUrl(url)
}

downloadArchive (filename) {
const url = `projects/${this.project.id}/jobs/${this.id}/archive/download?filename=${filename}`
downloadArchive (filename, view = false) {
const url = `projects/${this.project.id}/jobs/${this.id}/archive/download?filename=${filename}&view=${view}`
NewAPIService.openAPIUrl(url)
.catch((err) => {
NotificationService.$emit('NOTIFICATION', new Notification('It seems the archived file was deleted from the server'))
Expand Down

0 comments on commit 9d30645

Please sign in to comment.