Skip to content

Commit

Permalink
Fix submission download (#1524)
Browse files Browse the repository at this point in the history
* fix(projectSubmissions): csv & json download fix according to api

* fix(projectSubmissions): add project name as file name
  • Loading branch information
NSUWAL123 committed May 17, 2024
1 parent ae48dbe commit 693ff10
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/frontend/src/api/task.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import CoreModules from '@/shared/CoreModules';
import { CommonActions } from '@/store/slices/CommonSlice';

export const getDownloadProjectSubmission: Function = (url: string) => {
export const getDownloadProjectSubmission: Function = (url: string, projectName: string) => {
return async (dispatch) => {
const params = new URLSearchParams(url.split('?')[1]);
const isExportJson = params.get('export_json');
Expand All @@ -20,7 +20,7 @@ export const getDownloadProjectSubmission: Function = (url: string) => {
});
var a = document.createElement('a');
a.href = window.URL.createObjectURL(response.data);
a.download = 'Submissions';
a.download = isExportJson === 'true' ? `${projectName}.json` : `${projectName}.zip`;
a.click();
dispatch(
CoreModules.TaskActions.GetDownloadProjectSubmissionLoading({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,14 @@ const SubmissionsTable = ({ toggleView }) => {
dispatch(
getDownloadProjectSubmission(
`${import.meta.env.VITE_API_URL}/submission/download?project_id=${projectId}&export_json=false`,
projectInfo?.title,
),
);
} else if (downloadType === 'json') {
dispatch(
getDownloadProjectSubmissionJson(
`${import.meta.env.VITE_API_URL}/submission/download-submission?project_id=${projectId}`,
getDownloadProjectSubmission(
`${import.meta.env.VITE_API_URL}/submission/download?project_id=${projectId}&export_json=true`,
projectInfo?.title,
),
);
}
Expand Down

0 comments on commit 693ff10

Please sign in to comment.