const uiClient = app?.appContext.config.globalProperties.$uiClient
onMounted(() => {
- uiClient.listTemplates().then((response: ResponsePayload) => {
- if (app != null && app.appContext.config.globalProperties.$templates == null) {
- app.appContext.config.globalProperties.$templates = response.templates
- }
- })
+ uiClient
+ .listTemplates()
+ .then((response: ResponsePayload) => {
+ if (app != null && app.appContext.config.globalProperties.$templates == null) {
+ app.appContext.config.globalProperties.$templates = response.templates
+ }
+ })
+ .catch((error: Error) => {
+ // TODO: add code for UI notifications or other error handling logic
+ console.error('Error at fetching charging station templates:', error)
+ })
})
</script>
<Container id="buttons-container">
<Button id="simulator-button" @click="startSimulator()">Start Simulator</Button>
<Button id="simulator-button" @click="stopSimulator()">Stop Simulator</Button>
- <ReloadButton id="reload-button" :loading="state.isLoading" @click="loadChargingStations()" />
+ <ReloadButton
+ id="reload-button"
+ :loading="state.isLoading"
+ @click="loadChargingStations(() => $router.go(0))"
+ />
</Container>
- <CSTable
- :charging-stations="
- getCurrentInstance()?.appContext.config.globalProperties.$chargingStations ?? []
- "
- />
+ <CSTable :charging-stations="app?.appContext.config.globalProperties.$chargingStations ?? []" />
</Container>
</template>
const app = getCurrentInstance()
const uiClient = app?.appContext.config.globalProperties.$uiClient
-function loadChargingStations(): void {
+function loadChargingStations(reloadCallback?: () => void): void {
if (state.isLoading === false) {
state.isLoading = true
uiClient
console.error('Error at fetching charging stations:', error)
})
.finally(() => {
+ if (reloadCallback != null) {
+ reloadCallback()
+ }
state.isLoading = false
})
}