]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
refactor(webui): align $ prefix convention on composable locals
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 3 Apr 2026 11:00:52 +0000 (13:00 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 3 Apr 2026 11:00:52 +0000 (13:00 +0200)
Rename uiClient to $uiClient in 4 components (convention:
composable-returned Vue service instances use $ prefix).
Rename ref to $chargingStations in Utils.ts (was shadowing
Vue ref import). Keep chargingStationsRef unchanged in
ChargingStationsView (would shadow globalProperty in template).

ui/web/src/components/actions/StartTransaction.vue
ui/web/src/components/charging-stations/CSConnector.vue
ui/web/src/components/charging-stations/CSData.vue
ui/web/src/composables/Utils.ts
ui/web/src/views/ChargingStationsView.vue

index 973c0426a21a38cf9a8e59e6ef381f0b8dc50269..abfe0fe48dc0bbc3767f982c95ba25e91d875925 100644 (file)
@@ -72,7 +72,7 @@ const state = ref<{ authorizeIdTag: boolean; idTag: string }>({
   idTag: '',
 })
 
-const uiClient = useUIClient()
+const $uiClient = useUIClient()
 
 const toggleButtonId = computed(
   () => `${props.hashId}-${evseId.value ?? 0}-${props.connectorId}-start-transaction`
@@ -87,7 +87,7 @@ const handleStartTransaction = async (): Promise<void> => {
       return
     }
     try {
-      await uiClient.authorize(props.hashId, idTag)
+      await $uiClient.authorize(props.hashId, idTag)
     } catch (error) {
       $toast.error('Error at authorizing RFID tag')
       console.error('Error at authorizing RFID tag:', error)
@@ -98,7 +98,7 @@ const handleStartTransaction = async (): Promise<void> => {
   }
 
   try {
-    await uiClient.startTransaction(props.hashId, {
+    await $uiClient.startTransaction(props.hashId, {
       connectorId: convertToInt(props.connectorId),
       evseId: evseId.value,
       idTag,
index da93ee203a890d519736269712c1bb197732fbd6..2324a1aae7be14981b8048ad36128c37fc98128e 100644 (file)
@@ -87,7 +87,7 @@ const props = defineProps<{
 
 const $emit = defineEmits(['need-refresh'])
 
-const uiClient = useUIClient()
+const $uiClient = useUIClient()
 
 const $toast = useToast()
 
@@ -99,7 +99,7 @@ const stopTransaction = (): void => {
     return
   }
   executeAction(
-    uiClient.stopTransaction(props.hashId, {
+    $uiClient.stopTransaction(props.hashId, {
       ocppVersion: props.ocppVersion,
       transactionId: props.connector.transactionId,
     }),
@@ -109,28 +109,28 @@ const stopTransaction = (): void => {
 }
 const lockConnector = (): void => {
   executeAction(
-    uiClient.lockConnector(props.hashId, props.connectorId),
+    $uiClient.lockConnector(props.hashId, props.connectorId),
     'Connector successfully locked',
     'Error at locking connector'
   )
 }
 const unlockConnector = (): void => {
   executeAction(
-    uiClient.unlockConnector(props.hashId, props.connectorId),
+    $uiClient.unlockConnector(props.hashId, props.connectorId),
     'Connector successfully unlocked',
     'Error at unlocking connector'
   )
 }
 const startAutomaticTransactionGenerator = (): void => {
   executeAction(
-    uiClient.startAutomaticTransactionGenerator(props.hashId, props.connectorId),
+    $uiClient.startAutomaticTransactionGenerator(props.hashId, props.connectorId),
     'Automatic transaction generator successfully started',
     'Error at starting automatic transaction generator'
   )
 }
 const stopAutomaticTransactionGenerator = (): void => {
   executeAction(
-    uiClient.stopAutomaticTransactionGenerator(props.hashId, props.connectorId),
+    $uiClient.stopAutomaticTransactionGenerator(props.hashId, props.connectorId),
     'Automatic transaction generator successfully stopped',
     'Error at stopping automatic transaction generator'
   )
index 4da1d553167e155de48494cda16dd1c8a74d8416..cb51e7d5068bc79b2082f3b6a286355272196dc0 100644 (file)
@@ -207,7 +207,7 @@ const getWSState = (): string => {
   }
 }
 
-const uiClient = useUIClient()
+const $uiClient = useUIClient()
 
 const $toast = useToast()
 
@@ -215,34 +215,34 @@ const executeAction = useExecuteAction($emit)
 
 const startChargingStation = (): void => {
   executeAction(
-    uiClient.startChargingStation(props.chargingStation.stationInfo.hashId),
+    $uiClient.startChargingStation(props.chargingStation.stationInfo.hashId),
     'Charging station successfully started',
     'Error at starting charging station'
   )
 }
 const stopChargingStation = (): void => {
   executeAction(
-    uiClient.stopChargingStation(props.chargingStation.stationInfo.hashId),
+    $uiClient.stopChargingStation(props.chargingStation.stationInfo.hashId),
     'Charging station successfully stopped',
     'Error at stopping charging station'
   )
 }
 const openConnection = (): void => {
   executeAction(
-    uiClient.openConnection(props.chargingStation.stationInfo.hashId),
+    $uiClient.openConnection(props.chargingStation.stationInfo.hashId),
     'Connection successfully opened',
     'Error at opening connection'
   )
 }
 const closeConnection = (): void => {
   executeAction(
-    uiClient.closeConnection(props.chargingStation.stationInfo.hashId),
+    $uiClient.closeConnection(props.chargingStation.stationInfo.hashId),
     'Connection successfully closed',
     'Error at closing connection'
   )
 }
 const deleteChargingStation = (): void => {
-  uiClient
+  $uiClient
     .deleteChargingStation(props.chargingStation.stationInfo.hashId)
     .then(() => {
       for (const key in getLocalStorage()) {
index 2bbb8127d70e7914571e8b454b88618ae50dccd5..c5531deda351dc167ac514d084839545313121b9 100644 (file)
@@ -94,10 +94,10 @@ export const useChargingStations = (): Ref<ChargingStationData[]> | undefined =>
 }
 
 export const refreshChargingStations = async (): Promise<void> => {
-  const ref = useChargingStations()
-  if (ref == null) return
+  const $chargingStations = useChargingStations()
+  if ($chargingStations == null) return
   const response = await useUIClient().listChargingStations()
-  ref.value = response.chargingStations as ChargingStationData[]
+  $chargingStations.value = response.chargingStations as ChargingStationData[]
 }
 
 export const useExecuteAction = (emit: (event: 'need-refresh') => void) => {
index d6860fdd2766f11393699c5895a94fc2789ff24d..386525430a4d2da52265e4f4b52c955c3085c4c5 100644 (file)
@@ -199,14 +199,14 @@ const clearChargingStations = (): void => {
   }
 }
 
-const uiClient = useUIClient()
+const $uiClient = useUIClient()
 
 const $toast = useToast()
 
 const getSimulatorState = (): void => {
   if (state.value.gettingSimulatorState === false) {
     state.value.gettingSimulatorState = true
-    uiClient
+    $uiClient
       .simulatorState()
       .then((response: ResponsePayload) => {
         simulatorState.value = response.state as SimulatorState
@@ -225,7 +225,7 @@ const getSimulatorState = (): void => {
 const getTemplates = (): void => {
   if (state.value.gettingTemplates === false) {
     state.value.gettingTemplates = true
-    uiClient
+    $uiClient
       .listTemplates()
       .then((response: ResponsePayload) => {
         if (app != null) {
@@ -247,7 +247,7 @@ const getTemplates = (): void => {
 const getChargingStations = (): void => {
   if (state.value.gettingChargingStations === false) {
     state.value.gettingChargingStations = true
-    uiClient
+    $uiClient
       .listChargingStations()
       .then((response: ResponsePayload) => {
         if (chargingStationsRef != null) {
@@ -273,22 +273,22 @@ const getData = (): void => {
 }
 
 const registerWSEventListeners = () => {
-  uiClient.registerWSEventListener('open', getData)
-  uiClient.registerWSEventListener('error', clearChargingStations)
-  uiClient.registerWSEventListener('close', clearChargingStations)
+  $uiClient.registerWSEventListener('open', getData)
+  $uiClient.registerWSEventListener('error', clearChargingStations)
+  $uiClient.registerWSEventListener('close', clearChargingStations)
 }
 
 const unregisterWSEventListeners = () => {
-  uiClient.unregisterWSEventListener('open', getData)
-  uiClient.unregisterWSEventListener('error', clearChargingStations)
-  uiClient.unregisterWSEventListener('close', clearChargingStations)
+  $uiClient.unregisterWSEventListener('open', getData)
+  $uiClient.unregisterWSEventListener('error', clearChargingStations)
+  $uiClient.unregisterWSEventListener('close', clearChargingStations)
 }
 
 let unsubscribeRefresh: (() => void) | undefined
 
 onMounted(() => {
   registerWSEventListeners()
-  unsubscribeRefresh = uiClient.onRefresh(() => {
+  unsubscribeRefresh = $uiClient.onRefresh(() => {
     getChargingStations()
   })
 })
@@ -310,7 +310,7 @@ const uiServerConfigurations: {
 }))
 
 const startSimulator = (): void => {
-  uiClient
+  $uiClient
     .startSimulator()
     .then(() => {
       return $toast.success('Simulator successfully started')
@@ -324,7 +324,7 @@ const startSimulator = (): void => {
     })
 }
 const stopSimulator = (): void => {
-  uiClient
+  $uiClient
     .stopSimulator()
     .then(() => {
       clearChargingStations()