feat: add command to list templates on UI services
[e-mobility-charging-stations-simulator.git] / src / charging-station / ui-server / ui-services / AbstractUIService.ts
index 416d660d7d5f4c6ead5a5f003c528f13d69b0c9e..6eda2c9a32024a7d9ec435e36a6a03f4e1620c9c 100644 (file)
@@ -65,6 +65,7 @@ export abstract class AbstractUIService {
     this.uiServer = uiServer
     this.version = version
     this.requestHandlers = new Map<ProcedureName, ProtocolRequestHandler>([
+      [ProcedureName.LIST_TEMPLATES, this.handleListTemplates.bind(this)],
       [ProcedureName.LIST_CHARGING_STATIONS, this.handleListChargingStations.bind(this)],
       [ProcedureName.START_SIMULATOR, this.handleStartSimulator.bind(this)],
       [ProcedureName.STOP_SIMULATOR, this.handleStopSimulator.bind(this)]
@@ -202,6 +203,13 @@ export abstract class AbstractUIService {
     this.broadcastChannelRequests.set(uuid, expectedNumberOfResponses)
   }
 
+  private handleListTemplates (): ResponsePayload {
+    return {
+      status: ResponseStatus.SUCCESS,
+      templates: [...this.uiServer.chargingStationTemplates.values()] as JsonType[]
+    } satisfies ResponsePayload
+  }
+
   private handleListChargingStations (): ResponsePayload {
     return {
       status: ResponseStatus.SUCCESS,