Skip to content

Commit bf733f3

Browse files
authored
Migrated Heal and Watch pages to mds (#3016)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
1 parent bbf4027 commit bf733f3

File tree

3 files changed

+216
-321
lines changed

3 files changed

+216
-321
lines changed

portal-ui/src/screens/Console/Heal/Heal.tsx

Lines changed: 135 additions & 183 deletions
Original file line numberDiff line numberDiff line change
@@ -16,116 +16,48 @@
1616

1717
import React, { Fragment, useEffect, useState } from "react";
1818
import { useSelector } from "react-redux";
19+
import { IMessageEvent, w3cwebsocket as W3CWebSocket } from "websocket";
1920
import {
20-
FormControl,
21+
Box,
22+
Button,
23+
Checkbox,
2124
Grid,
22-
InputBase,
23-
MenuItem,
25+
HealIcon,
26+
InputBox,
27+
InputLabel,
28+
PageLayout,
2429
Select,
25-
TextField,
26-
} from "@mui/material";
27-
import { IMessageEvent, w3cwebsocket as W3CWebSocket } from "websocket";
28-
import { Theme } from "@mui/material/styles";
29-
import { Button, HealIcon, PageLayout } from "mds";
30-
import createStyles from "@mui/styles/createStyles";
31-
import withStyles from "@mui/styles/withStyles";
32-
import { wsProtocol } from "../../../utils/wsUtils";
33-
import { colorH, HealStatus } from "./types";
34-
import { niceBytes } from "../../../common/utils";
35-
import {
36-
actionsTray,
37-
containerForHeader,
38-
inlineCheckboxes,
39-
searchField,
40-
} from "../Common/FormComponents/common/styleLibrary";
41-
import {
42-
CONSOLE_UI_RESOURCE,
43-
IAM_SCOPES,
44-
} from "../../../common/SecureComponent/permissions";
45-
import CheckboxWrapper from "../Common/FormComponents/CheckboxWrapper/CheckboxWrapper";
46-
import { SecureComponent } from "../../../common/SecureComponent";
47-
import DistributedOnly from "../Common/DistributedOnly/DistributedOnly";
48-
import { selDistSet, setHelpName } from "../../../systemSlice";
49-
import makeStyles from "@mui/styles/makeStyles";
50-
import PageHeaderWrapper from "../Common/PageHeaderWrapper/PageHeaderWrapper";
30+
} from "mds";
5131
import {
5232
Bar,
5333
BarChart,
5434
CartesianGrid,
35+
Legend,
5536
ResponsiveContainer,
5637
Tooltip,
5738
XAxis,
5839
YAxis,
5940
} from "recharts";
60-
import { Legend } from "recharts";
61-
import HelpMenu from "../HelpMenu";
62-
import { useAppDispatch } from "../../../store";
41+
6342
import { api } from "api";
6443
import { Bucket } from "api/consoleApi";
6544
import { errorToHandler } from "api/errors";
66-
67-
const useStyles = makeStyles((theme: Theme) =>
68-
createStyles({
69-
graphContainer: {
70-
backgroundColor: "#fff",
71-
border: "#EAEDEE 1px solid",
72-
borderRadius: 3,
73-
padding: "19px 38px",
74-
marginTop: 15,
75-
},
76-
scanInfo: {
77-
marginTop: 20,
78-
display: "flex",
79-
flexDirection: "row",
80-
justifyContent: "space-between",
81-
},
82-
scanData: {
83-
fontSize: 13,
84-
},
85-
formBox: {
86-
padding: 15,
87-
border: "1px solid #EAEAEA",
88-
},
89-
buttonBar: {
90-
display: "flex",
91-
alignItems: "center",
92-
justifyContent: "flex-end",
93-
},
94-
bucketField: {
95-
flex: 1,
96-
},
97-
prefixField: {
98-
...searchField.searchField,
99-
marginLeft: 10,
100-
flex: 1,
101-
},
102-
actionsTray: {
103-
...actionsTray.actionsTray,
104-
marginBottom: 0,
105-
},
106-
...inlineCheckboxes,
107-
...searchField,
108-
...containerForHeader,
109-
}),
110-
);
111-
112-
const SelectStyled = withStyles((theme: Theme) =>
113-
createStyles({
114-
root: {
115-
lineHeight: "50px",
116-
marginRight: 15,
117-
"label + &": {
118-
marginTop: theme.spacing(3),
119-
},
120-
"& .MuiSelect-select:focus": {
121-
backgroundColor: "transparent",
122-
},
123-
},
124-
}),
125-
)(InputBase);
45+
import { wsProtocol } from "../../../utils/wsUtils";
46+
import { colorH, HealStatus } from "./types";
47+
import { niceBytes } from "../../../common/utils";
48+
import { modalStyleUtils } from "../Common/FormComponents/common/styleLibrary";
49+
import {
50+
CONSOLE_UI_RESOURCE,
51+
IAM_SCOPES,
52+
} from "../../../common/SecureComponent/permissions";
53+
import { selDistSet, setHelpName } from "../../../systemSlice";
54+
import { SecureComponent } from "../../../common/SecureComponent";
55+
import { useAppDispatch } from "../../../store";
56+
import DistributedOnly from "../Common/DistributedOnly/DistributedOnly";
57+
import PageHeaderWrapper from "../Common/PageHeaderWrapper/PageHeaderWrapper";
58+
import HelpMenu from "../HelpMenu";
12659

12760
const Heal = () => {
128-
const classes = useStyles();
12961
const distributedSetup = useSelector(selDistSet);
13062

13163
const [start, setStart] = useState(false);
@@ -166,13 +98,13 @@ const Heal = () => {
16698

16799
// forceStart and forceStop need to be mutually exclusive
168100
useEffect(() => {
169-
if (forceStart === true) {
101+
if (forceStart) {
170102
setForceStop(false);
171103
}
172104
}, [forceStart]);
173105

174106
useEffect(() => {
175-
if (forceStop === true) {
107+
if (forceStop) {
176108
setForceStart(false);
177109
}
178110
}, [forceStop]);
@@ -285,84 +217,81 @@ const Heal = () => {
285217
scopes={[IAM_SCOPES.ADMIN_HEAL]}
286218
resource={CONSOLE_UI_RESOURCE}
287219
>
288-
<Grid xs={12} item className={classes.formBox}>
289-
<Grid item xs={12} className={classes.actionsTray}>
290-
<FormControl variant="outlined" className={classes.bucketField}>
220+
<Box withBorders>
221+
<Box
222+
sx={{
223+
display: "flex" as const,
224+
alignItems: "center",
225+
marginBottom: 15,
226+
gap: 15,
227+
}}
228+
>
229+
<Box sx={{ flexGrow: 1, width: "100%" }}>
230+
<InputLabel>Bucket</InputLabel>
291231
<Select
292-
label="Bucket"
293232
id="bucket-name"
294233
name="bucket-name"
295234
value={bucketName}
235+
onChange={(value) => {
236+
setBucketName(value as string);
237+
}}
238+
options={bucketNames}
239+
placeholder={"Select Bucket"}
240+
/>
241+
</Box>
242+
<Box sx={{ flexGrow: 1, width: "100%" }}>
243+
<InputLabel>Prefix</InputLabel>
244+
<InputBox
245+
id="prefix-resource"
246+
disabled={false}
296247
onChange={(e) => {
297-
setBucketName(e.target.value as string);
248+
setPrefix(e.target.value);
298249
}}
299-
className={classes.searchField}
300-
input={<SelectStyled />}
301-
displayEmpty
302-
>
303-
<MenuItem value="" key={`select-bucket-name-default`}>
304-
Select Bucket
305-
</MenuItem>
306-
{bucketNames.map((option) => (
307-
<MenuItem
308-
value={option.value}
309-
key={`select-bucket-name-${option.label}`}
310-
>
311-
{option.label}
312-
</MenuItem>
313-
))}
314-
</Select>
315-
</FormControl>
316-
<TextField
317-
label="Prefix"
318-
className={classes.prefixField}
319-
id="prefix-resource"
320-
disabled={false}
321-
InputProps={{
322-
disableUnderline: true,
323-
}}
324-
onChange={(e) => {
325-
setPrefix(e.target.value);
326-
}}
327-
variant="standard"
328-
/>
329-
</Grid>
330-
<Grid item xs={12} className={classes.inlineCheckboxes}>
331-
<CheckboxWrapper
332-
name="recursive"
333-
id="recursive"
334-
value="recursive"
335-
checked={recursive}
336-
onChange={(e) => {
337-
setRecursive(e.target.checked);
338-
}}
339-
disabled={false}
340-
label="Recursive"
341-
/>
342-
<CheckboxWrapper
343-
name="forceStart"
344-
id="forceStart"
345-
value="forceStart"
346-
checked={forceStart}
347-
onChange={(e) => {
348-
setForceStart(e.target.checked);
349-
}}
350-
disabled={false}
351-
label="Force Start"
352-
/>
353-
<CheckboxWrapper
354-
name="forceStop"
355-
id="forceStop"
356-
value="forceStop"
357-
checked={forceStop}
358-
onChange={(e) => {
359-
setForceStop(e.target.checked);
360-
}}
361-
disabled={false}
362-
label="Force Stop"
363-
/>
364-
</Grid>
365-
<Grid item xs={12} className={classes.buttonBar}>
250+
/>
251+
</Box>
252+
</Box>
253+
<Box sx={{ display: "flex", gap: 20 }}>
254+
<Box>
255+
<Checkbox
256+
name="recursive"
257+
id="recursive"
258+
value="recursive"
259+
checked={recursive}
260+
onChange={() => {
261+
setRecursive(!recursive);
262+
}}
263+
disabled={false}
264+
label="Recursive"
265+
/>
266+
</Box>
267+
<Box>
268+
<Checkbox
269+
name="forceStart"
270+
id="forceStart"
271+
value="forceStart"
272+
checked={forceStart}
273+
onChange={() => {
274+
setForceStart(!forceStart);
275+
}}
276+
disabled={false}
277+
label="Force Start"
278+
/>
279+
</Box>
280+
<Box>
281+
<Checkbox
282+
name="forceStop"
283+
id="forceStop"
284+
value="forceStop"
285+
checked={forceStop}
286+
onChange={() => {
287+
setForceStop(!forceStop);
288+
}}
289+
disabled={false}
290+
label="Force Stop"
291+
/>
292+
</Box>
293+
</Box>
294+
<Box sx={modalStyleUtils.modalButtonBar}>
366295
<Button
367296
id={"start-heal"}
368297
type="submit"
@@ -372,9 +301,18 @@ const Heal = () => {
372301
onClick={() => setStart(true)}
373302
label={"Start"}
374303
/>
375-
</Grid>
376-
</Grid>
377-
<Grid item xs={12} className={classes.graphContainer}>
304+
</Box>
305+
</Box>
306+
<Box
307+
withBorders
308+
sx={{
309+
marginTop: 15,
310+
'& ul li:not([class*="Mui"])::before': {
311+
listStyle: "none",
312+
content: "' '",
313+
},
314+
}}
315+
>
378316
<ResponsiveContainer width={"90%"} height={400}>
379317
<BarChart
380318
width={600}
@@ -391,34 +329,48 @@ const Heal = () => {
391329
<XAxis dataKey="name" />
392330
<YAxis />
393331
<Tooltip />
394-
<Legend verticalAlign={"top"} layout={"vertical"} />
332+
<Legend
333+
verticalAlign={"top"}
334+
layout={"horizontal"}
335+
className={"noLi"}
336+
/>
395337
<Bar
396338
dataKey="ah"
397339
name={"After Healing"}
398-
fill="rgba(0, 0, 255, 0.2)"
399-
stroke="rgba(0, 0, 255, 1)"
340+
fill="#2781B060"
341+
stroke="#2781B0"
400342
/>
401343
<Bar
402344
dataKey="bh"
403345
name={"Before Healing"}
404-
fill="rgba(153, 102, 255, 0.2)"
405-
stroke="rgba(153, 102, 255, 1)"
346+
fill="#C83B5160"
347+
stroke="#C83B51"
406348
/>
407349
</BarChart>
408350
</ResponsiveContainer>
409-
<Grid item xs={12} className={classes.scanInfo}>
410-
<div className={classes.scanData}>
351+
<Grid
352+
item
353+
xs={12}
354+
sx={{
355+
marginTop: 20,
356+
display: "flex",
357+
flexDirection: "row",
358+
justifyContent: "space-between",
359+
"& .scanData": {},
360+
}}
361+
>
362+
<Box className={"scanData"}>
411363
<strong>Size scanned:</strong> {hStatus.sizeScanned}
412-
</div>
413-
<div className={classes.scanData}>
364+
</Box>
365+
<Box className={"scanData"}>
414366
<strong>Objects healed:</strong> {hStatus.objectsHealed} /{" "}
415367
{hStatus.objectsScanned}
416-
</div>
417-
<div className={classes.scanData}>
368+
</Box>
369+
<Box className={"scanData"}>
418370
<strong>Healing time:</strong> {hStatus.healDuration}s
419-
</div>
371+
</Box>
420372
</Grid>
421-
</Grid>
373+
</Box>
422374
</SecureComponent>
423375
)}
424376
</PageLayout>

0 commit comments

Comments
 (0)