From f2ac0f69131dc174d5407b8b1298de408e3b2083 Mon Sep 17 00:00:00 2001 From: deaflynx Date: Wed, 3 Mar 2021 14:35:58 +0200 Subject: [PATCH] Minor getEdgeEventContentByEntityType refactoring --- ui-ngx/src/app/core/http/entity.service.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ui-ngx/src/app/core/http/entity.service.ts b/ui-ngx/src/app/core/http/entity.service.ts index c7213ac11f..7a0ef5acd0 100644 --- a/ui-ngx/src/app/core/http/entity.service.ts +++ b/ui-ngx/src/app/core/http/entity.service.ts @@ -1323,7 +1323,9 @@ export class EntityService { public getEdgeEventContentByEntityType(entity: any): Observable { let entityObservable: Observable; - switch (entity.type) { + const entityId = entity.entityId; + const entityType = entity.type; + switch (entityType) { case EdgeEventType.DASHBOARD: case EdgeEventType.ALARM: case EdgeEventType.RULE_CHAIN: @@ -1334,19 +1336,19 @@ export class EntityService { case EdgeEventType.ASSET: case EdgeEventType.DEVICE: case EdgeEventType.ENTITY_VIEW: - entityObservable = this.getEntity(entity.type, entity.entityId, { ignoreLoading: true, ignoreErrors: true }); + entityObservable = this.getEntity(entityType, entityId, { ignoreLoading: true, ignoreErrors: true }); break; case EdgeEventType.RULE_CHAIN_METADATA: - entityObservable = this.ruleChainService.getRuleChainMetadata(entity.entityId); + entityObservable = this.ruleChainService.getRuleChainMetadata(entityId); break; case EdgeEventType.WIDGET_TYPE: - entityObservable = this.widgetService.getWidgetTypeById(entity.entityId); + entityObservable = this.widgetService.getWidgetTypeById(entityId); break; case EdgeEventType.WIDGETS_BUNDLE: - entityObservable = this.widgetService.getWidgetsBundle(entity.entityId); + entityObservable = this.widgetService.getWidgetsBundle(entityId); break; case EdgeEventType.DEVICE_PROFILE: - entityObservable = this.deviceProfileService.getDeviceProfile(entity.entityId); + entityObservable = this.deviceProfileService.getDeviceProfile(entityId); break; case EdgeEventType.RELATION: entityObservable = of(entity.body);