diff --git a/Client/src/Components/MonitorTable/index.jsx b/Client/src/Components/MonitorTable/index.jsx
index 5e032f875..c84313b52 100644
--- a/Client/src/Components/MonitorTable/index.jsx
+++ b/Client/src/Components/MonitorTable/index.jsx
@@ -3,117 +3,137 @@ import PropTypes from "prop-types";
import { DataGrid } from "@mui/x-data-grid";
import OpenIt from "../../assets/Images/Icon-open-in-tab-gray.png";
import ResponseTimeChart from "../Charts/ResponseTimeChart";
-import { useState, useEffect } from "react";
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableContainer,
+ TableHead,
+ TableRow,
+ Paper,
+} from "@mui/material";
+
+/**
+ * Host component.
+ * This subcomponent receives a params object and displays the host details.
+ *
+ * @component
+ * @param {Object} params - An object containing the following properties:
+ * @param {string} params.url - The URL of the host.
+ * @param {string} params.title - The name of the host.
+ * @param {string} params.percentageColor - The color of the percentage text.
+ * @param {number} params.precentage - The percentage to display.
+ * @returns {React.ElementType} Returns a div element with the host details.
+ */
const Host = ({ params }) => {
return (
-
+
-
{params.value.title}
+
{params.title}
- {params.value.precentage}%
+ {params.precentage}%
);
};
+/**
+ * Status component.
+ * This subcomponent receives a params object and displays the status details of a monitor.
+ *
+ * @component
+ * @param {Object} params - An object containing the following properties:
+ * @param {string} params.backgroundColor - The background color of the status box.
+ * @param {string} params.statusDotColor - The color of the status dot.
+ * @param {string} params.status - The status text to display.
+ * @returns {React.ElementType} Returns a div element with the host status.
+ */
const Status = ({ params }) => {
return (
-
{params.value.status}
+
{params.status}
);
};
-const cols = [
- {
- field: "host",
- headerName: "Host",
- renderCell: (params) => {
- return ;
- },
- flex: 1,
- },
- {
- field: "status",
- headerName: "Status",
- renderCell: (params) => {
- return ;
- },
- },
- {
- field: "response",
- headerName: "Response",
- renderCell: (params) => {
- return ;
- },
- flex: 1,
- },
- {
- field: "actions",
- headerName: "Actions",
- },
-];
-
+/**
+ * MonitorTable component.
+ * Takes an array of monitor objects and displays them in a table.
+ * Each row in the table represents a monitor and includes the host, status, response time, and action.
+ *
+ * @component
+ * @param {Object[]} monitors - An array of monitor objects. Each object should have the following properties:
+ * @param {string} monitors[].url - The URL of the monitor.
+ * @param {string} monitors[].name - The name of the monitor.
+ * @param {boolean} monitors[].status - The status of the monitor. True if the monitor is up, false otherwise.
+ * @param {Object[]} monitors[].checks - An array of check objects for the response time chart.
+ * @returns {React.Component} Returns a table with the monitor data.
+ */
const MonitorTable = ({ monitors = [] }) => {
- const [rows, setRows] = useState([]);
- useEffect(() => {
- const mappedRows = monitors.map((monitor) => {
- return {
- id: monitor._id,
- host: {
- title: monitor.name,
- url: monitor.url,
- precentage: 100,
- percentageColor:
- monitor.status === true
- ? "var(--env-var-color-17)"
- : "var(--env-var-color-19)",
- },
- status: {
- status: monitor.status === true ? "Up" : "Down",
- backgroundColor:
- monitor.status === true
- ? "var(--env-var-color-20)"
- : "var(--env-var-color-21)",
- statusDotColor:
- monitor.status === true
- ? "var(--env-var-color-17)"
- : "var(--env-var-color-19)",
- },
- response: {
- checks: monitor.checks,
- },
- };
- });
- setRows(mappedRows);
- }, [monitors]);
+ const mappedRows = monitors.map((monitor) => {
+ const params = {
+ url: monitor.url,
+ title: monitor.name,
+ precentage: 100,
+ percentageColor:
+ monitor.status === true
+ ? "var(--env-var-color-17)"
+ : "var(--env-var-color-19)",
+ status: monitor.status === true ? "up" : "down",
+ backgroundColor:
+ monitor.status === true
+ ? "var(--env-var-color-20)"
+ : "var(--env-var-color-21)",
+ statusDotColor:
+ monitor.status === true
+ ? "var(--env-var-color-17)"
+ : "var(--env-var-color-19)",
+ };
+
+ return (
+
+
+
+
+
+
+
+
+
+
+ TODO Add Actions
+
+ );
+ });
return (
-
+
+
+
+
+ Host
+ Status
+ Response Time
+ Action
+
+
+ {mappedRows}
+
+
);
};