Skip to content

Commit

Permalink
Metrics tweaks for free space (#2113)
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
  • Loading branch information
dvaldivia committed Jun 10, 2022
1 parent 5d591b1 commit 0b5e3d5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
Expand Up @@ -41,6 +41,7 @@ import {
DLayoutColumnProps,
DLayoutRowProps,
resourcesPanelsLayout,
resourcesPanelsLayoutAdvanced,
RowPanelLayout,
summaryPanelsLayout,
trafficPanelsLayout,
Expand Down Expand Up @@ -192,6 +193,10 @@ const PrDashboard = ({ apiPrefix = "admin" }: IPrDashboard) => {
return renderPanelItems(resourcesPanelsLayout);
};

const renderAdvancedResourcesPanels = () => {
return renderPanelItems(resourcesPanelsLayoutAdvanced);
};

return (
<PageLayout>
{zoomOpen && (
Expand Down Expand Up @@ -251,6 +256,10 @@ const PrDashboard = ({ apiPrefix = "admin" }: IPrDashboard) => {
<TabPanel index={2} value={curTab}>
<RowPanelLayout>
{panelInformation.length ? renderResourcesPanels() : null}
<h2 style={{ margin: 0, borderBottom: "1px solid #dedede" }}>
Advanced
</h2>
{panelInformation.length ? renderAdvancedResourcesPanels() : null}
</RowPanelLayout>
</TabPanel>
</Grid>
Expand Down
Expand Up @@ -49,6 +49,7 @@ const CapacityItem = ({
const [loading, setLoading] = useState<boolean>(true);

const [totalUsableFree, setTotalUsableFree] = useState<number>(0);
const [totalUsableFreeRatio, setTotalUsableFreeRatio] = useState<number>(0);
const [totalUsed, setTotalUsed] = useState<number>(0);
const [totalUsable, setTotalUsable] = useState<number>(0);

Expand Down Expand Up @@ -100,7 +101,10 @@ const CapacityItem = ({
});
});

const freeRatio = Math.round((tFree / tUsable) * 100);

setTotalUsableFree(tFree);
setTotalUsableFreeRatio(freeRatio);
setTotalUsed(tUsed);
setTotalUsable(tUsable);

Expand Down Expand Up @@ -175,7 +179,7 @@ const CapacityItem = ({
fontSize: 12,
}}
>
{niceBytesInt(totalUsableFree)}
{`${totalUsableFreeRatio}%`}
<br />
<Box
sx={{
Expand All @@ -187,7 +191,7 @@ const CapacityItem = ({
textAlign: "center",
}}
>
Current Usable Capacity
Free
</Box>
</Box>
<PieChart width={110} height={110}>
Expand Down
Expand Up @@ -216,13 +216,15 @@ export const resourcesPanelsLayout: DLayoutRowProps[] = [
},
columns: [
{
componentId: 11,
componentId: 82,
},
{
componentId: 8,
componentId: 74,
},
],
},
];
export const resourcesPanelsLayoutAdvanced: DLayoutRowProps[] = [
{
sx: {
display: "grid",
Expand All @@ -232,14 +234,15 @@ export const resourcesPanelsLayout: DLayoutRowProps[] = [
},
columns: [
{
componentId: 82,
componentId: 11,
},
{
componentId: 74,
componentId: 8,
},
],
},
];

export const RowPanelLayout = ({ children }: { children: any }) => {
return (
<Box
Expand Down

0 comments on commit 0b5e3d5

Please sign in to comment.