From 60cf7503e038ec157e0e368a48314dede35f45f7 Mon Sep 17 00:00:00 2001 From: hatim dinia Date: Fri, 20 Dec 2024 16:44:28 +0100 Subject: [PATCH] feat(ui-matrix): add raw file download option for matrices --- webapp/public/locales/en/main.json | 1 + webapp/public/locales/fr/main.json | 1 + .../components/common/buttons/DownloadMatrixButton.tsx | 8 +++++++- webapp/src/services/api/studies/raw/constants.ts | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/webapp/public/locales/en/main.json b/webapp/public/locales/en/main.json index 1f13b6e551..2d7b4059cc 100644 --- a/webapp/public/locales/en/main.json +++ b/webapp/public/locales/en/main.json @@ -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", diff --git a/webapp/public/locales/fr/main.json b/webapp/public/locales/fr/main.json index 14dbcda923..313f910b29 100644 --- a/webapp/public/locales/fr/main.json +++ b/webapp/public/locales/fr/main.json @@ -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é", diff --git a/webapp/src/components/common/buttons/DownloadMatrixButton.tsx b/webapp/src/components/common/buttons/DownloadMatrixButton.tsx index 0f27f75eef..30e4db88b0 100644 --- a/webapp/src/components/common/buttons/DownloadMatrixButton.tsx +++ b/webapp/src/components/common/buttons/DownloadMatrixButton.tsx @@ -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"; @@ -38,6 +38,7 @@ function DownloadMatrixButton(props: DownloadMatrixButtonProps) { }, { label: "TSV", value: "tsv" }, { label: "XLSX", value: "xlsx" }, + { label: `${t("global.rawFile")}`, value: "raw" }, ]; //////////////////////////////////////////////////////////////// @@ -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({ diff --git a/webapp/src/services/api/studies/raw/constants.ts b/webapp/src/services/api/studies/raw/constants.ts index 9481e0557c..d4a701d611 100644 --- a/webapp/src/services/api/studies/raw/constants.ts +++ b/webapp/src/services/api/studies/raw/constants.ts @@ -18,4 +18,5 @@ export const TableExportFormat = { TSV: "tsv", CSV: "csv", CSV_SEMICOLON: "csv (semicolon)", + RAW: "raw", } as const;