From 9739ffe201bf3d5b0060ff038af83f515b7d6921 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 16 Apr 2026 03:30:18 +0200 Subject: [PATCH] =?utf8?q?refactor:=20consolidate=20all=20types=20into=20u?= =?utf8?q?i-common=20=E2=80=94=20single=20import=20source?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- ui/common/src/client/browser-adapter.ts | 3 ++- ui/common/src/config/schema.ts | 1 - ui/common/src/index.ts | 2 ++ .../src/types/ChargingStationType.ts | 6 ++--- .../src/types/ConfigurationType.ts | 5 ++--- ui/common/src/types/UIProtocol.ts | 22 +++++++++++++++++++ ui/web/docker/Dockerfile | 1 + .../components/actions/StartTransaction.vue | 2 +- .../charging-stations/CSConnector.vue | 4 ++-- .../components/charging-stations/CSData.vue | 4 ++-- .../components/charging-stations/CSTable.vue | 2 +- ui/web/src/composables/UIClient.ts | 16 +++++--------- ui/web/src/composables/Utils.ts | 5 +---- ui/web/src/main.ts | 9 +++++--- ui/web/src/types/UIProtocol.ts | 21 ------------------ ui/web/src/views/ChargingStationsView.vue | 6 +---- ui/web/tests/unit/CSConnector.test.ts | 2 +- ui/web/tests/unit/CSData.test.ts | 5 +++-- ui/web/tests/unit/CSTable.test.ts | 4 ++-- ui/web/tests/unit/StartTransaction.test.ts | 2 +- ui/web/tests/unit/UIClient.test.ts | 10 +++++++-- ui/web/tests/unit/constants.ts | 10 ++++----- 22 files changed, 70 insertions(+), 72 deletions(-) rename ui/{web => common}/src/types/ChargingStationType.ts (98%) rename ui/{web => common}/src/types/ConfigurationType.ts (77%) delete mode 100644 ui/web/src/types/UIProtocol.ts diff --git a/ui/common/src/client/browser-adapter.ts b/ui/common/src/client/browser-adapter.ts index 397a4b75..04258c54 100644 --- a/ui/common/src/client/browser-adapter.ts +++ b/ui/common/src/client/browser-adapter.ts @@ -1,6 +1,7 @@ -import type { WebSocketLike } from './types.js' import type { WebSocketReadyState } from './types.js' +import { type WebSocketLike } from './types.js' + interface BrowserWebSocket { close(code?: number, reason?: string): void set onclose(handler: ((event: { code: number; reason: string }) => void) | null) diff --git a/ui/common/src/config/schema.ts b/ui/common/src/config/schema.ts index 5f1ceb19..34e9f852 100644 --- a/ui/common/src/config/schema.ts +++ b/ui/common/src/config/schema.ts @@ -40,4 +40,3 @@ export const configurationSchema = z.object({ export type Configuration = z.infer export type UIServerConfig = z.infer -export type { UIServerConfig as UIServerConfigurationSection } diff --git a/ui/common/src/index.ts b/ui/common/src/index.ts index 2424f85b..17671897 100644 --- a/ui/common/src/index.ts +++ b/ui/common/src/index.ts @@ -3,6 +3,8 @@ export * from './client/types.js' export * from './client/WebSocketClient.js' export * from './config/schema.js' export * from './constants.js' +export * from './types/ChargingStationType.js' +export * from './types/ConfigurationType.js' export * from './types/JsonType.js' export * from './types/UIProtocol.js' export * from './types/UUID.js' diff --git a/ui/web/src/types/ChargingStationType.ts b/ui/common/src/types/ChargingStationType.ts similarity index 98% rename from ui/web/src/types/ChargingStationType.ts rename to ui/common/src/types/ChargingStationType.ts index bfce74dd..d1789200 100644 --- a/ui/web/src/types/ChargingStationType.ts +++ b/ui/common/src/types/ChargingStationType.ts @@ -1,4 +1,4 @@ -import type { JsonObject } from 'ui-common' +import type { JsonObject } from './JsonType.js' export enum AmpereUnits { AMPERE = 'A', @@ -161,9 +161,7 @@ export interface ChargingStationData extends JsonObject { supervisionUrl: string wsState?: | typeof WebSocket.CLOSED - | typeof WebSocket.CLOSING - | typeof WebSocket.CONNECTING - | typeof WebSocket.OPEN + } export interface ChargingStationInfo extends JsonObject { diff --git a/ui/web/src/types/ConfigurationType.ts b/ui/common/src/types/ConfigurationType.ts similarity index 77% rename from ui/web/src/types/ConfigurationType.ts rename to ui/common/src/types/ConfigurationType.ts index 6fe0af4a..2a3641b6 100644 --- a/ui/web/src/types/ConfigurationType.ts +++ b/ui/common/src/types/ConfigurationType.ts @@ -1,6 +1,5 @@ -import type { AuthenticationType, ProtocolVersion } from 'ui-common' - -import type { Protocol } from './UIProtocol' +import type { AuthenticationType, ProtocolVersion } from './UIProtocol.js' +import type { Protocol } from './UIProtocol.js' export interface ConfigurationData { theme?: string diff --git a/ui/common/src/types/UIProtocol.ts b/ui/common/src/types/UIProtocol.ts index 6fb1e547..3e28bd30 100644 --- a/ui/common/src/types/UIProtocol.ts +++ b/ui/common/src/types/UIProtocol.ts @@ -1,6 +1,11 @@ import type { JsonObject } from './JsonType.js' import type { UUIDv4 } from './UUID.js' +export enum ApplicationProtocol { + WS = 'ws', + WSS = 'wss', +} + export enum AuthenticationType { PROTOCOL_BASIC_AUTH = 'protocol-basic-auth', } @@ -43,6 +48,10 @@ export enum ProcedureName { UNLOCK_CONNECTOR = 'unlockConnector', } +export enum Protocol { + UI = 'ui', +} + export enum ProtocolVersion { '0.0.1' = '0.0.1', } @@ -86,3 +95,16 @@ export interface ResponsePayload extends JsonObject { responsesFailed?: BroadcastChannelResponsePayload[] status: ResponseStatus } + +export interface SimulatorState { + started: boolean + templateStatistics: Record + version: string +} + +export interface TemplateStatistics { + added: number + configured: number + indexes: number[] + started: number +} diff --git a/ui/web/docker/Dockerfile b/ui/web/docker/Dockerfile index dc15dc34..bb618847 100644 --- a/ui/web/docker/Dockerfile +++ b/ui/web/docker/Dockerfile @@ -26,4 +26,5 @@ RUN set -ex \ && chmod +x /run.sh \ && chmod +x /autoconfig.sh +EXPOSE 3030 ENTRYPOINT ["/bin/sh", "-c", "/autoconfig.sh && /run.sh"] diff --git a/ui/web/src/components/actions/StartTransaction.vue b/ui/web/src/components/actions/StartTransaction.vue index 73a47d30..cd0cac67 100644 --- a/ui/web/src/components/actions/StartTransaction.vue +++ b/ui/web/src/components/actions/StartTransaction.vue @@ -37,13 +37,13 @@