Web UI: configuration namespace cleanup
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 28 Aug 2022 11:43:38 +0000 (13:43 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 28 Aug 2022 11:43:38 +0000 (13:43 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/assets/CSSimulatorUIProtocol.postman_collection.json
src/ui/web/src/assets/config.ts
src/ui/web/src/composables/UIClient.ts
src/ui/web/src/types/ConfigurationType.ts

index fa625198e8afa5eaf1c19083426b1b64602fe053..22e711b240949ec33b578e451e5cb32c85c08fec 100644 (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"
-               }
-       ]
-}
\ 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"
+    }
+  ]
+}
index ae8a364abeea689fbd795b6560557bc8f89ad601..44bfebdecfc17750d85b3cc6294645e5f18b347e 100644 (file)
@@ -1,7 +1,7 @@
 import type { BaseConfig } from '@/types/ConfigurationType';
 
 const config: BaseConfig = {
-  emobility: {
+  uiServer: {
     host: 'localhost',
     port: 8080,
     protocol: 'ui0.0.1',
index c5e81a31030775f89475900aad579fba27f6dd9f..8f76c53251f72b935f32b5bec0079ca13d2cbcb8 100644 (file)
@@ -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);
     };
   }
 
index 69e2b9cd5b16d485b1ea8f050af7a4b19b370762..e9eb729daf04098d07b65c30ea473f0f754032cb 100644 (file)
@@ -1,8 +1,8 @@
 export interface BaseConfig {
-  emobility: EMobilityConfig;
+  uiServer: UIServerConfig;
 }
 
-export interface EMobilityConfig {
+interface UIServerConfig {
   host: string;
   port: number;
   protocol: string;