diff --git a/Client/src/Pages/Uptime/Home/UptimeTable/Skeleton/index.jsx b/Client/src/Pages/Uptime/Home/UptimeTable/Skeleton/index.jsx
index 22d885c97..c17f6d74b 100644
--- a/Client/src/Pages/Uptime/Home/UptimeTable/Skeleton/index.jsx
+++ b/Client/src/Pages/Uptime/Home/UptimeTable/Skeleton/index.jsx
@@ -1,32 +1,47 @@
-import { Skeleton, TableCell, TableRow } from "@mui/material";
+import { Skeleton } from "@mui/material";
+import DataTable from "../../../../../Components/Table";
const ROWS_NUMBER = 7;
const ROWS_ARRAY = Array.from({ length: ROWS_NUMBER }, (_, i) => i);
-const TableBodySkeleton = () => {
+const TableSkeleton = () => {
/* TODO Skeleton does not follow light and dark theme */
+
+ const headers = [
+ {
+ id: "name",
+
+ content: "Host",
+
+ render: () => ,
+ },
+ {
+ id: "status",
+ content: "Status",
+ render: () => ,
+ },
+ {
+ id: "responseTime",
+ content: "Response Time",
+ render: () => ,
+ },
+ {
+ id: "type",
+ content: "Type",
+ render: () => ,
+ },
+ {
+ id: "actions",
+ content: "Actions",
+ render: () => ,
+ },
+ ];
+
return (
- <>
- {ROWS_ARRAY.map((row) => (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ))}
- >
+
);
};
-export { TableBodySkeleton };
+export { TableSkeleton };
diff --git a/Client/src/Pages/Uptime/Home/UptimeTable/index.jsx b/Client/src/Pages/Uptime/Home/UptimeTable/index.jsx
index a19da2a43..0aa0eef90 100644
--- a/Client/src/Pages/Uptime/Home/UptimeTable/index.jsx
+++ b/Client/src/Pages/Uptime/Home/UptimeTable/index.jsx
@@ -10,27 +10,18 @@ import { logger } from "../../../../Utils/Logger";
import { jwtDecode } from "jwt-decode";
import { networkService } from "../../../../main";
-import {
- TableContainer,
- Table,
- TableHead,
- TableRow,
- TableCell,
- TableBody,
- Paper,
- Box,
- CircularProgress,
-} from "@mui/material";
+import { Box, CircularProgress } from "@mui/material";
import ActionsMenu from "../actionsMenu";
import Host from "../host";
import { StatusLabel } from "../../../../Components/Label";
-import { TableBodySkeleton } from "./Skeleton";
+import { TableSkeleton } from "./Skeleton";
import BarChart from "../../../../Components/Charts/BarChart";
import ArrowDownwardRoundedIcon from "@mui/icons-material/ArrowDownwardRounded";
import ArrowUpwardRoundedIcon from "@mui/icons-material/ArrowUpwardRounded";
-import { Pagination } from "../../../Infrastructure/components/TablePagination";
+import { Pagination } from "../../../../Components/Table/TablePagination";
+import DataTable from "../../../../Components/Table";
const MonitorTable = ({ isAdmin, filter, setIsSearching, isSearching, handlePause }) => {
const theme = useTheme();
@@ -46,7 +37,95 @@ const MonitorTable = ({ isAdmin, filter, setIsSearching, isSearching, handlePaus
const [monitorCount, setMonitorCount] = useState(0);
const [updateTrigger, setUpdateTrigger] = useState(false);
const [sort, setSort] = useState({});
+ const [data, setData] = useState([]);
const prevFilter = useRef(filter);
+ const headers = [
+ {
+ id: "name",
+ content: (
+ handleSort("name")}>
+ Host
+
+ {sort.order === "asc" ? (
+
+ ) : (
+
+ )}
+
+
+ ),
+ render: (row) => (
+
+ ),
+ },
+ {
+ id: "status",
+ content: (
+ handleSort("status")}
+ >
+ {" "}
+ Status
+
+ {sort.order === "asc" ? (
+
+ ) : (
+
+ )}
+
+
+ ),
+ render: (row) => {
+ const status = determineState(row.monitor);
+ return (
+
+ );
+ },
+ },
+ {
+ id: "responseTime",
+ content: "Response Time",
+ render: (row) => ,
+ },
+ {
+ id: "type",
+ content: "Type",
+ render: (row) => (
+ {row.monitor.type}
+ ),
+ },
+ {
+ id: "actions",
+ content: "Actions",
+ render: (row) => (
+
+ ),
+ },
+ ];
const handleRowUpdate = () => {
setUpdateTrigger((prev) => !prev);
@@ -144,7 +223,41 @@ const MonitorTable = ({ isAdmin, filter, setIsSearching, isSearching, handlePaus
setMonitors(res?.data?.data?.monitors ?? []);
setMonitorCount(res?.data?.data?.monitorCount ?? 0);
};
- /* TODO Apply component basic table? */
+
+ useEffect(() => {
+ const mappedMonitors = monitors.map((monitor) => {
+ let uptimePercentage = "";
+ let percentageColor = theme.palette.percentage.uptimeExcellent;
+
+ // Determine uptime percentage and color based on the monitor's uptimePercentage value
+ if (monitor.uptimePercentage !== undefined) {
+ uptimePercentage =
+ monitor.uptimePercentage === 0
+ ? "0"
+ : (monitor.uptimePercentage * 100).toFixed(2);
+
+ 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,
+ url: monitor.url,
+ title: monitor.name,
+ percentage: uptimePercentage,
+ percentageColor,
+ monitor: monitor,
+ };
+ });
+ setData(mappedMonitors);
+ }, [monitors, theme]);
+
return (
{isSearching && (
@@ -177,141 +290,37 @@ const MonitorTable = ({ isAdmin, filter, setIsSearching, isSearching, handlePaus
>
)}
-
-
-
-
- handleSort("name")}
- >
-
- Host
-
- {sort.order === "asc" ? (
-
- ) : (
-
- )}
-
-
-
- handleSort("status")}
- >
- {" "}
-
- {" "}
- Status
-
- {sort.order === "asc" ? (
-
- ) : (
-
- )}
-
-
-
- Response Time
- Type
- Actions
-
-
-
- {/* TODO add empty state. Check if is searching, and empty => skeleton. Is empty, not searching => skeleton */}
- {monitors.length > 0 ? (
- monitors.map((monitor) => {
- let uptimePercentage = "";
- let percentageColor = theme.palette.percentage.uptimeExcellent;
-
- // Determine uptime percentage and color based on the monitor's uptimePercentage value
- if (monitor.uptimePercentage !== undefined) {
- uptimePercentage =
- monitor.uptimePercentage === 0
- ? "0"
- : (monitor.uptimePercentage * 100).toFixed(2);
-
- 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;
- }
-
- const params = {
- url: monitor.url,
- title: monitor.name,
- percentage: uptimePercentage,
- percentageColor,
- status: determineState(monitor),
- };
-
- return (
- {
- navigate(`/uptime/${monitor._id}`);
- }}
- >
-
-
-
-
-
-
-
-
-
-
- {monitor.type}
-
-
-
-
-
- );
- })
- ) : (
-
- )}
-
-
-
+ {/*
+ This is the original SX for the row, doesn't match infrastructure table
+ rowSX: {
+ cursor: "pointer",
+ "&:hover": {
+ filter: "brightness(.75)",
+ opacity: 0.75,
+ transition: "filter 0.3s ease, opacity 0.3s ease",
+ },
+ },
+ */}
+ {monitors.length > 0 ? (
+ {
+ navigate(`/uptime/${row.id}`);
+ },
+ emptyView: "No monitors found",
+ }}
+ />
+ ) : (
+
+ )}