]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commit
fix(ui): allow changing status of individual connectors (#1834)
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Thu, 7 May 2026 21:56:02 +0000 (23:56 +0200)
committerGitHub <noreply@github.com>
Thu, 7 May 2026 21:56:02 +0000 (23:56 +0200)
commit2a98dc8b2bc98a2c3136e1737894f4c29891350a
treeb188882e03ef164042be560ac2f13f6a5ef993b6
parent608d7962dbdde0f3b3261badca05ab6dad36d84b
fix(ui): allow changing status of individual connectors (#1834)

* feat(ui/web): allow changing status of individual connectors

Add a 'Set Status' action to the connector UI in both modern and classic
skins. Users can simulate OCPP connector statuses (e.g. Faulted, Unavailable)
directly from the dashboard.

- UIClient.setConnectorStatus sends STATUS_NOTIFICATION via existing ProcedureName
- useConnectorActions exposes setConnectorStatus with pending.setStatus guard
- Modern skin: SetConnectorStatusDialog presents a status picker in a modal
- Classic skin: inline <select> triggers status change on change event
- Test helpers and composable tests updated accordingly

* fix: correct OCPP version handling for connector status changes

- Add OCPP20ConnectorStatusEnumType enum to ui-common
- Fix UIClient.setConnectorStatus to send version-aware payload:
  connectorStatus field for OCPP 2.0.x, status field for OCPP 1.6
- Update useConnectorActions to accept ocppVersion and pass it through;
  widen status parameter type to union of 1.6 and 2.0.x enums;
  accept optional onSuccess callback per action invocation
- Fix SetConnectorStatusDialog to close only after action resolves
  (pass close as onSuccess instead of calling it immediately)
- Show version-appropriate status options in SetConnectorStatusDialog
- Forward ocppVersion and onRefresh from ConnectorRow to dialog
- Propagate need-refresh event through ConnectorRow → StationCard → ModernLayout
- Add tests for new OCPP 2.0.x paths and dialog behaviour

* [autofix.ci] apply automated fixes

* feat(ui): complete connector status change with error simulation and local state update

- Fix classic skin to show version-appropriate status options (OCPP 1.6/2.0.x)
- Pass ocppVersion to useConnectorActions in classic skin
- Replace passthrough STATUS_NOTIFICATION handler with sendAndSetConnectorStatus
  to update in-memory connector state and emit connectorStatusChanged event
- Add OCPP 1.6 errorCode support (issue requests error simulation capability)
- Add OCPP16ChargePointErrorCode enum to ui-common
- Add error code selector in both skins (OCPP 1.6 only, hidden for 2.0.x)
- Remove unnecessary re-exports from useConnectorActions composable
- Update tests for new errorCode parameter and passthrough behavior change

Resolves the outstanding HIGH findings from automated review.

* fix(ui): polish connector status — reactivity consistency, JSDoc, tests, init from current status

- Wrap props in computed() in SetConnectorStatusDialog for consistency
- Fix JSDoc on mountDialog test helper to satisfy jsdoc/require-jsdoc
- Initialize selectedStatus from connector.status for OCPP 2.0.x too
- Add 5 unit tests for classic skin CSConnector status change behavior

* refactor(ui): remove redundant onRefresh from connector actions

The server already pushes a REFRESH notification via WebSocket when
connector state changes (connectorStatusChanged → buildUpdatedMessage →
workerEventUpdated → scheduleClientNotification → REFRESH broadcast).

The onRefresh callback in useConnectorActions duplicated this by manually
calling getChargingStations() after each action. Remove it along with
the need-refresh event bubbling chain in the modern skin.

The useAsyncAction onRefresh mechanism remains available for composables
where the server does NOT push updates (e.g., useStationActions).

* [autofix.ci] apply automated fixes

* refactor(ui-common): extract buildStatusNotificationPayload shared builder

Factor version-aware StatusNotification payload construction into
ui-common alongside existing buildAuthorize/Start/StopTransactionPayload
builders. Both CLI and Web UI now use the shared builder, eliminating
duplicated OCPP 1.6 vs 2.0.x branching logic.

* [autofix.ci] apply automated fixes

* fix(ui-common): keep buildStatusNotificationPayload strongly typed

Remove string fallback from status/errorCode parameters — the builder
accepts only the OCPP enum types. The CLI casts user input at the call
site, keeping the shared API type-safe.

* [autofix.ci] apply automated fixes

* fix(ui-common): remove invalid Occupied from OCPP16ChargePointStatus enum

Occupied is an OCPP 2.0.x-only connector status. It was erroneously
included in the OCPP 1.6 enum, causing the UI dropdown to offer an
invalid status option for OCPP 1.6 stations. Tests referencing it are
updated to use OCPP20ConnectorStatusEnumType.OCCUPIED or a valid 1.6
status as appropriate.

* fix(ui-common): make ChargePointStatus a union of OCPP 1.6 and 2.0.x enums

ChargePointStatus was aliased to OCPP16ChargePointStatus only, which
made ConnectorStatus.status unable to represent OCPP 2.0.x values like
Occupied. Now it is OCPP16ChargePointStatus | OCPP20ConnectorStatusEnumType,
matching the src/ canonical ConnectorStatusEnum pattern.

* refactor(ui-common): use ChargePointStatus type alias instead of inline union

Replace all occurrences of the verbose
'OCPP16ChargePointStatus | OCPP20ConnectorStatusEnumType' inline union
with the existing ChargePointStatus type alias across ui-common, web UI,
and CLI.

* [autofix.ci] apply automated fixes

* fix: add connectorId guard to handleStatusNotification for consistency

Other broadcast channel handlers (handleMeterValues, UNLOCK_CONNECTOR,
LOCK_CONNECTOR) throw BaseError when connectorId is missing. Without
this guard, a malformed request would silently succeed.

* fix(ui): address review feedback — clickable status pill, stale state sync, error-code apply

Modern skin:
- Replace 'Set Status' button with clickable status pill (edit icon on
  hover, tooltip with status, aria-haspopup=dialog). More compact UX per
  reviewer request (DerGenaue).
- Add .modern-pill--editable CSS with hover border, focus ring, and
  fade-in edit icon.

Classic skin:
- Add watch on props.connector.status to sync selectedStatus ref when
  server pushes new state (fixes stale dropdown after external changes).
- Add @change handler on error-code select so changing errorCode alone
  also triggers a StatusNotification (previously only status change did).

Addresses review feedback from hyperspace-insights, copilot, and
DerGenaue.

* fix: persist errorCode on ConnectorStatus, remove Partial<> cast, add tooltip

Backend:
- Add errorCode field to ConnectorStatus (src/ and ui-common)
- Persist errorCode in sendAndSetConnectorStatus alongside status
- Move errorCode defaulting from buildStatusNotificationRequest to
  OCPP16RequestService.buildRequestPayload via spread default pattern:
  { errorCode: NO_ERROR, ...commandParams }
- Remove Partial<> cast and ?? fallback from the builder — it now
  simply passes through commandParams.errorCode (always defined by
  the time it reaches the builder)

UI:
- Status pill tooltip shows errorCode when present and not NoError
  (e.g., 'Faulted (ConnectorLockFailure)'), per DerGenaue's request
- ConnectorStatus.errorCode propagates automatically through existing
  buildUpdatedMessage → spread serialization chain

* fix(ui): address DerGenaue feedback — always-visible icon, preserve pill height

- Edit icon always visible (no hover-only opacity transition)
- Smaller icon (8px) + reduced gap (3px) to preserve original pill height
- Simpler pencil SVG (single path, thicker stroke for clarity at small size)
- Removed opacity animation rules

* fix(ui): editable status pill design (#1838)

* fix: validate status field in handleStatusNotification

Prevents connectorStatus.status corruption when ocppStrictCompliance is
disabled and the payload arrives without a status value.

---------

Co-authored-by: OpenCode Agent <agent@opencode.ai>
Co-authored-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jérôme Benoit <jerome.benoit@sap.com>
Co-authored-by: Daniel <7558512+DerGenaue@users.noreply.github.com>
22 files changed:
src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts
src/charging-station/ocpp/1.6/OCPP16RequestService.ts
src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts
src/charging-station/ocpp/OCPPConnectorStatusOperations.ts
src/types/ConnectorStatus.ts
tests/charging-station/ocpp/1.6/OCPP16ServiceUtils.test.ts
ui/cli/src/commands/ocpp.ts
ui/cli/tests/format.test.ts
ui/common/src/types/ChargingStationType.ts
ui/common/src/utils/payloadBuilders.ts
ui/web/src/core/UIClient.ts
ui/web/src/shared/composables/useConnectorActions.ts
ui/web/src/skins/classic/components/charging-stations/CSConnector.vue
ui/web/src/skins/modern/components/ConnectorRow.vue
ui/web/src/skins/modern/components/dialogs/SetConnectorStatusDialog.vue [new file with mode: 0644]
ui/web/src/skins/modern/modern.css
ui/web/tests/unit/helpers.ts
ui/web/tests/unit/shared/composables/stationStatus.test.ts
ui/web/tests/unit/shared/composables/useConnectorActions.test.ts
ui/web/tests/unit/skins/classic/CSConnector.test.ts
ui/web/tests/unit/skins/modern/ConnectorRow.test.ts
ui/web/tests/unit/skins/modern/Dialogs.test.ts