feat(ui): add helper to dynamically set configuration on UI client
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 19 Feb 2024 19:59:35 +0000 (20:59 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 19 Feb 2024 19:59:35 +0000 (20:59 +0100)
  singleton

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
ui/web/src/components/charging-stations/CSData.vue
ui/web/src/composables/UIClient.ts

index b88086396c2fb7faa53391ef5f777a3da7b7920d..4cd878baaceb6f86034cb1a98f8b3c293f26d8d6 100644 (file)
@@ -79,15 +79,15 @@ const props = defineProps<{
 
 const getConnectorStatuses = (): ConnectorStatus[] => {
   if (Array.isArray(props.chargingStation.evses) && props.chargingStation.evses.length > 0) {
-    const connectorsStatus: ConnectorStatus[] = []
+    const connectorStatuses: ConnectorStatus[] = []
     for (const [evseId, evseStatus] of props.chargingStation.evses.entries()) {
       if (evseId > 0 && Array.isArray(evseStatus.connectors) && evseStatus.connectors.length > 0) {
         for (const connectorStatus of evseStatus.connectors) {
-          connectorsStatus.push(connectorStatus)
+          connectorStatuses.push(connectorStatus)
         }
       }
     }
-    return connectorsStatus
+    return connectorStatuses
   }
   return props.chargingStation.connectors?.slice(1)
 }
index 9a6920418d3adb255f64a8e97e50be35e9586640..c6e80946c7bbfec42d0157a73afe18b4fe8a51b8 100644 (file)
@@ -33,6 +33,12 @@ export class UIClient {
     return UIClient.instance
   }
 
+  public setConfiguration(uiServerConfiguration: UIServerConfigurationSection): void {
+    this.ws.close()
+    this.uiServerConfiguration = uiServerConfiguration
+    this.openWS()
+  }
+
   public registerWSEventListener<K extends keyof WebSocketEventMap>(
     event: K,
     listener: (event: WebSocketEventMap[K]) => void