From b9d447d2a538b560faa62320f7b37ce1a66c9a80 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 17 Feb 2024 23:15:01 +0100 Subject: [PATCH 1/1] fix(ui): fix charging stations refresh MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../components/actions/AddChargingStations.vue | 16 +++++++++++----- ui/web/src/views/ChargingStationsView.vue | 17 ++++++++++------- 2 files changed, 21 insertions(+), 12 deletions(-) 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 }) } -- 2.34.1