From 3c03618d3e6b7014fa3069f4ce3e7b5a4faded74 Mon Sep 17 00:00:00 2001 From: deaflynx Date: Wed, 3 Mar 2021 11:52:24 +0200 Subject: [PATCH] Edge Downlinks: deleted @Input tenandId, added Widgets/DeviceProfile fetch methods --- .../edge/edge-downlink-table-config.ts | 40 ++++++++++--------- .../edge/edge-downlink-table.component.ts | 16 ++++---- 2 files changed, 31 insertions(+), 25 deletions(-) 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 f4562b1b20..2fc307ebd1 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 @@ -50,22 +50,26 @@ import { EdgeDownlinkTableHeaderComponent } from '@home/components/edge/edge-dow import { EdgeService } from '@core/http/edge.service'; import { map } from 'rxjs/operators'; import { EntityService } from "@core/http/entity.service"; +import { WidgetService } from "@core/http/widget.service"; +import { DeviceProfileService } from "@core/http/device-profile.service"; export class EdgeDownlinkTableConfig extends EntityTableConfig { queueStartTs: number; constructor(private edgeService: EdgeService, + private entityService: EntityService, private dialogService: DialogService, private translate: TranslateService, - private entityService: EntityService, - private ruleChainService: RuleChainService, private attributeService: AttributeService, + private deviceProfileService: DeviceProfileService, + private ruleChainService: RuleChainService, + private widgetService: WidgetService, private datePipe: DatePipe, private dialog: MatDialog, - public entityId: EntityId, - public tenantId: string) { + public entityId: EntityId) { super(); + this.loadDataOnInit = false; this.tableTitle = ''; this.useTimePageLink = true; @@ -76,13 +80,11 @@ export class EdgeDownlinkTableConfig extends EntityTableConfig; this.entitiesFetchFunction = pageLink => this.fetchEvents(pageLink); - this.defaultSortOrder = {property: 'createdTime', direction: Direction.DESC}; this.updateColumns(); @@ -159,9 +161,6 @@ export class EdgeDownlinkTableConfig extends EntityTableConfig { - return JSON.stringify(entity); - }) + map((entity) => JSON.stringify(entity)) ); case EdgeEventType.RELATION: return of(JSON.stringify(entity.body)); case EdgeEventType.RULE_CHAIN_METADATA: - return this.ruleChainService.getRuleChainMetadata(entity.entityId, null).pipe( - map((ruleChainMetaData) => { - return JSON.stringify(ruleChainMetaData.nodes); - }) + return this.ruleChainService.getRuleChainMetadata(entity.entityId).pipe( + map((ruleChainMetaData) => JSON.stringify(ruleChainMetaData.nodes)) ); - case EdgeEventType.DEVICE_PROFILE: - case EdgeEventType.WIDGETS_BUNDLE: case EdgeEventType.WIDGET_TYPE: + return this.widgetService.getWidgetTypeById(entity.entityId).pipe( + map((widgetType) => JSON.stringify(widgetType)) + ); + case EdgeEventType.WIDGETS_BUNDLE: + return this.widgetService.getWidgetsBundle(entity.entityId).pipe( + map((widgetBundles) => JSON.stringify(widgetBundles)) + ); + case EdgeEventType.DEVICE_PROFILE: + return this.deviceProfileService.getDeviceProfile(entity.entityId).pipe( + map((deviceProfile) => JSON.stringify(deviceProfile)) + ); case EdgeEventType.ADMIN_SETTINGS: return of(null); } diff --git a/ui-ngx/src/app/modules/home/components/edge/edge-downlink-table.component.ts b/ui-ngx/src/app/modules/home/components/edge/edge-downlink-table.component.ts index b0eb5f4c30..50cedbe426 100644 --- a/ui-ngx/src/app/modules/home/components/edge/edge-downlink-table.component.ts +++ b/ui-ngx/src/app/modules/home/components/edge/edge-downlink-table.component.ts @@ -26,6 +26,8 @@ import { RuleChainService } from '@core/http/rule-chain.service'; import { AttributeService } from '@core/http/attribute.service'; import { EdgeService } from '@core/http/edge.service'; import { EntityService } from "@core/http/entity.service"; +import { WidgetService } from "@core/http/widget.service"; +import { DeviceProfileService } from "@core/http/device-profile.service"; @Component({ selector: 'tb-edge-downlink-table', @@ -34,9 +36,6 @@ import { EntityService } from "@core/http/entity.service"; }) export class EdgeDownlinkTableComponent implements OnInit { - @Input() - tenantId: string; - activeValue = false; dirtyValue = false; entityIdValue: EntityId; @@ -73,7 +72,9 @@ export class EdgeDownlinkTableComponent implements OnInit { private dialogService: DialogService, private translate: TranslateService, private attributeService: AttributeService, + private deviceProfileService: DeviceProfileService, private ruleChainService: RuleChainService, + private widgetService: WidgetService, private datePipe: DatePipe, private dialog: MatDialog) { } @@ -82,15 +83,16 @@ export class EdgeDownlinkTableComponent implements OnInit { this.dirtyValue = !this.activeValue; this.edgeDownlinkTableConfig = new EdgeDownlinkTableConfig( this.edgeService, + this.entityService, this.dialogService, this.translate, - this.entityService, - this.ruleChainService, this.attributeService, + this.deviceProfileService, + this.ruleChainService, + this.widgetService, this.datePipe, this.dialog, - this.entityIdValue, - this.tenantId + this.entityIdValue ); }