@@ -10,6 +10,7 @@ import { ChargersState } from '../pages/chargers';
1010import { Dispatch , StateUpdater , useEffect } from 'preact/hooks' ;
1111import { showAlert } from './Alert' ;
1212import { useLocation } from 'preact-iso' ;
13+ import { useTranslation } from 'react-i18next' ;
1314
1415interface VirtualNetworkInterfaceSetParentState {
1516 chargersState : Dispatch < StateUpdater < ChargersState > > ,
@@ -260,6 +261,7 @@ export class Frame extends Component<FrameProps, FrameState> {
260261 setTimeout ( ( ) => sessionStorage . setItem ( "currentConnection" , JSON . stringify ( this . props . parentState ) ) )
261262 }
262263
264+ const that = this ;
263265 // this is used by the app to close the remote connection via the native app menu.
264266 ( window as any ) . close = ( ) => {
265267 this . props . setParentState ( {
@@ -268,6 +270,7 @@ export class Frame extends Component<FrameProps, FrameState> {
268270 connectedName : "" ,
269271 connectedPort : 0 ,
270272 } ) ;
273+ clearTimeout ( that . interface . timeout ) ;
271274 this . route ( "/chargers" ) ;
272275 setAppNavigation ( ) ;
273276 sessionStorage . removeItem ( "currentConnection" ) ;
@@ -289,6 +292,8 @@ export class Frame extends Component<FrameProps, FrameState> {
289292
290293 render ( ) {
291294 const { route } = useLocation ( ) ;
295+ const { t} = useTranslation ( "" , { useSuspense : false , keyPrefix : "chargers" } ) ;
296+
292297 useEffect ( ( ) => {
293298 this . route = route ;
294299 this . interface = new VirtualNetworkInterface ( {
@@ -315,6 +320,14 @@ export class Frame extends Component<FrameProps, FrameState> {
315320 i18n . t ( "chargers.connecting" ) :
316321 i18n . t ( "chargers.loading_webinterface" ) }
317322 </ div >
323+ < Button className = "col-lg-1 col-md-2 col-sm-3 col-6 mt-3"
324+ variant = "outline-warning"
325+ type = "button"
326+ onClick = { ( e ) => {
327+ e . stopPropagation ( ) ;
328+ e . preventDefault ( ) ;
329+ ( window as any ) . close ( ) ;
330+ } } > { t ( "abort" ) } </ Button >
318331 </ Row >
319332 < Row className = "flex-grow-1 m-0" >
320333 < iframe class = "p-0" hidden = { this . state . show_spinner } width = "100%" height = "100%" id = "interface" > </ iframe >
0 commit comments