Web UI: add and fix support for start/stop charging station
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 26 Aug 2022 09:56:04 +0000 (11:56 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 26 Aug 2022 09:56:04 +0000 (11:56 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts
src/ui/web/src/components/Modal.vue
src/ui/web/src/components/charging-stations/CSConnector.vue
src/ui/web/src/components/charging-stations/CSData.vue
src/ui/web/src/components/charging-stations/CSInfoModal.vue
src/ui/web/src/components/charging-stations/CSTable.vue
src/ui/web/src/components/charging-stations/IdTagInputModal.vue
src/ui/web/src/composable/UIClient.ts

index 5631a9845d8c2df6c131aedcf240b76f02f9b180..f74cf4bd89906bc6218d648d967e3e12913ef8b8 100644 (file)
@@ -550,8 +550,8 @@ export default class ChargingStation {
     this.templateFileWatcher.close();
     this.sharedLRUCache.deleteChargingStationTemplate(this.stationInfo?.templateHash);
     this.bootNotificationResponse = null;
-    parentPort.postMessage(MessageChannelUtils.buildStoppedMessage(this));
     this.stopped = true;
+    parentPort.postMessage(MessageChannelUtils.buildStoppedMessage(this));
   }
 
   public async reset(reason?: StopTransactionReason): Promise<void> {
index 20d7f0d54257981665d290a0915fa9b758e201a7..954c936102cf56d2e98b11936777ffaaea3ff642 100644 (file)
@@ -1,6 +1,6 @@
 <template>
   <teleport to="body">
-    <div id="backdrop" v-if="visibility" @click.self="close()">
+    <div id="backdrop" v-if="props.visibility" @click.self="close()">
       <slot></slot>
     </div>
   </teleport>
index e2dee5c8f7332d0e6b3d948078fd53bc5c4790ae..c0dd4c4465a70837d4895b87e9a55fb28bc8d8c8 100644 (file)
@@ -1,5 +1,9 @@
 <template>
   <td class="cs-table__action-col">
+    <Button @click="startChargingStation()">Start Charging Station</Button>
+    <Button @click="stopChargingStation()">Stop Charging Station</Button>
+    <Button @click="openConnection()">Open Connection</Button>
+    <Button @click="closeConnection()">Close Connection</Button>
     <Button @click="startTransaction()">Start Transaction</Button>
     <!-- <IdTagInputModal
       :visibility="state.isIdTagModalVisible"
       Start Transaction
     </IdTagInputModal> -->
     <Button @click="stopTransaction()">Stop Transaction</Button>
-    <Button @click="openConnection()">Open Connection</Button>
-    <Button @click="closeConnection()">Close Connection</Button>
   </td>
   <td class="cs-table__connector-col">{{ connectorId }}</td>
   <td class="cs-table__status-col">{{ connector.status }}</td>
-  <td class="cs-table__transaction-col">{{ connector.transactionStarted }}</td>
+  <td class="cs-table__transaction-col">{{ connector.transactionStarted ? 'Yes' : 'No' }}</td>
 </template>
 
 <script setup lang="ts">
@@ -59,11 +61,11 @@ const props = defineProps<{
 //   state.isIdTagModalVisible = false;
 // }
 
-function startTransaction(): void {
-  UIClient.instance.startTransaction(props.hashId, props.connectorId, props.idTag);
+function startChargingStation(): void {
+  UIClient.instance.startChargingStation(props.hashId);
 }
-function stopTransaction(): void {
-  UIClient.instance.stopTransaction(props.hashId, props.transactionId);
+function stopChargingStation(): void {
+  UIClient.instance.stopChargingStation(props.hashId);
 }
 function openConnection(): void {
   UIClient.instance.openConnection(props.hashId);
@@ -71,4 +73,10 @@ function openConnection(): void {
 function closeConnection(): void {
   UIClient.instance.closeConnection(props.hashId);
 }
+function startTransaction(): void {
+  UIClient.instance.startTransaction(props.hashId, props.connectorId, props.idTag);
+}
+function stopTransaction(): void {
+  UIClient.instance.stopTransaction(props.hashId, props.transactionId);
+}
 </script>
index 857ef1e232d283ec53e3fd933e66a0d294ad1701..fac035d04cfa69008c583ea3e7c31777726eb6ae 100644 (file)
@@ -8,6 +8,7 @@
       :id-tag="props.idTag"
     />
     <td class="cs-table__name-col">{{ getId() }}</td>
+    <td class="cs-table__stopped-col">{{ getStopped() }}</td>
     <td class="cs-table__vendor-col">{{ getVendor() }}</td>
     <td class="cs-table__model-col">{{ getModel() }}</td>
     <td class="cs-table__firmware-col">{{ getFirmwareVersion() }}</td>
@@ -61,6 +62,9 @@ function getVendor(): string {
 function getFirmwareVersion(): string {
   return Utils.ifUndefined<string>(getInfo().firmwareVersion, 'Ø');
 }
+function getStopped(): string {
+  return props.chargingStation.stopped ? 'Yes' : 'No';
+}
 // function showTagModal(): void {
 //   state.isTagModalVisible = true;
 // }
index d7740d0f33c4ca57384f80a1c1180a822e266849..dd7835fd847a7202bc5fe42c05bc7a17188cd488 100644 (file)
@@ -1,5 +1,5 @@
 <template>
-  <Modal :visibility="isVisible">
+  <Modal :visibility="props.isVisible">
     <div class="card-info">vendor: {{ props.info.chargePointVendor }}</div>
   </Modal>
 </template>
index 34517c416b5cca44e06cfc17b8d3ed49ee545f53..dc4865a127ecba4bc9f424329fd9a7acb9900da3 100644 (file)
@@ -7,6 +7,7 @@
         <th scope="col" class="cs-table__status-col">Status</th>
         <th scope="col" class="cs-table__transaction-col">Transaction</th>
         <th scope="col" class="cs-table__name-col">Name</th>
+        <th scope="col" class="cs-table__stopped-col">Stopped</th>
         <th scope="col" class="cs-table__vendor-col">Vendor</th>
         <th scope="col" class="cs-table__model-col">Model</th>
         <th scope="col" class="cs-table__firmware-col">Firmware Version</th>
@@ -64,7 +65,6 @@ const props = defineProps<{
 #cs-table__body {
   /* width: 100%; */
   /* direction: rtl; */
-  /* overflow: visible scroll; */
   overflow: visible overlay;
   flex-grow: 1;
 }
@@ -73,8 +73,9 @@ const props = defineProps<{
   width: 100%;
   /* display: inline-block; */
   display: flex;
+  justify-content: center;
+  align-items: center;
   /* align-content: stretch; */
-  /* align-items: baseline; */
 }
 #cs-table__head .cs-table__row {
   background-color: rgb(194, 188, 188);
@@ -88,6 +89,7 @@ const props = defineProps<{
 .cs-table__status-col,
 .cs-table__transaction-col,
 .cs-table__name-col,
+.cs-table__stopped-col,
 .cs-table__model-col,
 .cs-table__vendor-col,
 .cs-table__firmware-col {
@@ -115,6 +117,9 @@ const props = defineProps<{
 .cs-table__name-col {
   /* min-width: 120px; */
 }
+.cs-table__stopped-col {
+  /* min-width: 120px; */
+}
 .cs-table__model-col {
   /* min-width: 120px; */
 }
index 8645f6b6d3acaa58faa0dd85c6562e14d39b321a..ec3db54ac42d6b3feabf3af5aa496bf160e216df 100644 (file)
@@ -1,5 +1,5 @@
 <template>
-  <Modal :visibility="visibility">
+  <Modal :visibility="props.visibility">
     <label for="idTag">IdTag</label>
     <!-- eslint-disable-next-line vue/no-mutating-props -->
     <input type="text" name="idTag" v-model="props.idTag" @keypress.enter="done()" />
index 7e1fdc01d10229240763de118bbccad47964f8d9..d0a93beeb3a640ce2f4a7d70cb3c8e938638034d 100644 (file)
@@ -49,6 +49,26 @@ export default class UIClient {
     return this.sendRequest(ProcedureName.LIST_CHARGING_STATIONS, {});
   }
 
+  public async startChargingStation(hashId: string): Promise<ResponsePayload> {
+    return this.sendRequest(ProcedureName.START_CHARGING_STATION, { hashId });
+  }
+
+  public async stopChargingStation(hashId: string): Promise<ResponsePayload> {
+    return this.sendRequest(ProcedureName.STOP_CHARGING_STATION, { hashId });
+  }
+
+  public async openConnection(hashId: string): Promise<ResponsePayload> {
+    return this.sendRequest(ProcedureName.OPEN_CONNECTION, {
+      hashId,
+    });
+  }
+
+  public async closeConnection(hashId: string): Promise<ResponsePayload> {
+    return this.sendRequest(ProcedureName.CLOSE_CONNECTION, {
+      hashId,
+    });
+  }
+
   public async startTransaction(
     hashId: string,
     connectorId: number,
@@ -71,18 +91,6 @@ export default class UIClient {
     });
   }
 
-  public async openConnection(hashId: string): Promise<ResponsePayload> {
-    return this.sendRequest(ProcedureName.OPEN_CONNECTION, {
-      hashId,
-    });
-  }
-
-  public async closeConnection(hashId: string): Promise<ResponsePayload> {
-    return this.sendRequest(ProcedureName.CLOSE_CONNECTION, {
-      hashId,
-    });
-  }
-
   private openWS(): void {
     this._ws = new WebSocket(
       `ws://${config.emobility.host}:${config.emobility.port}`,