X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=ui%2Fweb%2Fsrc%2Fviews%2FChargingStationsView.vue;h=fe361c1c1766dfe11753890146dfb5c5ed4f36f6;hb=4b10e4f94fe91fab12f8ba298137c49fc295774c;hp=abea2075cc1207114d0a0d1174f5b1453058a709;hpb=258666f9962451dda19d0db528bbf07e41838ff2;p=e-mobility-charging-stations-simulator.git diff --git a/ui/web/src/views/ChargingStationsView.vue b/ui/web/src/views/ChargingStationsView.vue index abea2075..fe361c1c 100644 --- a/ui/web/src/views/ChargingStationsView.vue +++ b/ui/web/src/views/ChargingStationsView.vue @@ -9,34 +9,36 @@ v-model="state.uiServerIndex" @change=" () => { - try { - if ( - getFromLocalStorage('uiServerConfigurationIndex', 0) !== state.uiServerIndex - ) { - setToLocalStorage('uiServerConfigurationIndex', state.uiServerIndex) - app?.appContext.config.globalProperties.$uiClient.registerWSEventListener( - 'close', - () => { - app!.appContext.config.globalProperties.$chargingStations = [] - }, - { once: true } - ) - app?.appContext.config.globalProperties.$uiClient.setConfiguration( - app?.appContext.config.globalProperties.$configuration.uiServer[ - getFromLocalStorage('uiServerConfigurationIndex', state.uiServerIndex) - ] - ) - app?.appContext.config.globalProperties.$uiClient.registerWSEventListener( - 'open', - () => { - loadChargingStations(() => (state.renderChargingStationsList = randomUUID())) - }, - { once: true } - ) - } - } catch (error) { - $toast.error('Error at changing UI server configuration') - console.error('Error at changing UI server configuration:', error) + if ( + getFromLocalStorage('uiServerConfigurationIndex', 0) !== state.uiServerIndex + ) { + app?.appContext.config.globalProperties.$uiClient.setConfiguration( + app?.appContext.config.globalProperties.$configuration.uiServer[state.uiServerIndex] + ) + initializeWSEventListeners() + app?.appContext.config.globalProperties.$uiClient.registerWSEventListener( + 'open', + () => { + setToLocalStorage('uiServerConfigurationIndex', state.uiServerIndex) + clearToggleButtons() + $router.currentRoute.value.name !== 'charging-stations' && + $router.push({ name: 'charging-stations' }) + }, + { once: true } + ) + app?.appContext.config.globalProperties.$uiClient.registerWSEventListener( + 'error', + () => { + state.uiServerIndex = getFromLocalStorage('uiServerConfigurationIndex', 0) + app?.appContext.config.globalProperties.$uiClient.setConfiguration( + app?.appContext.config.globalProperties.$configuration.uiServer[ + getFromLocalStorage('uiServerConfigurationIndex', 0) + ] + ) + initializeWSEventListeners() + }, + { once: true } + ) } } " @@ -50,50 +52,161 @@ - - - + @@ -196,7 +318,7 @@ const stopSimulator = (): void => { } #reload-button:active { - background-color: red; + background-color: darkblue; } #action {