Skip to content

Commit

Permalink
view data
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienMattiussi committed Oct 25, 2023
1 parent 80d3251 commit 49750ac
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 18 deletions.
4 changes: 3 additions & 1 deletion src/app/custom/translations.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
72 changes: 72 additions & 0 deletions src/app/js/admin/precomputed/PrecomputedDataDialog.js
Original file line number Diff line number Diff line change
@@ -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 (
<Dialog open={isOpen} onClose={handleClose} scroll="body" maxWidth="lg">
<DialogTitle>{polyglot.t('precomputed_data')}</DialogTitle>
<DialogContent
style={{
margin: 20,
padding: 10,
width: '1100px',
border: '1px solid',
borderColor: 'info.main',
}}
>
<Typography>{JSON.stringify(data)}</Typography>
</DialogContent>
<DialogActions>
<Box display="flex" justifyContent="flex-end">
<CancelButton onClick={handleClose}>
{polyglot.t('close')}
</CancelButton>
<Button
onClick={handleDownloadData}
color="primary"
variant="contained"
>
{polyglot.t('download_data')}
</Button>
</Box>
</DialogActions>
</Dialog>
);
};

PrecomputedDataDialog.propTypes = {
isOpen: PropTypes.bool.isRequired,
handleClose: PropTypes.func.isRequired,
data: PropTypes.object.isRequired,
p: polyglotPropTypes.isRequired,
};

export default compose(translate)(PrecomputedDataDialog);
69 changes: 52 additions & 17 deletions src/app/js/admin/precomputed/PrecomputedForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(
[],
Expand Down Expand Up @@ -386,23 +388,56 @@ export const PrecomputedForm = ({
{polyglot.t('precomputed_status')} : &nbsp;
{renderStatus(precomputedStatus, polyglot)}
</Typography>
<Button
variant="link"
sx={{
paddingRight: 0,
textDecoration: 'underline',
}}
onClick={() => setOpenPrecomputedLogs(true)}
>
{polyglot.t('see_logs')}
</Button>
<PrecomputedFormLogsDialogComponent
isOpen={openPrecomputedLogs}
logs={precomputedLogs}
handleClose={() =>
setOpenPrecomputedLogs(false)
}
/>
<Box>
<Button
variant="link"
sx={{
paddingRight: 0,
textDecoration: 'underline',
}}
onClick={() =>
setOpenPrecomputedLogs(true)
}
>
{polyglot.t('see_logs')}
</Button>
<PrecomputedFormLogsDialogComponent
isOpen={openPrecomputedLogs}
logs={precomputedLogs}
handleClose={() =>
setOpenPrecomputedLogs(false)
}
/>
{isEditMode &&
precomputedStatus === FINISHED && (
<>
<Button
variant="link"
sx={{
paddingRight: 0,
textDecoration:
'underline',
}}
onClick={() =>
setOpenPrecomputedData(
true,
)
}
>
{polyglot.t('see_data')}
</Button>
<PrecomputedFormDataDialogComponent
isOpen={openPrecomputedData}
data={initialValues.data}
handleClose={() =>
setOpenPrecomputedData(
false,
)
}
/>
</>
)}
</Box>
</Box>
)}
</Box>
Expand Down

0 comments on commit 49750ac

Please sign in to comment.