'open',
() => {
setToLocalStorage<number>('uiServerConfigurationIndex', state.uiServerIndex)
- for (const key in getLocalStorage()) {
- if (key.includes('toggle-button')) {
- removeFromLocalStorage(key)
- }
- }
$router.currentRoute.value.name !== 'charging-stations' &&
$router.push({ name: 'charging-stations' })
},
<Button @click="stopSimulator()">Stop Simulator</Button>
<ToggleButton
:id="'add-charging-stations'"
+ :key="state.renderAddChargingStations"
:shared="true"
:on="
() => {
<ReloadButton
id="reload-button"
:loading="state.loading"
- @click="loadChargingStations(() => (state.renderChargingStationsList = randomUUID()))"
+ @click="loadChargingStations(() => (state.renderChargingStations = randomUUID()))"
/>
</Container>
<CSTable
v-show="
Array.isArray(app?.appContext.config.globalProperties.$chargingStations) &&
- app?.appContext.config.globalProperties.$chargingStations.length > 0
+ app.appContext.config.globalProperties.$chargingStations.length > 0
"
- :key="state.renderChargingStationsList"
+ :key="state.renderChargingStations"
:charging-stations="app?.appContext.config.globalProperties.$chargingStations"
/>
</Container>
const app = getCurrentInstance()
+const clearToggleButtons = (): void => {
+ for (const key in getLocalStorage()) {
+ if (key.includes('toggle-button')) {
+ removeFromLocalStorage(key)
+ }
+ }
+}
+
+const clearChargingStations = (): void => {
+ clearToggleButtons()
+ app!.appContext.config.globalProperties.$chargingStations = []
+ state.value.renderAddChargingStations = randomUUID()
+ state.value.renderChargingStations = randomUUID()
+}
+
const initializeWSEventListeners = () => {
app?.appContext.config.globalProperties.$uiClient.registerWSEventListener('open', () => {
uiClient
$toast.error('Error at fetching charging station templates')
console.error('Error at fetching charging station templates:', error)
})
- loadChargingStations(() => (state.value.renderChargingStationsList = randomUUID()))
- })
- app?.appContext.config.globalProperties.$uiClient.registerWSEventListener('error', () => {
- app.appContext.config.globalProperties.$chargingStations = []
- state.value.renderChargingStationsList = randomUUID()
- })
- app?.appContext.config.globalProperties.$uiClient.registerWSEventListener('close', () => {
- app.appContext.config.globalProperties.$chargingStations = []
- state.value.renderChargingStationsList = randomUUID()
+ loadChargingStations(() => {
+ state.value.renderAddChargingStations = randomUUID()
+ state.value.renderChargingStations = randomUUID()
+ })
})
+ app?.appContext.config.globalProperties.$uiClient.registerWSEventListener(
+ 'error',
+ clearChargingStations
+ )
+ app?.appContext.config.globalProperties.$uiClient.registerWSEventListener(
+ 'close',
+ clearChargingStations
+ )
}
onMounted(() => {
})
const state = ref({
- renderChargingStationsList: randomUUID(),
+ renderAddChargingStations: randomUUID(),
+ renderChargingStations: randomUUID(),
loading: false,
uiServerIndex: getFromLocalStorage<number>('uiServerConfigurationIndex', 0)
})