@@ -396,85 +396,89 @@ function Sessions({ client, conf, user }: { client: Client, conf: Configuration,
396
396
397
397
return (
398
398
< Resources < Session > label = "Sessions" callback = { async ( ) => await client . listSessions ( ) } >
399
- { ( resources : Record < string , Session > , setSessions : Dispatch < SetStateAction < Record < string , Session > | null > > ) => (
400
- < >
401
- { Object . keys ( resources ) . length > 0
402
- ?
403
- < >
404
- < EnhancedTableToolbar user = { user } label = "Sessions" selected = { selected } onCreate = { ( ) => setShowCreationDialog ( true ) } onUpdate = { ( ) => setShowUpdateDialog ( true ) } onDelete = { ( ) => onDelete ( setSessions ) } />
405
- < TableContainer component = { Paper } >
406
- < Table className = { classes . table } aria-label = "simple table" >
407
- < TableHead >
408
- < TableRow >
409
- < TableCell > </ TableCell >
410
- < TableCell > ID</ TableCell >
411
- < TableCell > Template</ TableCell >
412
- < TableCell > URL</ TableCell >
413
- < TableCell > Duration</ TableCell >
414
- < TableCell > Phase</ TableCell >
415
- < TableCell > Node</ TableCell >
416
- </ TableRow >
417
- </ TableHead >
418
- < TableBody >
419
- { Object . entries ( resources ) . map ( ( [ id , session ] , index ) => {
420
- const isItemSelected = isSelected ( id ) ;
421
- const labelId = `enhanced-table-checkbox-${ index } ` ;
422
- return (
423
- < TableRow
424
- key = { id }
425
- hover
426
- onClick = { ( event ) => handleClick ( event , id ) }
427
- role = "checkbox"
428
- aria-checked = { isItemSelected }
429
- tabIndex = { - 1 }
430
- selected = { isItemSelected } >
431
- < TableCell padding = "checkbox" >
432
- < Checkbox
433
- checked = { isItemSelected }
434
- inputProps = { { 'aria-labelledby' : labelId } }
435
- />
436
- </ TableCell >
437
- < TableCell component = "th" scope = "row" >
438
- < a href = { `https://github.com/${ id } ` } > { id } </ a >
439
- </ TableCell >
440
- < TableCell > { session . template . name } </ TableCell >
441
- < TableCell > < a href = { `//${ session . url } ` } > { session . url } </ a > </ TableCell >
442
- < TableCell > { session . duration } </ TableCell >
443
- < TableCell > { session . pod . phase } </ TableCell >
444
- < TableCell > { session . node } </ TableCell >
445
- </ TableRow >
446
- ) } ) }
447
- </ TableBody >
448
- < TableFooter >
449
- < TableRow >
450
- < TablePagination
451
- rowsPerPageOptions = { [ 5 , 10 , 25 , { label : 'All' , value : - 1 } ] }
452
- colSpan = { 3 }
453
- count = { Object . entries ( resources ) . length }
454
- rowsPerPage = { rowsPerPage }
455
- page = { page }
456
- SelectProps = { {
457
- inputProps : { 'aria-label' : 'rows per page' } ,
458
- native : true ,
459
- } }
460
- onChangePage = { handleChangePage }
461
- onChangeRowsPerPage = { handleChangeRowsPerPage }
462
- ActionsComponent = { TablePaginationActions }
463
- />
464
- </ TableRow >
465
- </ TableFooter >
466
- </ Table >
467
- </ TableContainer >
468
- </ >
469
- : < NoResourcesContainer user = { user } label = "No sessions" action = { ( ) => setShowCreationDialog ( true ) } /> }
470
- { errorMessage &&
471
- < ErrorSnackbar open = { true } message = { errorMessage } onClose = { ( ) => setErrorMessage ( null ) } /> }
472
- { showCreationDialog &&
473
- < SessionCreationDialog allowUserSelection = { true } client = { client } conf = { conf } sessions = { resources } user = { user } templates = { templates } show = { showCreationDialog } onCreate = { ( conf , id ) => onCreate ( conf , id , setSessions ) } onHide = { ( ) => setShowCreationDialog ( false ) } /> }
474
- { ( selected && showUpdateDialog ) &&
475
- < SessionUpdateDialog id = { selected } duration = { resources [ selected ] . duration } show = { showUpdateDialog } onUpdate = { ( id , conf ) => onUpdate ( id , conf , setSessions ) } onHide = { ( ) => setShowUpdateDialog ( false ) } /> }
476
- </ >
477
- ) }
399
+ { ( resources : Record < string , Session > , setSessions : Dispatch < SetStateAction < Record < string , Session > | null > > ) => {
400
+ const allResources = Object . entries ( resources ) ;
401
+ const filteredResources = rowsPerPage > 0 ? allResources . slice ( page * rowsPerPage , page * rowsPerPage + rowsPerPage ) : allResources ;
402
+ return (
403
+ < >
404
+ { allResources . length > 0
405
+ ?
406
+ < >
407
+ < EnhancedTableToolbar user = { user } label = "Sessions" selected = { selected } onCreate = { ( ) => setShowCreationDialog ( true ) } onUpdate = { ( ) => setShowUpdateDialog ( true ) } onDelete = { ( ) => onDelete ( setSessions ) } />
408
+ < TableContainer component = { Paper } >
409
+ < Table className = { classes . table } aria-label = "simple table" >
410
+ < TableHead >
411
+ < TableRow >
412
+ < TableCell > </ TableCell >
413
+ < TableCell > ID</ TableCell >
414
+ < TableCell > Template</ TableCell >
415
+ < TableCell > URL</ TableCell >
416
+ < TableCell > Duration</ TableCell >
417
+ < TableCell > Phase</ TableCell >
418
+ < TableCell > Node</ TableCell >
419
+ </ TableRow >
420
+ </ TableHead >
421
+ < TableBody >
422
+ { filteredResources . map ( ( [ id , session ] : [ id : string , session : Session ] , index : number ) => {
423
+ const isItemSelected = isSelected ( id ) ;
424
+ const labelId = `enhanced-table-checkbox-${ index } ` ;
425
+ return (
426
+ < TableRow
427
+ key = { id }
428
+ hover
429
+ onClick = { ( event ) => handleClick ( event , id ) }
430
+ role = "checkbox"
431
+ aria-checked = { isItemSelected }
432
+ tabIndex = { - 1 }
433
+ selected = { isItemSelected } >
434
+ < TableCell padding = "checkbox" >
435
+ < Checkbox
436
+ checked = { isItemSelected }
437
+ inputProps = { { 'aria-labelledby' : labelId } }
438
+ />
439
+ </ TableCell >
440
+ < TableCell component = "th" scope = "row" >
441
+ < a href = { `https://github.com/${ id } ` } > { id } </ a >
442
+ </ TableCell >
443
+ < TableCell > { session . template . name } </ TableCell >
444
+ < TableCell > < a href = { `//${ session . url } ` } > { session . url } </ a > </ TableCell >
445
+ < TableCell > { session . duration } </ TableCell >
446
+ < TableCell > { session . pod . phase } </ TableCell >
447
+ < TableCell > { session . node } </ TableCell >
448
+ </ TableRow >
449
+ ) } ) }
450
+ </ TableBody >
451
+ < TableFooter >
452
+ < TableRow >
453
+ < TablePagination
454
+ rowsPerPageOptions = { [ 5 , 10 , 25 , { label : 'All' , value : - 1 } ] }
455
+ colSpan = { 3 }
456
+ count = { Object . entries ( resources ) . length }
457
+ rowsPerPage = { rowsPerPage }
458
+ page = { page }
459
+ SelectProps = { {
460
+ inputProps : { 'aria-label' : 'rows per page' } ,
461
+ native : true ,
462
+ } }
463
+ onChangePage = { handleChangePage }
464
+ onChangeRowsPerPage = { handleChangeRowsPerPage }
465
+ ActionsComponent = { TablePaginationActions }
466
+ />
467
+ </ TableRow >
468
+ </ TableFooter >
469
+ </ Table >
470
+ </ TableContainer >
471
+ </ >
472
+ : < NoResourcesContainer user = { user } label = "No sessions" action = { ( ) => setShowCreationDialog ( true ) } /> }
473
+ { errorMessage &&
474
+ < ErrorSnackbar open = { true } message = { errorMessage } onClose = { ( ) => setErrorMessage ( null ) } /> }
475
+ { showCreationDialog &&
476
+ < SessionCreationDialog allowUserSelection = { true } client = { client } conf = { conf } sessions = { resources } user = { user } templates = { templates } show = { showCreationDialog } onCreate = { ( conf , id ) => onCreate ( conf , id , setSessions ) } onHide = { ( ) => setShowCreationDialog ( false ) } /> }
477
+ { ( selected && showUpdateDialog ) &&
478
+ < SessionUpdateDialog id = { selected } duration = { resources [ selected ] . duration } show = { showUpdateDialog } onUpdate = { ( id , conf ) => onUpdate ( id , conf , setSessions ) } onHide = { ( ) => setShowUpdateDialog ( false ) } /> }
479
+ </ >
480
+ ) ;
481
+ } }
478
482
</ Resources >
479
483
) ;
480
484
}
0 commit comments