Skip to content

Commit

Permalink
feat(ui-matrix): add raw file download option for matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
hdinia committed Dec 20, 2024
1 parent 5257aa7 commit 60cf750
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions webapp/public/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"global.date": "Date",
"global.general": "General",
"global.files": "Files",
"global.rawFile": "Raw file",
"global.none": "None",
"global.upload": "Upload",
"global.key": "Key",
Expand Down
1 change: 1 addition & 0 deletions webapp/public/locales/fr/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"global.date": "Date",
"global.general": "Général",
"global.files": "Fichiers",
"global.rawFile": "Fichier brut",
"global.none": "Aucun",
"global.upload": "Charger",
"global.key": "Clé",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* This file is part of the Antares project.
*/

import { getMatrixFile } from "../../../services/api/studies/raw";
import { getMatrixFile, getRawFile } from "../../../services/api/studies/raw";
import { downloadFile } from "../../../utils/fileUtils";
import { StudyMetadata } from "../../../common/types";
import { useTranslation } from "react-i18next";
Expand All @@ -38,6 +38,7 @@ function DownloadMatrixButton(props: DownloadMatrixButtonProps) {
},
{ label: "TSV", value: "tsv" },
{ label: "XLSX", value: "xlsx" },
{ label: `${t("global.rawFile")}`, value: "raw" },
];

////////////////////////////////////////////////////////////////
Expand All @@ -49,6 +50,11 @@ function DownloadMatrixButton(props: DownloadMatrixButtonProps) {
return;
}

if (format === "raw") {
const { data, filename } = await getRawFile({ studyId, path });
return downloadFile(data, filename);
}

const isXlsx = format === "xlsx";

const matrixFile = await getMatrixFile({
Expand Down
1 change: 1 addition & 0 deletions webapp/src/services/api/studies/raw/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ export const TableExportFormat = {
TSV: "tsv",
CSV: "csv",
CSV_SEMICOLON: "csv (semicolon)",
RAW: "raw",
} as const;

0 comments on commit 60cf750

Please sign in to comment.