From: Jérôme Benoit Date: Sat, 17 Feb 2024 22:15:01 +0000 (+0100) Subject: fix(ui): fix charging stations refresh X-Git-Tag: v1.2.37~20 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=b9d447d2a538b560faa62320f7b37ce1a66c9a80;hp=7086aac2294163414002bc34bab83acf515a5d37;p=e-mobility-charging-stations-simulator.git fix(ui): fix charging stations refresh Signed-off-by: Jérôme Benoit --- diff --git a/ui/web/src/components/actions/AddChargingStations.vue b/ui/web/src/components/actions/AddChargingStations.vue index b1409bb7..94879da1 100644 --- a/ui/web/src/components/actions/AddChargingStations.vue +++ b/ui/web/src/components/actions/AddChargingStations.vue @@ -9,11 +9,17 @@ const app = getCurrentInstance() 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) + }) }) diff --git a/ui/web/src/views/ChargingStationsView.vue b/ui/web/src/views/ChargingStationsView.vue index f5757248..5e0ce534 100644 --- a/ui/web/src/views/ChargingStationsView.vue +++ b/ui/web/src/views/ChargingStationsView.vue @@ -3,13 +3,13 @@ - + - + @@ -28,7 +28,7 @@ const state = reactive({ 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 @@ -43,6 +43,9 @@ function loadChargingStations(): void { console.error('Error at fetching charging stations:', error) }) .finally(() => { + if (reloadCallback != null) { + reloadCallback() + } state.isLoading = false }) }