File tree Expand file tree Collapse file tree 3 files changed +22
-16
lines changed
Expand file tree Collapse file tree 3 files changed +22
-16
lines changed Original file line number Diff line number Diff line change @@ -30,9 +30,11 @@ import AccordionDetails from '@mui/material/AccordionDetails';
3030import ExpandMoreIcon from '@mui/icons-material/ExpandMore' ;
3131import Box from '@mui/material/Box' ;
3232import { Warning } from '@mui/icons-material' ;
33+ import { ImportExportDelete } from './ImportExportDelete' ;
3334
3435interface Props {
3536 onAdd : ( ) => void ;
37+ onRefresh : ( ) => void ;
3638}
3739
3840export const AddDevice = observer (
@@ -158,7 +160,9 @@ export const AddDevice = observer(
158160 return (
159161 < >
160162 < Card >
161- < CardHeader title = "Add A Device" />
163+ < CardHeader title = "Add A Device"
164+ action = { < ImportExportDelete onRefresh = { ( ) => this . props . onRefresh ( ) } /> }
165+ />
162166 < CardContent >
163167 < form onSubmit = { this . submit } >
164168 < FormControl fullWidth >
Original file line number Diff line number Diff line change @@ -61,20 +61,20 @@ export const Devices = observer(
6161 ) ;
6262 }
6363 return (
64- < Grid container spacing = { 3 } justifyContent = "center" >
65- < Grid item xs = { 12 } >
66- < Grid container spacing = { 3 } >
67- { this . devices . current . map ( ( device , i ) => (
68- < Grid key = { i } item xs = { 12 } sm = { 6 } md = { 4 } lg = { 3 } >
69- < DeviceListItem device = { device } onRemove = { ( ) => this . devices . refresh ( ) } />
70- </ Grid >
71- ) ) }
64+ < Grid container spacing = { 3 } justifyContent = "center" >
65+ < Grid item xs = { 12 } >
66+ < Grid container spacing = { 3 } >
67+ { this . devices . current . map ( ( device , i ) => (
68+ < Grid key = { i } item xs = { 12 } sm = { 6 } md = { 4 } lg = { 3 } >
69+ < DeviceListItem device = { device } onRemove = { ( ) => this . devices . refresh ( ) } />
70+ </ Grid >
71+ ) ) }
72+ </ Grid >
73+ </ Grid >
74+ < Grid item xs = { 12 } sm = { 10 } md = { 10 } lg = { 6 } >
75+ < AddDevice onAdd = { ( ) => this . devices . refresh ( ) } onRefresh = { ( ) => this . devices . refresh ( ) } />
7276 </ Grid >
7377 </ Grid >
74- < Grid item xs = { 12 } sm = { 10 } md = { 10 } lg = { 6 } >
75- < AddDevice onAdd = { ( ) => this . devices . refresh ( ) } />
76- </ Grid >
77- </ Grid >
7878 ) ;
7979 }
8080 } ,
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import { toast } from './Toast';
1111import { confirm } from './Present' ;
1212
1313
14- export function ImportExportDelete ( ) {
14+ export function ImportExportDelete ( { onRefresh } : { onRefresh ?: ( ) => void } ) {
1515 const handleExport = async ( ) => {
1616 try {
1717 const response = await grpc . devices . listDevices ( { } ) ;
@@ -54,7 +54,8 @@ export function ImportExportDelete() {
5454 } ) ;
5555 }
5656
57- toast ( { text : 'Devices imported successfully' , intent : 'success' } ) ;
57+ toast ( { text : 'Devices imported successfully' , intent : 'success' } ) ;
58+ if ( onRefresh ) onRefresh ( ) ;
5859 } catch ( error ) {
5960 toast ( { text : 'Failed to import devices: ' + ( error as Error ) . message , intent : 'error' } ) ;
6061 }
@@ -72,7 +73,8 @@ export function ImportExportDelete() {
7273 } ) ;
7374 }
7475
75- toast ( { text : 'All devices deleted successfully' , intent : 'success' } ) ;
76+ toast ( { text : 'All devices deleted successfully' , intent : 'success' } ) ;
77+ if ( onRefresh ) onRefresh ( ) ;
7678 } catch ( error ) {
7779 toast ( { text : 'Failed to delete devices: ' + ( error as Error ) . message , intent : 'error' } ) ;
7880 }
You can’t perform that action at this time.
0 commit comments