Aligned method naming
MODIFY
src/authorization/Authorizations.ts
src/authorization/Authorizations.ts
@@ -124,7 +124,7 @@ export default class Authorizations {
const siteAdminIDs = [];
const siteOwnerIDs = [];
// Get User's site
- const sites = (await UserStorage.getSites(tenantID, { userID: user.id },
+ const sites = (await UserStorage.getUserSites(tenantID, { userID: user.id },
Constants.DB_PARAMS_MAX_LIMIT)).result;
sites.forEach((siteUser) => {
if (!Authorizations.isAdmin(user)) {

MODIFY
src/scheduler/tasks/CheckPreparingSessionNotStartedTask.ts
src/scheduler/tasks/CheckPreparingSessionNotStartedTask.ts
@@ -29,7 +29,7 @@ export default class CheckPreparingSessionNotStartedTask extends SchedulerTask {
// Get site owner and then send notification
if (chargingStation.siteArea && chargingStation.siteArea.siteID) {
// Get Site Owners
- const siteOwners = await SiteStorage.getUsers(tenant.id, { siteID: chargingStation.siteArea.siteID, siteOwnerOnly: true }, Constants.DB_PARAMS_MAX_LIMIT);
+ const siteOwners = await SiteStorage.getSiteUsers(tenant.id, { siteID: chargingStation.siteArea.siteID, siteOwnerOnly: true }, Constants.DB_PARAMS_MAX_LIMIT);
if (siteOwners && siteOwners.count > 0) {
// Send notification
moment.locale(siteOwners.result[0].user.locale);

MODIFY
src/server/rest/CentralRestServerService.ts
src/server/rest/CentralRestServerService.ts
@@ -58,8 +58,8 @@ class RequestMapper {
);
// Register REST actions
this.registerJsonActionsPaths({
- [ServerAction.ADD_CHARGING_STATION_TO_SITE_AREA]: SiteAreaService.handleAssignChargingStationsToSiteArea.bind(this),
- [ServerAction.REMOVE_CHARGING_STATION_FROM_SITE_AREA]: SiteAreaService.handleAssignChargingStationsToSiteArea.bind(this),
+ [ServerAction.ADD_CHARGING_STATIONS_TO_SITE_AREA]: SiteAreaService.handleAssignChargingStationsToSiteArea.bind(this),
+ [ServerAction.REMOVE_CHARGING_STATIONS_FROM_SITE_AREA]: SiteAreaService.handleAssignChargingStationsToSiteArea.bind(this),
[ServerAction.REGISTRATION_TOKEN_CREATE]: RegistrationTokenService.handleCreateRegistrationToken.bind(this),
[ServerAction.USER_CREATE]: UserService.handleCreateUser.bind(this),
[ServerAction.COMPANY_CREATE]: CompanyService.handleCreateCompany.bind(this),

MODIFY
src/server/rest/service/SiteAreaService.ts
src/server/rest/service/SiteAreaService.ts
@@ -155,7 +155,7 @@ export default class SiteAreaService {
});
}
for (const connector of chargingStation.connectors) {
- if (connector.numberOfConnectedPhase !== 1 && siteArea.numberOfPhases === 1 && action === ServerAction.ADD_CHARGING_STATION_TO_SITE_AREA) {
+ if (connector.numberOfConnectedPhase !== 1 && siteArea.numberOfPhases === 1 && action === ServerAction.ADD_CHARGING_STATIONS_TO_SITE_AREA) {
throw new AppError({
source: Constants.CENTRAL_SERVER,
action: action,
@@ -168,7 +168,7 @@ export default class SiteAreaService {
}
}
// Save
- if (action === ServerAction.ADD_CHARGING_STATION_TO_SITE_AREA) {
+ if (action === ServerAction.ADD_CHARGING_STATIONS_TO_SITE_AREA) {
await SiteAreaStorage.addChargingStationsToSiteArea(req.user.tenantID, filteredRequest.siteAreaID, filteredRequest.chargingStationIDs);
} else {
await SiteAreaStorage.removeChargingStationsFromSiteArea(req.user.tenantID, filteredRequest.siteAreaID, filteredRequest.chargingStationIDs);

MODIFY
src/server/rest/service/SiteService.ts
src/server/rest/service/SiteService.ts
@@ -287,7 +287,7 @@ export default class SiteService {
});
}
// Get users
- const users = await SiteStorage.getUsers(req.user.tenantID,
+ const users = await SiteStorage.getSiteUsers(req.user.tenantID,
{
search: filteredRequest.Search,
siteID: filteredRequest.SiteID

MODIFY
src/server/rest/service/UserService.ts
src/server/rest/service/UserService.ts
@@ -753,7 +753,7 @@ export default class UserService {
});
}
// Get users
- const userSites = await UserStorage.getSites(req.user.tenantID,
+ const userSites = await UserStorage.getUserSites(req.user.tenantID,
{
search: filteredRequest.Search,
userID: filteredRequest.UserID

MODIFY
src/storage/mongodb/SiteStorage.ts
src/storage/mongodb/SiteStorage.ts
@@ -93,11 +93,11 @@ export default class SiteStorage {
Logging.traceEnd(MODULE_NAME, 'addUsersToSite', uniqueTimerID, { siteID, userIDs });
}
- public static async getUsers(tenantID: string,
+ public static async getSiteUsers(tenantID: string,
params: { search?: string; siteID: string; siteOwnerOnly?: boolean },
dbParams: DbParams, projectFields?: string[]): Promise<DataResult<UserSite>> {
// Debug
- const uniqueTimerID = Logging.traceStart(MODULE_NAME, 'getUsers');
+ const uniqueTimerID = Logging.traceStart(MODULE_NAME, 'getSitesUsers');
// Check Tenant
await Utils.checkTenant(tenantID);
// Check Limit
@@ -202,7 +202,7 @@ export default class SiteStorage {
}
}
// Debug
- Logging.traceEnd(MODULE_NAME, 'getUsers', uniqueTimerID, { siteID: params.siteID });
+ Logging.traceEnd(MODULE_NAME, 'getSitesUsers', uniqueTimerID, { siteID: params.siteID });
// Ok
return {
count: (usersCountMDB.length > 0 ?

MODIFY
src/storage/mongodb/UserStorage.ts
src/storage/mongodb/UserStorage.ts
@@ -917,7 +917,7 @@ export default class UserStorage {
Logging.traceEnd(MODULE_NAME, 'deleteUser', uniqueTimerID, { id });
}
- public static async getSites(tenantID: string,
+ public static async getUserSites(tenantID: string,
params: { search?: string; userID: string; siteAdmin?: boolean; siteOwner?: boolean },
dbParams: DbParams, projectFields?: string[]): Promise<DataResult<SiteUser>> {
// Debug

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -249,8 +249,8 @@ export enum ServerAction {
FIRMWARE_STATUS_NOTIFICATION = 'FirmwareStatusNotification',
- ADD_CHARGING_STATION_TO_SITE_AREA = 'AddChargingStationsToSiteArea',
- REMOVE_CHARGING_STATION_FROM_SITE_AREA = 'RemoveChargingStationsFromSiteArea',
+ ADD_CHARGING_STATIONS_TO_SITE_AREA = 'AddChargingStationsToSiteArea',
+ REMOVE_CHARGING_STATIONS_FROM_SITE_AREA = 'RemoveChargingStationsFromSiteArea',
ADD_ASSET_TO_SITE_AREA = 'AddAssetsToSiteArea',
REMOVE_ASSET_TO_SITE_AREA = 'RemoveAssetsFromSiteArea',

Aligned method naming