Skip to content

Commit 419aa28

Browse files
committed
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).
1 parent 081d850 commit 419aa28

5 files changed

Lines changed: 31 additions & 31 deletions

File tree

ui/web/src/components/actions/StartTransaction.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const state = ref<{ authorizeIdTag: boolean; idTag: string }>({
7272
idTag: '',
7373
})
7474
75-
const uiClient = useUIClient()
75+
const $uiClient = useUIClient()
7676
7777
const toggleButtonId = computed(
7878
() => `${props.hashId}-${evseId.value ?? 0}-${props.connectorId}-start-transaction`
@@ -87,7 +87,7 @@ const handleStartTransaction = async (): Promise<void> => {
8787
return
8888
}
8989
try {
90-
await uiClient.authorize(props.hashId, idTag)
90+
await $uiClient.authorize(props.hashId, idTag)
9191
} catch (error) {
9292
$toast.error('Error at authorizing RFID tag')
9393
console.error('Error at authorizing RFID tag:', error)
@@ -98,7 +98,7 @@ const handleStartTransaction = async (): Promise<void> => {
9898
}
9999
100100
try {
101-
await uiClient.startTransaction(props.hashId, {
101+
await $uiClient.startTransaction(props.hashId, {
102102
connectorId: convertToInt(props.connectorId),
103103
evseId: evseId.value,
104104
idTag,

ui/web/src/components/charging-stations/CSConnector.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const props = defineProps<{
8787
8888
const $emit = defineEmits(['need-refresh'])
8989
90-
const uiClient = useUIClient()
90+
const $uiClient = useUIClient()
9191
9292
const $toast = useToast()
9393
@@ -99,7 +99,7 @@ const stopTransaction = (): void => {
9999
return
100100
}
101101
executeAction(
102-
uiClient.stopTransaction(props.hashId, {
102+
$uiClient.stopTransaction(props.hashId, {
103103
ocppVersion: props.ocppVersion,
104104
transactionId: props.connector.transactionId,
105105
}),
@@ -109,28 +109,28 @@ const stopTransaction = (): void => {
109109
}
110110
const lockConnector = (): void => {
111111
executeAction(
112-
uiClient.lockConnector(props.hashId, props.connectorId),
112+
$uiClient.lockConnector(props.hashId, props.connectorId),
113113
'Connector successfully locked',
114114
'Error at locking connector'
115115
)
116116
}
117117
const unlockConnector = (): void => {
118118
executeAction(
119-
uiClient.unlockConnector(props.hashId, props.connectorId),
119+
$uiClient.unlockConnector(props.hashId, props.connectorId),
120120
'Connector successfully unlocked',
121121
'Error at unlocking connector'
122122
)
123123
}
124124
const startAutomaticTransactionGenerator = (): void => {
125125
executeAction(
126-
uiClient.startAutomaticTransactionGenerator(props.hashId, props.connectorId),
126+
$uiClient.startAutomaticTransactionGenerator(props.hashId, props.connectorId),
127127
'Automatic transaction generator successfully started',
128128
'Error at starting automatic transaction generator'
129129
)
130130
}
131131
const stopAutomaticTransactionGenerator = (): void => {
132132
executeAction(
133-
uiClient.stopAutomaticTransactionGenerator(props.hashId, props.connectorId),
133+
$uiClient.stopAutomaticTransactionGenerator(props.hashId, props.connectorId),
134134
'Automatic transaction generator successfully stopped',
135135
'Error at stopping automatic transaction generator'
136136
)

ui/web/src/components/charging-stations/CSData.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,42 +207,42 @@ const getWSState = (): string => {
207207
}
208208
}
209209
210-
const uiClient = useUIClient()
210+
const $uiClient = useUIClient()
211211
212212
const $toast = useToast()
213213
214214
const executeAction = useExecuteAction($emit)
215215
216216
const startChargingStation = (): void => {
217217
executeAction(
218-
uiClient.startChargingStation(props.chargingStation.stationInfo.hashId),
218+
$uiClient.startChargingStation(props.chargingStation.stationInfo.hashId),
219219
'Charging station successfully started',
220220
'Error at starting charging station'
221221
)
222222
}
223223
const stopChargingStation = (): void => {
224224
executeAction(
225-
uiClient.stopChargingStation(props.chargingStation.stationInfo.hashId),
225+
$uiClient.stopChargingStation(props.chargingStation.stationInfo.hashId),
226226
'Charging station successfully stopped',
227227
'Error at stopping charging station'
228228
)
229229
}
230230
const openConnection = (): void => {
231231
executeAction(
232-
uiClient.openConnection(props.chargingStation.stationInfo.hashId),
232+
$uiClient.openConnection(props.chargingStation.stationInfo.hashId),
233233
'Connection successfully opened',
234234
'Error at opening connection'
235235
)
236236
}
237237
const closeConnection = (): void => {
238238
executeAction(
239-
uiClient.closeConnection(props.chargingStation.stationInfo.hashId),
239+
$uiClient.closeConnection(props.chargingStation.stationInfo.hashId),
240240
'Connection successfully closed',
241241
'Error at closing connection'
242242
)
243243
}
244244
const deleteChargingStation = (): void => {
245-
uiClient
245+
$uiClient
246246
.deleteChargingStation(props.chargingStation.stationInfo.hashId)
247247
.then(() => {
248248
for (const key in getLocalStorage()) {

ui/web/src/composables/Utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ export const useChargingStations = (): Ref<ChargingStationData[]> | undefined =>
9494
}
9595

9696
export const refreshChargingStations = async (): Promise<void> => {
97-
const ref = useChargingStations()
98-
if (ref == null) return
97+
const $chargingStations = useChargingStations()
98+
if ($chargingStations == null) return
9999
const response = await useUIClient().listChargingStations()
100-
ref.value = response.chargingStations as ChargingStationData[]
100+
$chargingStations.value = response.chargingStations as ChargingStationData[]
101101
}
102102

103103
export const useExecuteAction = (emit: (event: 'need-refresh') => void) => {

ui/web/src/views/ChargingStationsView.vue

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,14 @@ const clearChargingStations = (): void => {
199199
}
200200
}
201201
202-
const uiClient = useUIClient()
202+
const $uiClient = useUIClient()
203203
204204
const $toast = useToast()
205205
206206
const getSimulatorState = (): void => {
207207
if (state.value.gettingSimulatorState === false) {
208208
state.value.gettingSimulatorState = true
209-
uiClient
209+
$uiClient
210210
.simulatorState()
211211
.then((response: ResponsePayload) => {
212212
simulatorState.value = response.state as SimulatorState
@@ -225,7 +225,7 @@ const getSimulatorState = (): void => {
225225
const getTemplates = (): void => {
226226
if (state.value.gettingTemplates === false) {
227227
state.value.gettingTemplates = true
228-
uiClient
228+
$uiClient
229229
.listTemplates()
230230
.then((response: ResponsePayload) => {
231231
if (app != null) {
@@ -247,7 +247,7 @@ const getTemplates = (): void => {
247247
const getChargingStations = (): void => {
248248
if (state.value.gettingChargingStations === false) {
249249
state.value.gettingChargingStations = true
250-
uiClient
250+
$uiClient
251251
.listChargingStations()
252252
.then((response: ResponsePayload) => {
253253
if (chargingStationsRef != null) {
@@ -273,22 +273,22 @@ const getData = (): void => {
273273
}
274274
275275
const registerWSEventListeners = () => {
276-
uiClient.registerWSEventListener('open', getData)
277-
uiClient.registerWSEventListener('error', clearChargingStations)
278-
uiClient.registerWSEventListener('close', clearChargingStations)
276+
$uiClient.registerWSEventListener('open', getData)
277+
$uiClient.registerWSEventListener('error', clearChargingStations)
278+
$uiClient.registerWSEventListener('close', clearChargingStations)
279279
}
280280
281281
const unregisterWSEventListeners = () => {
282-
uiClient.unregisterWSEventListener('open', getData)
283-
uiClient.unregisterWSEventListener('error', clearChargingStations)
284-
uiClient.unregisterWSEventListener('close', clearChargingStations)
282+
$uiClient.unregisterWSEventListener('open', getData)
283+
$uiClient.unregisterWSEventListener('error', clearChargingStations)
284+
$uiClient.unregisterWSEventListener('close', clearChargingStations)
285285
}
286286
287287
let unsubscribeRefresh: (() => void) | undefined
288288
289289
onMounted(() => {
290290
registerWSEventListeners()
291-
unsubscribeRefresh = uiClient.onRefresh(() => {
291+
unsubscribeRefresh = $uiClient.onRefresh(() => {
292292
getChargingStations()
293293
})
294294
})
@@ -310,7 +310,7 @@ const uiServerConfigurations: {
310310
}))
311311
312312
const startSimulator = (): void => {
313-
uiClient
313+
$uiClient
314314
.startSimulator()
315315
.then(() => {
316316
return $toast.success('Simulator successfully started')
@@ -324,7 +324,7 @@ const startSimulator = (): void => {
324324
})
325325
}
326326
const stopSimulator = (): void => {
327-
uiClient
327+
$uiClient
328328
.stopSimulator()
329329
.then(() => {
330330
clearChargingStations()

0 commit comments

Comments
 (0)