From: Jérôme Benoit Date: Wed, 23 Jul 2025 19:27:10 +0000 (+0200) Subject: feat(ui): allow to authorize RFID tag at start transaction X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=9a5f80980118c8dbc771a1dcd3c8f87ac39f29d4;p=e-mobility-charging-stations-simulator.git feat(ui): allow to authorize RFID tag at start transaction closes #1476 closes #1475 Signed-off-by: Jérôme Benoit --- diff --git a/README.md b/README.md index c03b3f5e..410da5d1 100644 --- a/README.md +++ b/README.md @@ -848,6 +848,22 @@ Set the Websocket header _Sec-Websocket-Protocol_ to `ui0.0.1`. Examples: +- **Authorize** +- Request: + `ProcedureName`: 'authorize' + `PDU`: { + `hashIds`: charging station unique identifier strings array (optional, default: all charging stations), + `idTag`: RFID tag string + } + +- Response: + `PDU`: { + `status`: 'success' | 'failure', + `hashIdsSucceeded`: charging station unique identifier strings array, + `hashIdsFailed`: charging station unique identifier strings array (optional), + `responsesFailed`: failed responses payload array (optional) + } + - **Start Transaction** - Request: `ProcedureName`: 'startTransaction' diff --git a/src/charging-station/broadcast-channel/UIServiceWorkerBroadcastChannel.ts b/src/charging-station/broadcast-channel/UIServiceWorkerBroadcastChannel.ts index 48bf1691..12bc6824 100644 --- a/src/charging-station/broadcast-channel/UIServiceWorkerBroadcastChannel.ts +++ b/src/charging-station/broadcast-channel/UIServiceWorkerBroadcastChannel.ts @@ -34,16 +34,18 @@ export class UIServiceWorkerBroadcastChannel extends WorkerBroadcastChannel { const responsesStatus = this.responses .get(uuid) - ?.responses.every(({ status }) => status === ResponseStatus.SUCCESS) === true + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + ?.responses.every(response => response?.status === ResponseStatus.SUCCESS) === true ? ResponseStatus.SUCCESS : ResponseStatus.FAILURE return { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain hashIdsSucceeded: this.responses .get(uuid) - ?.responses.map(({ hashId, status }) => { - if (hashId != null && status === ResponseStatus.SUCCESS) { - return hashId + ?.responses.map(response => { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (response?.hashId != null && response?.status === ResponseStatus.SUCCESS) { + return response.hashId } return undefined }) @@ -53,9 +55,10 @@ export class UIServiceWorkerBroadcastChannel extends WorkerBroadcastChannel { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain hashIdsFailed: this.responses .get(uuid) - ?.responses.map(({ hashId, status }) => { - if (hashId != null && status === ResponseStatus.FAILURE) { - return hashId + ?.responses.map(response => { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (response?.hashId != null && response?.status === ResponseStatus.FAILURE) { + return response.hashId } return undefined }) @@ -66,7 +69,8 @@ export class UIServiceWorkerBroadcastChannel extends WorkerBroadcastChannel { responsesFailed: this.responses .get(uuid) ?.responses.map(response => { - if (response.status === ResponseStatus.FAILURE) { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (response?.status === ResponseStatus.FAILURE) { return response } return undefined diff --git a/src/types/UIProtocol.ts b/src/types/UIProtocol.ts index 76e3ee7e..9418d8be 100644 --- a/src/types/UIProtocol.ts +++ b/src/types/UIProtocol.ts @@ -46,6 +46,7 @@ export enum Protocol { export enum ProtocolVersion { '0.0.1' = '0.0.1', } + export enum ResponseStatus { FAILURE = 'failure', SUCCESS = 'success', diff --git a/ui/web/src/components/actions/StartTransaction.vue b/ui/web/src/components/actions/StartTransaction.vue index d6829d46..a4510948 100644 --- a/ui/web/src/components/actions/StartTransaction.vue +++ b/ui/web/src/components/actions/StartTransaction.vue @@ -4,31 +4,70 @@

{{ chargingStationId }}

Connector {{ connectorId }}

-

Scan RFID tag:

- +

+ RFID tag: + +

+

+ Authorize RFID tag: + +