Added distance in return of Sites Site Areas and Companies
MODIFY
src/server/rest/service/CompanyService.ts
src/server/rest/service/CompanyService.ts
@@ -149,7 +149,7 @@ export default class CompanyService {
locMaxDistanceMeters: filteredRequest.LocMaxDistanceMeters,
},
{ limit: filteredRequest.Limit, skip: filteredRequest.Skip, sort: filteredRequest.Sort, onlyRecordCount: filteredRequest.OnlyRecordCount },
- [ 'id', 'name', 'address.coordinates', 'address.city', 'address.country', 'logo', 'issuer']
+ [ 'id', 'name', 'address.coordinates', 'address.city', 'address.country', 'logo', 'issuer', 'distanceMeters']
);
// Filter
CompanySecurity.filterCompaniesResponse(companies, req.user);

MODIFY
src/server/rest/service/SiteAreaService.ts
src/server/rest/service/SiteAreaService.ts
@@ -307,7 +307,8 @@ export default class SiteAreaService {
locMaxDistanceMeters: filteredRequest.LocMaxDistanceMeters,
},
{ limit: filteredRequest.Limit, skip: filteredRequest.Skip, sort: filteredRequest.Sort, onlyRecordCount: filteredRequest.OnlyRecordCount },
- ['id', 'name', 'siteID', 'maximumPower', 'numberOfPhases', 'accessControl', 'smartCharging', 'address.coordinates', 'address.city', 'address.country', 'site.id', 'site.name', 'issuer']
+ ['id', 'name', 'siteID', 'maximumPower', 'numberOfPhases', 'accessControl', 'smartCharging', 'address.coordinates',
+ 'address.city', 'address.country', 'site.id', 'site.name', 'issuer', 'distanceMeters']
);
// Filter
SiteAreaSecurity.filterSiteAreasResponse(siteAreas, req.user);

MODIFY
src/server/rest/service/SiteService.ts
src/server/rest/service/SiteService.ts
@@ -393,7 +393,7 @@ export default class SiteService {
onlyRecordCount: filteredRequest.OnlyRecordCount
},
['id', 'name', 'address.coordinates', 'address.city', 'address.country', 'companyID', 'company.name',
- 'autoUserSiteAssignment', 'issuer', 'autoUserSiteAssignment']
+ 'autoUserSiteAssignment', 'issuer', 'autoUserSiteAssignment', 'distanceMeters']
);
// Build the result
if (sites.result && sites.result.length > 0) {

MODIFY
src/server/rest/service/security/CompanySecurity.ts
src/server/rest/service/security/CompanySecurity.ts
@@ -69,27 +69,23 @@ export default class CompanySecurity {
public static filterCompanyResponse(company: Company, loggedUser: UserToken): Company {
let filteredCompany;
-
if (!company) {
return null;
}
// Check auth
if (Authorizations.canReadCompany(loggedUser, company.id)) {
- // Admin?
- if (Authorizations.isAdmin(loggedUser)) {
- // Yes: set all params
- filteredCompany = company;
- } else {
// Set only necessary info
filteredCompany = {};
filteredCompany.id = company.id;
filteredCompany.name = company.name;
filteredCompany.logo = company.logo;
filteredCompany.address = UtilsSecurity.filterAddressRequest(company.address);
- }
if (company.sites) {
filteredCompany.sites = company.sites.map((site) => SiteSecurity.filterSiteResponse(site, loggedUser));
}
+ if (Utils.objectHasProperty(company, 'distanceMeters')) {
+ filteredCompany.distanceMeters = company.distanceMeters;
+ }
// Created By / Last Changed By
UtilsSecurity.filterCreatedAndLastChanged(
filteredCompany, company, loggedUser);

MODIFY
src/server/rest/service/security/SiteAreaSecurity.ts
src/server/rest/service/security/SiteAreaSecurity.ts
@@ -123,6 +123,9 @@ export default class SiteAreaSecurity {
ChargingStationSecurity.filterChargingStationResponse(chargingStation, loggedUser)
);
}
+ if (Utils.objectHasProperty(siteArea, 'distanceMeters')) {
+ filteredSiteArea.distanceMeters = siteArea.distanceMeters;
+ }
// Created By / Last Changed By
UtilsSecurity.filterCreatedAndLastChanged(filteredSiteArea, siteArea, loggedUser);
}

MODIFY
src/server/rest/service/security/SiteSecurity.ts
src/server/rest/service/security/SiteSecurity.ts
@@ -144,6 +144,9 @@ export default class SiteSecurity {
if (site.connectorStats) {
filteredSite.connectorStats = site.connectorStats;
}
+ if (Utils.objectHasProperty(site, 'distanceMeters')) {
+ filteredSite.distanceMeters = site.distanceMeters;
+ }
// Created By / Last Changed By
UtilsSecurity.filterCreatedAndLastChanged(filteredSite, site, loggedUser);
}

Added distance in return of Sites Site Areas and Companies