Skip to content

Commit 9caa6c8

Browse files
authored
Merge pull request #3249 from bluewave-labs/feat/v2-logs
Feat/v2 logs
2 parents 3b25b37 + ea115ed commit 9caa6c8

File tree

34 files changed

+894
-1021
lines changed

34 files changed

+894
-1021
lines changed

client/package-lock.json

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"joi": "17.13.3",
3535
"lucide-react": "^0.562.0",
3636
"mui-color-input": "^7.0.0",
37+
"pretty-bytes": "^7.1.0",
3738
"pretty-ms": "^9.3.0",
3839
"react": "18.3.1",
3940
"react-dom": "^18.2.0",

client/src/Components/v2/design-elements/Gauge.tsx

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { BaseChart } from "@/Components/v2/design-elements";
2+
import Stack from "@mui/material/Stack";
13
import Box from "@mui/material/Box";
24
import Typography from "@mui/material/Typography";
35

@@ -104,3 +106,50 @@ export const Gauge = ({
104106
</Box>
105107
);
106108
};
109+
110+
export const DetailGauge = ({
111+
title,
112+
progress,
113+
upperLabel,
114+
upperValue,
115+
lowerLabel,
116+
lowerValue,
117+
}: {
118+
title: string;
119+
progress: number;
120+
upperLabel?: string;
121+
upperValue?: string | number;
122+
lowerLabel?: string;
123+
lowerValue?: string | number;
124+
}) => {
125+
const theme = useTheme();
126+
return (
127+
<BaseChart
128+
icon={null}
129+
title={title}
130+
maxWidth={225}
131+
>
132+
<Stack
133+
alignItems={"center"}
134+
mb={theme.spacing(4)}
135+
gap={theme.spacing(4)}
136+
>
137+
<Gauge progress={progress} />
138+
</Stack>
139+
<Stack
140+
direction={"row"}
141+
justifyContent={"space-between"}
142+
>
143+
<Typography>{upperLabel}</Typography>
144+
<Typography>{upperValue}</Typography>
145+
</Stack>
146+
<Stack
147+
direction={"row"}
148+
justifyContent={"space-between"}
149+
>
150+
<Typography>{lowerLabel}</Typography>
151+
<Typography>{lowerValue}</Typography>
152+
</Stack>
153+
</BaseChart>
154+
);
155+
};

client/src/Components/v2/design-elements/Table.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import type { TablePaginationOwnProps } from "@mui/material/TablePagination";
2929
import { useTranslation } from "react-i18next";
3030
import { useState, Fragment, useEffect } from "react";
3131
import { useTheme } from "@mui/material/styles";
32+
import type { SxProps, Theme } from "@mui/material/styles";
3233
import useMediaQuery from "@mui/material/useMediaQuery";
3334

3435
export type Header<T> = {
@@ -47,6 +48,7 @@ type DataTableProps<T extends { id?: string | number; _id?: string | number }> =
4748
renderExpandedContent?: (row: T) => React.ReactNode;
4849
emptyViewText?: string;
4950
emptyViewPositive?: boolean;
51+
getRowSx?: (row: T) => SxProps<Theme>;
5052
};
5153

5254
export function DataTable<
@@ -64,6 +66,7 @@ export function DataTable<
6466
renderExpandedContent,
6567
emptyViewText,
6668
emptyViewPositive,
69+
getRowSx,
6770
}: DataTableProps<T>) {
6871
const theme = useTheme();
6972
const [expanded, setExpanded] = useState<(string | number) | null>(null);
@@ -204,6 +207,7 @@ export function DataTable<
204207
<TableRow
205208
sx={{
206209
cursor: onRowClick ? "pointer" : "default",
210+
...(getRowSx?.(row) as object),
207211
}}
208212
onClick={() => {
209213
if (expandableRows) handleExpand(row);

client/src/Features/UI/uiSlice.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ const initialState = {
1919
infrastructure: {
2020
rowsPerPage: 5,
2121
},
22+
logs: {
23+
rowsPerPage: 15,
24+
},
2225
sidebar: {
2326
collapsed: false,
2427
},
@@ -41,9 +44,10 @@ const uiSlice = createSlice({
4144
},
4245
setRowsPerPage: (state, action) => {
4346
const { table, value } = action.payload;
44-
if (state[table]) {
45-
state[table].rowsPerPage = value;
47+
if (!state[table]) {
48+
state[table] = {};
4649
}
50+
state[table].rowsPerPage = value;
4751
},
4852
toggleSidebar: (state) => {
4953
state.sidebar.collapsed = !state.sidebar.collapsed;

client/src/Pages/Infrastructure/Details/Components/Gauges.tsx

Lines changed: 4 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,12 @@
11
import Stack from "@mui/material/Stack";
2-
import Typography from "@mui/material/Typography";
3-
import { BaseChart, Gauge } from "@/Components/v2/design-elements";
2+
import { DetailGauge } from "@/Components/v2/design-elements";
43

54
import { useTranslation } from "react-i18next";
65
import { getGbs, getFrequency } from "@/Utils/InfraUtils";
76
import { useTheme } from "@mui/material";
87
import useMediaQuery from "@mui/material/useMediaQuery";
98
import type { CheckSnapshot } from "@/Types/Check";
109

11-
const InfraDetailGauge = ({
12-
title,
13-
progress,
14-
upperLabel,
15-
upperValue,
16-
lowerLabel,
17-
lowerValue,
18-
}: {
19-
title: string;
20-
progress: number;
21-
upperLabel?: string;
22-
upperValue?: string | number;
23-
lowerLabel?: string;
24-
lowerValue?: string | number;
25-
}) => {
26-
const theme = useTheme();
27-
return (
28-
<BaseChart
29-
icon={null}
30-
title={title}
31-
maxWidth={225}
32-
>
33-
<Stack
34-
alignItems={"center"}
35-
mb={theme.spacing(4)}
36-
gap={theme.spacing(4)}
37-
>
38-
<Gauge progress={progress} />
39-
</Stack>
40-
<Stack
41-
direction={"row"}
42-
justifyContent={"space-between"}
43-
>
44-
<Typography>{upperLabel}</Typography>
45-
<Typography>{upperValue}</Typography>
46-
</Stack>
47-
<Stack
48-
direction={"row"}
49-
justifyContent={"space-between"}
50-
>
51-
<Typography>{lowerLabel}</Typography>
52-
<Typography>{lowerValue}</Typography>
53-
</Stack>
54-
</BaseChart>
55-
);
56-
};
57-
5810
export const InfraDetailsGauges = ({
5911
snapshot,
6012
}: {
@@ -74,15 +26,15 @@ export const InfraDetailsGauges = ({
7426
spacing={theme.spacing(8)}
7527
alignItems={"center"}
7628
>
77-
<InfraDetailGauge
29+
<DetailGauge
7830
title={t("pages.infrastructure.gauges.memory.title")}
7931
progress={(snapshot?.memory?.usage_percent || 0) * 100}
8032
upperLabel={t("pages.infrastructure.gauges.memory.upperLabel")}
8133
upperValue={getGbs(snapshot?.memory?.used_bytes || 0)}
8234
lowerLabel={t("pages.infrastructure.gauges.memory.lowerLabel")}
8335
lowerValue={getGbs(snapshot?.memory?.total_bytes || 0)}
8436
/>
85-
<InfraDetailGauge
37+
<DetailGauge
8638
title={t("pages.infrastructure.gauges.cpu.title")}
8739
progress={(snapshot?.cpu?.usage_percent || 0) * 100}
8840
upperLabel={t("pages.infrastructure.gauges.cpu.upperLabel")}
@@ -92,7 +44,7 @@ export const InfraDetailsGauges = ({
9244
/>
9345
{snapshot?.disk?.map((disk, idx) => {
9446
return (
95-
<InfraDetailGauge
47+
<DetailGauge
9648
key={disk?.device || 0 + idx}
9749
// title={`Disk ${idx} usage`}
9850
title={t("pages.infrastructure.gauges.disk.title", { idx })}

0 commit comments

Comments
 (0)