X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=ui%2Fweb%2Fsrc%2Fviews%2FChargingStationsView.vue;h=cbd8a34ba64bf13ad17f8e57a679cb67aa455c63;hb=3eea3ebcd6172a2928aba166e26d5f06cd4dbe42;hp=113137c80a44a5eb302c0d1cead562f5acae90ad;hpb=86545028054a9b13982500366c51e7ea2503a4eb;p=e-mobility-charging-stations-simulator.git diff --git a/ui/web/src/views/ChargingStationsView.vue b/ui/web/src/views/ChargingStationsView.vue index 113137c8..cbd8a34b 100644 --- a/ui/web/src/views/ChargingStationsView.vue +++ b/ui/web/src/views/ChargingStationsView.vue @@ -9,20 +9,35 @@ v-model="state.uiServerIndex" @change=" () => { - try { - if ( - getFromLocalStorage('uiServerConfigurationIndex', 0) !== state.uiServerIndex - ) { - setToLocalStorage('uiServerConfigurationIndex', state.uiServerIndex) - app!.appContext.config.globalProperties.$uiClient.setConfiguration( - app?.appContext.config.globalProperties.$configuration.uiServer[ - getFromLocalStorage('uiServerConfigurationIndex', state.uiServerIndex) - ] - ) - } - } 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) + $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 } + ) } } " @@ -31,54 +46,123 @@ v-for="uiServerConfiguration in uiServerConfigurations" :value="uiServerConfiguration.index" > - {{ uiServerConfiguration.configuration.host }} + {{ uiServerConfiguration.configuration.name ?? uiServerConfiguration.configuration.host }} - +