Commit 3c03618d3e6b7014fa3069f4ce3e7b5a4faded74

Authored by deaflynx
1 parent cdd9c867

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

... ... @@ -50,22 +50,26 @@ import { EdgeDownlinkTableHeaderComponent } from '@home/components/edge/edge-dow
50 50 import { EdgeService } from '@core/http/edge.service';
51 51 import { map } from 'rxjs/operators';
52 52 import { EntityService } from "@core/http/entity.service";
  53 +import { WidgetService } from "@core/http/widget.service";
  54 +import { DeviceProfileService } from "@core/http/device-profile.service";
53 55
54 56 export class EdgeDownlinkTableConfig extends EntityTableConfig<EdgeEvent, TimePageLink> {
55 57
56 58 queueStartTs: number;
57 59
58 60 constructor(private edgeService: EdgeService,
  61 + private entityService: EntityService,
59 62 private dialogService: DialogService,
60 63 private translate: TranslateService,
61   - private entityService: EntityService,
62   - private ruleChainService: RuleChainService,
63 64 private attributeService: AttributeService,
  65 + private deviceProfileService: DeviceProfileService,
  66 + private ruleChainService: RuleChainService,
  67 + private widgetService: WidgetService,
64 68 private datePipe: DatePipe,
65 69 private dialog: MatDialog,
66   - public entityId: EntityId,
67   - public tenantId: string) {
  70 + public entityId: EntityId) {
68 71 super();
  72 +
69 73 this.loadDataOnInit = false;
70 74 this.tableTitle = '';
71 75 this.useTimePageLink = true;
... ... @@ -76,13 +80,11 @@ export class EdgeDownlinkTableConfig extends EntityTableConfig<EdgeEvent, TimePa
76 80 this.entitiesDeleteEnabled = false;
77 81
78 82 this.headerComponent = EdgeDownlinkTableHeaderComponent;
79   -
80 83 this.entityTranslations = {
81 84 noEntities: 'edge.no-downlinks-prompt'
82 85 };
83 86 this.entityResources = {} as EntityTypeResource<EdgeEvent>;
84 87 this.entitiesFetchFunction = pageLink => this.fetchEvents(pageLink);
85   -
86 88 this.defaultSortOrder = {property: 'createdTime', direction: Direction.DESC};
87 89
88 90 this.updateColumns();
... ... @@ -159,9 +161,6 @@ export class EdgeDownlinkTableConfig extends EntityTableConfig<EdgeEvent, TimePa
159 161
160 162 isEdgeEventHasData(edgeEventType: EdgeEventType) {
161 163 switch (edgeEventType) {
162   - case EdgeEventType.DEVICE_PROFILE:
163   - case EdgeEventType.WIDGETS_BUNDLE:
164   - case EdgeEventType.WIDGET_TYPE:
165 164 case EdgeEventType.ADMIN_SETTINGS:
166 165 return false;
167 166 default:
... ... @@ -182,21 +181,26 @@ export class EdgeDownlinkTableConfig extends EntityTableConfig<EdgeEvent, TimePa
182 181 case EdgeEventType.RULE_CHAIN:
183 182 case EdgeEventType.ALARM:
184 183 return this.entityService.getEntity(entity.type, entity.entityId, { ignoreLoading: true, ignoreErrors: true }).pipe(
185   - map((entity) => {
186   - return JSON.stringify(entity);
187   - })
  184 + map((entity) => JSON.stringify(entity))
188 185 );
189 186 case EdgeEventType.RELATION:
190 187 return of(JSON.stringify(entity.body));
191 188 case EdgeEventType.RULE_CHAIN_METADATA:
192   - return this.ruleChainService.getRuleChainMetadata(entity.entityId, null).pipe(
193   - map((ruleChainMetaData) => {
194   - return JSON.stringify(ruleChainMetaData.nodes);
195   - })
  189 + return this.ruleChainService.getRuleChainMetadata(entity.entityId).pipe(
  190 + map((ruleChainMetaData) => JSON.stringify(ruleChainMetaData.nodes))
196 191 );
197   - case EdgeEventType.DEVICE_PROFILE:
198   - case EdgeEventType.WIDGETS_BUNDLE:
199 192 case EdgeEventType.WIDGET_TYPE:
  193 + return this.widgetService.getWidgetTypeById(entity.entityId).pipe(
  194 + map((widgetType) => JSON.stringify(widgetType))
  195 + );
  196 + case EdgeEventType.WIDGETS_BUNDLE:
  197 + return this.widgetService.getWidgetsBundle(entity.entityId).pipe(
  198 + map((widgetBundles) => JSON.stringify(widgetBundles))
  199 + );
  200 + case EdgeEventType.DEVICE_PROFILE:
  201 + return this.deviceProfileService.getDeviceProfile(entity.entityId).pipe(
  202 + map((deviceProfile) => JSON.stringify(deviceProfile))
  203 + );
200 204 case EdgeEventType.ADMIN_SETTINGS:
201 205 return of(null);
202 206 }
... ...
... ... @@ -26,6 +26,8 @@ import { RuleChainService } from '@core/http/rule-chain.service';
26 26 import { AttributeService } from '@core/http/attribute.service';
27 27 import { EdgeService } from '@core/http/edge.service';
28 28 import { EntityService } from "@core/http/entity.service";
  29 +import { WidgetService } from "@core/http/widget.service";
  30 +import { DeviceProfileService } from "@core/http/device-profile.service";
29 31
30 32 @Component({
31 33 selector: 'tb-edge-downlink-table',
... ... @@ -34,9 +36,6 @@ import { EntityService } from "@core/http/entity.service";
34 36 })
35 37 export class EdgeDownlinkTableComponent implements OnInit {
36 38
37   - @Input()
38   - tenantId: string;
39   -
40 39 activeValue = false;
41 40 dirtyValue = false;
42 41 entityIdValue: EntityId;
... ... @@ -73,7 +72,9 @@ export class EdgeDownlinkTableComponent implements OnInit {
73 72 private dialogService: DialogService,
74 73 private translate: TranslateService,
75 74 private attributeService: AttributeService,
  75 + private deviceProfileService: DeviceProfileService,
76 76 private ruleChainService: RuleChainService,
  77 + private widgetService: WidgetService,
77 78 private datePipe: DatePipe,
78 79 private dialog: MatDialog) {
79 80 }
... ... @@ -82,15 +83,16 @@ export class EdgeDownlinkTableComponent implements OnInit {
82 83 this.dirtyValue = !this.activeValue;
83 84 this.edgeDownlinkTableConfig = new EdgeDownlinkTableConfig(
84 85 this.edgeService,
  86 + this.entityService,
85 87 this.dialogService,
86 88 this.translate,
87   - this.entityService,
88   - this.ruleChainService,
89 89 this.attributeService,
  90 + this.deviceProfileService,
  91 + this.ruleChainService,
  92 + this.widgetService,
90 93 this.datePipe,
91 94 this.dialog,
92   - this.entityIdValue,
93   - this.tenantId
  95 + this.entityIdValue
94 96 );
95 97 }
96 98
... ...