feat(ui): add support for multiple UI server configurations
[e-mobility-charging-stations-simulator.git] / ui / web / src / composables / UIClient.ts
index d569b93b09719e91cd8536a4ac5f315ddc5e4417..51d61f263f7788adcd45e930ef79103dbd92d883 100644 (file)
@@ -1,3 +1,4 @@
+import { useToast } from 'vue-toast-notification'
 import {
   ApplicationProtocol,
   AuthenticationType,
@@ -161,15 +162,21 @@ export class UIClient {
       `${this.uiServerConfiguration.secure === true ? ApplicationProtocol.WSS : ApplicationProtocol.WS}://${this.uiServerConfiguration.host}:${this.uiServerConfiguration.port}`,
       protocols
     )
-    this.ws.onopen = openEvent => {
-      console.info('WebSocket opened', openEvent)
+    this.ws.onopen = () => {
+      useToast().success(
+        `WebSocket to UI server '${this.uiServerConfiguration.host}' successfully opened`
+      )
     }
     this.ws.onmessage = this.responseHandler.bind(this)
     this.ws.onerror = errorEvent => {
-      console.error('WebSocket error: ', errorEvent)
+      useToast().error(`Error in WebSocket to UI server '${this.uiServerConfiguration.host}'`)
+      console.error(
+        `Error in WebSocket to UI server '${this.uiServerConfiguration.host}'`,
+        errorEvent
+      )
     }
-    this.ws.onclose = closeEvent => {
-      console.info('WebSocket closed: ', closeEvent)
+    this.ws.onclose = () => {
+      useToast().info(`WebSocket to UI server '${this.uiServerConfiguration.host}' closed`)
     }
   }