Added Site in Asset list
MODIFY
src/assets/server/rest/v1/docs/e-mobility-oas.json
src/assets/server/rest/v1/docs/e-mobility-oas.json
{
"$ref": "#/components/parameters/SiteIDs"
},
+ {
+ "$ref": "#/components/parameters/WithSite"
+ },
{
"$ref": "#/components/parameters/WithSiteArea"
},

MODIFY
src/authorization/AuthorizationsDefinition.ts
src/authorization/AuthorizationsDefinition.ts
@@ -424,7 +424,8 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
resource: Entity.ASSET, action: Action.LIST,
attributes: [
'id', 'name', 'siteAreaID', 'siteArea.id', 'siteArea.name', 'siteArea.siteID', 'siteID', 'assetType', 'coordinates',
- 'dynamicAsset', 'usesPushAPI', 'connectionID', 'meterID', 'currentInstantWatts', 'currentStateOfCharge', 'issuer'
+ 'dynamicAsset', 'usesPushAPI', 'connectionID', 'meterID', 'currentInstantWatts', 'currentStateOfCharge', 'issuer',
+ 'site.id', 'site.name'
]
},
{
@@ -871,7 +872,7 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
resource: Entity.ASSET, action: Action.LIST,
attributes: [
'id', 'name', 'siteAreaID', 'siteArea.id', 'siteArea.name', 'siteArea.siteID', 'siteID', 'assetType', 'coordinates',
- 'dynamicAsset', 'connectionID', 'meterID', 'currentInstantWatts', 'currentStateOfCharge'
+ 'dynamicAsset', 'connectionID', 'meterID', 'currentInstantWatts', 'currentStateOfCharge', 'site.id', 'site.name'
]
},
{ resource: Entity.ASSET, action: Action.READ },
@@ -1170,7 +1171,7 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
attributes: [
'id', 'name', 'siteAreaID', 'siteArea.id', 'siteArea.name', 'siteArea.siteID', 'siteID', 'assetType', 'coordinates',
'dynamicAsset', 'connectionID', 'meterID', 'currentInstantWatts', 'currentStateOfCharge', 'excludeFromSmartCharging',
- 'staticValueWatt', 'variationThresholdPercent', 'fluctuationPercent'
+ 'staticValueWatt', 'variationThresholdPercent', 'fluctuationPercent', 'site.id', 'site.name'
],
},
{

MODIFY
src/server/rest/v1/service/AssetService.ts
src/server/rest/v1/service/AssetService.ts
@@ -359,6 +359,7 @@ export default class AssetService {
siteAreaIDs: (filteredRequest.SiteAreaID ? filteredRequest.SiteAreaID.split('|') : null),
siteIDs: (filteredRequest.SiteID ? filteredRequest.SiteID.split('|') : null),
withSiteArea: filteredRequest.WithSiteArea,
+ withSite: filteredRequest.WithSite,
withNoSiteArea: filteredRequest.WithNoSiteArea,
dynamicOnly: filteredRequest.DynamicOnly,
...authorizationAssetsFilter.filters

MODIFY
src/storage/mongodb/AssetStorage.ts
src/storage/mongodb/AssetStorage.ts
@@ -99,7 +99,7 @@ export default class AssetStorage {
public static async getAssets(tenant: Tenant,
params: { search?: string; assetIDs?: string[]; siteAreaIDs?: string[]; siteIDs?: string[]; withSiteArea?: boolean;
- withNoSiteArea?: boolean; dynamicOnly?: boolean; issuer?: boolean; } = {},
+ withSite?: boolean; withNoSiteArea?: boolean; dynamicOnly?: boolean; issuer?: boolean; } = {},
dbParams?: DbParams, projectFields?: string[]): Promise<DataResult<Asset>> {
const startTime = Logging.traceDatabaseRequestStart();
DatabaseUtils.checkTenantObject(tenant);
@@ -195,6 +195,13 @@ export default class AssetStorage {
asField: 'siteArea', oneToOneCardinality: true
});
}
+ // Site
+ if (params.withSite) {
+ DatabaseUtils.pushSiteLookupInAggregation({
+ tenantID: tenant.id, aggregation: aggregation, localField: 'siteID', foreignField: '_id',
+ asField: 'site', oneToOneCardinality: true
+ });
+ }
// Handle the ID
DatabaseUtils.pushRenameDatabaseID(aggregation);
DatabaseUtils.pushConvertObjectIDToString(aggregation, 'siteAreaID');

MODIFY
src/types/requests/HttpAssetRequest.ts
src/types/requests/HttpAssetRequest.ts
@@ -11,6 +11,7 @@ export interface HttpAssetsRequest extends HttpDatabaseRequest {
Search?: string;
SiteAreaID?: string;
SiteID?: string;
+ WithSite?: boolean;
WithSiteArea?: boolean;
WithNoSiteArea?: boolean;
DynamicOnly?: boolean;

Added Site in Asset list