add uptime percentage to Hardware Monitors

This commit is contained in:
Alex Holliday committed 2024-11-30 16:50:31 +08:00
1 parent e5a1cd1294
commit 79d8d61944
1 file changed
+71 -67
+71 -67
View File
@@ -125,6 +125,8 @@ function Infrastructure() {
const { determineState } = useUtils(); const { determineState } = useUtils();
const { monitors, total: totalMonitors } = monitorState; const { monitors, total: totalMonitors } = monitorState;
console.log(monitors);
const monitorsAsRows = monitors.map((monitor) => { const monitorsAsRows = monitors.map((monitor) => {
const processor = const processor =
((monitor.checks[0]?.cpu?.usage_frequency ?? 0) / 1000).toFixed(2) + " GHz"; ((monitor.checks[0]?.cpu?.usage_frequency ?? 0) / 1000).toFixed(2) + " GHz";
@@ -224,78 +226,80 @@ function Infrastructure() {
</TableRow> </TableRow>
</TableHead> </TableHead>
<TableBody> <TableBody>
{monitorsAsRows.map((row) => ( {monitorsAsRows.map((row) => {
<TableRow return (
key={row.id} <TableRow
onClick={() => openDetails(row.id)} key={row.id}
sx={{ onClick={() => openDetails(row.id)}
cursor: "pointer", sx={{
"&:hover": { cursor: "pointer",
backgroundColor: theme.palette.background.accent, "&:hover": {
}, backgroundColor: theme.palette.background.accent,
}} },
> }}
{/* TODO iterate over column and get column id, applying row[column.id] */} >
<TableCell> {/* TODO iterate over column and get column id, applying row[column.id] */}
<Host <TableCell>
title={row.name} <Host
url={row.url} title={row.name}
/> url={row.url}
</TableCell>
<TableCell align="center">
<StatusLabel
status={row.status}
text={row.status}
/* Use capitalize inside of Status Label */
/* Update component so we don't need to pass text and status separately*/
customStyles={{ textTransform: "capitalize" }}
/>
</TableCell>
<TableCell align="center">
<Stack
direction={"row"}
justifyContent={"center"}
alignItems={"center"}
gap=".25rem"
>
<CPUChipIcon
width={20}
height={20}
/> />
{row.processor} </TableCell>
</Stack> <TableCell align="center">
</TableCell> <StatusLabel
<TableCell align="center"> status={row.status}
<CustomGauge progress={row.cpu} /> text={row.status}
</TableCell> /* Use capitalize inside of Status Label */
<TableCell align="center"> /* Update component so we don't need to pass text and status separately*/
<CustomGauge progress={row.mem} /> customStyles={{ textTransform: "capitalize" }}
</TableCell>
<TableCell align="center">
<CustomGauge progress={row.disk} />
</TableCell>
<TableCell align="center">
{/* Get ActionsMenu from Monitor Table and create a component */}
<IconButton
sx={{
"& svg path": {
stroke: theme.palette.other.icon,
},
}}
>
<InfrastructureMenu
monitor={row}
isAdmin={isAdmin}
updateCallback={handleActionMenuDelete}
/> />
{/* <GearIcon </TableCell>
<TableCell align="center">
<Stack
direction={"row"}
justifyContent={"center"}
alignItems={"center"}
gap=".25rem"
>
<CPUChipIcon
width={20}
height={20}
/>
{row.processor}
</Stack>
</TableCell>
<TableCell align="center">
<CustomGauge progress={row.cpu} />
</TableCell>
<TableCell align="center">
<CustomGauge progress={row.mem} />
</TableCell>
<TableCell align="center">
<CustomGauge progress={row.disk} />
</TableCell>
<TableCell align="center">
{/* Get ActionsMenu from Monitor Table and create a component */}
<IconButton
sx={{
"& svg path": {
stroke: theme.palette.other.icon,
},
}}
>
<InfrastructureMenu
monitor={row}
isAdmin={isAdmin}
updateCallback={handleActionMenuDelete}
/>
{/* <GearIcon
width={20} width={20}
height={20} height={20}
/> */} /> */}
</IconButton> </IconButton>
</TableCell> </TableCell>
</TableRow> </TableRow>
))} );
})}
</TableBody> </TableBody>
</Table> </Table>
</TableContainer> </TableContainer>