diff --git a/Client/src/Pages/Infrastructure/index.jsx b/Client/src/Pages/Infrastructure/index.jsx
index 10d897da7..af24bf861 100644
--- a/Client/src/Pages/Infrastructure/index.jsx
+++ b/Client/src/Pages/Infrastructure/index.jsx
@@ -125,7 +125,7 @@ function Infrastructure() {
const { determineState } = useUtils();
const { monitors, total: totalMonitors } = monitorState;
-
+ // do it here
function openDetails(id) {
navigate(`/infrastructure/${id}`);
}
@@ -133,6 +133,38 @@ function Infrastructure() {
fetchMonitors();
}
+ const monitorsAsRows = monitors.map((monitor) => {
+ const processor =
+ ((monitor.checks[0]?.cpu?.usage_frequency ?? 0) / 1000).toFixed(2) + " GHz";
+ const cpu = (monitor?.checks[0]?.cpu.usage_percent ?? 0) * 100;
+ const mem = (monitor?.checks[0]?.memory.usage_percent ?? 0) * 100;
+ const disk = (monitor?.checks[0]?.disk[0]?.usage_percent ?? 0) * 100;
+ const status = determineState(monitor);
+ const uptimePercentage = ((monitor?.uptimePercentage ?? 0) * 100)
+ .toFixed(2)
+ .toString();
+ const percentageColor =
+ monitor.uptimePercentage < 0.25
+ ? theme.palette.percentage.uptimePoor
+ : monitor.uptimePercentage < 0.5
+ ? theme.palette.percentage.uptimeFair
+ : monitor.uptimePercentage < 0.75
+ ? theme.palette.percentage.uptimeGood
+ : theme.palette.percentage.uptimeExcellent;
+ return {
+ id: monitor._id,
+ name: monitor.name,
+ url: monitor.url,
+ processor,
+ cpu,
+ mem,
+ disk,
+ status,
+ uptimePercentage,
+ percentageColor,
+ };
+ });
+
return (
- {monitors.map((monitor) => {
- const processor =
- ((monitor.checks[0]?.cpu?.usage_frequency ?? 0) / 1000).toFixed(2) +
- " GHz";
- const cpu = (monitor?.checks[0]?.cpu.usage_percent ?? 0) * 100;
- const mem = (monitor?.checks[0]?.memory.usage_percent ?? 0) * 100;
- const disk = (monitor?.checks[0]?.disk[0]?.usage_percent ?? 0) * 100;
- const status = determineState(monitor);
- const uptimePercentage = ((monitor?.uptimePercentage ?? 0) * 100)
- .toFixed(2)
- .toString();
- const percentageColor =
- monitor.uptimePercentage < 0.25
- ? theme.palette.percentage.uptimePoor
- : monitor.uptimePercentage < 0.5
- ? theme.palette.percentage.uptimeFair
- : monitor.uptimePercentage < 0.75
- ? theme.palette.percentage.uptimeGood
- : theme.palette.percentage.uptimeExcellent;
+ {monitorsAsRows.map((row) => {
return (
openDetails(monitor.id)}
+ key={row.id}
+ onClick={() => openDetails(row.id)}
sx={{
cursor: "pointer",
"&:hover": {
@@ -240,16 +254,16 @@ function Infrastructure() {
{/* TODO iterate over column and get column id, applying row[column.id] */}
- {processor}
+ {row.processor}
-
+
-
+
-
+
{/* Get ActionsMenu from Monitor Table and create a component */}
@@ -288,7 +302,7 @@ function Infrastructure() {
}}
>