Browse Source

Edge Downlinks: deleted @Input tenandId, added Widgets/DeviceProfile fetch methods

pull/3811/head
deaflynx 6 years ago
parent
commit
3c03618d3e
  1. 40
      ui-ngx/src/app/modules/home/components/edge/edge-downlink-table-config.ts
  2. 16
      ui-ngx/src/app/modules/home/components/edge/edge-downlink-table.component.ts

40
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<EdgeEvent, TimePageLink> {
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<EdgeEvent, TimePa
this.entitiesDeleteEnabled = false;
this.headerComponent = EdgeDownlinkTableHeaderComponent;
this.entityTranslations = {
noEntities: 'edge.no-downlinks-prompt'
};
this.entityResources = {} as EntityTypeResource<EdgeEvent>;
this.entitiesFetchFunction = pageLink => this.fetchEvents(pageLink);
this.defaultSortOrder = {property: 'createdTime', direction: Direction.DESC};
this.updateColumns();
@ -159,9 +161,6 @@ export class EdgeDownlinkTableConfig extends EntityTableConfig<EdgeEvent, TimePa
isEdgeEventHasData(edgeEventType: EdgeEventType) {
switch (edgeEventType) {
case EdgeEventType.DEVICE_PROFILE:
case EdgeEventType.WIDGETS_BUNDLE:
case EdgeEventType.WIDGET_TYPE:
case EdgeEventType.ADMIN_SETTINGS:
return false;
default:
@ -182,21 +181,26 @@ export class EdgeDownlinkTableConfig extends EntityTableConfig<EdgeEvent, TimePa
case EdgeEventType.RULE_CHAIN:
case EdgeEventType.ALARM:
return this.entityService.getEntity(entity.type, entity.entityId, { ignoreLoading: true, ignoreErrors: true }).pipe(
map((entity) => {
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);
}

16
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
);
}

Loading…
Cancel
Save