Skip to content

Commit

Permalink
Fixed some issues with dump (#904)
Browse files Browse the repository at this point in the history
* Changed method for downloading annotations

* Initial commit

* Initial commit

* Updated download method for dataset

* fixed eslint error
  • Loading branch information
bsekachev authored and nmanovic committed Dec 5, 2019
1 parent f3a3f4c commit 7251755
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
12 changes: 5 additions & 7 deletions cvat-core/src/server-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions cvat-ui/src/actions/tasks-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ ThunkAction<Promise<void>, {}, {}, 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;
Expand Down Expand Up @@ -270,9 +270,9 @@ ThunkAction<Promise<void>, {}, {}, 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));
}
Expand Down
1 change: 1 addition & 0 deletions cvat-ui/src/components/cvat-app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ export default class CVATApplication extends React.PureComponent<CVATAppProps> {
</Switch>
<FeedbackComponent/>
<ModelRunnerModalContainer/>
<a id='downloadAnchor' style={{ display: 'none' }} download/>
</Layout.Content>
</Layout>
</BrowserRouter>
Expand Down
2 changes: 1 addition & 1 deletion cvat/apps/engine/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 7251755

Please sign in to comment.