File tree Expand file tree Collapse file tree 4 files changed +36
-7
lines changed Expand file tree Collapse file tree 4 files changed +36
-7
lines changed Original file line number Diff line number Diff line change @@ -373,6 +373,7 @@ def get(self, dataset_id):
373
373
374
374
time_delta = datetime .datetime .utcnow () - export .created_at
375
375
dict_export .append ({
376
+ 'id' : export .id ,
376
377
'ago' : query_util .td_format (time_delta ),
377
378
'tags' : export .tags
378
379
})
Original file line number Diff line number Diff line change
1
+ from flask import send_file
1
2
from flask_restplus import Namespace , Resource , reqparse
2
3
from flask_login import login_required , current_user
3
4
@@ -66,5 +67,5 @@ def get(self, export_id):
66
67
if not current_user .can_download (dataset ):
67
68
return {"message" : "You do not have permission to download the dataset's annotations" }, 403
68
69
69
- return {}
70
+ return send_file ( export . path , attachment_filename = f" { dataset . name } - { '-' . join ( export . tags ) } .json" , as_attachment = True )
70
71
Original file line number Diff line number Diff line change
1
+ import axios from "axios" ;
2
+
3
+ const baseURL = "/api/export" ;
4
+
5
+ export default {
6
+ download ( id , dataset ) {
7
+ axios ( {
8
+ url : `${ baseURL } /${ id } /download` ,
9
+ method : "GET" ,
10
+ responseType : "blob"
11
+ } ) . then ( response => {
12
+ const url = window . URL . createObjectURL ( new Blob ( [ response . data ] ) ) ;
13
+ const link = document . createElement ( "a" ) ;
14
+ link . href = url ;
15
+ link . setAttribute ( "download" , `${ dataset } -${ id } .json` ) ;
16
+ document . body . appendChild ( link ) ;
17
+ link . click ( ) ;
18
+ } ) ;
19
+ }
20
+ } ;
Original file line number Diff line number Diff line change 66
66
<h6 class =" border-bottom border-gray pb-2" ><b >Exports</b ></h6 >
67
67
68
68
<div class =" media text-muted pt-3" v-for =" exp in datasetExports" >
69
- <div class =" media-body pb-3 mb-0 small lh-125 border-bottom border-gray" >
70
- <div class =" d-flex justify-content-between align-items-center w-100" >
71
- <div class =" text-gray-dark" >
72
- <strong >Exported {{ exp.ago.length > 0 ? exp.ago : 0 + " seconds" }} ago</strong >
73
- </div >
74
- </div >
69
+ <div class =" media-body lh-125 border-bottom border-gray" >
70
+ Exported {{ exp.ago.length > 0 ? exp.ago : 0 + " seconds" }} ago
71
+ <button
72
+ class =" btn btn-sm btn-success"
73
+ style =" float : right ; margin : 2px ; padding : 2px "
74
+ @click =" downloadExport(exp.id)"
75
+ >
76
+ Download
77
+ </button >
75
78
</div >
76
79
</div >
77
80
</div >
340
343
<script >
341
344
import toastrs from " @/mixins/toastrs" ;
342
345
import Dataset from " @/models/datasets" ;
346
+ import Export from " @/models/exports" ;
343
347
import ImageCard from " @/components/cards/ImageCard" ;
344
348
import Pagination from " @/components/Pagination" ;
345
349
import PanelString from " @/components/PanelInputString" ;
@@ -463,6 +467,9 @@ export default {
463
467
this .users = response .data
464
468
});
465
469
},
470
+ downloadExport (id ) {
471
+ Export .download (id, this .dataset .name );
472
+ },
466
473
getExports () {
467
474
Dataset .getExports (this .dataset .id )
468
475
.then (response => {
You can’t perform that action at this time.
0 commit comments