From: Jérôme Benoit Date: Tue, 13 Feb 2024 18:49:55 +0000 (+0100) Subject: refactor(ui): cleanup configuration types and variables namespace X-Git-Tag: v1.2.37~66 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=b7169a17b4108623c950d5ef4a46bcc04b5c2c12;p=e-mobility-charging-stations-simulator.git refactor(ui): cleanup configuration types and variables namespace Signed-off-by: Jérôme Benoit --- diff --git a/ui/web/src/assets/config.ts b/ui/web/src/assets/config.ts index cf6f3eb2..28b3f158 100644 --- a/ui/web/src/assets/config.ts +++ b/ui/web/src/assets/config.ts @@ -1,6 +1,6 @@ -import type { BaseConfig } from '@/types' +import type { ConfigurationData } from '@/types' -const config: BaseConfig = { +const configuration: ConfigurationData = { uiServer: { host: 'localhost', port: 8080, @@ -8,4 +8,4 @@ const config: BaseConfig = { } } -export default config +export default configuration diff --git a/ui/web/src/composables/UIClient.ts b/ui/web/src/composables/UIClient.ts index fa1479ef..d056f631 100644 --- a/ui/web/src/composables/UIClient.ts +++ b/ui/web/src/composables/UIClient.ts @@ -5,7 +5,7 @@ import { type ResponsePayload, ResponseStatus } from '@/types' -import config from '@/assets/config' +import configuration from '@/assets/config' type ResponseHandler = { procedureName: ProcedureName @@ -111,8 +111,8 @@ export class UIClient { private openWS(): void { this.ws = new WebSocket( - `ws://${config.uiServer.host}:${config.uiServer.port}`, - config.uiServer.protocol + `ws://${configuration.uiServer.host}:${configuration.uiServer.port}`, + configuration.uiServer.protocol ) this.ws.onmessage = this.responseHandler.bind(this) this.ws.onerror = errorEvent => { diff --git a/ui/web/src/types/ConfigurationType.ts b/ui/web/src/types/ConfigurationType.ts index 3753d584..cfdbf34a 100644 --- a/ui/web/src/types/ConfigurationType.ts +++ b/ui/web/src/types/ConfigurationType.ts @@ -1,8 +1,8 @@ -export type BaseConfig = { - uiServer: UIServerConfig +export type ConfigurationData = { + uiServer: UIServerConfigurationSection } -type UIServerConfig = { +type UIServerConfigurationSection = { host: string port: number protocol: string diff --git a/ui/web/src/types/index.ts b/ui/web/src/types/index.ts index ec7821f3..1f1f0556 100644 --- a/ui/web/src/types/index.ts +++ b/ui/web/src/types/index.ts @@ -3,7 +3,7 @@ export type { ChargingStationInfo, ConnectorStatus } from './ChargingStationType' -export type { BaseConfig } from './ConfigurationType' +export type { ConfigurationData } from './ConfigurationType' export { ProcedureName, type ProtocolResponse,