From 6a619ccea8a197e5510ef643a79c16d02e7a8f29 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 28 Aug 2022 13:43:38 +0200 Subject: [PATCH] Web UI: configuration namespace cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- ...imulatorUIProtocol.postman_collection.json | 538 ++++++++---------- src/ui/web/src/assets/config.ts | 2 +- src/ui/web/src/composables/UIClient.ts | 11 +- src/ui/web/src/types/ConfigurationType.ts | 4 +- 4 files changed, 250 insertions(+), 305 deletions(-) diff --git a/src/assets/CSSimulatorUIProtocol.postman_collection.json b/src/assets/CSSimulatorUIProtocol.postman_collection.json index fa625198..22e711b2 100644 --- a/src/assets/CSSimulatorUIProtocol.postman_collection.json +++ b/src/assets/CSSimulatorUIProtocol.postman_collection.json @@ -1,299 +1,241 @@ { - "info": { - "_postman_id": "2d4009e7-04a8-4516-adaf-8b60780df9f4", - "name": "CSSimulatorUIProtocol", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", - "_exporter_id": "23011687" - }, - "item": [ - { - "name": "listChargingStations", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseUrl}}/{{protocol}}/{{version}}/listChargingStations", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "{{protocol}}", - "{{version}}", - "listChargingStations" - ] - } - }, - "response": [] - }, - { - "name": "startChargingStation", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"hashIds\": [\n \"0058d8b50e422cce5bbd0c0a4ad13d5d657e8a88670dcf04c1b2b563fea3db5b96a3686278b374ed050e21baef89060e\",\n \"331d024fea36e3e2483a0e5dc9376234241c8c099ad201a441437b23622c308555183f37cbc84a1818c1c45aaae50896\"\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseUrl}}/{{protocol}}/{{version}}/startChargingStation", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "{{protocol}}", - "{{version}}", - "startChargingStation" - ] - } - }, - "response": [] - }, - { - "name": "stopChargingStation", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"hashIds\": [\n \"0058d8b50e422cce5bbd0c0a4ad13d5d657e8a88670dcf04c1b2b563fea3db5b96a3686278b374ed050e21baef89060e\",\n \"331d024fea36e3e2483a0e5dc9376234241c8c099ad201a441437b23622c308555183f37cbc84a1818c1c45aaae50896\"\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseUrl}}/{{protocol}}/{{version}}/stopChargingStation", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "{{protocol}}", - "{{version}}", - "stopChargingStation" - ] - } - }, - "response": [] - }, - { - "name": "startSimulator", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseUrl}}/{{protocol}}/{{version}}/startSimulator", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "{{protocol}}", - "{{version}}", - "startSimulator" - ] - } - }, - "response": [] - }, - { - "name": "stopSimulator", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseUrl}}/{{protocol}}/{{version}}/stopSimulator", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "{{protocol}}", - "{{version}}", - "stopSimulator" - ] - } - }, - "response": [] - }, - { - "name": "openConnection", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"hashIds\": [\n \"0058d8b50e422cce5bbd0c0a4ad13d5d657e8a88670dcf04c1b2b563fea3db5b96a3686278b374ed050e21baef89060e\",\n \"331d024fea36e3e2483a0e5dc9376234241c8c099ad201a441437b23622c308555183f37cbc84a1818c1c45aaae50896\"\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseUrl}}/{{protocol}}/{{version}}/openConnection", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "{{protocol}}", - "{{version}}", - "openConnection" - ] - } - }, - "response": [] - }, - { - "name": "closeConnection", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"hashIds\": [\n \"0058d8b50e422cce5bbd0c0a4ad13d5d657e8a88670dcf04c1b2b563fea3db5b96a3686278b374ed050e21baef89060e\",\n \"331d024fea36e3e2483a0e5dc9376234241c8c099ad201a441437b23622c308555183f37cbc84a1818c1c45aaae50896\"\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseUrl}}/{{protocol}}/{{version}}/closeConnection", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "{{protocol}}", - "{{version}}", - "closeConnection" - ] - } - }, - "response": [] - }, - { - "name": "startTransaction", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"hashIds\": [\n \"0058d8b50e422cce5bbd0c0a4ad13d5d657e8a88670dcf04c1b2b563fea3db5b96a3686278b374ed050e21baef89060e\"\n ],\n \"connectorId\": 1,\n \"idTag\": \"test\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseUrl}}/{{protocol}}/{{version}}/startTransaction", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "{{protocol}}", - "{{version}}", - "startTransaction" - ] - } - }, - "response": [] - }, - { - "name": "stopTransaction", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"hashIds\": [\n \"0058d8b50e422cce5bbd0c0a4ad13d5d657e8a88670dcf04c1b2b563fea3db5b96a3686278b374ed050e21baef89060e\"\n ],\n \"transactionId\": 1236043451\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{baseUrl}}/{{protocol}}/{{version}}/stopTransaction", - "host": [ - "{{baseUrl}}" - ], - "path": [ - "{{protocol}}", - "{{version}}", - "stopTransaction" - ] - } - }, - "response": [] - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - }, - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - } - ], - "variable": [ - { - "key": "baseUrl", - "value": "http://localhost:8080", - "type": "string" - }, - { - "key": "protocol", - "value": "ui", - "type": "string" - }, - { - "key": "version", - "value": "0.0.1", - "type": "string" - } - ] -} \ No newline at end of file + "info": { + "_postman_id": "2d4009e7-04a8-4516-adaf-8b60780df9f4", + "name": "CSSimulatorUIProtocol", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "23011687" + }, + "item": [ + { + "name": "listChargingStations", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/{{protocol}}/{{version}}/listChargingStations", + "host": ["{{baseUrl}}"], + "path": ["{{protocol}}", "{{version}}", "listChargingStations"] + } + }, + "response": [] + }, + { + "name": "startChargingStation", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"hashIds\": [\n \"0058d8b50e422cce5bbd0c0a4ad13d5d657e8a88670dcf04c1b2b563fea3db5b96a3686278b374ed050e21baef89060e\",\n \"331d024fea36e3e2483a0e5dc9376234241c8c099ad201a441437b23622c308555183f37cbc84a1818c1c45aaae50896\"\n ]\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/{{protocol}}/{{version}}/startChargingStation", + "host": ["{{baseUrl}}"], + "path": ["{{protocol}}", "{{version}}", "startChargingStation"] + } + }, + "response": [] + }, + { + "name": "stopChargingStation", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"hashIds\": [\n \"0058d8b50e422cce5bbd0c0a4ad13d5d657e8a88670dcf04c1b2b563fea3db5b96a3686278b374ed050e21baef89060e\",\n \"331d024fea36e3e2483a0e5dc9376234241c8c099ad201a441437b23622c308555183f37cbc84a1818c1c45aaae50896\"\n ]\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/{{protocol}}/{{version}}/stopChargingStation", + "host": ["{{baseUrl}}"], + "path": ["{{protocol}}", "{{version}}", "stopChargingStation"] + } + }, + "response": [] + }, + { + "name": "startSimulator", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/{{protocol}}/{{version}}/startSimulator", + "host": ["{{baseUrl}}"], + "path": ["{{protocol}}", "{{version}}", "startSimulator"] + } + }, + "response": [] + }, + { + "name": "stopSimulator", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/{{protocol}}/{{version}}/stopSimulator", + "host": ["{{baseUrl}}"], + "path": ["{{protocol}}", "{{version}}", "stopSimulator"] + } + }, + "response": [] + }, + { + "name": "openConnection", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"hashIds\": [\n \"0058d8b50e422cce5bbd0c0a4ad13d5d657e8a88670dcf04c1b2b563fea3db5b96a3686278b374ed050e21baef89060e\",\n \"331d024fea36e3e2483a0e5dc9376234241c8c099ad201a441437b23622c308555183f37cbc84a1818c1c45aaae50896\"\n ]\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/{{protocol}}/{{version}}/openConnection", + "host": ["{{baseUrl}}"], + "path": ["{{protocol}}", "{{version}}", "openConnection"] + } + }, + "response": [] + }, + { + "name": "closeConnection", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"hashIds\": [\n \"0058d8b50e422cce5bbd0c0a4ad13d5d657e8a88670dcf04c1b2b563fea3db5b96a3686278b374ed050e21baef89060e\",\n \"331d024fea36e3e2483a0e5dc9376234241c8c099ad201a441437b23622c308555183f37cbc84a1818c1c45aaae50896\"\n ]\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/{{protocol}}/{{version}}/closeConnection", + "host": ["{{baseUrl}}"], + "path": ["{{protocol}}", "{{version}}", "closeConnection"] + } + }, + "response": [] + }, + { + "name": "startTransaction", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"hashIds\": [\n \"0058d8b50e422cce5bbd0c0a4ad13d5d657e8a88670dcf04c1b2b563fea3db5b96a3686278b374ed050e21baef89060e\"\n ],\n \"connectorId\": 1,\n \"idTag\": \"test\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/{{protocol}}/{{version}}/startTransaction", + "host": ["{{baseUrl}}"], + "path": ["{{protocol}}", "{{version}}", "startTransaction"] + } + }, + "response": [] + }, + { + "name": "stopTransaction", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"hashIds\": [\n \"0058d8b50e422cce5bbd0c0a4ad13d5d657e8a88670dcf04c1b2b563fea3db5b96a3686278b374ed050e21baef89060e\"\n ],\n \"transactionId\": 1236043451\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/{{protocol}}/{{version}}/stopTransaction", + "host": ["{{baseUrl}}"], + "path": ["{{protocol}}", "{{version}}", "stopTransaction"] + } + }, + "response": [] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "type": "text/javascript", + "exec": [""] + } + }, + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [""] + } + } + ], + "variable": [ + { + "key": "baseUrl", + "value": "http://localhost:8080", + "type": "string" + }, + { + "key": "protocol", + "value": "ui", + "type": "string" + }, + { + "key": "version", + "value": "0.0.1", + "type": "string" + } + ] +} diff --git a/src/ui/web/src/assets/config.ts b/src/ui/web/src/assets/config.ts index ae8a364a..44bfebde 100644 --- a/src/ui/web/src/assets/config.ts +++ b/src/ui/web/src/assets/config.ts @@ -1,7 +1,7 @@ import type { BaseConfig } from '@/types/ConfigurationType'; const config: BaseConfig = { - emobility: { + uiServer: { host: 'localhost', port: 8080, protocol: 'ui0.0.1', diff --git a/src/ui/web/src/composables/UIClient.ts b/src/ui/web/src/composables/UIClient.ts index c5e81a31..8f76c532 100644 --- a/src/ui/web/src/composables/UIClient.ts +++ b/src/ui/web/src/composables/UIClient.ts @@ -90,12 +90,15 @@ export default class UIClient { private openWS(): void { this._ws = new WebSocket( - `ws://${config.emobility.host}:${config.emobility.port}`, - config.emobility.protocol + `ws://${config.uiServer.host}:${config.uiServer.port}`, + config.uiServer.protocol ); this._ws.onmessage = this.responseHandler.bind(this); - this._ws.onerror = (error) => { - console.error('WebSocket error: ', error); + this._ws.onerror = (errorEvent) => { + console.error('WebSocket error: ', errorEvent); + }; + this._ws.onclose = (closeEvent) => { + console.info('WebSocket close: ', closeEvent); }; } diff --git a/src/ui/web/src/types/ConfigurationType.ts b/src/ui/web/src/types/ConfigurationType.ts index 69e2b9cd..e9eb729d 100644 --- a/src/ui/web/src/types/ConfigurationType.ts +++ b/src/ui/web/src/types/ConfigurationType.ts @@ -1,8 +1,8 @@ export interface BaseConfig { - emobility: EMobilityConfig; + uiServer: UIServerConfig; } -export interface EMobilityConfig { +interface UIServerConfig { host: string; port: number; protocol: string; -- 2.34.1