refactor(ui): revert wrongly introduced code to handle multiples UI
[e-mobility-charging-stations-simulator.git] / ui / web / src / main.ts
index 27405eb66fa969ace6e7bbd8db4b71a3c6393307..97f0167a740f8b5390eee6c1882f31933d287101 100644 (file)
@@ -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-bootstrap.css'
 
 const initializeApp = (config: ConfigurationData) => {
   const app = createApp(App)
@@ -10,21 +12,22 @@ const initializeApp = (config: ConfigurationData) => {
     console.error('Error:', error)
     console.info('Vue instance:', instance)
     console.info('Error info:', info)
-    // TODO: Add code for UI notifications or other error handling logic
+    // TODO: add code for UI notifications or other error handling logic
   }
-  app.config.globalProperties.$uiClient = UIClient.getInstance(config)
-  app.config.globalProperties.$uiClient.registerWSonOpenListener(async () => {
+  app.config.globalProperties.$uiClient = UIClient.getInstance(config.uiServer)
+  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)
         throw error
       })
       .finally(() => {
-        app.use(router).mount('#app')
+        app.use(router).use(ToastPlugin).mount('#app')
       })
   })
 }