mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-17 21:00:45 +00:00
QQQ-37 fixing links to source-table (need full table meta data for primary key)
This commit is contained in:
@ -28,9 +28,10 @@ import Grid from "@mui/material/Grid";
|
|||||||
import Icon from "@mui/material/Icon";
|
import Icon from "@mui/material/Icon";
|
||||||
import List from "@mui/material/List";
|
import List from "@mui/material/List";
|
||||||
import ListItemText from "@mui/material/ListItemText";
|
import ListItemText from "@mui/material/ListItemText";
|
||||||
import React from "react";
|
import React, {useState} from "react";
|
||||||
import MDBox from "components/MDBox";
|
import MDBox from "components/MDBox";
|
||||||
import {ProcessSummaryLine} from "qqq/pages/process-run/model/ProcessSummaryLine";
|
import {ProcessSummaryLine} from "qqq/pages/process-run/model/ProcessSummaryLine";
|
||||||
|
import QClient from "qqq/utils/QClient";
|
||||||
|
|
||||||
interface Props
|
interface Props
|
||||||
{
|
{
|
||||||
@ -48,17 +49,26 @@ function QProcessSummaryResults({
|
|||||||
qInstance, process, table = null, processValues, step,
|
qInstance, process, table = null, processValues, step,
|
||||||
}: Props): JSX.Element
|
}: Props): JSX.Element
|
||||||
{
|
{
|
||||||
const sourceTable = qInstance.tables.get(processValues.sourceTable);
|
const [sourceTableMetaData, setSourceTableMetaData] = useState(null as QTableMetaData);
|
||||||
|
|
||||||
|
if(processValues.sourceTable && !sourceTableMetaData)
|
||||||
|
{
|
||||||
|
(async () =>
|
||||||
|
{
|
||||||
|
const sourceTableMetaData = await QClient.getInstance().loadTableMetaData(processValues.sourceTable)
|
||||||
|
setSourceTableMetaData(sourceTableMetaData);
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
|
||||||
const resultValidationList = (
|
const resultValidationList = (
|
||||||
<List sx={{mt: 2}}>
|
<List sx={{mt: 2}}>
|
||||||
{
|
{
|
||||||
processValues?.recordCount !== undefined && sourceTable && (
|
processValues?.recordCount !== undefined && sourceTableMetaData && (
|
||||||
<ListItem sx={{my: 2}}>
|
<ListItem sx={{my: 2}}>
|
||||||
<ListItemText primaryTypographyProps={{fontSize: 16}}>
|
<ListItemText primaryTypographyProps={{fontSize: 16}}>
|
||||||
{processValues.recordCount.toLocaleString()}
|
{processValues.recordCount.toLocaleString()}
|
||||||
{" "}
|
{" "}
|
||||||
{sourceTable.label}
|
{sourceTableMetaData.label}
|
||||||
{" "}
|
{" "}
|
||||||
records were processed.
|
records were processed.
|
||||||
</ListItemText>
|
</ListItemText>
|
||||||
@ -67,7 +77,7 @@ function QProcessSummaryResults({
|
|||||||
}
|
}
|
||||||
<List>
|
<List>
|
||||||
{
|
{
|
||||||
processValues.processResults && processValues.processResults.map((processSummaryLine: ProcessSummaryLine, i: number) => (new ProcessSummaryLine(processSummaryLine).getProcessSummaryListItem(i, sourceTable, qInstance, true)))
|
processValues.processResults && processValues.processResults.map((processSummaryLine: ProcessSummaryLine, i: number) => (new ProcessSummaryLine(processSummaryLine).getProcessSummaryListItem(i, sourceTableMetaData, qInstance, true)))
|
||||||
}
|
}
|
||||||
</List>
|
</List>
|
||||||
</List>
|
</List>
|
||||||
|
@ -36,6 +36,7 @@ import React, {useState} from "react";
|
|||||||
import MDBox from "components/MDBox";
|
import MDBox from "components/MDBox";
|
||||||
import MDTypography from "components/MDTypography";
|
import MDTypography from "components/MDTypography";
|
||||||
import {ProcessSummaryLine} from "qqq/pages/process-run/model/ProcessSummaryLine";
|
import {ProcessSummaryLine} from "qqq/pages/process-run/model/ProcessSummaryLine";
|
||||||
|
import QClient from "qqq/utils/QClient";
|
||||||
import QValueUtils from "qqq/utils/QValueUtils";
|
import QValueUtils from "qqq/utils/QValueUtils";
|
||||||
|
|
||||||
interface Props
|
interface Props
|
||||||
@ -60,7 +61,16 @@ function QValidationReview({
|
|||||||
}: Props): JSX.Element
|
}: Props): JSX.Element
|
||||||
{
|
{
|
||||||
const [previewRecordIndex, setPreviewRecordIndex] = useState(0);
|
const [previewRecordIndex, setPreviewRecordIndex] = useState(0);
|
||||||
const sourceTable = qInstance.tables.get(processValues.sourceTable);
|
const [sourceTableMetaData, setSourceTableMetaData] = useState(null as QTableMetaData);
|
||||||
|
|
||||||
|
if(processValues.sourceTable && !sourceTableMetaData)
|
||||||
|
{
|
||||||
|
(async () =>
|
||||||
|
{
|
||||||
|
const sourceTableMetaData = await QClient.getInstance().loadTableMetaData(processValues.sourceTable)
|
||||||
|
setSourceTableMetaData(sourceTableMetaData);
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
|
||||||
const updatePreviewRecordIndex = (offset: number) =>
|
const updatePreviewRecordIndex = (offset: number) =>
|
||||||
{
|
{
|
||||||
@ -120,10 +130,10 @@ function QValidationReview({
|
|||||||
const preValidationList = (
|
const preValidationList = (
|
||||||
<List sx={{mt: 2}}>
|
<List sx={{mt: 2}}>
|
||||||
{
|
{
|
||||||
processValues?.recordCount !== undefined && sourceTable && (
|
processValues?.recordCount !== undefined && sourceTableMetaData && (
|
||||||
<ListItem sx={{my: 2}}>
|
<ListItem sx={{my: 2}}>
|
||||||
<ListItemText primaryTypographyProps={{fontSize: 16}}>
|
<ListItemText primaryTypographyProps={{fontSize: 16}}>
|
||||||
{`Input: ${processValues.recordCount.toLocaleString()} ${sourceTable?.label} record${processValues.recordCount === 1 ? "" : "s"}.`}
|
{`Input: ${processValues.recordCount.toLocaleString()} ${sourceTableMetaData?.label} record${processValues.recordCount === 1 ? "" : "s"}.`}
|
||||||
</ListItemText>
|
</ListItemText>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
)
|
)
|
||||||
@ -175,11 +185,11 @@ function QValidationReview({
|
|||||||
const postValidationList = (
|
const postValidationList = (
|
||||||
<List sx={{mt: 2}}>
|
<List sx={{mt: 2}}>
|
||||||
{
|
{
|
||||||
processValues?.recordCount !== undefined && sourceTable && (
|
processValues?.recordCount !== undefined && sourceTableMetaData && (
|
||||||
<ListItem sx={{my: 2}}>
|
<ListItem sx={{my: 2}}>
|
||||||
<ListItemText primaryTypographyProps={{fontSize: 16}}>
|
<ListItemText primaryTypographyProps={{fontSize: 16}}>
|
||||||
Validation complete on
|
Validation complete on
|
||||||
{` ${processValues.recordCount.toLocaleString()} ${sourceTable?.label} `}
|
{` ${processValues.recordCount.toLocaleString()} ${sourceTableMetaData?.label} `}
|
||||||
records.
|
records.
|
||||||
</ListItemText>
|
</ListItemText>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
@ -187,7 +197,7 @@ function QValidationReview({
|
|||||||
}
|
}
|
||||||
<List>
|
<List>
|
||||||
{
|
{
|
||||||
processValues.validationSummary && processValues.validationSummary.map((processSummaryLine: ProcessSummaryLine, i: number) => (new ProcessSummaryLine(processSummaryLine).getProcessSummaryListItem(i, sourceTable, qInstance)))
|
processValues.validationSummary && processValues.validationSummary.map((processSummaryLine: ProcessSummaryLine, i: number) => (new ProcessSummaryLine(processSummaryLine).getProcessSummaryListItem(i, sourceTableMetaData, qInstance)))
|
||||||
}
|
}
|
||||||
</List>
|
</List>
|
||||||
</List>
|
</List>
|
||||||
|
@ -68,6 +68,21 @@ export class ProcessSummaryLine
|
|||||||
messageWords.splice(messageWords.length - 1, 1);
|
messageWords.splice(messageWords.length - 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// try to get a link to the records - but note, it may come back null for various reasons - //
|
||||||
|
// if it's null, then don't output a link tag. //
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
const linkToRecords = this.getLinkToRecords(table, qInstance);
|
||||||
|
let linkTag = null;
|
||||||
|
if(linkToRecords)
|
||||||
|
{
|
||||||
|
linkTag = <Link target="_blank" to={linkToRecords}>
|
||||||
|
<Tooltip title="See these records in a new tab" sx={{py: 0}}>
|
||||||
|
<IconButton sx={{py: 0}}><Icon fontSize="small">open_in_new</Icon></IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
</Link>
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ListItem key={i} sx={{pl: 4, my: 2}}>
|
<ListItem key={i} sx={{pl: 4, my: 2}}>
|
||||||
<MDBox display="flex" alignItems="top">
|
<MDBox display="flex" alignItems="top">
|
||||||
@ -76,15 +91,9 @@ export class ProcessSummaryLine
|
|||||||
{/* work hard to prevent the icon from falling down to the next line by itself... */}
|
{/* work hard to prevent the icon from falling down to the next line by itself... */}
|
||||||
{`${this.count.toLocaleString()} ${messageWords.join(" ")} `}
|
{`${this.count.toLocaleString()} ${messageWords.join(" ")} `}
|
||||||
{
|
{
|
||||||
(table && this.primaryKeys) ? (
|
(linkTag) ? (
|
||||||
<span style={{whiteSpace: "nowrap"}}>
|
<span style={{whiteSpace: "nowrap"}}>
|
||||||
{/* eslint-disable-next-line react/jsx-one-expression-per-line */}
|
{lastWord} {linkTag}
|
||||||
{lastWord} <Link target="_blank" to={this.getLinkToRecords(table, qInstance)}>
|
|
||||||
<Tooltip title="See these records in a new tab" sx={{py: 0}}>
|
|
||||||
<IconButton sx={{py: 0}}><Icon fontSize="small">open_in_new</Icon></IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
{/* eslint-disable-next-line react/jsx-closing-tag-location */}
|
|
||||||
</Link>
|
|
||||||
</span>
|
</span>
|
||||||
) : <span>{lastWord}</span>
|
) : <span>{lastWord}</span>
|
||||||
}
|
}
|
||||||
@ -139,10 +148,42 @@ export class ProcessSummaryLine
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private getLinkToRecords(table: QTableMetaData, qInstance: QInstance): string
|
private getLinkToRecords(table: QTableMetaData, qInstance: QInstance): string | null
|
||||||
{
|
{
|
||||||
|
if(!table)
|
||||||
|
{
|
||||||
|
console.log("No table, so not returning a link to records");
|
||||||
|
return (null);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!table.primaryKeyField)
|
||||||
|
{
|
||||||
|
console.log("No table.primaryKeyField, so not returning a link to records");
|
||||||
|
return (null);
|
||||||
|
}
|
||||||
|
|
||||||
const tablePath = qInstance.getTablePath(table);
|
const tablePath = qInstance.getTablePath(table);
|
||||||
|
if(!tablePath)
|
||||||
|
{
|
||||||
|
console.log("No tablePath, so not returning a link to records");
|
||||||
|
return (null);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!this.primaryKeys)
|
||||||
|
{
|
||||||
|
console.log("No primaryKeys, so not returning a link to records");
|
||||||
|
return (null);
|
||||||
|
}
|
||||||
|
|
||||||
const filter = new QQueryFilter([new QFilterCriteria(table.primaryKeyField, QCriteriaOperator.IN, this.primaryKeys)]);
|
const filter = new QQueryFilter([new QFilterCriteria(table.primaryKeyField, QCriteriaOperator.IN, this.primaryKeys)]);
|
||||||
return (`${tablePath}?filter=${JSON.stringify(filter)}`);
|
const path = `${tablePath}?filter=${JSON.stringify(filter)}`;
|
||||||
|
|
||||||
|
if(path.length > 2048)
|
||||||
|
{
|
||||||
|
console.log(`Path is too long [${path.length}], so not returning a link to records.`);
|
||||||
|
return (null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user