diff --git a/ui-ngx/src/app/core/http/entity.service.ts b/ui-ngx/src/app/core/http/entity.service.ts index 6665beb3b3..3346d5ce83 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, 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'; @@ -1402,7 +1407,11 @@ export class EntityService { case EdgeEventType.ASSET: case EdgeEventType.DEVICE: case EdgeEventType.ENTITY_VIEW: - entityObservable = this.getEntity(entityType, entityId, { ignoreLoading: true, ignoreErrors: true }); + if (bodyContentEdgeEventActionTypes.includes(entity.action)) { + entityObservable = of(entity.body); + } else { + entityObservable = this.getEntity(entityType, entityId, { ignoreLoading: true, ignoreErrors: true }); + } break; case EdgeEventType.RULE_CHAIN_METADATA: entityObservable = this.ruleChainService.getRuleChainMetadata(entityId); diff --git a/ui-ngx/src/app/modules/home/components/edge/edge-downlink-table-config.ts b/ui-ngx/src/app/modules/home/components/edge/edge-downlink-table-config.ts index 517415a68a..38c3317ff0 100644 --- a/ui-ngx/src/app/modules/home/components/edge/edge-downlink-table-config.ts +++ b/ui-ngx/src/app/modules/home/components/edge/edge-downlink-table-config.ts @@ -47,7 +47,7 @@ import { AttributeService } from '@core/http/attribute.service'; import { AttributeScope } from '@shared/models/telemetry/telemetry.models'; import { EdgeDownlinkTableHeaderComponent } from '@home/components/edge/edge-downlink-table-header.component'; import { EdgeService } from '@core/http/edge.service'; -import { map } from 'rxjs/operators'; +import { concatMap, map } from 'rxjs/operators'; import { EntityService } from "@core/http/entity.service"; import { Store } from '@ngrx/store'; import { AppState } from '@core/core.state'; @@ -55,7 +55,7 @@ import { ActionNotificationShow } from '@core/notification/notification.actions' export class EdgeDownlinkTableConfig extends EntityTableConfig { - queueStartTs: number; + private queueStartTs: number; constructor(private attributeService: AttributeService, private datePipe: DatePipe, @@ -85,19 +85,14 @@ export class EdgeDownlinkTableConfig extends EntityTableConfig> { - this.loadEdgeInfo(); - return this.edgeService.getEdgeEvents(this.entityId, pageLink); - } - - loadEdgeInfo(): void { - this.attributeService.getEntityAttributes(this.entityId, AttributeScope.SERVER_SCOPE, ['queueStartTs']) - .subscribe( - attributes => this.onUpdate(attributes) - ); + private fetchEvents(pageLink: TimePageLink): Observable> { + return this.attributeService.getEntityAttributes(this.entityId, AttributeScope.SERVER_SCOPE, ['queueStartTs']).pipe( + map((attributes) => this.onUpdate(attributes)), + concatMap(() => this.edgeService.getEdgeEvents(this.entityId, pageLink)) + ); } - onUpdate(attributes): void { + private onUpdate(attributes: any): void { this.queueStartTs = 0; let edge = attributes.reduce(function (map, attribute) { map[attribute.key] = attribute; @@ -108,7 +103,7 @@ export class EdgeDownlinkTableConfig extends EntityTableConfig('createdTime', 'event.event-time', this.datePipe, '120px'), @@ -117,7 +112,7 @@ export class EdgeDownlinkTableConfig extends EntityTableConfig('action', 'edge.event-action', '25%', entity => this.translate.instant(edgeEventActionTypeTranslations.get(entity.action)), entity => ({}), false), new EntityTableColumn('entityId', 'edge.entity-id', '40%', - (entity) => entity.entityId, entity => ({}), false), + (entity) => entity.entityId ? entity.entityId : '', () => ({}), false), new EntityTableColumn('status', 'event.status', '10%', (entity) => this.updateEdgeEventStatus(entity.createdTime), entity => ({ @@ -143,7 +138,7 @@ export class EdgeDownlinkTableConfig extends EntityTableConfig this.queueStartTs; } - isEdgeEventHasData(entity: EdgeEvent): boolean { + private isEdgeEventHasData(entity: EdgeEvent): boolean { return !(entity.type === EdgeEventType.ADMIN_SETTINGS || entity.action === EdgeEventActionType.DELETED); } - prepareEdgeEventContent(entity: EdgeEvent): Observable { + private prepareEdgeEventContent(entity: EdgeEvent): Observable { return this.entityService.getEdgeEventContent(entity).pipe( map((result) => JSON.stringify(result)) ); } - showEdgeEventContent($event: MouseEvent, content: string, title: string): void { + private showEdgeEventContent($event: MouseEvent, content: string, title: string): void { if ($event) { $event.stopPropagation(); } @@ -181,7 +176,7 @@ export class EdgeDownlinkTableConfig extends EntityTableConfig( [ [EdgeEventStatus.DEPLOYED, '#000000'],