2024-11-15 14:55:05 -05:00
|
|
|
import {
|
|
|
|
|
Box,
|
|
|
|
|
Button,
|
|
|
|
|
Stack,
|
|
|
|
|
Table,
|
|
|
|
|
TableBody,
|
|
|
|
|
TableCell,
|
|
|
|
|
TableContainer,
|
2024-11-16 22:48:46 -05:00
|
|
|
TableFooter,
|
2024-11-15 14:55:05 -05:00
|
|
|
TableHead,
|
2024-11-16 22:48:46 -05:00
|
|
|
TablePagination,
|
2024-11-15 14:55:05 -05:00
|
|
|
TableRow,
|
|
|
|
|
} from "@mui/material";
|
2024-11-08 18:36:43 -05:00
|
|
|
import { Heading } from "../../Components/Heading";
|
2024-11-15 14:55:05 -05:00
|
|
|
import { useTheme } from "@emotion/react";
|
|
|
|
|
import Greeting from "../../Utils/greeting";
|
|
|
|
|
import Breadcrumbs from "../../Components/Breadcrumbs";
|
2024-11-16 22:48:46 -05:00
|
|
|
import { StatusLabel } from "../../Components/Label";
|
|
|
|
|
import { Gauge } from "../../Components/Charts/Gauge";
|
2024-11-15 14:55:05 -05:00
|
|
|
|
|
|
|
|
const mockedData = {
|
|
|
|
|
ip: "https://192.168.1.30",
|
2024-11-16 22:48:46 -05:00
|
|
|
status: "up",
|
2024-11-15 14:55:05 -05:00
|
|
|
processor: "2Ghz",
|
|
|
|
|
cpu: 80,
|
|
|
|
|
mem: 50,
|
|
|
|
|
disk: 70,
|
|
|
|
|
};
|
|
|
|
|
|
2024-11-16 22:48:46 -05:00
|
|
|
const ROWS = Array.from(Array(20).keys()).map(() => mockedData);
|
2024-11-15 14:55:05 -05:00
|
|
|
console.log(ROWS);
|
|
|
|
|
|
|
|
|
|
const columns = [
|
|
|
|
|
{
|
|
|
|
|
label: "Host",
|
|
|
|
|
/* id: "name", */
|
|
|
|
|
/* minWidth: 170 */
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
/* id: "code", */
|
|
|
|
|
label: "Status",
|
|
|
|
|
/* minWidth: 100 */
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
/* id: "population", */
|
|
|
|
|
label: "Frequency",
|
|
|
|
|
/* minWidth: 170,
|
|
|
|
|
align: "right", */
|
|
|
|
|
/* format: (value) => value.toLocaleString("en-US"), */
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
/* id: "size", */
|
|
|
|
|
label: "CPU",
|
|
|
|
|
/* minWidth: 170, */
|
|
|
|
|
/* align: "right", */
|
|
|
|
|
/* format: (value) => value.toLocaleString("en-US"), */
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
/* id: "density", */
|
|
|
|
|
label: "Mem",
|
|
|
|
|
/* minWidth: 170, */
|
|
|
|
|
/* align: "right",
|
|
|
|
|
format: (value) => value.toFixed(2), */
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "Disk",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "Actions",
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/* TODO steps
|
|
|
|
|
|
|
|
|
|
1) Extract Client\src\Pages\Monitors\Home\MonitorTable\index.jsx to reusable component
|
|
|
|
|
|
|
|
|
|
...
|
|
|
|
|
z) Check error pointed by Shemy on theme
|
|
|
|
|
*/
|
2024-11-08 18:36:43 -05:00
|
|
|
|
2024-11-13 21:10:00 -05:00
|
|
|
/**
|
|
|
|
|
* This is the Infrastructure monitoring page. This is a work in progress
|
|
|
|
|
*
|
|
|
|
|
* @param - Define params.
|
|
|
|
|
* @returns {JSX.Element} The infrastructure monitoring page.
|
|
|
|
|
*/
|
|
|
|
|
|
2024-11-07 04:21:32 -05:00
|
|
|
function Infrastructure() {
|
2024-11-15 14:55:05 -05:00
|
|
|
const theme = useTheme();
|
2024-11-08 18:36:43 -05:00
|
|
|
return (
|
2024-11-15 14:55:05 -05:00
|
|
|
<Stack
|
|
|
|
|
component="main"
|
|
|
|
|
style={{ width: "100%", gap: "1rem" }}
|
|
|
|
|
>
|
|
|
|
|
<Breadcrumbs list={[{ name: `infrastructure`, path: "/infrastructure" }]} />
|
|
|
|
|
<Stack
|
|
|
|
|
direction="row"
|
|
|
|
|
/* spacing={8} */
|
|
|
|
|
sx={{
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
gap: "1rem",
|
|
|
|
|
flexWrap: "wrap",
|
|
|
|
|
marginBottom: "3rem",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2024-11-16 22:48:46 -05:00
|
|
|
<Box style={{ maxWidth: "65ch" }}>
|
|
|
|
|
<Greeting type="uptime" />
|
|
|
|
|
</Box>
|
2024-11-15 14:55:05 -05:00
|
|
|
<Button
|
|
|
|
|
variant="contained"
|
|
|
|
|
color="primary"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
// navigate("/monitors/create");
|
|
|
|
|
}}
|
|
|
|
|
sx={{ fontWeight: 500 }}
|
|
|
|
|
>
|
|
|
|
|
Create infrastructure monitor
|
|
|
|
|
</Button>
|
|
|
|
|
</Stack>
|
|
|
|
|
<Stack
|
|
|
|
|
sx={{
|
|
|
|
|
gap: "1rem",
|
2024-11-08 18:36:43 -05:00
|
|
|
}}
|
|
|
|
|
>
|
2024-11-15 14:55:05 -05:00
|
|
|
<Stack
|
|
|
|
|
direction="row"
|
|
|
|
|
/* spacing={8} */
|
|
|
|
|
sx={{
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
gap: ".25rem",
|
|
|
|
|
flexWrap: "wrap",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Heading component="h2">Infrastructure monitors</Heading>
|
|
|
|
|
{/* TODO Correct the class, messy stuff */}
|
|
|
|
|
<Box
|
|
|
|
|
component="span"
|
|
|
|
|
className="current-monitors-counter"
|
|
|
|
|
color={theme.palette.text.primary}
|
|
|
|
|
border={1}
|
|
|
|
|
borderColor={theme.palette.border.light}
|
|
|
|
|
backgroundColor={theme.palette.background.accent}
|
|
|
|
|
>
|
|
|
|
|
5
|
|
|
|
|
</Box>
|
|
|
|
|
</Stack>
|
|
|
|
|
<TableContainer>
|
|
|
|
|
<Table stickyHeader>
|
|
|
|
|
<TableHead>
|
|
|
|
|
<TableRow>
|
|
|
|
|
{columns.map((column, index) => (
|
|
|
|
|
<TableCell
|
|
|
|
|
key={index}
|
|
|
|
|
/* align={column.align} */
|
|
|
|
|
/* style={{ minWidth: column.minWidth }} */
|
|
|
|
|
>
|
|
|
|
|
{column.label}
|
|
|
|
|
</TableCell>
|
|
|
|
|
))}
|
|
|
|
|
</TableRow>
|
|
|
|
|
</TableHead>
|
|
|
|
|
<TableBody>
|
|
|
|
|
{ROWS.map((row, index) => (
|
|
|
|
|
<TableRow key={index}>
|
|
|
|
|
{/* TODO iterate over column and get column id, applying row[column.id] */}
|
|
|
|
|
<TableCell>{row.ip}</TableCell>
|
2024-11-16 22:48:46 -05:00
|
|
|
<TableCell>
|
|
|
|
|
<StatusLabel
|
|
|
|
|
status={row.status}
|
|
|
|
|
text={row.status}
|
|
|
|
|
/* Usar o capitalize dentro do Status Label */
|
|
|
|
|
/* Fazer nao precisar mais passar o text*/
|
|
|
|
|
customStyles={{ textTransform: "capitalize" }}
|
|
|
|
|
/>
|
|
|
|
|
</TableCell>
|
2024-11-15 14:55:05 -05:00
|
|
|
<TableCell>{row.processor}</TableCell>
|
2024-11-16 22:48:46 -05:00
|
|
|
<TableCell>
|
|
|
|
|
<Gauge
|
|
|
|
|
progressValue={row.cpu}
|
|
|
|
|
containerWidth={60}
|
|
|
|
|
/>
|
|
|
|
|
</TableCell>
|
|
|
|
|
<TableCell>
|
|
|
|
|
<Gauge
|
|
|
|
|
progressValue={row.mem}
|
|
|
|
|
containerWidth={60}
|
|
|
|
|
/>
|
|
|
|
|
</TableCell>
|
|
|
|
|
<TableCell>
|
|
|
|
|
<Gauge
|
|
|
|
|
progressValue={row.disk}
|
|
|
|
|
containerWidth={60}
|
|
|
|
|
/>
|
|
|
|
|
</TableCell>
|
2024-11-15 14:55:05 -05:00
|
|
|
<TableCell>actions</TableCell>
|
|
|
|
|
</TableRow>
|
|
|
|
|
))}
|
|
|
|
|
</TableBody>
|
2024-11-16 22:48:46 -05:00
|
|
|
<TableFooter>
|
|
|
|
|
<TableRow>
|
|
|
|
|
<TablePagination></TablePagination>
|
|
|
|
|
</TableRow>
|
|
|
|
|
</TableFooter>
|
2024-11-15 14:55:05 -05:00
|
|
|
</Table>
|
|
|
|
|
</TableContainer>
|
|
|
|
|
</Stack>
|
|
|
|
|
</Stack>
|
2024-11-08 18:36:43 -05:00
|
|
|
);
|
2024-11-07 04:21:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export { Infrastructure };
|