From a4baab6300ff8bd111e0915f860b1cb05bb594e9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 19 Feb 2024 20:59:35 +0100 Subject: [PATCH] feat(ui): add helper to dynamically set configuration on UI client singleton MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- ui/web/src/components/charging-stations/CSData.vue | 6 +++--- ui/web/src/composables/UIClient.ts | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ui/web/src/components/charging-stations/CSData.vue b/ui/web/src/components/charging-stations/CSData.vue index b8808639..4cd878ba 100644 --- a/ui/web/src/components/charging-stations/CSData.vue +++ b/ui/web/src/components/charging-stations/CSData.vue @@ -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) } diff --git a/ui/web/src/composables/UIClient.ts b/ui/web/src/composables/UIClient.ts index 9a692041..c6e80946 100644 --- a/ui/web/src/composables/UIClient.ts +++ b/ui/web/src/composables/UIClient.ts @@ -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( event: K, listener: (event: WebSocketEventMap[K]) => void -- 2.34.1