@@ -13,6 +13,7 @@ import { ModelLink, OTALink, VendorLink } from '../vendor-links/vendor-links';
13
13
import { useTranslation , WithTranslation , withTranslation } from 'react-i18next' ;
14
14
import { Column } from 'react-table' ;
15
15
import { Table } from '../grid/ReactTableCom' ;
16
+ import cx from 'classnames' ;
16
17
17
18
type OtaRowProps = {
18
19
device : Device ;
@@ -21,7 +22,7 @@ type OtaRowProps = {
21
22
22
23
const StateCell : FunctionComponent < OtaRowProps & OtaApi > = ( props ) => {
23
24
const { t } = useTranslation ( 'ota' ) ;
24
- const { device, state, checkOTA, updateOTA } = props ;
25
+ const { device, state, checkOTA, scheduleOTA , unscheduleOTA , updateOTA } = props ;
25
26
const otaState = ( state ?. update ?? { } ) as OTAState ;
26
27
switch ( otaState . state ) {
27
28
case 'updating' :
@@ -40,20 +41,67 @@ const StateCell: FunctionComponent<OtaRowProps & OtaApi> = (props) => {
40
41
) ;
41
42
case 'available' :
42
43
return (
43
- < Button < string >
44
- className = "btn btn-danger btn-sm"
45
- onClick = { updateOTA }
46
- item = { device . friendly_name }
47
- prompt
48
- >
49
- { t ( 'update' ) }
50
- </ Button >
44
+ < div className = "btn-group btn-group-sm" role = "group" >
45
+ < Button < string >
46
+ className = "btn btn-danger btn-sm me-1"
47
+ onClick = { updateOTA }
48
+ item = { device . friendly_name }
49
+ prompt
50
+ >
51
+ { t ( 'update' ) }
52
+ </ Button >
53
+ < Button < string >
54
+ className = "btn btn-sm btn-info"
55
+ onClick = { scheduleOTA }
56
+ item = { device . friendly_name }
57
+ title = { t ( 'schedule' ) }
58
+ prompt
59
+ >
60
+ < i className = { cx ( 'fa' , 'fa-clock' ) } />
61
+ </ Button >
62
+ </ div >
63
+ ) ;
64
+ case 'scheduled' :
65
+ return (
66
+ < div className = "btn-group btn-group-sm" role = "group" >
67
+ < Button < string >
68
+ className = "btn btn-primary btn-sm me-1"
69
+ onClick = { checkOTA }
70
+ item = { device . friendly_name }
71
+ >
72
+ { t ( 'check' ) }
73
+ </ Button >
74
+ < Button < string >
75
+ className = { cx ( 'btn' , 'btn-sm' , 'btn-danger' ) }
76
+ onClick = { unscheduleOTA }
77
+ item = { device . friendly_name }
78
+ title = { t ( 'scheduled' ) }
79
+ prompt
80
+ >
81
+ < i className = { cx ( 'fa' , 'fa-clock' ) } />
82
+ </ Button >
83
+ </ div >
51
84
) ;
52
85
default :
53
86
return (
54
- < Button < string > className = "btn btn-primary btn-sm" onClick = { checkOTA } item = { device . friendly_name } >
55
- { t ( 'check' ) }
56
- </ Button >
87
+ < div className = "btn-group btn-group-sm" role = "group" >
88
+ < Button < string >
89
+ className = "btn btn-primary btn-sm me-1"
90
+ onClick = { checkOTA }
91
+ item = { device . friendly_name }
92
+ >
93
+ { t ( 'check' ) }
94
+ </ Button >
95
+ < Button < string >
96
+ className = { cx ( 'btn' , 'btn-sm' , 'btn-info' ) }
97
+ onClick = { scheduleOTA }
98
+ item = { device . friendly_name }
99
+ title = { t ( 'schedule' ) }
100
+ prompt
101
+ >
102
+ < i className = { cx ( 'fa' , 'fa-clock' ) } />
103
+ </ Button >
104
+ </ div >
57
105
) ;
58
106
}
59
107
} ;
@@ -85,8 +133,8 @@ class OtaPage extends Component<PropsFromStore & OtaApi & WithTranslation<'ota'>
85
133
otaDevices . forEach ( ( { device } ) => checkOTA ( device . friendly_name ) ) ;
86
134
} ;
87
135
render ( ) {
88
- const { checkOTA, updateOTA, t } = this . props ;
89
- const otaApi = { checkOTA, updateOTA } ;
136
+ const { checkOTA, scheduleOTA , unscheduleOTA , updateOTA, t } = this . props ;
137
+ const otaApi = { checkOTA, scheduleOTA , unscheduleOTA , updateOTA } ;
90
138
const otaDevices = this . getAllOtaDevices ( ) ;
91
139
const columns : Column < OtaGridData > [ ] = [
92
140
{
0 commit comments