changes to feature to switch to boolean identifier
MODIFY
src/authorization/Authorizations.ts
src/authorization/Authorizations.ts
@@ -778,7 +778,9 @@ export default class Authorizations {
});
}
// Check User
- const user = await UserStorage.getUser(tenantID, tag.user.id, { withTag: true });
+ const user = await UserStorage.getUser(tenantID, tag.user.id);
+ // Repush the tag in user
+ user.tags = [tag];
// User status
if (user.status !== UserStatus.ACTIVE) {
// Reject but save ok

MODIFY
src/server/ocpp/utils/OCPPUtils.ts
src/server/ocpp/utils/OCPPUtils.ts
-import moment from 'moment';
import { ActionsResponse, KeyValue } from '../../../types/GlobalType';
import { ChargingProfile, ChargingProfilePurposeType } from '../../../types/ChargingProfile';
import ChargingStation, { ChargingStationCapabilities, ChargingStationOcppParameters, ChargingStationTemplate, ConnectorCurrentLimitSource, CurrentType, OcppParameter, StaticLimitAmps, TemplateUpdateResult } from '../../../types/ChargingStation';
import { OCPPAuthorizeRequestExtended, OCPPMeasurand, OCPPNormalizedMeterValue, OCPPPhase, OCPPReadingContext, OCPPStopTransactionRequestExtended, OCPPUnitOfMeasure } from '../../../types/ocpp/OCPPServer';
-import { OCPPChangeConfigurationCommandParam, OCPPChangeConfigurationCommandResult, OCPPChargingProfileStatus, OCPPConfigurationStatus, OCPPGetConfigurationCommandParam, OCPPGetConfigurationCommandResult } from '../../../types/ocpp/OCPPClient';
+import { OCPPChangeConfigurationCommandParam, OCPPChangeConfigurationCommandResult, OCPPChargingProfileStatus, OCPPConfigurationStatus, OCPPCustomConfigurationParam, OCPPGetConfigurationCommandParam, OCPPGetConfigurationCommandResult } from '../../../types/ocpp/OCPPClient';
import Transaction, { InactivityStatus, TransactionAction, TransactionStop } from '../../../types/Transaction';
-import ChargingStationClientFactory from '../../../client/ocpp/ChargingStationClientFactory';
import BackendError from '../../../exception/BackendError';
+import { BillingDataTransactionStop } from '../../../types/Billing';
import BillingFactory from '../../../integration/billing/BillingFactory';
-import ChargingStationVendorFactory from '../../../integration/charging-station-vendor/ChargingStationVendorFactory';
-import PricingFactory from '../../../integration/pricing/PricingFactory';
+import ChargingStationClientFactory from '../../../client/ocpp/ChargingStationClientFactory';
import ChargingStationStorage from '../../../storage/mongodb/ChargingStationStorage';
+import ChargingStationVendorFactory from '../../../integration/charging-station-vendor/ChargingStationVendorFactory';
+import Constants from '../../../utils/Constants';
+import Consumption from '../../../types/Consumption';
import ConsumptionStorage from '../../../storage/mongodb/ConsumptionStorage';
import CpoOCPIClient from '../../../client/ocpi/CpoOCPIClient';
import { DataResult } from '../../../types/DataResult';
@@ -19,27 +20,19 @@ import Logging from '../../../utils/Logging';
import OCPIClientFactory from '../../../client/ocpi/OCPIClientFactory';
import { OCPIRole } from '../../../types/ocpi/OCPIRole';
import OCPPStorage from '../../../storage/mongodb/OCPPStorage';
-import TenantStorage from '../../../storage/mongodb/TenantStorage';
-import TransactionStorage from '../../../storage/mongodb/TransactionStorage';
-import { BillingDataTransactionStop } from '../../../types/Billing';
-import { ChargingProfile, ChargingProfilePurposeType } from '../../../types/ChargingProfile';
-import ChargingStation, { ChargingStationCapabilities, ChargingStationOcppParameters, ChargingStationTemplate, ConnectorCurrentLimitSource, CurrentType, OcppParameter, SiteAreaLimitSource, TemplateUpdateResult } from '../../../types/ChargingStation';
-import Consumption from '../../../types/Consumption';
-import { ActionsResponse, KeyValue } from '../../../types/GlobalType';
-import { OCPPChangeConfigurationCommandParam, OCPPChangeConfigurationCommandResult, OCPPChargingProfileStatus, OCPPConfigurationStatus, OCPPCustomConfigurationParam, OCPPGetConfigurationCommandParam, OCPPGetConfigurationCommandResult, OCPPTypeConfigurationResult } from '../../../types/ocpp/OCPPClient';
-import { OCPPMeasurand, OCPPNormalizedMeterValue, OCPPPhase, OCPPReadingContext, OCPPStopTransactionRequestExtended, OCPPUnitOfMeasure } from '../../../types/ocpp/OCPPServer';
import { PricedConsumption } from '../../../types/Pricing';
-import { ServerAction } from '../../../types/Server';
+import PricingFactory from '../../../integration/pricing/PricingFactory';
import { PricingSettingsType } from '../../../types/Setting';
+import { ServerAction } from '../../../types/Server';
import SiteArea from '../../../types/SiteArea';
import Tenant from '../../../types/Tenant';
import TenantComponents from '../../../types/TenantComponents';
-import Transaction, { InactivityStatus, TransactionAction, TransactionStop } from '../../../types/Transaction';
+import TenantStorage from '../../../storage/mongodb/TenantStorage';
+import TransactionStorage from '../../../storage/mongodb/TransactionStorage';
import User from '../../../types/User';
import UserToken from '../../../types/UserToken';
-import Constants from '../../../utils/Constants';
-import Logging from '../../../utils/Logging';
import Utils from '../../../utils/Utils';
+import moment from 'moment';
const MODULE_NAME = 'OCPPUtils';
@@ -1445,8 +1438,8 @@ export default class OCPPUtils {
return chargingStation;
}
- public static async requestAndSaveChargingStationOcppParameters(tenantID: string,
- chargingStation: ChargingStation, forceUpdateOcppParametersWithTemplate = false, typedParameter?: OCPPCustomConfigurationParam): Promise<OCPPChangeConfigurationCommandResult> {
+ public static async requestAndSaveChargingStationOcppParameters(tenantID: string, chargingStation: ChargingStation,
+ forceUpdateOcppParametersWithTemplate = false, customParameter?: OCPPCustomConfigurationParam): Promise<OCPPChangeConfigurationCommandResult> {
try {
// Get the OCPP Client
const chargingStationClient = await ChargingStationClientFactory.getChargingStationClient(tenantID, chargingStation);
@@ -1487,15 +1480,15 @@ export default class OCPPUtils {
chargingStationOcppParameters.configuration = ocppParametersFromDB.result;
}
}
- // Retype all fetched Parameters
+ // Reverify all fetched Parameters
chargingStationOcppParameters.configuration.forEach((fetchedParam) => {
const dbParam = ocppParametersFromDB.result.find((param) => param.key === fetchedParam.key);
- if (dbParam && dbParam.type) {
- fetchedParam.type = dbParam.type;
+ if (dbParam && dbParam.custom) {
+ fetchedParam.custom = dbParam.custom;
}
- // If new param, type it
- if (!dbParam && typedParameter && typedParameter.key === fetchedParam.key) {
- fetchedParam.type = typedParameter.type;
+ // If new param, set custom status
+ if (!dbParam && customParameter && customParameter.key === fetchedParam.key) {
+ fetchedParam.custom = customParameter.custom;
}
});
// Save config

MODIFY
src/server/rest/service/ChargingStationService.ts
src/server/rest/service/ChargingStationService.ts
@@ -1325,11 +1325,11 @@ export default class ChargingStationService {
});
}
// Refresh Configuration
- if (params.type) {
+ if (params.custom) {
await OCPPUtils.requestAndSaveChargingStationOcppParameters(tenantID, chargingStation, false, {
key: params.key,
value: params.value,
- isCustom: params.isCustom
+ custom: params.custom
});
} else {
await OCPPUtils.requestAndSaveChargingStationOcppParameters(tenantID, chargingStation);

MODIFY
src/types/ChargingStation.ts
src/types/ChargingStation.ts
@@ -277,7 +277,7 @@ export interface OcppParameter {
key: string;
value: string;
readonly: boolean;
- type?: string;
+ custom?: boolean;
}
export type OCPPParams = {

MODIFY
src/types/ocpp/OCPPClient.ts
src/types/ocpp/OCPPClient.ts
import { ChargingProfile, ChargingRateUnitType, ChargingSchedule, Profile } from '../../types/ChargingProfile';
+
import { OcppParameter } from '../ChargingStation';
// eslint-disable-next-line @typescript-eslint/no-empty-interface
@@ -63,7 +64,7 @@ export interface OCPPChangeConfigurationCommandResult {
export interface OCPPCustomConfigurationParam extends OCPPCommandParam {
key: string;
value: string;
- isCustom: boolean;
+ custom: boolean;
}
export interface OCPPCustomConfigurationResult {

changes to feature to switch to boolean identifier