Commit 02567a728ee82a848b2480ee371ba9df9f8b0c99

Authored by deaflynx
1 parent 4981db7a

getEdgeEventContent() refactored

... ... @@ -83,7 +83,12 @@ import {
83 83 import { alarmFields } from '@shared/models/alarm.models';
84 84 import { OtaPackageService } from '@core/http/ota-package.service';
85 85 import { EdgeService } from '@core/http/edge.service';
86   -import { Edge, EdgeEvent, EdgeEventActionType, EdgeEventType } from '@shared/models/edge.models';
  86 +import {
  87 + Edge,
  88 + EdgeEvent,
  89 + EdgeEventType,
  90 + bodyContentEdgeEventActionTypes
  91 +} from '@shared/models/edge.models';
87 92 import { RuleChainMetaData, RuleChainType } from '@shared/models/rule-chain.models';
88 93 import { WidgetService } from '@core/http/widget.service';
89 94 import { DeviceProfileService } from '@core/http/device-profile.service';
... ... @@ -1391,7 +1396,6 @@ export class EntityService {
1391 1396 let entityObservable: Observable<BaseData<HasId> | RuleChainMetaData | string>;
1392 1397 const entityId: string = entity.entityId;
1393 1398 const entityType: any = entity.type;
1394   - const entityAction: EdgeEventActionType = entity.action;
1395 1399 switch (entityType) {
1396 1400 case EdgeEventType.DASHBOARD:
1397 1401 case EdgeEventType.ALARM:
... ... @@ -1403,12 +1407,8 @@ export class EntityService {
1403 1407 case EdgeEventType.ASSET:
1404 1408 case EdgeEventType.DEVICE:
1405 1409 case EdgeEventType.ENTITY_VIEW:
1406   - if (entityAction === EdgeEventActionType.POST_ATTRIBUTES ||
1407   - entityAction === EdgeEventActionType.ATTRIBUTES_UPDATED ||
1408   - entityAction === EdgeEventActionType.ATTRIBUTES_DELETED ||
1409   - entityAction === EdgeEventActionType.TIMESERIES_UPDATED ||
1410   - entityAction === EdgeEventActionType.RPC_CALL) {
1411   - return of(entity.body);
  1410 + if (bodyContentEdgeEventActionTypes.indexOf(entity.action) > -1) {
  1411 + entityObservable = of(entity.body);
1412 1412 } else {
1413 1413 entityObservable = this.getEntity(entityType, entityId, { ignoreLoading: true, ignoreErrors: true });
1414 1414 }
... ...
... ... @@ -137,6 +137,14 @@ export const edgeEventActionTypeTranslations = new Map<EdgeEventActionType, stri
137 137 ]
138 138 );
139 139
  140 +export const bodyContentEdgeEventActionTypes = [
  141 + EdgeEventActionType.POST_ATTRIBUTES,
  142 + EdgeEventActionType.ATTRIBUTES_UPDATED,
  143 + EdgeEventActionType.ATTRIBUTES_DELETED,
  144 + EdgeEventActionType.TIMESERIES_UPDATED,
  145 + EdgeEventActionType.RPC_CALL
  146 +];
  147 +
140 148 export const edgeEventStatusColor = new Map<EdgeEventStatus, string>(
141 149 [
142 150 [EdgeEventStatus.DEPLOYED, '#000000'],
... ...