diff --git a/frontend/src/api/cubicweb.ts b/frontend/src/api/cubicweb.ts index f51fd48d5aef7f29cd403590e66b67e702afaba6_ZnJvbnRlbmQvc3JjL2FwaS9jdWJpY3dlYi50cw==..0558e92efffa0b0daad95b753ce66d96001309b6_ZnJvbnRlbmQvc3JjL2FwaS9jdWJpY3dlYi50cw== 100644 --- a/frontend/src/api/cubicweb.ts +++ b/frontend/src/api/cubicweb.ts @@ -306,6 +306,6 @@ // the state to fetch the TrInfo which leads to this state, and with the TrInfo entity you do have the // creation_date, the comment and so on return ( - "Any X, MAX(VAL_DATE), VAL_RECIPE, VAL_PROJECT, VAL_STATE " + - "GROUPBY X, VAL_RECIPE, VAL_PROJECT, VAL_STATE " + + "Any X, MAX(VAL_DATE), VAL_RECIPE, VAL_PROJECT, VAL_STATE, ATTR_SHACL_VALID " + + "GROUPBY X, VAL_RECIPE, VAL_PROJECT, VAL_STATE, ATTR_SHACL_VALID " + "ORDERBY MAX(VAL_DATE) DESC " + @@ -311,5 +311,5 @@ "ORDERBY MAX(VAL_DATE) DESC " + - "WHERE X is ImportProcess, " + + "WHERE X is ImportProcess, X shacl_valid ATTR_SHACL_VALID, " + getImportRecipePart(hasDataService, hasRecipe) + getImportProcedurePart(hasProject) + "X in_state S, S name VAL_STATE, " + @@ -341,8 +341,8 @@ // TODO fetch files for all import processes // See https://forge.extranet.logilab.fr/cubicweb/RQL/-/merge_requests/99 const dataLogQuery = transaction.push( - "Any X, DATA.download_url(), LOG.download_url() WHERE X eid %(eid)s, " + - "X has_output_dataset DATA?, X import_report LOG?", + "Any X, DATA.download_url(), LOG.download_url(), SHACL.download_url() WHERE X eid %(eid)s, " + + "X has_output_dataset DATA?, X import_report LOG?, X shacl_report SHACL?", { eid: importProcessListQuery.ref().row(0).column(0) }, ); const result = await client.executeTransaction(transaction); @@ -353,8 +353,9 @@ for (const result of importProcessListResult) { const dataLog = dataLogListResult.find((e) => e[0] === result[0]); if (dataLog != undefined) { - result[5] = dataLog[1]; - result[6] = dataLog[2]; + result[6] = dataLog[1]; + result[7] = dataLog[2]; + result[8] = dataLog[3]; } } return importProcessListResultSetToObject(importProcessListResult); @@ -378,8 +379,10 @@ recipe: r[2], project: r[3], state: r[4], - dataset_url: r[5], - log_url: r[6], + shacl_valid: r[5], + dataset_url: r[6], + log_url: r[7], + shacl_report_url: r[8], } as ImportProcess; }); } diff --git a/frontend/src/components/ImportProcessTable.tsx b/frontend/src/components/ImportProcessTable.tsx index f51fd48d5aef7f29cd403590e66b67e702afaba6_ZnJvbnRlbmQvc3JjL2NvbXBvbmVudHMvSW1wb3J0UHJvY2Vzc1RhYmxlLnRzeA==..0558e92efffa0b0daad95b753ce66d96001309b6_ZnJvbnRlbmQvc3JjL2NvbXBvbmVudHMvSW1wb3J0UHJvY2Vzc1RhYmxlLnRzeA== 100644 --- a/frontend/src/components/ImportProcessTable.tsx +++ b/frontend/src/components/ImportProcessTable.tsx @@ -9,6 +9,8 @@ CircularProgress, Typography, IconButton, + Tooltip, + Box, } from "@mui/material"; import CheckIcon from "@mui/icons-material/Check"; import CloseIcon from "@mui/icons-material/Close"; @@ -32,6 +34,8 @@ if (url) { const fileToOpen = await downloadFile(url); openFile(fileToOpen); + } else { + console.error("No file to open"); } } @@ -73,6 +77,7 @@ <TableCell>Projet</TableCell> <TableCell width={50}>Dataset</TableCell> <TableCell width={50}>Log</TableCell> + <TableCell width={50}>SHACL</TableCell> </TableRow> </TableHead> <TableBody> @@ -134,7 +139,8 @@ </IconButton> </ButtonTooltip> </TableCell> + <ShaclButton importProcess={importProcess} /> </TableRow> ); } @@ -137,7 +143,39 @@ </TableRow> ); } +function ShaclButton({ importProcess }: { importProcess: ImportProcess }) { + if (importProcess.shacl_valid) { + return ( + <TableCell> + <Tooltip title="La validation SHACL a réussi"> + <Box + style={{ + display: "flex", + justifyContent: "center", + alignItems: "center", + }} + > + <CheckIcon /> + </Box> + </Tooltip> + </TableCell> + ); + } + return ( + <TableCell> + <ButtonTooltip title={"Voir le rapport d'erreur SHACL"}> + <IconButton + color="primary" + onClick={() => showFile(importProcess.shacl_report_url)} + > + <Visibility color="warning" /> + </IconButton> + </ButtonTooltip> + </TableCell> + ); +} + function StateIcon({ state }: { state: ImportProcess["state"] }) { if (state === "successful") { return <CheckIcon />; diff --git a/frontend/src/types.ts b/frontend/src/types.ts index f51fd48d5aef7f29cd403590e66b67e702afaba6_ZnJvbnRlbmQvc3JjL3R5cGVzLnRz..0558e92efffa0b0daad95b753ce66d96001309b6_ZnJvbnRlbmQvc3JjL3R5cGVzLnRz 100644 --- a/frontend/src/types.ts +++ b/frontend/src/types.ts @@ -41,4 +41,6 @@ state: "waiting" | "ongoing" | "error" | "successful"; dataset_url?: string; log_url?: string; + shacl_valid: boolean; + shacl_report_url?: string; };