X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=ui%2Fweb%2Fsrc%2Fmain.ts;h=5d34ae912e8ecb44f36c276b9542e6c0dc2c6bdc;hb=53a8f2aadb2fceace1a8884770680f7e70437f73;hp=0e79968462d64a39b87bd39afc86d0b3feaea48a;hpb=7e2e8c9b820004dc6a84d6a5629575460daf8167;p=e-mobility-charging-stations-simulator.git diff --git a/ui/web/src/main.ts b/ui/web/src/main.ts index 0e799684..5d34ae91 100644 --- a/ui/web/src/main.ts +++ b/ui/web/src/main.ts @@ -1,6 +1,6 @@ import { type App as AppType, createApp } from 'vue' import ToastPlugin from 'vue-toast-notification' -import type { ConfigurationData, ResponsePayload } from '@/types' +import type { ConfigurationData } from '@/types' import { router } from '@/router' import { UIClient, getFromLocalStorage, setToLocalStorage } from '@/composables' import App from '@/App.vue' @@ -21,6 +21,9 @@ const initializeApp = (app: AppType, config: ConfigurationData) => { if (app.config.globalProperties.$configuration == null) { app.config.globalProperties.$configuration = config } + if (!Array.isArray(app.config.globalProperties.$templates)) { + app.config.globalProperties.$templates = [] + } if (!Array.isArray(app.config.globalProperties.$chargingStations)) { app.config.globalProperties.$chargingStations = [] } @@ -37,25 +40,8 @@ const initializeApp = (app: AppType, config: ConfigurationData) => { getFromLocalStorage('uiServerConfigurationIndex', 0) ] ) - app.config.globalProperties.$uiClient.registerWSEventListener( - 'open', - () => { - app.config.globalProperties.$uiClient - .listChargingStations() - .then((response: ResponsePayload) => { - app.config.globalProperties.$chargingStations = response.chargingStations - }) - .catch((error: Error) => { - // TODO: add code for UI notifications or other error handling logic - console.error('Error at fetching charging stations:', error) - }) - .finally(() => { - app.use(router).use(ToastPlugin).mount('#app') - }) - }, - { once: true } - ) } + app.use(router).use(ToastPlugin).mount('#app') } fetch('/config.json') @@ -68,12 +54,7 @@ fetch('/config.json') response .json() .then(config => { - try { - initializeApp(app, config) - } catch (error) { - // TODO: add code for UI notifications or other error handling logic - console.error('Error at initializing app:', error) - } + initializeApp(app, config) }) .catch(error => { // TODO: add code for UI notifications or other error handling logic