From 0b1c61bfa6edbc4c42545c68c9a6a6e8d906106e Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Thu, 5 Dec 2019 11:11:46 +0300 Subject: [PATCH 1/5] Changed method for downloading annotations --- cvat-core/src/server-proxy.js | 12 +++++------- cvat-ui/src/actions/tasks-actions.ts | 6 +++--- cvat-ui/src/components/cvat-app.tsx | 1 + 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cvat-core/src/server-proxy.js b/cvat-core/src/server-proxy.js index a4fad54288b9..018a58bdf962 100644 --- a/cvat-core/src/server-proxy.js +++ b/cvat-core/src/server-proxy.js @@ -563,20 +563,18 @@ return new Promise((resolve, reject) => { async function request() { - try { - const response = await Axios - .get(`${url}`, { - proxy: config.proxy, - }); + Axios.get(`${url}`, { + proxy: config.proxy, + }).then((response) => { if (response.status === 202) { setTimeout(request, 3000); } else { url = `${url}&action=download`; resolve(url); } - } catch (errorData) { + }).catch((errorData) => { reject(generateError(errorData)); - } + }); } setTimeout(request); diff --git a/cvat-ui/src/actions/tasks-actions.ts b/cvat-ui/src/actions/tasks-actions.ts index ae4b53016a0c..62255ea782b5 100644 --- a/cvat-ui/src/actions/tasks-actions.ts +++ b/cvat-ui/src/actions/tasks-actions.ts @@ -164,9 +164,9 @@ ThunkAction, {}, {}, AnyAction> { try { dispatch(dumpAnnotation(task, dumper)); const url = await task.annotations.dump(task.name, dumper); - // false positive - // eslint-disable-next-line security/detect-non-literal-fs-filename - window.open(url); + const downloadAnchor = (window.document.getElementById('downloadAnchor') as HTMLAnchorElement); + downloadAnchor.href = url; + downloadAnchor.click(); } catch (error) { dispatch(dumpAnnotationFailed(task, dumper, error)); return; diff --git a/cvat-ui/src/components/cvat-app.tsx b/cvat-ui/src/components/cvat-app.tsx index 09e3d4762300..9e94e41edb5e 100644 --- a/cvat-ui/src/components/cvat-app.tsx +++ b/cvat-ui/src/components/cvat-app.tsx @@ -233,6 +233,7 @@ export default class CVATApplication extends React.PureComponent { + From 5cbd6c644c2aa07c4faf7ed9d0ec00ca28555991 Mon Sep 17 00:00:00 2001 From: Nobody Date: Thu, 5 Dec 2019 08:21:50 +0000 Subject: [PATCH 2/5] Initial commit From 130d1298f3151c42d8483650c7a8daeb400e9259 Mon Sep 17 00:00:00 2001 From: Nobody Date: Thu, 5 Dec 2019 08:21:50 +0000 Subject: [PATCH 3/5] Initial commit From b62768fe04ae371a779246cbb9ab930ccd497401 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Thu, 5 Dec 2019 11:23:17 +0300 Subject: [PATCH 4/5] Updated download method for dataset --- cvat-ui/src/actions/tasks-actions.ts | 6 +++--- cvat/apps/engine/views.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cvat-ui/src/actions/tasks-actions.ts b/cvat-ui/src/actions/tasks-actions.ts index 62255ea782b5..1dfccf7f6826 100644 --- a/cvat-ui/src/actions/tasks-actions.ts +++ b/cvat-ui/src/actions/tasks-actions.ts @@ -270,9 +270,9 @@ ThunkAction, {}, {}, AnyAction> { try { const url = await task.annotations.exportDataset(exporter.tag); - // false positive - // eslint-disable-next-line security/detect-non-literal-fs-filename - window.open(url, '_blank'); + const downloadAnchor = (window.document.getElementById('downloadAnchor') as HTMLAnchorElement); + downloadAnchor.href = url; + downloadAnchor.click(); } catch (error) { dispatch(exportDatasetFailed(task, exporter, error)); } diff --git a/cvat/apps/engine/views.py b/cvat/apps/engine/views.py index 9326918e1909..47a262c1acb5 100644 --- a/cvat/apps/engine/views.py +++ b/cvat/apps/engine/views.py @@ -364,7 +364,7 @@ def dump(self, request, pk, filename): "{}.{}.{}.{}".format(filename, username, timestamp, db_dumper.format.lower())) queue = django_rq.get_queue("default") - rq_id = "{}@/api/v1/tasks/{}/annotations/{}".format(username, pk, filename) + rq_id = "{}@/api/v1/tasks/{}/annotations/{}/{}".format(username, pk, dump_format, filename) rq_job = queue.fetch_job(rq_id) if rq_job: From 9edc31492016fc61576af1d0cd3e0f5c27979f99 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Thu, 5 Dec 2019 12:14:48 +0300 Subject: [PATCH 5/5] fixed eslint error --- cvat-ui/src/components/cvat-app.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cvat-ui/src/components/cvat-app.tsx b/cvat-ui/src/components/cvat-app.tsx index 9e94e41edb5e..a99e908139ca 100644 --- a/cvat-ui/src/components/cvat-app.tsx +++ b/cvat-ui/src/components/cvat-app.tsx @@ -233,7 +233,7 @@ export default class CVATApplication extends React.PureComponent { - +