fix: fix supervision url handling at charging stations adding
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 26 Feb 2024 13:02:45 +0000 (14:02 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 26 Feb 2024 13:02:45 +0000 (14:02 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts
src/charging-station/Helpers.ts
ui/web/src/components/actions/AddChargingStations.vue

index 4ee9ff6783e2aecfbdb148e4a855bad1b602254c..82fba5adad98c6629a6579b8e7c8516df38bb7bb 100644 (file)
@@ -534,15 +534,6 @@ export class ChargingStation extends EventEmitter {
     return Constants.DEFAULT_HEARTBEAT_INTERVAL
   }
 
-  public setSupervisionUrls (urls: string | string[], saveStationInfo = true): void {
-    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
-    this.stationInfo!.supervisionUrls = urls
-    if (saveStationInfo) {
-      this.saveStationInfo()
-    }
-    this.configuredSupervisionUrl = this.getConfiguredSupervisionUrl()
-  }
-
   public setSupervisionUrl (url: string): void {
     if (
       this.stationInfo?.supervisionUrlOcppConfiguration === true &&
@@ -550,7 +541,10 @@ export class ChargingStation extends EventEmitter {
     ) {
       setConfigurationKeyValue(this, this.stationInfo.supervisionUrlOcppKey, url)
     } else {
-      this.setSupervisionUrls(url)
+      // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+      this.stationInfo!.supervisionUrls = url
+      this.configuredSupervisionUrl = this.getConfiguredSupervisionUrl()
+      this.saveStationInfo()
     }
   }
 
@@ -1251,7 +1245,6 @@ export class ChargingStation extends EventEmitter {
       stationInfoFromFile.templateHash === stationInfoFromTemplate.templateHash
     ) {
       return setChargingStationOptions(
-        this,
         { ...Constants.DEFAULT_STATION_INFO, ...stationInfoFromFile },
         options
       )
@@ -1263,7 +1256,6 @@ export class ChargingStation extends EventEmitter {
         stationInfoFromTemplate
       )
     return setChargingStationOptions(
-      this,
       { ...Constants.DEFAULT_STATION_INFO, ...stationInfoFromTemplate },
       options
     )
index 2b3e1c7eae58408f212fd79940db666ae1c37cac..22ed5041e0515cc6b0769b3acb85df2d54525287 100644 (file)
@@ -335,12 +335,11 @@ export const buildConnectorsMap = (
 }
 
 export const setChargingStationOptions = (
-  chargingStation: ChargingStation,
   stationInfo: ChargingStationInfo,
   options?: ChargingStationOptions
 ): ChargingStationInfo => {
   if (options?.supervisionUrls != null) {
-    chargingStation.setSupervisionUrls(options.supervisionUrls, false)
+    stationInfo.supervisionUrls = options.supervisionUrls
   }
   if (options?.persistentConfiguration != null) {
     stationInfo.stationInfoPersistentConfiguration = options.persistentConfiguration
index 612c8ee8f87796d88d98c4eadaee694c1763f790..076ffdbdb5bd06842f73c280ce4bbe6715b971e4 100644 (file)
     name="number-of-stations"
     placeholder="number of stations"
   />
-  <p>Options:</p>
+  <p>Template options overrides:</p>
   <ul>
+    <li>
+      Supervision url:
+      <input
+        id="supervision-url"
+        v-model.trim="state.supervisionUrl"
+        type="url"
+        name="supervision-url"
+        placeholder="wss://"
+      />
+    </li>
     <li>
       Auto start:
       <input v-model="state.autoStart" type="checkbox" true-value="true" false-value="false" />
@@ -58,6 +68,7 @@
       () => {
         uiClient
           .addChargingStations(state.template, state.numberOfStations, {
+            supervisionUrls: state.supervisionUrl.length > 0 ? state.supervisionUrl : undefined,
             autoStart: convertToBoolean(state.autoStart),
             persistentConfiguration: convertToBoolean(state.persistentConfiguration),
             ocppStrictCompliance: convertToBoolean(state.ocppStrictCompliance),
@@ -92,6 +103,7 @@ const state = reactive({
   ready: false,
   template: '',
   numberOfStations: 1,
+  supervisionUrl: '',
   autoStart: false,
   persistentConfiguration: true,
   ocppStrictCompliance: true,