feat(ui): add charging station options to add action
authorJérôme Benoit <jerome.benoit@sap.com>
Thu, 22 Feb 2024 16:18:02 +0000 (17:18 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Thu, 22 Feb 2024 16:18:02 +0000 (17:18 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
ui/web/src/components/actions/AddChargingStations.vue
ui/web/src/components/actions/StartTransaction.vue
ui/web/src/composables/UIClient.ts
ui/web/src/composables/index.ts
ui/web/src/types/ChargingStationType.ts
ui/web/src/types/index.ts

index 8412fdd0a7374251cd0b89d842fc23691bcd8c25..0ddf612e56a7f441690128d310ed1cadef75fec7 100644 (file)
     name="number-of-stations"
     placeholder="number of stations"
   />
+  <p>Options:</p>
+  <ul>
+    <li>
+      Auto start:
+      <input v-model="state.autoStart" type="checkbox" true-value="true" false-value="false" />
+    </li>
+  </ul>
   <br />
   <Button
     id="action-button"
     @click="
       () => {
         uiClient
-          .addChargingStations(state.template, state.numberOfStations)
+          .addChargingStations(state.template, state.numberOfStations, {
+            autoStart: convertToBoolean(state.autoStart)
+          })
           .then(() => {
             $toast.success('Charging stations successfully added')
           })
@@ -47,11 +56,13 @@ import { getCurrentInstance, onMounted, reactive } from 'vue'
 import { useToast } from 'vue-toast-notification'
 import Button from '@/components/buttons/Button.vue'
 import type { ResponsePayload } from '@/types'
+import { convertToBoolean } from '@/composables'
 
 const state = reactive({
   ready: false,
   template: '',
-  numberOfStations: 1
+  numberOfStations: 1,
+  autoStart: false
 })
 
 const app = getCurrentInstance()
index 5e83983f34512ab1057d65f98a069bafc3c1200d..fed7d3beabef1f9bac06940bd9fd996d72e40c53 100644 (file)
@@ -10,7 +10,7 @@
     @click="
       () => {
         uiClient
-          .startTransaction(props.hashId, parseInt(props.connectorId), state.idTag)
+          .startTransaction(props.hashId, convertToInt(props.connectorId), state.idTag)
           .then(() => {
             $toast.success('Transaction successfully started')
           })
@@ -32,6 +32,7 @@
 <script setup lang="ts">
 import { getCurrentInstance, reactive } from 'vue'
 import Button from '@/components/buttons/Button.vue'
+import { convertToInt } from '@/composables'
 
 const props = defineProps<{
   hashId: string
index c6e80946c7bbfec42d0157a73afe18b4fe8a51b8..d569b93b09719e91cd8536a4ac5f315ddc5e4417 100644 (file)
@@ -1,6 +1,7 @@
 import {
   ApplicationProtocol,
   AuthenticationType,
+  type ChargingStationOptions,
   ProcedureName,
   type ProtocolResponse,
   type RequestPayload,
@@ -64,9 +65,14 @@ export class UIClient {
 
   public async addChargingStations(
     template: string,
-    numberOfStations: number
+    numberOfStations: number,
+    options?: ChargingStationOptions
   ): Promise<ResponsePayload> {
-    return this.sendRequest(ProcedureName.ADD_CHARGING_STATIONS, { template, numberOfStations })
+    return this.sendRequest(ProcedureName.ADD_CHARGING_STATIONS, {
+      template,
+      numberOfStations,
+      options
+    })
   }
 
   public async deleteChargingStation(hashId: string): Promise<ResponsePayload> {
index a4b40639498a77ddd2d207350bd4f069c849b24a..31e231e87056fade9f399e9d8805428ba87febeb 100644 (file)
@@ -1 +1,2 @@
 export { UIClient } from './UIClient'
+export { convertToBoolean, convertToInt } from './Utils'
index 9baff1ae043b594cb028e2105246a7c08baef94c..6814737e811106b70d9212e61cff24a9b007500a 100644 (file)
@@ -64,6 +64,16 @@ export const FirmwareStatus = {
 } as const
 export type FirmwareStatus = OCPP16FirmwareStatus
 
+export interface ChargingStationOptions extends JsonObject {
+  supervisionUrls?: string | string[]
+  persistentConfiguration?: boolean
+  autoStart?: boolean
+  autoRegister?: boolean
+  enableStatistics?: boolean
+  ocppStrictCompliance?: boolean
+  stopTransactionsOnStopped?: boolean
+}
+
 export type ChargingStationInfo = {
   hashId: string
   templateIndex: number
index 596cc933303c66dfb4f05677551fd1483f2f68b0..a201ca7b88e0ee92e48635abf8ef63285a0fe136 100644 (file)
@@ -1,6 +1,7 @@
 export type {
   ChargingStationData,
   ChargingStationInfo,
+  ChargingStationOptions,
   ConnectorStatus,
   Status
 } from './ChargingStationType'