fix: silence TS strict null check errors
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 2 Aug 2024 10:25:32 +0000 (12:25 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 2 Aug 2024 10:25:32 +0000 (12:25 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
ui/web/src/components/actions/AddChargingStations.vue
ui/web/src/components/actions/SetSupervisionUrl.vue
ui/web/src/components/actions/StartTransaction.vue
ui/web/src/views/ChargingStationsView.vue

index 7a6fcec05681b8202064382e006f5ff082f35fa8..44ffcef3edacff2b85e5f476e941d145ab4b5a82 100644 (file)
@@ -14,8 +14,8 @@
       Please select a template
     </option>
     <option
-      v-for="template in $templates.value"
-      v-show="Array.isArray($templates.value) && $templates.value.length > 0"
+      v-for="template in $templates!.value"
+      v-show="Array.isArray($templates?.value) && $templates.value.length > 0"
       :key="template"
     >
       {{ template }}
@@ -85,7 +85,7 @@
     @click="
       () => {
         $uiClient
-          .addChargingStations(state.template, state.numberOfStations, {
+          ?.addChargingStations(state.template, state.numberOfStations, {
             supervisionUrls: state.supervisionUrl.length > 0 ? state.supervisionUrl : undefined,
             autoStart: convertToBoolean(state.autoStart),
             persistentConfiguration: convertToBoolean(state.persistentConfiguration),
@@ -135,7 +135,7 @@ const state = ref<{
   enableStatistics: false,
 })
 
-watch(getCurrentInstance()!.appContext.config.globalProperties.$templates, () => {
+watch(getCurrentInstance()!.appContext.config.globalProperties!.$templates, () => {
   state.value.renderTemplates = randomUUID()
 })
 </script>
index c904f704d7c4bdaa928b7bc78d14ec270dc17a37..76f4e940cf76efa955e59267ac2be6c4df62cac6 100644 (file)
@@ -17,7 +17,7 @@
     @click="
       () => {
         $uiClient
-          .setSupervisionUrl(hashId, state.supervisionUrl)
+          ?.setSupervisionUrl(hashId, state.supervisionUrl)
           .then(() => {
             $toast.success('Supervision url successfully set')
           })
index e4cf5b13ae70afcd3a1705fedd4261dd484c1f19..b91b8707e88842c01363d947507cb6ea8afacc1f 100644 (file)
@@ -18,7 +18,7 @@
     @click="
       () => {
         $uiClient
-          .startTransaction(hashId, convertToInt(connectorId), state.idTag)
+          ?.startTransaction(hashId, convertToInt(connectorId), state.idTag)
           .then(() => {
             $toast.success('Transaction successfully started')
           })
index e9b4d3b299f0e0e7199fc81603db4256a2935af3..90f4f0608052a85a3b2b87457a41d7c9aecb86bc 100644 (file)
               if (
                 getFromLocalStorage<number>('uiServerConfigurationIndex', 0) !== state.uiServerIndex
               ) {
-                $uiClient.setConfiguration(
-                  ($configuration.value.uiServer as UIServerConfigurationSection[])[
+                $uiClient?.setConfiguration(
+                  ($configuration!.value.uiServer as UIServerConfigurationSection[])[
                     state.uiServerIndex
                   ]
                 )
                 registerWSEventListeners()
-                $uiClient.registerWSEventListener(
+                $uiClient?.registerWSEventListener(
                   'open',
                   () => {
                     setToLocalStorage<number>('uiServerConfigurationIndex', state.uiServerIndex)
                   },
                   { once: true }
                 )
-                $uiClient.registerWSEventListener(
+                $uiClient?.registerWSEventListener(
                   'error',
                   () => {
                     state.uiServerIndex = getFromLocalStorage<number>(
                       'uiServerConfigurationIndex',
                       0
                     )
-                    $uiClient.setConfiguration(
-                      ($configuration.value.uiServer as UIServerConfigurationSection[])[
+                    $uiClient?.setConfiguration(
+                      ($configuration!.value.uiServer as UIServerConfigurationSection[])[
                         getFromLocalStorage<number>('uiServerConfigurationIndex', 0)
                       ]
                     )
@@ -99,9 +99,9 @@
       />
     </Container>
     <CSTable
-      v-show="Array.isArray($chargingStations.value) && $chargingStations.value.length > 0"
+      v-show="Array.isArray($chargingStations?.value) && $chargingStations.value.length > 0"
       :key="state.renderChargingStations"
-      :charging-stations="$chargingStations.value"
+      :charging-stations="$chargingStations!.value"
       @need-refresh="
         () => {
           state.renderAddChargingStations = randomUUID()
@@ -177,7 +177,7 @@ const clearToggleButtons = (): void => {
 
 const app = getCurrentInstance()
 
-watch(app!.appContext.config.globalProperties.$chargingStations, () => {
+watch(app!.appContext.config.globalProperties!.$chargingStations, () => {
   state.value.renderChargingStations = randomUUID()
 })
 
@@ -187,13 +187,13 @@ watch(simulatorState, () => {
 
 const clearTemplates = (): void => {
   if (app != null) {
-    app.appContext.config.globalProperties.$templates.value = []
+    app.appContext.config.globalProperties.$templates!.value = []
   }
 }
 
 const clearChargingStations = (): void => {
   if (app != null) {
-    app.appContext.config.globalProperties.$chargingStations.value = []
+    app.appContext.config.globalProperties.$chargingStations!.value = []
   }
 }
 
@@ -227,7 +227,7 @@ const getTemplates = (): void => {
       .listTemplates()
       .then((response: ResponsePayload) => {
         if (app != null) {
-          app.appContext.config.globalProperties.$templates.value = response.templates as string[]
+          app.appContext.config.globalProperties.$templates!.value = response.templates as string[]
         }
         return undefined
       })
@@ -249,7 +249,7 @@ const getChargingStations = (): void => {
       .listChargingStations()
       .then((response: ResponsePayload) => {
         if (app != null) {
-          app.appContext.config.globalProperties.$chargingStations.value =
+          app.appContext.config.globalProperties.$chargingStations!.value =
             response.chargingStations as ChargingStationData[]
         }
         return undefined
@@ -295,7 +295,7 @@ const uiServerConfigurations: {
   index: number
   configuration: UIServerConfigurationSection
 }[] = (
-  app?.appContext.config.globalProperties.$configuration.value
+  app!.appContext.config.globalProperties.$configuration!.value
     .uiServer as UIServerConfigurationSection[]
 ).map((configuration: UIServerConfigurationSection, index: number) => ({
   index,