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).
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.
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.
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