Skip to content

Commit 4a6eb11

Browse files
authored
metrics html, don't display alert unless metrics exceed threshold (#501)
Signed-off-by: Harper, Jason M <[email protected]>
1 parent 2fcee8d commit 4a6eb11

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

cmd/metrics/resources/base.html

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,17 @@
165165

166166
const all_metrics = <<.ALLMETRICS>>
167167
const [current_metrics, setCurrent_metrics] = React.useState(JSON.parse(JSON.stringify(all_metrics)));
168+
const [hasHighlightedMetrics, setHasHighlightedMetrics] = React.useState(false);
168169
const description = <<.DESCRIPTION>>
169170
const metadata = <<.METADATA>>
170171
const system_info = <<.SYSTEMINFO>>
172+
173+
// Check for highlighted metrics whenever current_metrics changes
174+
React.useEffect(() => {
175+
// Look for any metrics that exceed their thresholds
176+
const hasHighlighted = current_metrics.some(row => row[5] === "Yes");
177+
setHasHighlightedMetrics(hasHighlighted);
178+
}, [current_metrics]);
171179
// Define consistent colors for TMA categories with child variations
172180
const tmaColors = {
173181
// Blue family for Frontend
@@ -704,7 +712,7 @@
704712
</TableHead>
705713
<TableBody>
706714
{current_metrics.map((row) => {
707-
// Check if this metric has exceed its threshold
715+
// Check if this metric has exceeded its threshold
708716
const exceedsThreshold = row[5] == "Yes";
709717
return (
710718
<TableRow
@@ -823,23 +831,25 @@
823831
</TableBody>
824832
</Table>
825833
</TableContainer>
826-
<Box sx={{ marginTop: "16px" }}>
827-
<Alert
828-
severity="warning"
829-
sx={{
830-
marginBottom: "24px",
831-
backgroundColor: 'rgba(255, 255, 0, 0.2)',
832-
'& .MuiAlert-icon': {
833-
color: 'rgba(0, 0, 0, 0.7)'
834-
},
835-
'& .MuiAlert-message': {
836-
color: 'rgba(0, 0, 0, 0.7)'
837-
}
838-
}}
839-
>
840-
Metrics with a mean value exceeding their threshold formula are highlighted in yellow, indicating potential performance issues or anomalies that may require further investigation. Hover over the warning icon next to the mean value for more information.
841-
</Alert>
842-
</Box>
834+
{hasHighlightedMetrics && (
835+
<Box sx={{ marginTop: "16px" }}>
836+
<Alert
837+
severity="warning"
838+
sx={{
839+
marginBottom: "24px",
840+
backgroundColor: 'rgba(255, 255, 0, 0.2)',
841+
'& .MuiAlert-icon': {
842+
color: 'rgba(0, 0, 0, 0.7)'
843+
},
844+
'& .MuiAlert-message': {
845+
color: 'rgba(0, 0, 0, 0.7)'
846+
}
847+
}}
848+
>
849+
Metrics with a mean value exceeding their threshold formula are highlighted in yellow, indicating potential performance issues or anomalies that may require further investigation. Hover over the warning icon next to the mean value for more information.
850+
</Alert>
851+
</Box>
852+
)}
843853
</TabPanel>
844854
<TabPanel
845855
value={systemTabs}

0 commit comments

Comments
 (0)