X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=inline;f=ui%2Fweb%2Fsrc%2Fviews%2FChargingStationsView.vue;h=abea2075cc1207114d0a0d1174f5b1453058a709;hb=258666f9962451dda19d0db528bbf07e41838ff2;hp=18b0cc028d1373845cf5a3f4e73f8c83339a5958;hpb=a4868fd7e236faf73e62efeeadad20119e2d96eb;p=e-mobility-charging-stations-simulator.git diff --git a/ui/web/src/views/ChargingStationsView.vue b/ui/web/src/views/ChargingStationsView.vue index 18b0cc02..abea2075 100644 --- a/ui/web/src/views/ChargingStationsView.vue +++ b/ui/web/src/views/ChargingStationsView.vue @@ -14,11 +14,25 @@ getFromLocalStorage('uiServerConfigurationIndex', 0) !== state.uiServerIndex ) { setToLocalStorage('uiServerConfigurationIndex', state.uiServerIndex) - app!.appContext.config.globalProperties.$uiClient.setConfiguration( + 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') @@ -31,7 +45,7 @@ v-for="uiServerConfiguration in uiServerConfigurations" :value="uiServerConfiguration.index" > - {{ uiServerConfiguration.configuration.host }} + {{ uiServerConfiguration.configuration.name ?? uiServerConfiguration.configuration.host }} @@ -44,7 +58,7 @@ 0 " - :key="state.reload" + :key="state.renderChargingStationsList" :charging-stations="app?.appContext.config.globalProperties.$chargingStations" /> @@ -73,8 +87,8 @@ const randomUUID = (): `${string}-${string}-${string}-${string}-${string}` => { } const state = reactive({ + renderChargingStationsList: randomUUID(), loading: false, - reload: randomUUID(), uiServerIndex: getFromLocalStorage('uiServerConfigurationIndex', 0) }) @@ -90,7 +104,7 @@ const uiServerConfigurations: { configuration: UIServerConfigurationSection; ind const $toast = useToast() -const loadChargingStations = (reloadCallback?: () => void): void => { +const loadChargingStations = (renderCallback?: () => void): void => { if (state.loading === false) { state.loading = true uiClient @@ -105,8 +119,8 @@ const loadChargingStations = (reloadCallback?: () => void): void => { console.error('Error at fetching charging stations:', error) }) .finally(() => { - if (reloadCallback != null) { - reloadCallback() + if (renderCallback != null) { + renderCallback() } state.loading = false })