refactor(simulator): factor out common helpers
[e-mobility-charging-stations-simulator.git] / src / charging-station / ui-server / ui-services / AbstractUIService.ts
index d3d1231d49c578d5b7a32626202fe50208a547c3..71b057abe4a2f7369c1376d97ffcc55046eb0e89 100644 (file)
@@ -10,9 +10,10 @@ import {
   type ResponsePayload,
   ResponseStatus,
 } from '../../../types';
-import { logger } from '../../../utils/Logger';
-import { Utils } from '../../../utils/Utils';
-import { type AbstractUIServer, Bootstrap, UIServiceWorkerBroadcastChannel } from '../../internal';
+import { Utils, logger } from '../../../utils';
+import { Bootstrap } from '../../Bootstrap';
+import { UIServiceWorkerBroadcastChannel } from '../../broadcast-channel/UIServiceWorkerBroadcastChannel';
+import type { AbstractUIServer } from '../AbstractUIServer';
 
 const moduleName = 'AbstractUIService';
 
@@ -31,6 +32,7 @@ export abstract class AbstractUIService {
       BroadcastChannelProcedureName.START_AUTOMATIC_TRANSACTION_GENERATOR,
     [ProcedureName.STOP_AUTOMATIC_TRANSACTION_GENERATOR]:
       BroadcastChannelProcedureName.STOP_AUTOMATIC_TRANSACTION_GENERATOR,
+    [ProcedureName.SET_SUPERVISION_URL]: BroadcastChannelProcedureName.SET_SUPERVISION_URL,
     [ProcedureName.START_TRANSACTION]: BroadcastChannelProcedureName.START_TRANSACTION,
     [ProcedureName.STOP_TRANSACTION]: BroadcastChannelProcedureName.STOP_TRANSACTION,
     [ProcedureName.AUTHORIZE]: BroadcastChannelProcedureName.AUTHORIZE,
@@ -98,7 +100,7 @@ export abstract class AbstractUIService {
       };
     } finally {
       // Send response for payload not forwarded to broadcast channel
-      if (responsePayload !== undefined) {
+      if (!Utils.isNullOrUndefined(responsePayload)) {
         this.sendResponse(messageId, responsePayload);
       }
     }
@@ -151,7 +153,7 @@ export abstract class AbstractUIService {
   ): void {
     if (Utils.isNotEmptyArray(payload.hashIds)) {
       payload.hashIds = payload.hashIds
-        .filter((hashId) => hashId !== undefined)
+        .filter((hashId) => !Utils.isNullOrUndefined(hashId))
         .map((hashId) => {
           if (this.uiServer.chargingStations.has(hashId) === true) {
             return hashId;