feat: adding Host component to Infrastructure and adapting it
This commit is contained in:
1 parent
88020e9207
commit
5ad2df1d84
3 files changed
+34
-22
No files matched your search
@@ -27,6 +27,7 @@ import { Pagination } from "./components/TablePagination";
|
|||||||
// import { getInfrastructureMonitorsByTeamId } from "../../Features/InfrastructureMonitors/infrastructureMonitorsSlice";
|
// import { getInfrastructureMonitorsByTeamId } from "../../Features/InfrastructureMonitors/infrastructureMonitorsSlice";
|
||||||
import { networkService } from "../../Utils/NetworkService.js";
|
import { networkService } from "../../Utils/NetworkService.js";
|
||||||
import CustomGauge from "../../Components/Charts/CustomGauge/index.jsx";
|
import CustomGauge from "../../Components/Charts/CustomGauge/index.jsx";
|
||||||
|
import Host from "../Monitors/Home/host.jsx";
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{ label: "Host" },
|
{ label: "Host" },
|
||||||
@@ -124,7 +125,8 @@ function Infrastructure(/* {isAdmin} */) {
|
|||||||
console.log({ monitors });
|
console.log({ monitors });
|
||||||
console.log(monitors[0]?.checks[0]?.memory.usage_percent);
|
console.log(monitors[0]?.checks[0]?.memory.usage_percent);
|
||||||
const monitorsAsRows = monitors.map((monitor) => ({
|
const monitorsAsRows = monitors.map((monitor) => ({
|
||||||
ip: monitor.name,
|
url: monitor.url,
|
||||||
|
name: monitor.name,
|
||||||
status: determineState(monitor),
|
status: determineState(monitor),
|
||||||
processor: (monitor?.checks[0]?.cpu.frequency / 1000).toFixed(2) + " GHz",
|
processor: (monitor?.checks[0]?.cpu.frequency / 1000).toFixed(2) + " GHz",
|
||||||
cpu: monitor?.checks[0]?.cpu.usage_percent * 100,
|
cpu: monitor?.checks[0]?.cpu.usage_percent * 100,
|
||||||
@@ -228,7 +230,12 @@ function Infrastructure(/* {isAdmin} */) {
|
|||||||
/* ROWS */ monitorsAsRows.map((row, index) => (
|
/* ROWS */ monitorsAsRows.map((row, index) => (
|
||||||
<TableRow key={index}>
|
<TableRow key={index}>
|
||||||
{/* TODO iterate over column and get column id, applying row[column.id] */}
|
{/* TODO iterate over column and get column id, applying row[column.id] */}
|
||||||
<TableCell>{row.ip}</TableCell>
|
<TableCell>
|
||||||
|
<Host
|
||||||
|
title={row.name}
|
||||||
|
url={row.url}
|
||||||
|
/>
|
||||||
|
</TableCell>
|
||||||
<TableCell align="center">
|
<TableCell align="center">
|
||||||
<StatusLabel
|
<StatusLabel
|
||||||
status={row.status}
|
status={row.status}
|
||||||
|
|||||||
@@ -274,7 +274,10 @@ const MonitorTable = ({ isAdmin, filter, setIsSearching, isSearching }) => {
|
|||||||
<TableCell>
|
<TableCell>
|
||||||
<Host
|
<Host
|
||||||
key={monitor._id}
|
key={monitor._id}
|
||||||
params={params}
|
url={params.url}
|
||||||
|
title={params.title}
|
||||||
|
percentageColor={params.percentageColor}
|
||||||
|
percentage={params.percentage}
|
||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
|
|||||||
@@ -6,12 +6,14 @@ import PropTypes from "prop-types";
|
|||||||
*
|
*
|
||||||
* @component
|
* @component
|
||||||
* @param {Object} params - An object containing the following properties:
|
* @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.title - The name of the host.
|
||||||
* @param {string} params.percentageColor - The color of the percentage text.
|
* @param {string} params.percentageColor - The color of the percentage text.
|
||||||
* @param {number} params.percentage - The percentage to display.
|
* @param {number} params.percentage - The percentage to display.
|
||||||
* @returns {React.ElementType} Returns a div element with the host details.
|
* @returns {React.ElementType} Returns a div element with the host details.
|
||||||
*/
|
*/
|
||||||
const Host = ({ params }) => {
|
const Host = ({ url, title, percentageColor, percentage }) => {
|
||||||
|
const noTitle = title === undefined || title === url;
|
||||||
return (
|
return (
|
||||||
<Box className="host">
|
<Box className="host">
|
||||||
<Box
|
<Box
|
||||||
@@ -32,30 +34,30 @@ const Host = ({ params }) => {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{params.title}
|
{title}
|
||||||
</Box>
|
</Box>
|
||||||
<Typography
|
{percentageColor && percentage && (
|
||||||
component="span"
|
<Typography
|
||||||
sx={{
|
component="span"
|
||||||
color: params.percentageColor,
|
sx={{
|
||||||
fontWeight: 500,
|
color: percentageColor,
|
||||||
ml: "15px",
|
fontWeight: 500,
|
||||||
}}
|
ml: "15px",
|
||||||
>
|
}}
|
||||||
{params.percentage}%
|
>
|
||||||
</Typography>
|
{percentage}%
|
||||||
<Box sx={{ opacity: 0.6 }}>{params.url}</Box>
|
</Typography>
|
||||||
|
)}
|
||||||
|
{!noTitle && <Box sx={{ opacity: 0.6 }}>{url}</Box>}
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
Host.propTypes = {
|
Host.propTypes = {
|
||||||
params: PropTypes.shape({
|
title: PropTypes.string,
|
||||||
title: PropTypes.string,
|
percentageColor: PropTypes.string,
|
||||||
percentageColor: PropTypes.string,
|
percentage: PropTypes.string,
|
||||||
percentage: PropTypes.string,
|
url: PropTypes.string,
|
||||||
url: PropTypes.string,
|
|
||||||
}).isRequired,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Host;
|
export default Host;
|
||||||
Reference in new issue
Block a user