From 419aa281a14c852b5cb54f9381a4e6827a6b99a0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 3 Apr 2026 13:00:52 +0200 Subject: [PATCH] refactor(webui): align $ prefix convention on composable locals 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). --- .../components/actions/StartTransaction.vue | 6 ++--- .../charging-stations/CSConnector.vue | 12 ++++----- .../components/charging-stations/CSData.vue | 12 ++++----- ui/web/src/composables/Utils.ts | 6 ++--- ui/web/src/views/ChargingStationsView.vue | 26 +++++++++---------- 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/ui/web/src/components/actions/StartTransaction.vue b/ui/web/src/components/actions/StartTransaction.vue index 973c0426..abfe0fe4 100644 --- a/ui/web/src/components/actions/StartTransaction.vue +++ b/ui/web/src/components/actions/StartTransaction.vue @@ -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 => { 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 => { } try { - await uiClient.startTransaction(props.hashId, { + await $uiClient.startTransaction(props.hashId, { connectorId: convertToInt(props.connectorId), evseId: evseId.value, idTag, diff --git a/ui/web/src/components/charging-stations/CSConnector.vue b/ui/web/src/components/charging-stations/CSConnector.vue index da93ee20..2324a1aa 100644 --- a/ui/web/src/components/charging-stations/CSConnector.vue +++ b/ui/web/src/components/charging-stations/CSConnector.vue @@ -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' ) diff --git a/ui/web/src/components/charging-stations/CSData.vue b/ui/web/src/components/charging-stations/CSData.vue index 4da1d553..cb51e7d5 100644 --- a/ui/web/src/components/charging-stations/CSData.vue +++ b/ui/web/src/components/charging-stations/CSData.vue @@ -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()) { diff --git a/ui/web/src/composables/Utils.ts b/ui/web/src/composables/Utils.ts index 2bbb8127..c5531ded 100644 --- a/ui/web/src/composables/Utils.ts +++ b/ui/web/src/composables/Utils.ts @@ -94,10 +94,10 @@ export const useChargingStations = (): Ref | undefined => } export const refreshChargingStations = async (): Promise => { - 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) => { diff --git a/ui/web/src/views/ChargingStationsView.vue b/ui/web/src/views/ChargingStationsView.vue index d6860fdd..38652543 100644 --- a/ui/web/src/views/ChargingStationsView.vue +++ b/ui/web/src/views/ChargingStationsView.vue @@ -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() -- 2.53.0