Change converter type
MODIFY
src/server/rest/service/CarService.ts
src/server/rest/service/CarService.ts
@@ -51,7 +51,7 @@ export default class CarService {
['id', 'vehicleModel', 'vehicleMake', 'vehicleModelVersion', 'batteryCapacityFull', 'fastchargeChargeSpeed', 'performanceTopspeed',
'performanceAcceleration', 'rangeWLTP', 'rangeReal', 'efficiencyReal', 'image',
'chargeStandardPower','chargeStandardPhase','chargeStandardPhaseAmp','chargeAlternativePower','chargeOptionPower',
- 'chargeOptionPhaseAmp','chargeAlternativePhaseAmp', 'chargePlug', 'fastChargePlug','fastChargePowerMax', 'drivetrainPowerHP']
+ 'chargeOptionPhaseAmp','chargeOptionPhase','chargeAlternativePhaseAmp','chargeAlternativePhase', 'chargePlug', 'fastChargePlug','fastChargePowerMax', 'drivetrainPowerHP']
);
// Filter
CarSecurity.filterCarCatalogsResponse(carCatalogs, req.user);
@@ -88,7 +88,7 @@ export default class CarService {
'drivetrainTorque', 'batteryCapacityUseable', 'chargePlug', 'fastChargePlug', 'fastChargePowerMax', 'chargePlugLocation',
'drivetrainPowerHP', 'chargeStandardChargeSpeed', 'chargeStandardChargeTime', 'miscSeats', 'miscBody', 'miscIsofix', 'miscTurningCircle',
'miscSegment', 'miscIsofixSeats', 'chargeStandardPower', 'chargeStandardPhase','chargeAlternativePower',
- 'chargeAlternativePhase','chargeOptionPower', 'chargeOptionPhase', 'image']);
+ 'chargeAlternativePhase','chargeOptionPower', 'chargeOptionPhase', 'image','chargeOptionPhaseAmp','chargeAlternativePhaseAmp']);
} else {
// Get the car
carCatalog = await CarStorage.getCarCatalog(filteredRequest.ID);
@@ -264,7 +264,7 @@ export default class CarService {
vin: filteredRequest.vin,
createdBy: { id: req.user.id },
type: filteredRequest.type,
- converterType: filteredRequest.converterType,
+ converter: filteredRequest.converter,
createdOn: new Date()
} as Car;
newCar.id = await CarStorage.saveCar(req.user.tenantID, newCar);
@@ -351,7 +351,7 @@ export default class CarService {
car.vin = filteredRequest.vin;
car.licensePlate = filteredRequest.licensePlate;
car.type = filteredRequest.type;
- car.converterType = filteredRequest.converterType;
+ car.converter = filteredRequest.converter;
car.lastChangedBy = { 'id': req.user.id };
car.lastChangedOn = new Date();
await CarStorage.saveCar(req.user.tenantID, car);

MODIFY
src/server/rest/service/security/CarSecurity.ts
src/server/rest/service/security/CarSecurity.ts
@@ -91,6 +91,9 @@ export default class CarSecurity {
chargeAlternativePhase: carCatalog.chargeAlternativePhase,
chargeOptionPower: carCatalog.chargeOptionPower,
chargeOptionPhase: carCatalog.chargeOptionPhase,
+ chargeOptionPhaseAmp: carCatalog.chargeOptionPhaseAmp,
+ chargeAlternativePhaseAmp: carCatalog.chargeAlternativePhaseAmp,
+ chargeStandardPhaseAmp: carCatalog.chargeStandardPhaseAmp
} as CarCatalog;
}
// Created By / Last Changed By
@@ -168,6 +171,8 @@ export default class CarSecurity {
chargeStandardPhaseAmp: carCatalog.chargeStandardPhaseAmp,
chargeOptionPhaseAmp: carCatalog.chargeOptionPhaseAmp,
chargeAlternativePhaseAmp: carCatalog.chargeAlternativePhaseAmp,
+ chargeAlternativePhase: carCatalog.chargeAlternativePhase,
+ chargeOptionPhase: carCatalog.chargeOptionPhase
});
}
}
@@ -181,7 +186,12 @@ export default class CarSecurity {
carCatalogID: Utils.convertToInt(sanitize(request.carCatalogID)),
forced: UtilsSecurity.filterBoolean(request.forced),
type: sanitize(request.type),
- converterType: sanitize(request.converterType),
+ converter: {
+ powerAmps: Utils.convertToFloat(sanitize(request.converter.powerAmps)),
+ numberOfPhases: Utils.convertToInt(sanitize(request.converter.numberOfPhases)),
+ type: sanitize(request.converter.type),
+ powerWatts: Utils.convertToFloat(sanitize(request.converter.powerWatts))
+ },
usersAdded: request.usersUpserted ? request.usersUpserted.map((userUpserted: UserCar) => ({
user: userUpserted.user,
default: userUpserted.default,
@@ -197,7 +207,12 @@ export default class CarSecurity {
carCatalogID: Utils.convertToInt(sanitize(request.carCatalogID)),
type: sanitize(request.type),
id: sanitize(request.id),
- converterType: sanitize(request.converterType),
+ converter: {
+ powerAmps: Utils.convertToFloat(sanitize(request.converter.powerAmps)),
+ numberOfPhases: Utils.convertToInt(sanitize(request.converter.numberOfPhases)),
+ type: sanitize(request.converterType.type),
+ powerWatts: Utils.convertToFloat(sanitize(request.converter.powerWatts))
+ },
usersRemoved: request.usersRemoved ? request.usersRemoved.map((userRemoved: UserCar) => ({
id: userRemoved.id,
user: userRemoved.user,
@@ -249,7 +264,7 @@ export default class CarSecurity {
licensePlate: car.licensePlate,
carCatalogID: car.carCatalogID,
type: car.type,
- converterType: car.converterType,
+ converter: car.converter,
carCatalog: car.carCatalog,
};
}

MODIFY
src/storage/mongodb/CarStorage.ts
src/storage/mongodb/CarStorage.ts
@@ -461,7 +461,7 @@ export default class CarStorage {
licensePlate: carToSave.licensePlate,
carCatalogID: Utils.convertToInt(carToSave.carCatalogID),
type: carToSave.type,
- converterType: carToSave.converterType
+ converter: carToSave.converter
};
// Add Last Changed/Created props
DatabaseUtils.addLastChangedCreatedProps(carMDB, carToSave);

MODIFY
src/types/Car.ts
src/types/Car.ts
@@ -137,9 +137,23 @@ export interface Car extends CreatedUpdatedProps {
userIDs?: string;
carUsers?: UserCar[];
type?: CarType;
- converterType?: string;
+ converter?: Converter;
}
+export interface Converter {
+ powerWatts: number;
+ powerAmps: number;
+ numberOfPhases: number;
+ type: ConverterType;
+}
+
+export enum ConverterType {
+ STANDARD = 'S',
+ OPTION = 'O',
+ ALTERNATIVE = 'A',
+}
+
+
export interface CarUser extends CreatedUpdatedProps {
id: string;
car: Car;

MODIFY
src/types/requests/HttpCarRequest.ts
src/types/requests/HttpCarRequest.ts
-import { CarType } from '../Car';
+import { CarType, Converter } from '../Car';
+
import HttpDatabaseRequest from './HttpDatabaseRequest';
import { UserCar } from '../User';
@@ -30,7 +31,7 @@ export interface HttpCarCreateRequest {
forced?: boolean;
type: CarType;
id?: string;
- converterType?: string;
+ converter?: Converter;
usersAdded?: UserCar[];
}
@@ -41,7 +42,7 @@ export interface HttpCarUpdateRequest {
forced?: boolean;
type: CarType;
id?: string;
- converterType?: string;
+ converter?: Converter;
usersRemoved?: UserCar[];
usersUpserted?: UserCar[];
}

Change converter type