getFromLocalStorage<number>('uiServerConfigurationIndex', 0) !== state.uiServerIndex
) {
setToLocalStorage<number>('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<number>('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')
v-for="uiServerConfiguration in uiServerConfigurations"
:value="uiServerConfiguration.index"
>
- {{ uiServerConfiguration.configuration.host }}
+ {{ uiServerConfiguration.configuration.name ?? uiServerConfiguration.configuration.host }}
</option>
</select>
</Container>
<ReloadButton
id="reload-button"
:loading="state.loading"
- @click="loadChargingStations(() => (state.reload = randomUUID()))"
+ @click="loadChargingStations(() => (state.renderChargingStationsList = randomUUID()))"
/>
</Container>
<CSTable
Array.isArray(app?.appContext.config.globalProperties.$chargingStations) &&
app?.appContext.config.globalProperties.$chargingStations.length > 0
"
- :key="state.reload"
+ :key="state.renderChargingStationsList"
:charging-stations="app?.appContext.config.globalProperties.$chargingStations"
/>
</Container>
}
const state = reactive({
+ renderChargingStationsList: randomUUID(),
loading: false,
- reload: randomUUID(),
uiServerIndex: getFromLocalStorage<number>('uiServerConfigurationIndex', 0)
})
const $toast = useToast()
-const loadChargingStations = (reloadCallback?: () => void): void => {
+const loadChargingStations = (renderCallback?: () => void): void => {
if (state.loading === false) {
state.loading = true
uiClient
console.error('Error at fetching charging stations:', error)
})
.finally(() => {
- if (reloadCallback != null) {
- reloadCallback()
+ if (renderCallback != null) {
+ renderCallback()
}
state.loading = false
})