2024-11-15 14:55:05 -05:00
|
|
|
import {
|
|
|
|
|
Box,
|
|
|
|
|
Button,
|
2024-11-17 18:16:25 -05:00
|
|
|
IconButton,
|
|
|
|
|
Paper,
|
2024-11-15 14:55:05 -05:00
|
|
|
Stack,
|
|
|
|
|
Table,
|
|
|
|
|
TableBody,
|
|
|
|
|
TableCell,
|
|
|
|
|
TableContainer,
|
|
|
|
|
TableHead,
|
|
|
|
|
TableRow,
|
2024-11-17 18:45:51 -05:00
|
|
|
// TablePagination,
|
|
|
|
|
// Typography,
|
2024-11-15 14:55:05 -05:00
|
|
|
} 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-17 18:16:25 -05:00
|
|
|
import GearIcon from "../../Assets/icons/settings-bold.svg?react";
|
|
|
|
|
import CPUChipIcon from "../../Assets/icons/cpu-chip.svg?react";
|
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 = [
|
2024-11-17 18:16:25 -05:00
|
|
|
{ label: "Host" },
|
|
|
|
|
{ label: "Status" },
|
|
|
|
|
{ label: "Frequency" },
|
|
|
|
|
{ label: "CPU" },
|
|
|
|
|
{ label: "Mem" },
|
|
|
|
|
{ label: "Disk" },
|
|
|
|
|
{ label: "Actions" },
|
2024-11-15 14:55:05 -05:00
|
|
|
];
|
|
|
|
|
|
2024-11-17 18:16:25 -05:00
|
|
|
/* TODO
|
|
|
|
|
Create reusable table component.
|
|
|
|
|
It should receive as a parameter the following object:
|
|
|
|
|
tableData = [
|
|
|
|
|
columns = [
|
|
|
|
|
{
|
|
|
|
|
id: example,
|
|
|
|
|
label: Example Extendable,
|
|
|
|
|
align: "center" | "left" (default)
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
rows: [
|
|
|
|
|
{
|
|
|
|
|
**Number of keys will be equal to number of columns**
|
|
|
|
|
key1: string,
|
|
|
|
|
key2: number,
|
|
|
|
|
key3: Component
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
Apply to Monitor Table, and Account/Team.
|
|
|
|
|
Analyze existing BasicTable
|
2024-11-15 14:55:05 -05:00
|
|
|
*/
|
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"
|
|
|
|
|
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"
|
|
|
|
|
sx={{
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
gap: ".25rem",
|
|
|
|
|
flexWrap: "wrap",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Heading component="h2">Infrastructure monitors</Heading>
|
2024-11-17 18:16:25 -05:00
|
|
|
{/* TODO Correct the class current-monitors-counter, there are some unnecessary things there */}
|
2024-11-15 14:55:05 -05:00
|
|
|
<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>
|
2024-11-17 18:16:25 -05:00
|
|
|
<TableContainer
|
|
|
|
|
component={Paper}
|
2024-11-17 19:01:27 -05:00
|
|
|
sx={{
|
|
|
|
|
maxHeight: "55vh",
|
|
|
|
|
"&::-webkit-scrollbar": {
|
|
|
|
|
width: ".75rem",
|
|
|
|
|
},
|
|
|
|
|
"&::-webkit-scrollbar-track": {
|
|
|
|
|
backgroundColor: theme.palette.secondary.light,
|
|
|
|
|
},
|
|
|
|
|
"&::-webkit-scrollbar-thumb": {
|
|
|
|
|
backgroundColor: theme.palette.secondary.contrastText,
|
|
|
|
|
outline: `1px solid ${theme.palette.secondary.contrastText}`,
|
|
|
|
|
},
|
|
|
|
|
}}
|
2024-11-17 18:16:25 -05:00
|
|
|
>
|
2024-11-15 14:55:05 -05:00
|
|
|
<Table stickyHeader>
|
2024-11-17 18:16:25 -05:00
|
|
|
<TableHead sx={{ backgroundColor: theme.palette.background.accent }}>
|
2024-11-15 14:55:05 -05:00
|
|
|
<TableRow>
|
|
|
|
|
{columns.map((column, index) => (
|
|
|
|
|
<TableCell
|
|
|
|
|
key={index}
|
2024-11-17 18:16:25 -05:00
|
|
|
align={index === 0 ? "left" : "center"}
|
2024-11-17 19:01:27 -05:00
|
|
|
sx={{
|
|
|
|
|
backgroundColor: theme.palette.background.accent,
|
|
|
|
|
}}
|
2024-11-15 14:55:05 -05:00
|
|
|
>
|
|
|
|
|
{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-17 18:16:25 -05:00
|
|
|
<TableCell align="center">
|
2024-11-16 22:48:46 -05:00
|
|
|
<StatusLabel
|
|
|
|
|
status={row.status}
|
|
|
|
|
text={row.status}
|
2024-11-17 18:16:25 -05:00
|
|
|
/* Use capitalize inside of Status Label */
|
|
|
|
|
/* Update component so we don't need to pass text and status separately*/
|
2024-11-16 22:48:46 -05:00
|
|
|
customStyles={{ textTransform: "capitalize" }}
|
|
|
|
|
/>
|
|
|
|
|
</TableCell>
|
2024-11-17 18:16:25 -05:00
|
|
|
<TableCell align="center">
|
|
|
|
|
<Stack
|
|
|
|
|
direction={"row"}
|
|
|
|
|
justifyContent={"center"}
|
|
|
|
|
alignItems={"center"}
|
|
|
|
|
gap=".25rem"
|
|
|
|
|
>
|
|
|
|
|
<CPUChipIcon
|
|
|
|
|
width={20}
|
|
|
|
|
height={20}
|
|
|
|
|
/>
|
|
|
|
|
{row.processor}
|
|
|
|
|
</Stack>
|
|
|
|
|
</TableCell>
|
|
|
|
|
<TableCell align="center">
|
2024-11-16 22:48:46 -05:00
|
|
|
<Gauge
|
|
|
|
|
progressValue={row.cpu}
|
|
|
|
|
containerWidth={60}
|
|
|
|
|
/>
|
|
|
|
|
</TableCell>
|
2024-11-17 18:16:25 -05:00
|
|
|
<TableCell align="center">
|
2024-11-16 22:48:46 -05:00
|
|
|
<Gauge
|
|
|
|
|
progressValue={row.mem}
|
|
|
|
|
containerWidth={60}
|
|
|
|
|
/>
|
|
|
|
|
</TableCell>
|
2024-11-17 18:16:25 -05:00
|
|
|
<TableCell align="center">
|
2024-11-16 22:48:46 -05:00
|
|
|
<Gauge
|
|
|
|
|
progressValue={row.disk}
|
|
|
|
|
containerWidth={60}
|
|
|
|
|
/>
|
|
|
|
|
</TableCell>
|
2024-11-17 18:16:25 -05:00
|
|
|
<TableCell align="center">
|
|
|
|
|
{/* Get ActionsMenu from Monitor Table and create a component */}
|
|
|
|
|
<IconButton
|
|
|
|
|
sx={{
|
|
|
|
|
"& svg path": {
|
|
|
|
|
stroke: theme.palette.other.icon,
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<GearIcon
|
|
|
|
|
width={20}
|
|
|
|
|
height={20}
|
|
|
|
|
/>
|
|
|
|
|
</IconButton>
|
|
|
|
|
</TableCell>
|
2024-11-15 14:55:05 -05:00
|
|
|
</TableRow>
|
|
|
|
|
))}
|
|
|
|
|
</TableBody>
|
|
|
|
|
</Table>
|
|
|
|
|
</TableContainer>
|
2024-11-17 18:45:51 -05:00
|
|
|
{/* <Stack
|
|
|
|
|
direction="row"
|
|
|
|
|
alignItems="center"
|
|
|
|
|
justifyContent="space-between"
|
|
|
|
|
marginTop={8}
|
|
|
|
|
>
|
|
|
|
|
<Typography
|
|
|
|
|
// px={theme.spacing(2)}
|
|
|
|
|
variant="body2"
|
|
|
|
|
// sx={{ opacity: 0.7 }}
|
|
|
|
|
>
|
|
|
|
|
Showing {getRange()} of {monitorCount} monitor(s)
|
|
|
|
|
</Typography>
|
|
|
|
|
<TablePagination
|
|
|
|
|
component="div"
|
|
|
|
|
count={monitorCount}
|
|
|
|
|
page={page}
|
|
|
|
|
onPageChange={handleChangePage}
|
|
|
|
|
rowsPerPage={rowsPerPage}
|
|
|
|
|
rowsPerPageOptions={[5, 10, 15, 25]}
|
|
|
|
|
onRowsPerPageChange={handleChangeRowsPerPage}
|
|
|
|
|
ActionsComponent={TablePaginationActions}
|
|
|
|
|
labelRowsPerPage="Rows per page"
|
|
|
|
|
labelDisplayedRows={({ page, count }) =>
|
|
|
|
|
`Page ${page + 1} of ${Math.max(0, Math.ceil(count / rowsPerPage))}`
|
|
|
|
|
}
|
|
|
|
|
slotProps={{
|
|
|
|
|
select: {
|
|
|
|
|
MenuProps: {
|
|
|
|
|
keepMounted: true,
|
|
|
|
|
disableScrollLock: true,
|
|
|
|
|
PaperProps: {
|
|
|
|
|
className: "pagination-dropdown",
|
|
|
|
|
sx: {
|
|
|
|
|
mt: 0,
|
|
|
|
|
mb: theme.spacing(2),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
transformOrigin: { vertical: "bottom", horizontal: "left" },
|
|
|
|
|
anchorOrigin: { vertical: "top", horizontal: "left" },
|
|
|
|
|
sx: {
|
|
|
|
|
mt: theme.spacing(-2),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
inputProps: { id: "pagination-dropdown" },
|
|
|
|
|
IconComponent: SelectorVertical,
|
|
|
|
|
sx: {
|
|
|
|
|
ml: theme.spacing(4),
|
|
|
|
|
mr: theme.spacing(12),
|
|
|
|
|
minWidth: theme.spacing(20),
|
|
|
|
|
textAlign: "left",
|
|
|
|
|
"&.Mui-focused > div": {
|
|
|
|
|
backgroundColor: theme.palette.background.main,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
sx={{
|
|
|
|
|
color: theme.palette.text.secondary,
|
|
|
|
|
"& svg path": {
|
|
|
|
|
stroke: theme.palette.text.tertiary,
|
|
|
|
|
strokeWidth: 1.3,
|
|
|
|
|
},
|
|
|
|
|
"& .MuiSelect-select": {
|
|
|
|
|
border: 1,
|
|
|
|
|
borderColor: theme.palette.border.light,
|
|
|
|
|
borderRadius: theme.shape.borderRadius,
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</Stack> */}
|
2024-11-15 14:55:05 -05:00
|
|
|
</Stack>
|
|
|
|
|
</Stack>
|
2024-11-08 18:36:43 -05:00
|
|
|
);
|
2024-11-07 04:21:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export { Infrastructure };
|