13
13
//
14
14
// You should have received a copy of the GNU Affero General Public License
15
15
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
16
17
import React , { Fragment , useEffect , useState } from "react" ;
17
18
import { IMessageEvent , w3cwebsocket as W3CWebSocket } from "websocket" ;
18
- import { Theme } from "@mui/material/styles" ;
19
- import { Button , PageLayout } from "mds" ;
20
- import createStyles from "@mui/styles/createStyles" ;
21
- import withStyles from "@mui/styles/withStyles" ;
19
+ import { Box , Button , Grid , PageLayout , Select } from "mds" ;
22
20
import { useSelector } from "react-redux" ;
23
- import { FormControl , Grid , InputBase , MenuItem , Select } from "@mui/material" ;
24
-
25
- import { ErrorResponseHandler } from "../../../../../src/common/types" ;
26
- import api from "../../../../../src/common/api" ;
21
+ import { ErrorResponseHandler } from "../../../../common/types" ;
27
22
import { AppState , useAppDispatch } from "../../../../store" ;
28
-
29
23
import { wsProtocol } from "../../../../utils/wsUtils" ;
30
24
import {
31
- actionsTray ,
32
- containerForHeader ,
33
- inlineCheckboxes ,
34
- searchField ,
35
- } from "../../Common/FormComponents/common/styleLibrary " ;
25
+ logMessageReceived ,
26
+ logResetMessages ,
27
+ setLogsStarted ,
28
+ } from "../logsSlice" ;
29
+ import { setHelpName } from "../../../../systemSlice " ;
36
30
import SearchBox from "../../Common/SearchBox" ;
31
+ import api from "../../../../../src/common/api" ;
37
32
import Paper from "@mui/material/Paper" ;
38
33
import Table from "@mui/material/Table" ;
39
34
import TableBody from "@mui/material/TableBody" ;
40
35
import TableContainer from "@mui/material/TableContainer" ;
41
36
import LogLine from "./LogLine" ;
42
- import {
43
- logMessageReceived ,
44
- logResetMessages ,
45
- setLogsStarted ,
46
- } from "../logsSlice" ;
47
- import makeStyles from "@mui/styles/makeStyles" ;
48
37
import PageHeaderWrapper from "../../Common/PageHeaderWrapper/PageHeaderWrapper" ;
49
38
import HelpMenu from "../../HelpMenu" ;
50
- import { setHelpName } from "../../../../systemSlice" ;
51
-
52
- const useStyles = makeStyles ( ( theme : Theme ) =>
53
- createStyles ( {
54
- logList : {
55
- background : "#fff" ,
56
- minHeight : 400 ,
57
- height : "calc(100vh - 200px)" ,
58
- overflow : "auto" ,
59
- fontSize : 13 ,
60
- borderRadius : 4 ,
61
- } ,
62
- logerror_tab : {
63
- color : "#A52A2A" ,
64
- paddingLeft : 25 ,
65
- } ,
66
- nodeField : {
67
- width : "100%" ,
68
- } ,
69
- ...actionsTray ,
70
- actionsTray : {
71
- ...actionsTray . actionsTray ,
72
- marginBottom : 0 ,
73
- } ,
74
- ...searchField ,
75
-
76
- ...inlineCheckboxes ,
77
- ...containerForHeader ,
78
- } ) ,
79
- ) ;
80
-
81
- export const SelectStyled = withStyles ( ( theme : Theme ) =>
82
- createStyles ( {
83
- root : {
84
- lineHeight : "50px" ,
85
- "label + &" : {
86
- marginTop : theme . spacing ( 3 ) ,
87
- } ,
88
- "& .MuiSelect-select:focus" : {
89
- backgroundColor : "transparent" ,
90
- } ,
91
- } ,
92
- } ) ,
93
- ) ( InputBase ) ;
94
39
95
40
var c : any = null ;
96
41
97
42
const ErrorLogs = ( ) => {
98
43
const dispatch = useAppDispatch ( ) ;
99
- const classes = useStyles ( ) ;
100
44
101
45
const messages = useSelector ( ( state : AppState ) => state . logs . logMessages ) ;
102
46
const logsStarted = useSelector ( ( state : AppState ) => state . logs . logsStarted ) ;
@@ -223,9 +167,6 @@ const ErrorLogs = () => {
223
167
. invoke ( "GET" , `/api/v1/nodes` )
224
168
. then ( ( res : string [ ] ) => {
225
169
setNodes ( res ) ;
226
- // if (res.length > 0) {
227
- // setSelectedNode(res[0]);
228
- // }
229
170
setLoadingNodes ( false ) ;
230
171
} )
231
172
. catch ( ( err : ErrorResponseHandler ) => {
@@ -243,97 +184,64 @@ const ErrorLogs = () => {
243
184
< PageHeaderWrapper label = "Logs" actions = { < HelpMenu /> } />
244
185
245
186
< PageLayout >
246
- < Grid container spacing = { 1 } >
247
- < Grid item xs = { 4 } >
187
+ < Grid container sx = { { gap : 15 } } >
188
+ < Grid item xs = { 3 } >
248
189
{ ! loadingNodes ? (
249
- < FormControl variant = "outlined" className = { classes . nodeField } >
250
- < Select
251
- id = "node"
252
- name = "node"
253
- data-test-id = "node-selector"
254
- value = { selectedNode }
255
- onChange = { ( e ) => {
256
- setSelectedNode ( e . target . value as string ) ;
257
- } }
258
- className = { classes . searchField }
259
- disabled = { loadingNodes || logsStarted }
260
- input = { < SelectStyled /> }
261
- placeholder = { "Select Node" }
262
- >
263
- < MenuItem value = { "all" } key = { `select-node-all` } >
264
- All Nodes
265
- </ MenuItem >
266
- { nodes . map ( ( aNode ) => (
267
- < MenuItem value = { aNode } key = { `select-node-name-${ aNode } ` } >
268
- { aNode }
269
- </ MenuItem >
270
- ) ) }
271
- </ Select >
272
- </ FormControl >
190
+ < Select
191
+ id = "node-selector"
192
+ name = "node"
193
+ data-test-id = "node-selector"
194
+ value = { selectedNode }
195
+ onChange = { ( value ) => {
196
+ setSelectedNode ( value as string ) ;
197
+ } }
198
+ disabled = { loadingNodes || logsStarted }
199
+ options = { [
200
+ { label : "All Nodes" , value : "all" } ,
201
+ ...nodes . map ( ( aNode ) => ( { label : aNode , value : aNode } ) ) ,
202
+ ] }
203
+ />
273
204
) : (
274
205
< h3 > Loading nodes</ h3 >
275
206
) }
276
207
</ Grid >
277
208
278
209
< Grid item xs = { 3 } >
279
- < FormControl variant = "outlined" className = { classes . nodeField } >
280
- < Select
281
- id = "logType"
282
- name = "logType"
283
- data-test-id = "log-type"
284
- value = { logType }
285
- onChange = { ( e ) => {
286
- setLogType ( e . target . value as string ) ;
287
- } }
288
- className = { classes . searchField }
289
- disabled = { loadingNodes || logsStarted }
290
- input = { < SelectStyled /> }
291
- placeholder = { "Select Log Type" }
292
- >
293
- < MenuItem value = "all" key = "all-log-types" >
294
- All Log Types
295
- </ MenuItem >
296
- < MenuItem value = "minio" key = "minio-log-type" >
297
- MinIO
298
- </ MenuItem >
299
- < MenuItem value = "application" key = "app-log-type" >
300
- Application
301
- </ MenuItem >
302
- </ Select >
303
- </ FormControl >
210
+ < Select
211
+ id = "logType"
212
+ name = "logType"
213
+ data-test-id = "log-type"
214
+ value = { logType }
215
+ onChange = { ( value ) => {
216
+ setLogType ( value as string ) ;
217
+ } }
218
+ disabled = { loadingNodes || logsStarted }
219
+ options = { [
220
+ { value : "all" , label : "All Log Types" } ,
221
+ {
222
+ value : "minio" ,
223
+ label : "MinIO" ,
224
+ } ,
225
+ { value : "application" , label : "Application" } ,
226
+ ] }
227
+ />
304
228
</ Grid >
305
229
< Grid item xs = { 3 } >
306
230
{ userAgents . length > 1 && (
307
- < FormControl variant = "outlined" className = { classes . nodeField } >
308
- < Select
309
- id = "userAgent"
310
- name = "userAgent"
311
- data-test-id = "user-agent"
312
- value = { selectedUserAgent }
313
- onChange = { ( e ) => {
314
- setSelectedUserAgent ( e . target . value as string ) ;
315
- } }
316
- className = { classes . searchField }
317
- disabled = { userAgents . length < 1 || logsStarted }
318
- input = { < SelectStyled /> }
319
- >
320
- < MenuItem
321
- value = { selectedUserAgent }
322
- key = { `select-user-agent-default` }
323
- disabled = { true }
324
- >
325
- Select User Agent
326
- </ MenuItem >
327
- { userAgents . map ( ( anAgent ) => (
328
- < MenuItem
329
- value = { anAgent }
330
- key = { `select-user-agent-${ anAgent } ` }
331
- >
332
- { anAgent }
333
- </ MenuItem >
334
- ) ) }
335
- </ Select >
336
- </ FormControl >
231
+ < Select
232
+ id = "userAgent"
233
+ name = "userAgent"
234
+ data-test-id = "user-agent"
235
+ value = { selectedUserAgent }
236
+ onChange = { ( value ) => {
237
+ setSelectedUserAgent ( value as string ) ;
238
+ } }
239
+ disabled = { userAgents . length < 1 || logsStarted }
240
+ options = { userAgents . map ( ( anAgent ) => ( {
241
+ label : anAgent ,
242
+ value : anAgent ,
243
+ } ) ) }
244
+ />
337
245
) }
338
246
</ Grid >
339
247
< Grid
@@ -361,7 +269,21 @@ const ErrorLogs = () => {
361
269
/>
362
270
) }
363
271
</ Grid >
364
- < Grid item xs = { 12 } className = { classes . actionsTray } >
272
+ < Grid
273
+ item
274
+ xs = { 12 }
275
+ sx = { {
276
+ display : "flex" as const ,
277
+ justifyContent : "space-between" as const ,
278
+ alignItems : "center" ,
279
+ marginBottom : "1rem" ,
280
+ "& button" : {
281
+ flexGrow : 0 ,
282
+ marginLeft : 8 ,
283
+ marginBottom : 0 ,
284
+ } ,
285
+ } }
286
+ >
365
287
< SearchBox
366
288
placeholder = "Filter"
367
289
onChange = { ( e ) => {
@@ -371,10 +293,16 @@ const ErrorLogs = () => {
371
293
/>
372
294
</ Grid >
373
295
< Grid item xs = { 12 } >
374
- < div
296
+ < Box
375
297
id = "logs-container"
376
- className = { classes . logList }
377
298
data-test-id = "logs-list-container"
299
+ sx = { {
300
+ minHeight : 400 ,
301
+ height : "calc(100vh - 200px)" ,
302
+ overflow : "auto" ,
303
+ fontSize : 13 ,
304
+ borderRadius : 4 ,
305
+ } }
378
306
>
379
307
< TableContainer component = { Paper } >
380
308
< Table aria-label = "collapsible table" >
@@ -390,7 +318,7 @@ const ErrorLogs = () => {
390
318
</ div >
391
319
) }
392
320
</ TableContainer >
393
- </ div >
321
+ </ Box >
394
322
</ Grid >
395
323
</ Grid >
396
324
</ PageLayout >
0 commit comments