Skip to content

Commit 9d30645

Browse files
iberryfulib-steffen
authored andcommitted
support view archive online (#252)
1 parent 073f277 commit 9d30645

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/api/handlers/projects/jobs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ class ArchiveDownload(Resource):
381381

382382
def get(self, project_id, job_id):
383383
filename = request.args.get('filename', None)
384-
384+
force_download = request.args.get('view', "false") == "false"
385385
if not filename:
386386
abort(404)
387387

@@ -422,7 +422,7 @@ def get(self, project_id, job_id):
422422
logger.error(key)
423423
abort(404)
424424

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

427427
@ns.route('/<job_id>/archive')
428428
@api.response(403, 'Not Authorized')

src/dashboard-client/src/components/job/Archive.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
<md-table-row>
77
<md-table-head md-sort-by="filename">Filename</md-table-head>
88
<md-table-head md-sort-by="size">Size</md-table-head>
9+
<md-table-head >View</md-table-head>
910
</md-table-row>
1011
</md-table-header>
1112

1213
<md-table-body>
1314
<md-table-row v-for="a in files" :key="a.filename">
1415
<md-table-cell><a @click="job.downloadArchive(a.filename)">{{ a.filename }}</a></md-table-cell>
1516
<md-table-cell>{{ Math.round(a.size / 1024) }} kb</md-table-cell>
17+
<md-table-cell><a @click="job.downloadArchive(a.filename, 'true')">View Online</a></md-table-cell>
1618
</md-table-row>
1719
</md-table-body>
1820
</md-table>

src/dashboard-client/src/models/Job.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,8 @@ export default class Job {
317317
NewAPIService.openAPIUrl(url)
318318
}
319319

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

0 commit comments

Comments
 (0)