@@ -5,6 +5,10 @@ import { DataStore } from "@device-ui/lib/device/data_store";
55import { TimeOps } from "@device-ui/lib/algo/time_ops" ;
66import { ConnectionHandler } from "@device-ui/lib/device/connection_handler" ;
77import { FanoutConnectionHandler } from "@device-ui/lib/device/fanout_connection_handler" ;
8+ import { Notificator } from "@device-ui/lib/system/notificator" ;
9+ import { Config } from "@device-ui/lib/device/config" ;
10+
11+ import { FormConfigComponent } from "@device-ui/ui/preact/form_config_component" ;
812
913import "@device-ui/ui/preact/system_status_component.css" ;
1014
@@ -17,6 +21,15 @@ export type SystemStatusComponentProps = {
1721
1822 // Connection handler to receive the device connection status.
1923 connectionHandler : FanoutConnectionHandler ;
24+
25+ // Notificator to send various notifications.
26+ notificator : Notificator ;
27+
28+ // Config to configure the mDNS.
29+ mDNSConfig : Config ;
30+
31+ // Config to configure the UNIX time.
32+ systemTimeConfig : Config ;
2033} ;
2134
2235class TelemetryData {
@@ -45,6 +58,8 @@ class RegistrationData {
4558type SystemStatusComponentState = {
4659 expanded : boolean ;
4760 connected : boolean ;
61+ enableConfiguration : boolean ;
62+ config : Config | null ;
4863 telemetry : TelemetryData | null ;
4964 registration : RegistrationData | null ;
5065 showCopied : boolean ;
@@ -79,6 +94,8 @@ export class SystemStatusComponent
7994 this . state = {
8095 expanded : false ,
8196 connected : false ,
97+ enableConfiguration : false ,
98+ config : null ,
8299 telemetry : null ,
83100 registration : null ,
84101 showCopied : false ,
@@ -137,6 +154,8 @@ export class SystemStatusComponent
137154 this . setState ( {
138155 expanded : false ,
139156 connected : false ,
157+ enableConfiguration : false ,
158+ config : null ,
140159 telemetry : null ,
141160 registration : null ,
142161 showCopied : false ,
@@ -268,8 +287,38 @@ export class SystemStatusComponent
268287 </ >
269288 ) }
270289 </ div >
290+ { /* Configuration mode */ }
291+ { this . state . enableConfiguration && (
292+ < FormConfigComponent
293+ config = { this . state . config ! }
294+ onClose = { this . handleConfigEnd }
295+ notificator = { this . props . notificator }
296+ />
297+ ) }
271298 </ div >
272299 ) }
300+
301+ { this . state . expanded && ! this . state . enableConfiguration && (
302+ < >
303+ < div className = "config-button-container" >
304+ < button
305+ onClick = { this . handleConfigBeginMdns }
306+ className = "config-button"
307+ >
308+ Configure mDNS
309+ </ button >
310+ </ div >
311+
312+ < div className = "config-button-container" >
313+ < button
314+ onClick = { this . handleConfigBeginSystemTime }
315+ className = "config-button"
316+ >
317+ Configure System Time
318+ </ button >
319+ </ div >
320+ </ >
321+ ) }
273322 </ div >
274323 ) ;
275324 }
@@ -313,6 +362,31 @@ export class SystemStatusComponent
313362 } ) ;
314363 } ;
315364
365+ private handleConfigBeginMdns = ( ) => {
366+ this . setState ( {
367+ ...this . state ,
368+ enableConfiguration : true ,
369+ config : this . props . mDNSConfig ,
370+ } ) ;
371+ } ;
372+
373+ private handleConfigBeginSystemTime = ( ) => {
374+ this . setState ( {
375+ ...this . state ,
376+ enableConfiguration : true ,
377+ config : this . props . systemTimeConfig ,
378+ } ) ;
379+ } ;
380+
381+ private handleConfigEnd = ( ) => {
382+ this . setState ( {
383+ ...this . state ,
384+ expanded : false ,
385+ enableConfiguration : false ,
386+ config : null ,
387+ } ) ;
388+ } ;
389+
316390 private copyDeviceId = async ( e : Event ) => {
317391 e . stopPropagation ( ) ; // Prevent card expansion/collapse
318392
0 commit comments