Add headers to charts, add multpilier for percentages, increase chart spacing
This commit is contained in:
1 parent
0c194a0403
commit
7f380cef10
1 file changed
+99
-75
@@ -23,6 +23,7 @@ const BaseBox = ({ children }) => {
|
|||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
|
height: "100%",
|
||||||
padding: `${theme.spacing(4)} ${theme.spacing(8)}`,
|
padding: `${theme.spacing(4)} ${theme.spacing(8)}`,
|
||||||
minWidth: 200,
|
minWidth: 200,
|
||||||
width: 225,
|
width: 225,
|
||||||
@@ -98,7 +99,6 @@ const InfrastructureDetails = () => {
|
|||||||
{ name: "infrastructure monitors", path: "/infrastructure" },
|
{ name: "infrastructure monitors", path: "/infrastructure" },
|
||||||
{ name: "details", path: `/infrastructure/${monitorId}` },
|
{ name: "details", path: `/infrastructure/${monitorId}` },
|
||||||
];
|
];
|
||||||
console.log(testData);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
@@ -130,7 +130,7 @@ const InfrastructureDetails = () => {
|
|||||||
/>
|
/>
|
||||||
<StatBox
|
<StatBox
|
||||||
heading={"Status"}
|
heading={"Status"}
|
||||||
subHeading={"Active"}
|
subHeading={latestCheck.status === true ? "Active" : "Inactive"}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack
|
<Stack
|
||||||
@@ -138,7 +138,7 @@ const InfrastructureDetails = () => {
|
|||||||
gap={theme.spacing(8)}
|
gap={theme.spacing(8)}
|
||||||
>
|
>
|
||||||
<GaugeBox
|
<GaugeBox
|
||||||
value={latestCheck.cpu.usage_percent}
|
value={latestCheck.cpu.usage_percent * 100}
|
||||||
heading={"Memory Usage"}
|
heading={"Memory Usage"}
|
||||||
metricOne={"Used"}
|
metricOne={"Used"}
|
||||||
valueOne={`${bytesToGB(latestCheck.memory.used_bytes)}GB`}
|
valueOne={`${bytesToGB(latestCheck.memory.used_bytes)}GB`}
|
||||||
@@ -146,7 +146,7 @@ const InfrastructureDetails = () => {
|
|||||||
valueTwo={`${bytesToGB(latestCheck.memory.total_bytes)}GB`}
|
valueTwo={`${bytesToGB(latestCheck.memory.total_bytes)}GB`}
|
||||||
/>
|
/>
|
||||||
<GaugeBox
|
<GaugeBox
|
||||||
value={latestCheck.cpu.usage_percent}
|
value={latestCheck.cpu.usage_percent * 100}
|
||||||
heading={"CPU Usage"}
|
heading={"CPU Usage"}
|
||||||
metricOne={"Cores"}
|
metricOne={"Cores"}
|
||||||
valueOne={latestCheck.cpu.physical_core}
|
valueOne={latestCheck.cpu.physical_core}
|
||||||
@@ -157,7 +157,7 @@ const InfrastructureDetails = () => {
|
|||||||
return (
|
return (
|
||||||
<GaugeBox
|
<GaugeBox
|
||||||
key={disk._id}
|
key={disk._id}
|
||||||
value={disk.usage_percent}
|
value={disk.usage_percent * 100}
|
||||||
heading={`Disk${idx} usage`}
|
heading={`Disk${idx} usage`}
|
||||||
metricOne={"Used"}
|
metricOne={"Used"}
|
||||||
valueOne={`${bytesToGB(disk.total_bytes - disk.free_bytes)}GB`}
|
valueOne={`${bytesToGB(disk.total_bytes - disk.free_bytes)}GB`}
|
||||||
@@ -169,84 +169,108 @@ const InfrastructureDetails = () => {
|
|||||||
</Stack>
|
</Stack>
|
||||||
<Stack
|
<Stack
|
||||||
direction={"row"}
|
direction={"row"}
|
||||||
height={300}
|
height={300} // FE team HELP!
|
||||||
gap={theme.spacing(2)}
|
gap={theme.spacing(8)} // FE team HELP!
|
||||||
flexWrap="wrap" // Better way to do this? FE team HELP!
|
flexWrap="wrap" // //FE team HELP! Better way to do this?
|
||||||
sx={{
|
sx={{
|
||||||
"& > *": {
|
"& > *": {
|
||||||
flexBasis: `calc(50% - ${theme.spacing(2)})`,
|
flexBasis: `calc(50% - ${theme.spacing(8)})`,
|
||||||
maxWidth: `calc(50% - ${theme.spacing(2)})`,
|
maxWidth: `calc(50% - ${theme.spacing(8)})`,
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<AreaChart
|
<BaseBox>
|
||||||
data={testData}
|
<Typography
|
||||||
dataKey="memory.usage_percent"
|
component="h2"
|
||||||
xKey="createdAt"
|
padding={theme.spacing(8)}
|
||||||
yKey="memory.usage_percent"
|
>
|
||||||
customTooltip={({ active, payload, label }) => (
|
Memory usage
|
||||||
<InfrastructureTooltip
|
</Typography>
|
||||||
label={label}
|
<AreaChart
|
||||||
yKey="memory.usage_percent"
|
data={testData}
|
||||||
yLabel="Memory Usage"
|
dataKey="memory.usage_percent"
|
||||||
active={active}
|
xKey="createdAt"
|
||||||
payload={payload}
|
yKey="memory.usage_percent"
|
||||||
/>
|
customTooltip={({ active, payload, label }) => (
|
||||||
)}
|
<InfrastructureTooltip
|
||||||
xTick={<TzTick />}
|
label={label}
|
||||||
yTick={<PercentTick />}
|
yKey="memory.usage_percent"
|
||||||
strokeColor={theme.palette.primary.main}
|
yLabel="Memory Usage"
|
||||||
gradient={true}
|
active={active}
|
||||||
gradientStartColor={theme.palette.primary.main}
|
payload={payload}
|
||||||
gradientEndColor="#ffffff"
|
/>
|
||||||
/>
|
)}
|
||||||
<AreaChart
|
xTick={<TzTick />}
|
||||||
data={testData}
|
yTick={<PercentTick />}
|
||||||
dataKey="cpu.usage_percent"
|
strokeColor={theme.palette.primary.main}
|
||||||
xKey="createdAt"
|
gradient={true}
|
||||||
yKey="cpu.usage_percent"
|
gradientStartColor={theme.palette.primary.main} //FE team HELP! Not sure what colors to use
|
||||||
customTooltip={({ active, payload, label }) => (
|
gradientEndColor="#ffffff" // FE team HELP!
|
||||||
<InfrastructureTooltip
|
/>
|
||||||
label={label}
|
</BaseBox>
|
||||||
yKey="cpu.usage_percent"
|
<BaseBox>
|
||||||
yLabel="CPU Usage"
|
<Typography
|
||||||
active={active}
|
component="h2"
|
||||||
payload={payload}
|
padding={theme.spacing(8)}
|
||||||
/>
|
>
|
||||||
)}
|
CPU usage
|
||||||
xTick={<TzTick />}
|
</Typography>
|
||||||
yTick={<PercentTick />}
|
<AreaChart
|
||||||
strokeColor={theme.palette.primary.main}
|
data={testData}
|
||||||
gradient={true}
|
dataKey="cpu.usage_percent"
|
||||||
gradientStartColor={theme.palette.primary.main}
|
xKey="createdAt"
|
||||||
gradientEndColor="#ffffff"
|
yKey="cpu.usage_percent"
|
||||||
/>
|
customTooltip={({ active, payload, label }) => (
|
||||||
|
<InfrastructureTooltip
|
||||||
|
label={label}
|
||||||
|
yKey="cpu.usage_percent"
|
||||||
|
yLabel="CPU Usage"
|
||||||
|
active={active}
|
||||||
|
payload={payload}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
xTick={<TzTick />}
|
||||||
|
yTick={<PercentTick />}
|
||||||
|
strokeColor={theme.palette.success.main} // FE team HELP!
|
||||||
|
gradient={true}
|
||||||
|
fill={theme.palette.success.main} // FE team HELP!
|
||||||
|
gradientStartColor={theme.palette.success.main}
|
||||||
|
gradientEndColor="#ffffff"
|
||||||
|
/>
|
||||||
|
</BaseBox>
|
||||||
{latestCheck.disk.map((disk, idx) => {
|
{latestCheck.disk.map((disk, idx) => {
|
||||||
// disk is an array of disks, so we need to map over it
|
// disk is an array of disks, so we need to map over it
|
||||||
return (
|
return (
|
||||||
<AreaChart
|
<BaseBox key={disk._id}>
|
||||||
key={disk._id}
|
<Typography
|
||||||
data={testData}
|
component="h2"
|
||||||
dataKey={`disk[${idx}].usage_percent`}
|
padding={theme.spacing(8)}
|
||||||
xKey="createdAt"
|
>
|
||||||
yKey={`disk[${idx}].usage_percent`} // We are looking for the usage_percent of the current disk in the array
|
{`Disk${idx} usage`}
|
||||||
customTooltip={({ active, payload, label }) => (
|
</Typography>
|
||||||
<InfrastructureTooltip
|
<AreaChart
|
||||||
label={label} // label must be a string
|
data={testData}
|
||||||
yKey={`disk.usage_percent`}
|
dataKey={`disk[${idx}].usage_percent`}
|
||||||
yLabel="Disk Usage"
|
xKey="createdAt"
|
||||||
yIdx={idx}
|
yKey={`disk[${idx}].usage_percent`} // We are looking for the usage_percent of the current disk in the array
|
||||||
active={active}
|
customTooltip={({ active, payload, label }) => (
|
||||||
payload={payload}
|
<InfrastructureTooltip
|
||||||
/>
|
label={label} // label must be a string
|
||||||
)}
|
yKey={`disk.usage_percent`}
|
||||||
xTick={<TzTick />}
|
yLabel="Disk Usage"
|
||||||
yTick={<PercentTick />}
|
yIdx={idx}
|
||||||
strokeColor={theme.palette.primary.main}
|
active={active}
|
||||||
gradient={true}
|
payload={payload}
|
||||||
gradientStartColor={theme.palette.primary.main}
|
/>
|
||||||
gradientEndColor="#ffffff"
|
)}
|
||||||
/>
|
xTick={<TzTick />}
|
||||||
|
yTick={<PercentTick />}
|
||||||
|
strokeColor={theme.palette.warning.main}
|
||||||
|
gradient={true}
|
||||||
|
gradientStartColor={theme.palette.warning.main}
|
||||||
|
gradientEndColor="#ffffff"
|
||||||
|
/>
|
||||||
|
</BaseBox>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
Reference in new issue
Block a user