From: Jérôme Benoit Date: Sun, 18 Feb 2024 13:15:56 +0000 (+0100) Subject: feat(ui): add action success/failure notifications X-Git-Tag: v1.2.37~13 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=cea23fa0af66a39cc3bf089217b90e1b5e9f0def;p=e-mobility-charging-stations-simulator.git feat(ui): add action success/failure notifications Signed-off-by: Jérôme Benoit --- diff --git a/ui/web/package.json b/ui/web/package.json index db4c7b4c..caa425a1 100644 --- a/ui/web/package.json +++ b/ui/web/package.json @@ -35,7 +35,8 @@ "finalhandler": "^1.2.0", "serve-static": "^1.15.0", "vue": "^3.4.19", - "vue-router": "^4.2.5" + "vue-router": "^4.2.5", + "vue-toast-notification": "^3.1.2" }, "devDependencies": { "@rushstack/eslint-patch": "^1.7.2", diff --git a/ui/web/pnpm-lock.yaml b/ui/web/pnpm-lock.yaml index 050f7de3..60741f5b 100644 --- a/ui/web/pnpm-lock.yaml +++ b/ui/web/pnpm-lock.yaml @@ -20,6 +20,9 @@ dependencies: vue-router: specifier: ^4.2.5 version: 4.2.5(vue@3.4.19) + vue-toast-notification: + specifier: ^3.1.2 + version: 3.1.2(vue@3.4.19) devDependencies: '@rushstack/eslint-patch': @@ -4219,6 +4222,15 @@ packages: vue: 3.4.19(typescript@5.3.3) dev: false + /vue-toast-notification@3.1.2(vue@3.4.19): + resolution: {integrity: sha512-oNRL/W9aaHoeScp+iTIW7k09vM16/+8aptp2maa+7qTB43JuxmAgKdXKFYtf+uvSNOYYq2BIWgLCeJ61pwom/A==} + engines: {node: '>=12.15.0'} + peerDependencies: + vue: ^3.0 + dependencies: + vue: 3.4.19(typescript@5.3.3) + dev: false + /vue@3.4.19(typescript@5.3.3): resolution: {integrity: sha512-W/7Fc9KUkajFU8dBeDluM4sRGc/aa4YJnOYck8dkjgZoXtVsn3OeTGni66FV1l3+nvPA7VBFYtPioaGKUmEADw==} peerDependencies: diff --git a/ui/web/src/components/actions/AddChargingStations.vue b/ui/web/src/components/actions/AddChargingStations.vue index 387d8a1a..7a2f8a59 100644 --- a/ui/web/src/components/actions/AddChargingStations.vue +++ b/ui/web/src/components/actions/AddChargingStations.vue @@ -20,8 +20,11 @@ () => { uiClient .addChargingStations(state.template, state.numberOfStations) + .then(() => { + $toast.success('Charging stations successfully added') + }) .catch((error: Error) => { - // TODO: add code for UI notifications or other error handling logic + $toast.error('Error at adding charging stations') console.error('Error at adding charging stations:', error) }) .finally(() => { @@ -36,6 +39,7 @@ diff --git a/ui/web/src/components/charging-stations/CSData.vue b/ui/web/src/components/charging-stations/CSData.vue index 4502f53c..423014bd 100644 --- a/ui/web/src/components/charging-stations/CSData.vue +++ b/ui/web/src/components/charging-stations/CSData.vue @@ -67,6 +67,7 @@ diff --git a/ui/web/src/main.ts b/ui/web/src/main.ts index 18186e16..bb42f576 100644 --- a/ui/web/src/main.ts +++ b/ui/web/src/main.ts @@ -1,8 +1,10 @@ import { createApp } from 'vue' +import ToastPlugin from 'vue-toast-notification' import type { ConfigurationData, ResponsePayload } from './types' import { router } from '@/router' import { UIClient } from '@/composables' import App from '@/App.vue' +import 'vue-toast-notification/dist/theme-default.css' const initializeApp = (config: ConfigurationData) => { const app = createApp(App) @@ -25,7 +27,7 @@ const initializeApp = (config: ConfigurationData) => { throw error }) .finally(() => { - app.use(router).mount('#app') + app.use(router).use(ToastPlugin).mount('#app') }) }) } diff --git a/ui/web/src/views/ChargingStationsView.vue b/ui/web/src/views/ChargingStationsView.vue index d0acc4e3..b8a719b7 100644 --- a/ui/web/src/views/ChargingStationsView.vue +++ b/ui/web/src/views/ChargingStationsView.vue @@ -18,6 +18,7 @@