refactor: changing friendly to display name

This commit is contained in:
Caio Cabral committed 2024-11-29 10:17:09 -05:00
1 parent 221ec01543
commit 88020e9207
4 files changed
+22 -23

No files matched your search

@@ -54,8 +54,8 @@ const CustomGauge = ({ progress = 0, radius = 70, strokeWidth = 15, threshold =
const fillColor = const fillColor =
progressWithinRange > threshold progressWithinRange > threshold
? theme.palette.primary.main ? theme.palette.percentage.uptimePoor
: theme.palette.percentage.uptimePoor; : theme.palette.primary.main;
return ( return (
<Box <Box
@@ -2,6 +2,8 @@ import { RadialBarChart, RadialBar, ResponsiveContainer } from "recharts";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
/* TODO delete component */
const MINIMUM_VALUE = 0; const MINIMUM_VALUE = 0;
const MAXIMUM_VALUE = 100; const MAXIMUM_VALUE = 100;
const CHART_MAXIMUM_DATA = { const CHART_MAXIMUM_DATA = {
@@ -266,7 +266,8 @@ const CreateInfrastructureMonitor = () => {
<Field <Field
type="text" type="text"
id="name" id="name"
label="Friendly name" label="Display name"
placeholder="Google"
isOptional={true} isOptional={true}
value={infrastructureMonitor.name} value={infrastructureMonitor.name}
onBlur={handleBlur} onBlur={handleBlur}
+16 -20
View File
@@ -23,14 +23,11 @@ import {
import Breadcrumbs from "../../Components/Breadcrumbs"; import Breadcrumbs from "../../Components/Breadcrumbs";
import { StatusLabel } from "../../Components/Label"; import { StatusLabel } from "../../Components/Label";
import { Heading } from "../../Components/Heading"; import { Heading } from "../../Components/Heading";
import { Gauge } from "../../Components/Charts/Gauge";
import { Pagination } from "./components/TablePagination"; 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";
// const ROWS = Array.from(Array(20).keys()).map(() => mockedData);
const columns = [ const columns = [
{ label: "Host" }, { label: "Host" },
{ label: "Status" }, { label: "Status" },
@@ -41,6 +38,8 @@ const columns = [
{ label: "Actions" }, { label: "Actions" },
]; ];
const BREADCRUMBS = [{ name: `infrastructure`, path: "/infrastructure" }];
/* TODO /* TODO
Create reusable table component. Create reusable table component.
It should receive as a parameter the following object: It should receive as a parameter the following object:
@@ -122,21 +121,28 @@ function Infrastructure(/* {isAdmin} */) {
const { determineState } = useUtils(); const { determineState } = useUtils();
const { monitors, total: totalMonitors } = monitorState; const { monitors, total: totalMonitors } = monitorState;
console.log({ monitors });
console.log(monitors[0]?.checks[0]?.memory.usage_percent);
const monitorsAsRows = monitors.map((monitor) => ({ const monitorsAsRows = monitors.map((monitor) => ({
ip: monitor.name, ip: monitor.name,
status: determineState(monitor), status: determineState(monitor),
processor: "2Ghz" /* How to retrieve that? */, processor: (monitor?.checks[0]?.cpu.frequency / 1000).toFixed(2) + " GHz",
cpu: 80 /* How to retrieve that? */, cpu: monitor?.checks[0]?.cpu.usage_percent * 100,
mem: 50 /* How to retrieve that? */, mem: monitor?.checks[0]?.memory.usage_percent * 100,
disk: 70 /* How to retrieve that? */, disk: monitor?.checks[0]?.disk[0]?.usage_percent * 100,
})); }));
/* TODO when friendyly name i added, it shoul display frindly name + url */
/* TODO remove table scrollbar */
/* Fix search in monitors page */
/* Adding actions to the table */
/* Adding click on row action */
return ( return (
<Stack <Stack
component="main" component="main"
style={{ width: "100%", gap: "1rem" }} style={{ width: "100%", gap: "1rem" }}
> >
<Breadcrumbs list={[{ name: `infrastructure`, path: "/infrastructure" }]} /> <Breadcrumbs list={BREADCRUMBS} />
<Stack <Stack
direction="row" direction="row"
sx={{ sx={{
@@ -247,23 +253,13 @@ function Infrastructure(/* {isAdmin} */) {
</Stack> </Stack>
</TableCell> </TableCell>
<TableCell align="center"> <TableCell align="center">
{/* <Gauge
progressValue={row.cpu}
containerWidth={60}
/> */}
<CustomGauge progress={row.cpu} /> <CustomGauge progress={row.cpu} />
</TableCell> </TableCell>
<TableCell align="center"> <TableCell align="center">
<Gauge <CustomGauge progress={row.mem} />
progressValue={row.mem}
containerWidth={60}
/>
</TableCell> </TableCell>
<TableCell align="center"> <TableCell align="center">
<Gauge <CustomGauge progress={row.disk} />
progressValue={row.disk}
containerWidth={60}
/>
</TableCell> </TableCell>
<TableCell align="center"> <TableCell align="center">
{/* Get ActionsMenu from Monitor Table and create a component */} {/* Get ActionsMenu from Monitor Table and create a component */}