From 02567a728ee82a848b2480ee371ba9df9f8b0c99 Mon Sep 17 00:00:00 2001 From: deaflynx Date: Tue, 21 Sep 2021 13:16:13 +0300 Subject: [PATCH] getEdgeEventContent() refactored --- ui-ngx/src/app/core/http/entity.service.ts | 16 ++++++++-------- ui-ngx/src/app/shared/models/edge.models.ts | 8 ++++++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/ui-ngx/src/app/core/http/entity.service.ts b/ui-ngx/src/app/core/http/entity.service.ts index 37e7b91206..015ba6ec88 100644 --- a/ui-ngx/src/app/core/http/entity.service.ts +++ b/ui-ngx/src/app/core/http/entity.service.ts @@ -83,7 +83,12 @@ import { import { alarmFields } from '@shared/models/alarm.models'; import { OtaPackageService } from '@core/http/ota-package.service'; import { EdgeService } from '@core/http/edge.service'; -import { Edge, EdgeEvent, EdgeEventActionType, EdgeEventType } from '@shared/models/edge.models'; +import { + Edge, + EdgeEvent, + EdgeEventType, + bodyContentEdgeEventActionTypes +} from '@shared/models/edge.models'; import { RuleChainMetaData, RuleChainType } from '@shared/models/rule-chain.models'; import { WidgetService } from '@core/http/widget.service'; import { DeviceProfileService } from '@core/http/device-profile.service'; @@ -1391,7 +1396,6 @@ export class EntityService { let entityObservable: Observable | RuleChainMetaData | string>; const entityId: string = entity.entityId; const entityType: any = entity.type; - const entityAction: EdgeEventActionType = entity.action; switch (entityType) { case EdgeEventType.DASHBOARD: case EdgeEventType.ALARM: @@ -1403,12 +1407,8 @@ export class EntityService { case EdgeEventType.ASSET: case EdgeEventType.DEVICE: case EdgeEventType.ENTITY_VIEW: - if (entityAction === EdgeEventActionType.POST_ATTRIBUTES || - entityAction === EdgeEventActionType.ATTRIBUTES_UPDATED || - entityAction === EdgeEventActionType.ATTRIBUTES_DELETED || - entityAction === EdgeEventActionType.TIMESERIES_UPDATED || - entityAction === EdgeEventActionType.RPC_CALL) { - return of(entity.body); + if (bodyContentEdgeEventActionTypes.indexOf(entity.action) > -1) { + entityObservable = of(entity.body); } else { entityObservable = this.getEntity(entityType, entityId, { ignoreLoading: true, ignoreErrors: true }); } diff --git a/ui-ngx/src/app/shared/models/edge.models.ts b/ui-ngx/src/app/shared/models/edge.models.ts index fd7cb57706..5cc1c7b23c 100644 --- a/ui-ngx/src/app/shared/models/edge.models.ts +++ b/ui-ngx/src/app/shared/models/edge.models.ts @@ -137,6 +137,14 @@ export const edgeEventActionTypeTranslations = new Map( [ [EdgeEventStatus.DEPLOYED, '#000000'],