Return address of Site, Site Area and Company
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', 'distanceMeters']
+ [ 'id', 'name', 'address', 'logo', 'issuer', 'distanceMeters']
);
// Filter
CompanySecurity.filterCompaniesResponse(companies, req.user);

MODIFY
src/server/rest/service/SiteAreaService.ts
src/server/rest/service/SiteAreaService.ts
@@ -307,8 +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', 'distanceMeters']
+ ['id', 'name', 'siteID', 'maximumPower', 'numberOfPhases', 'accessControl', 'smartCharging', 'address',
+ '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
@@ -392,8 +392,8 @@ export default class SiteService {
sort: filteredRequest.Sort,
onlyRecordCount: filteredRequest.OnlyRecordCount
},
- ['id', 'name', 'address.coordinates', 'address.city', 'address.country', 'companyID', 'company.name',
- 'autoUserSiteAssignment', 'issuer', 'autoUserSiteAssignment', 'distanceMeters']
+ ['id', 'name', 'address', 'companyID', 'company.name', 'autoUserSiteAssignment', 'issuer',
+ 'autoUserSiteAssignment', 'distanceMeters']
);
// Build the result
if (sites.result && sites.result.length > 0) {

MODIFY
src/server/rest/service/security/SiteAreaSecurity.ts
src/server/rest/service/security/SiteAreaSecurity.ts
@@ -106,12 +106,8 @@ export default class SiteAreaSecurity {
filteredSiteArea.smartCharging = siteArea.smartCharging;
filteredSiteArea.accessControl = siteArea.accessControl;
if (Utils.objectHasProperty(siteArea, 'address')) {
- if (forList) {
- filteredSiteArea.address = UtilsSecurity.filterAddressCoordinatesRequest(siteArea.address);
- } else {
filteredSiteArea.address = UtilsSecurity.filterAddressRequest(siteArea.address);
}
- }
if (siteArea.connectorStats) {
filteredSiteArea.connectorStats = siteArea.connectorStats;
}
@@ -160,7 +156,7 @@ export default class SiteAreaSecurity {
return null;
}
for (const siteArea of siteAreas.result) {
- const filteredSiteArea = SiteAreaSecurity.filterSiteAreaResponse(siteArea, loggedUser, true);
+ const filteredSiteArea = SiteAreaSecurity.filterSiteAreaResponse(siteArea, loggedUser);
if (filteredSiteArea) {
filteredSiteAreas.push(filteredSiteArea);
}

MODIFY
src/server/rest/service/security/SiteSecurity.ts
src/server/rest/service/security/SiteSecurity.ts
@@ -111,7 +111,7 @@ export default class SiteSecurity {
return filteredRequest;
}
- static filterSiteResponse(site: Site, loggedUser: UserToken, forList = false): Site {
+ static filterSiteResponse(site: Site, loggedUser: UserToken): Site {
let filteredSite;
if (!site) {
return null;
@@ -126,12 +126,8 @@ export default class SiteSecurity {
filteredSite.autoUserSiteAssignment = site.autoUserSiteAssignment;
filteredSite.issuer = site.issuer;
if (Utils.objectHasProperty(site, 'address')) {
- if (forList) {
- filteredSite.address = UtilsSecurity.filterAddressCoordinatesRequest(site.address);
- } else {
filteredSite.address = UtilsSecurity.filterAddressRequest(site.address);
}
- }
if (site.company) {
filteredSite.company = CompanySecurity.filterCompanyResponse(site.company, loggedUser);
}
@@ -164,7 +160,7 @@ export default class SiteSecurity {
}
for (const site of sites.result) {
// Filter
- const filteredSite = SiteSecurity.filterSiteResponse(site, loggedUser, true);
+ const filteredSite = SiteSecurity.filterSiteResponse(site, loggedUser);
if (filteredSite) {
filteredSites.push(filteredSite);
}

Return address of Site, Site Area and Company