16
16
17
17
import React , { Fragment , useEffect , useState } from "react" ;
18
18
import { useSelector } from "react-redux" ;
19
+ import { IMessageEvent , w3cwebsocket as W3CWebSocket } from "websocket" ;
19
20
import {
20
- FormControl ,
21
+ Box ,
22
+ Button ,
23
+ Checkbox ,
21
24
Grid ,
22
- InputBase ,
23
- MenuItem ,
25
+ HealIcon ,
26
+ InputBox ,
27
+ InputLabel ,
28
+ PageLayout ,
24
29
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" ;
51
31
import {
52
32
Bar ,
53
33
BarChart ,
54
34
CartesianGrid ,
35
+ Legend ,
55
36
ResponsiveContainer ,
56
37
Tooltip ,
57
38
XAxis ,
58
39
YAxis ,
59
40
} from "recharts" ;
60
- import { Legend } from "recharts" ;
61
- import HelpMenu from "../HelpMenu" ;
62
- import { useAppDispatch } from "../../../store" ;
41
+
63
42
import { api } from "api" ;
64
43
import { Bucket } from "api/consoleApi" ;
65
44
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" ;
126
59
127
60
const Heal = ( ) => {
128
- const classes = useStyles ( ) ;
129
61
const distributedSetup = useSelector ( selDistSet ) ;
130
62
131
63
const [ start , setStart ] = useState ( false ) ;
@@ -166,13 +98,13 @@ const Heal = () => {
166
98
167
99
// forceStart and forceStop need to be mutually exclusive
168
100
useEffect ( ( ) => {
169
- if ( forceStart === true ) {
101
+ if ( forceStart ) {
170
102
setForceStop ( false ) ;
171
103
}
172
104
} , [ forceStart ] ) ;
173
105
174
106
useEffect ( ( ) => {
175
- if ( forceStop === true ) {
107
+ if ( forceStop ) {
176
108
setForceStart ( false ) ;
177
109
}
178
110
} , [ forceStop ] ) ;
@@ -285,84 +217,81 @@ const Heal = () => {
285
217
scopes = { [ IAM_SCOPES . ADMIN_HEAL ] }
286
218
resource = { CONSOLE_UI_RESOURCE }
287
219
>
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 >
291
231
< Select
292
- label = "Bucket"
293
232
id = "bucket-name"
294
233
name = "bucket-name"
295
234
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 }
296
247
onChange = { ( e ) => {
297
- setBucketName ( e . target . value as string ) ;
248
+ setPrefix ( e . target . value ) ;
298
249
} }
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 } >
366
295
< Button
367
296
id = { "start-heal" }
368
297
type = "submit"
@@ -372,9 +301,18 @@ const Heal = () => {
372
301
onClick = { ( ) => setStart ( true ) }
373
302
label = { "Start" }
374
303
/>
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
+ >
378
316
< ResponsiveContainer width = { "90%" } height = { 400 } >
379
317
< BarChart
380
318
width = { 600 }
@@ -391,34 +329,48 @@ const Heal = () => {
391
329
< XAxis dataKey = "name" />
392
330
< YAxis />
393
331
< Tooltip />
394
- < Legend verticalAlign = { "top" } layout = { "vertical" } />
332
+ < Legend
333
+ verticalAlign = { "top" }
334
+ layout = { "horizontal" }
335
+ className = { "noLi" }
336
+ />
395
337
< Bar
396
338
dataKey = "ah"
397
339
name = { "After Healing" }
398
- fill = "rgba(0, 0, 255, 0.2) "
399
- stroke = "rgba(0, 0, 255, 1) "
340
+ fill = "#2781B060 "
341
+ stroke = "#2781B0 "
400
342
/>
401
343
< Bar
402
344
dataKey = "bh"
403
345
name = { "Before Healing" }
404
- fill = "rgba(153, 102, 255, 0.2) "
405
- stroke = "rgba(153, 102, 255, 1) "
346
+ fill = "#C83B5160 "
347
+ stroke = "#C83B51 "
406
348
/>
407
349
</ BarChart >
408
350
</ 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" } >
411
363
< strong > Size scanned:</ strong > { hStatus . sizeScanned }
412
- </ div >
413
- < div className = { classes . scanData } >
364
+ </ Box >
365
+ < Box className = { " scanData" } >
414
366
< strong > Objects healed:</ strong > { hStatus . objectsHealed } /{ " " }
415
367
{ hStatus . objectsScanned }
416
- </ div >
417
- < div className = { classes . scanData } >
368
+ </ Box >
369
+ < Box className = { " scanData" } >
418
370
< strong > Healing time:</ strong > { hStatus . healDuration } s
419
- </ div >
371
+ </ Box >
420
372
</ Grid >
421
- </ Grid >
373
+ </ Box >
422
374
</ SecureComponent >
423
375
) }
424
376
</ PageLayout >
0 commit comments