diff --git a/Client/src/Components/Charts/Gauge/index.jsx b/Client/src/Components/Charts/Gauge/index.jsx index 0ae872e3f..2757858e6 100644 --- a/Client/src/Components/Charts/Gauge/index.jsx +++ b/Client/src/Components/Charts/Gauge/index.jsx @@ -1,42 +1,32 @@ -import { RadialBarChart, RadialBar, ResponsiveContainer } from "recharts"; +import { RadialBarChart, RadialBar, ResponsiveContainer, Text, Legend } from "recharts"; import PropTypes from "prop-types"; import { useTheme } from "@emotion/react"; const MINIMUM_VALUE = 0; const MAXIMUM_VALUE = 100; -const DATA = [{ value: MAXIMUM_VALUE }]; const PROGRESS_THRESHOLD = 50; -const DEFAULT_CONTAINER_HEIGHT = 160; -const TEXT_POSITIONS = { - value: { x: "50%", y: "45%" }, - label: { x: "50%", y: "55%" }, -}; -const COMMON_RADIAL_BAR_PROPS = { - minAngle: 15, - clockWise: true, - dataKey: "value", - cornerRadius: 0, -}; +const DEFAULT_WIDTH = 60; +// const DEFAULT_CONTAINER_HEIGHT = 160; +// const TEXT_POSITIONS = { +// value: { x: "50%", y: "45%" }, +// label: { x: "50%", y: "55%" }, +// }; +const RADIUS = "90%"; +const START_ANGLE = 90; +const CHART_RANGE = 360; const RADIAL_BAR_CHART_PROPS = { - cx: "50%", - cy: "50%", - innerRadius: "45%", - outerRadius: "100%", - startAngle: 90, - endAngle: -270, + innerRadius: RADIUS, + outerRadius: RADIUS, + barSize: 6, + startAngle: START_ANGLE, + endAngle: START_ANGLE - CHART_RANGE, + margin: { top: 0, right: 0, bottom: 0, left: 0 }, }; -const RADIAL_BAR_OVERLAY_PROPS = { - transform: "rotate(180deg)", - position: "absolute", - top: "0", - left: "0", -}; - -const COMMON_HEADER_PROPS = { - textAnchor: "middle", - dominantBaseline: "middle", +const COMMON_RADIAL_BAR_PROPS = { + dataKey: "value", + cornerRadius: 8, }; /** @@ -64,19 +54,40 @@ const COMMON_HEADER_PROPS = { */ const Gauge = ({ progressValue, - displayText, - containerHeight, - gaugeHeader, - gaugeSubheader, + containerWidth, + // displayText, + // containerHeight, + // gaugeHeader, + // gaugeSubheader, }) => { const theme = useTheme(); const myProgressValue = Math.max(MINIMUM_VALUE, Math.min(progressValue, MAXIMUM_VALUE)); + const chartData = [ + { + value: MAXIMUM_VALUE, + fill: "transparent", + }, + { + value: myProgressValue, + fill: + progressValue > PROGRESS_THRESHOLD + ? theme.palette.primary.main + : theme.palette.percentage.uptimePoor, + }, + ]; + const width = containerWidth ?? DEFAULT_WIDTH; return ( - + ( + {`${myProgressValue}%`} + ), + }} + /* data={[{ value: myProgressValue }]} */ /> - - */} + {/* TODO what is the text tag? */} + {/* {`${displayText}`} - + */} ); @@ -121,4 +150,4 @@ Gauge.propTypes = { gaugeHeader: PropTypes.object, gaugeSubheader: PropTypes.object, }; -export default Gauge; +export { Gauge }; diff --git a/Client/src/Components/Layouts/HomeLayout/index.css b/Client/src/Components/Layouts/HomeLayout/index.css index 1a7ae4ceb..e08904f8e 100644 --- a/Client/src/Components/Layouts/HomeLayout/index.css +++ b/Client/src/Components/Layouts/HomeLayout/index.css @@ -6,6 +6,13 @@ padding: var(--env-var-spacing-2); } +/* TODO go for this approach for responsiveness. The aside needs to be taken care of */ +/* @media (max-width: 1000px) { + .home-layout { + flex-direction: column !important; + } +} */ + .home-layout aside { position: sticky; top: var(--env-var-spacing-2); diff --git a/Client/src/Pages/Infrastructure/index.jsx b/Client/src/Pages/Infrastructure/index.jsx index f079abfca..b58a306cd 100644 --- a/Client/src/Pages/Infrastructure/index.jsx +++ b/Client/src/Pages/Infrastructure/index.jsx @@ -6,24 +6,28 @@ import { TableBody, TableCell, TableContainer, + TableFooter, TableHead, + TablePagination, TableRow, } from "@mui/material"; import { Heading } from "../../Components/Heading"; import { useTheme } from "@emotion/react"; import Greeting from "../../Utils/greeting"; import Breadcrumbs from "../../Components/Breadcrumbs"; +import { StatusLabel } from "../../Components/Label"; +import { Gauge } from "../../Components/Charts/Gauge"; const mockedData = { ip: "https://192.168.1.30", - status: "Up", + status: "up", processor: "2Ghz", cpu: 80, mem: 50, disk: 70, }; -const ROWS = Array.from(Array(5).keys()).map(() => mockedData); +const ROWS = Array.from(Array(20).keys()).map(() => mockedData); console.log(ROWS); const columns = [ @@ -100,7 +104,9 @@ function Infrastructure() { marginBottom: "3rem", }} > - + + +