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):
373373
374374 time_delta = datetime .datetime .utcnow () - export .created_at
375375 dict_export .append ({
376+ 'id' : export .id ,
376377 'ago' : query_util .td_format (time_delta ),
377378 'tags' : export .tags
378379 })
Original file line number Diff line number Diff line change 1+ from flask import send_file
12from flask_restplus import Namespace , Resource , reqparse
23from flask_login import login_required , current_user
34
@@ -66,5 +67,5 @@ def get(self, export_id):
6667 if not current_user .can_download (dataset ):
6768 return {"message" : "You do not have permission to download the dataset's annotations" }, 403
6869
69- return {}
70+ return send_file ( export . path , attachment_filename = f" { dataset . name } - { '-' . join ( export . tags ) } .json" , as_attachment = True )
7071
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 6666 <h6 class =" border-bottom border-gray pb-2" ><b >Exports</b ></h6 >
6767
6868 <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 >
7578 </div >
7679 </div >
7780 </div >
340343<script >
341344import toastrs from " @/mixins/toastrs" ;
342345import Dataset from " @/models/datasets" ;
346+ import Export from " @/models/exports" ;
343347import ImageCard from " @/components/cards/ImageCard" ;
344348import Pagination from " @/components/Pagination" ;
345349import PanelString from " @/components/PanelInputString" ;
@@ -463,6 +467,9 @@ export default {
463467 this .users = response .data
464468 });
465469 },
470+ downloadExport (id ) {
471+ Export .download (id, this .dataset .name );
472+ },
466473 getExports () {
467474 Dataset .getExports (this .dataset .id )
468475 .then (response => {
You can’t perform that action at this time.
0 commit comments