feat(ui): add set supervision url action
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 18 Feb 2024 10:53:46 +0000 (11:53 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 18 Feb 2024 10:53:46 +0000 (11:53 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
ui/web/src/components/actions/SetSupervisionUrl.vue [new file with mode: 0644]
ui/web/src/components/charging-stations/CSData.vue
ui/web/src/composables/UIClient.ts
ui/web/src/router/index.ts
ui/web/src/types/UIProtocol.ts

diff --git a/ui/web/src/components/actions/SetSupervisionUrl.vue b/ui/web/src/components/actions/SetSupervisionUrl.vue
new file mode 100644 (file)
index 0000000..00f4ef3
--- /dev/null
@@ -0,0 +1,52 @@
+<template>
+  <h2>Action Set Supervision Url</h2>
+  <h3>Charging Station {{ chargingStationId }}</h3>
+  <p>Supervision Url:</p>
+  <input
+    id="supervision-url"
+    v-model="state.supervisionUrl"
+    type="text"
+    name="supervision-url"
+    placeholder="supervision url"
+  />
+  <br />
+  <Button
+    @click="
+      () => {
+        uiClient
+          .setSupervisionUrl(props.hashId, state.supervisionUrl)
+          .catch((error: Error) => {
+            // TODO: add code for UI notifications or other error handling logic
+            console.error('Error at setting supervision url:', error)
+          })
+          .finally(() => {
+            $router.push({ name: 'charging-stations' })
+          })
+      }
+    "
+    >Set Supervision Url</Button
+  >
+  <Button @click="$router.push({ name: 'charging-stations' })">Cancel</Button>
+</template>
+
+<script setup lang="ts">
+import { getCurrentInstance, reactive } from 'vue'
+import Button from '@/components/buttons/Button.vue'
+
+const props = defineProps<{
+  hashId: string
+  chargingStationId: string
+}>()
+
+const state = reactive({
+  supervisionUrl: ''
+})
+
+const uiClient = getCurrentInstance()?.appContext.config.globalProperties.$uiClient
+</script>
+
+<style>
+#supervision-url {
+  text-align: center;
+}
+</style>
index 107df4947b540c9ec8b2bdc43818f4484fedc118..4502f53cb300f48178119e3462382d2c4e7f7628 100644 (file)
     <td class="cs-table__column">
       <Button @click="startChargingStation()">Start Charging Station</Button>
       <Button @click="stopChargingStation()">Stop Charging Station</Button>
+      <Button
+        @click="
+          $router.push({
+            name: 'set-supervision-url',
+            params: {
+              hashId: props.chargingStation.stationInfo.hashId,
+              chargingStationId: props.chargingStation.stationInfo.chargingStationId
+            }
+          })
+        "
+        >Set Supervision Url</Button
+      >
       <Button @click="openConnection()">Open Connection</Button>
       <Button @click="closeConnection()">Close Connection</Button>
       <Button @click="deleteChargingStation()">Delete Charging Station</Button>
index c5f20ce09b2fb83d376a8cd2eddb736350a3abe5..ce459f1b253504abbb478fa54b5aef5544646a22 100644 (file)
@@ -67,6 +67,13 @@ export class UIClient {
     return this.sendRequest(ProcedureName.DELETE_CHARGING_STATIONS, { hashIds: [hashId] })
   }
 
+  public async setSupervisionUrl(hashId: string, supervisionUrl: string): Promise<ResponsePayload> {
+    return this.sendRequest(ProcedureName.SET_SUPERVISION_URL, {
+      hashIds: [hashId],
+      url: supervisionUrl
+    })
+  }
+
   public async startChargingStation(hashId: string): Promise<ResponsePayload> {
     return this.sendRequest(ProcedureName.START_CHARGING_STATION, { hashIds: [hashId] })
   }
index 0d250c5101a48e6402934fad6a038f7c64dac78e..bdb22503198337c01c2786bea3dc72c3156be686 100644 (file)
@@ -2,6 +2,7 @@ import { createRouter, createWebHistory } from 'vue-router'
 import ChargingStationsView from '@/views/ChargingStationsView.vue'
 import StartTransaction from '@/components/actions/StartTransaction.vue'
 import AddChargingStations from '@/components/actions/AddChargingStations.vue'
+import SetSupervisionUrl from '@/components/actions/SetSupervisionUrl.vue'
 
 export const router = createRouter({
   history: createWebHistory(),
@@ -21,6 +22,15 @@ export const router = createRouter({
         action: AddChargingStations
       }
     },
+    {
+      path: '/set-supervision-url/:hashId/:chargingStationId',
+      name: 'set-supervision-url',
+      components: {
+        default: ChargingStationsView,
+        action: SetSupervisionUrl
+      },
+      props: { default: false, action: true }
+    },
     {
       path: '/start-transaction/:hashId/:chargingStationId/:connectorId',
       name: 'start-transaction',
index 9e7a71a8d4cb43ac93c758e863afed30eba3abaf..afc55b03069540e6f7a48b7e86dec88f4cea1291 100644 (file)
@@ -31,6 +31,7 @@ export enum ProcedureName {
   LIST_CHARGING_STATIONS = 'listChargingStations',
   ADD_CHARGING_STATIONS = 'addChargingStations',
   DELETE_CHARGING_STATIONS = 'deleteChargingStations',
+  SET_SUPERVISION_URL = 'setSupervisionUrl',
   START_CHARGING_STATION = 'startChargingStation',
   STOP_CHARGING_STATION = 'stopChargingStation',
   OPEN_CONNECTION = 'openConnection',