From 49750acf3e2ae608121bf50e16d4850fa218e3a2 Mon Sep 17 00:00:00 2001 From: JulienM Date: Wed, 25 Oct 2023 14:04:36 +0200 Subject: [PATCH] view data --- src/app/custom/translations.tsv | 4 +- .../precomputed/PrecomputedDataDialog.js | 72 +++++++++++++++++++ .../js/admin/precomputed/PrecomputedForm.js | 69 +++++++++++++----- 3 files changed, 127 insertions(+), 18 deletions(-) create mode 100644 src/app/js/admin/precomputed/PrecomputedDataDialog.js diff --git a/src/app/custom/translations.tsv b/src/app/custom/translations.tsv index d5978b195..1edef6b28 100644 --- a/src/app/custom/translations.tsv +++ b/src/app/custom/translations.tsv @@ -695,6 +695,7 @@ "advancedModePreviewInfo" "Source preview replaces [URLConnect] with [transit] and runs your ini file, as if all instructions were executed, except the call to web services." "L'aperçu de la source remplace [URLConnect] par [transit] et exécute votre fichier ini, comme si toutes les instructions étaient exécutées, sauf l'appel aux services web." "enrichment_logs" "Enrichment logs" "Logs de l'enrichissement" "precomputed_logs" "Precomputed data logs" "Logs des données précalculées" +"precomputed_data" "Precomputed data" "Données précalculées" "published_data" "Published data" "Données publiées" "toggle_loaded" "Show/hide loaded columns" "Afficher/cacher les colonnes chargées" "toggle_enriched" "Show/hide enriched columns" "Afficher/cacher les colonnes enrichies" @@ -890,6 +891,7 @@ "dialog_import_has_enrichments" "Import has enrichments" "L'import a des enrichissements" "dialog_import_has_enrichments_description" "Enrichments are present in the model. Do not forget to run them again if they apply to a new dataset." "Des enrichissements sont présents dans le modèle. Ne pas oublier de les relancer s'ils s'appliquent à un nouveau jeu de données." "see_logs" "See logs" "Voir les logs" +"see_data" "See precomputed data" "Voir les données précalculées" "enrichment_status" "Status" "Statut" "enrichment_preview_description" "Value from source column or from advanced rule" "* valeur de la colonne source ou de la règle avancée" "enrichment_added_success" "Enrichment added successfully" "Enrichissement ajouté avec succès" @@ -940,7 +942,7 @@ "add_more_subresource" "Add more subresources" "Ajouter plus de sous-ressources" "density_tooltip" "Data density" "Choisir la densité de données" "column_tooltip" "Column" "Choisir les colonnes" -"download_logs" "Download logs" "Télécharger les logs" +"download_data" "Download data" "Télécharger les données" "blank_field" "Blank field" "Champ vierge" "pending_enrichment" "This enrichment is in waiting list because an enrichment is already in progress" "Cet enrichissement est en liste d'attente car un enrichissement est déjà en cours" "pending_precomputed" "These precomputed data are in waiting list because a precompute is already in progress" "Ces données précalculées sont en liste d'attente car un précalcul est déjà en cours" diff --git a/src/app/js/admin/precomputed/PrecomputedDataDialog.js b/src/app/js/admin/precomputed/PrecomputedDataDialog.js new file mode 100644 index 000000000..6a05d8323 --- /dev/null +++ b/src/app/js/admin/precomputed/PrecomputedDataDialog.js @@ -0,0 +1,72 @@ +import React from 'react'; +import compose from 'recompose/compose'; +import translate from 'redux-polyglot/translate'; +import { polyglot as polyglotPropTypes } from '../../propTypes'; +import PropTypes from 'prop-types'; +import { + Box, + Button, + Dialog, + DialogActions, + DialogContent, + DialogTitle, + Typography, +} from '@mui/material'; +import CancelButton from '../../lib/components/CancelButton'; + +export const PrecomputedDataDialog = ({ + isOpen, + data, + p: polyglot, + handleClose, +}) => { + const handleDownloadData = () => { + const file = new Blob([JSON.stringify(data)], { type: 'text/plain' }); + const element = document.createElement('a'); + element.href = URL.createObjectURL(file); + element.download = 'precomputed-data-' + Date.now() + '.json'; + document.body.appendChild(element); + element.click(); + document.body.removeChild(element); + }; + + return ( + + {polyglot.t('precomputed_data')} + + {JSON.stringify(data)} + + + + + {polyglot.t('close')} + + + + + + ); +}; + +PrecomputedDataDialog.propTypes = { + isOpen: PropTypes.bool.isRequired, + handleClose: PropTypes.func.isRequired, + data: PropTypes.object.isRequired, + p: polyglotPropTypes.isRequired, +}; + +export default compose(translate)(PrecomputedDataDialog); diff --git a/src/app/js/admin/precomputed/PrecomputedForm.js b/src/app/js/admin/precomputed/PrecomputedForm.js index a4099c01b..f8d2da065 100644 --- a/src/app/js/admin/precomputed/PrecomputedForm.js +++ b/src/app/js/admin/precomputed/PrecomputedForm.js @@ -3,6 +3,7 @@ import React, { useEffect, useMemo } from 'react'; import PrecomputedCatalogConnected from './PrecomputedCatalog'; import PrecomputedPreview from './PrecomputedPreview'; import PrecomputedFormLogsDialogComponent from './PrecomputedLogsDialog'; +import PrecomputedFormDataDialogComponent from './PrecomputedDataDialog'; import translate from 'redux-polyglot/translate'; import PlayArrowIcon from '@mui/icons-material/PlayArrow'; import PropTypes from 'prop-types'; @@ -175,6 +176,7 @@ export const PrecomputedForm = ({ }) => { const [openCatalog, setOpenCatalog] = React.useState(false); const [openPrecomputedLogs, setOpenPrecomputedLogs] = React.useState(false); + const [openPrecomputedData, setOpenPrecomputedData] = React.useState(false); const [isLoading, setIsLoading] = React.useState(false); const [dataPreviewPrecomputed, setDataPreviewPrecomputed] = React.useState( [], @@ -386,23 +388,56 @@ export const PrecomputedForm = ({ {polyglot.t('precomputed_status')} :   {renderStatus(precomputedStatus, polyglot)} - - - setOpenPrecomputedLogs(false) - } - /> + + + + setOpenPrecomputedLogs(false) + } + /> + {isEditMode && + precomputedStatus === FINISHED && ( + <> + + + setOpenPrecomputedData( + false, + ) + } + /> + + )} + )}