Browse Source

fixes

pull/8337/head
Maksym Dudnik 3 years ago
parent
commit
3765209600
  1. 4
      ui-ngx/src/app/shared/components/device/gateway-statistics.component.html
  2. 22
      ui-ngx/src/app/shared/components/device/gateway-statistics.component.ts

4
ui-ngx/src/app/shared/components/device/gateway-statistics.component.html

@ -24,8 +24,8 @@
<mat-option *ngFor="let key of statisticsKeys" [value]="key"> <mat-option *ngFor="let key of statisticsKeys" [value]="key">
{{key}} {{key}}
</mat-option> </mat-option>
<mat-option *ngFor="let command of commands" [value]="command.attributeName"> <mat-option *ngFor="let command of commands" [value]="command.attributeOnGateway">
{{command.attributeName}} {{command.attributeOnGateway}}
</mat-option> </mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>

22
ui-ngx/src/app/shared/components/device/gateway-statistics.component.ts

@ -67,10 +67,10 @@ export class GatewayStatisticsComponent extends PageComponent implements AfterVi
statisticKey: [null, []] statisticKey: [null, []]
}) })
this.statisticForm.get('statisticKey').valueChanges.subscribe(value=>{ this.statisticForm.get('statisticKey').valueChanges.subscribe(value => {
this.commandObj = null; this.commandObj = null;
if (this.commands.length) { if (this.commands.length) {
this.commandObj = this.commands.find(command=>command.attributeOnGateway === value); this.commandObj = this.commands.find(command => command.attributeOnGateway === value);
} }
this.changeSubscription(true); this.changeSubscription(true);
}) })
@ -80,10 +80,10 @@ export class GatewayStatisticsComponent extends PageComponent implements AfterVi
ngAfterViewInit() { ngAfterViewInit() {
if (this.ctx.defaultSubscription.datasources.length) { if (this.ctx.defaultSubscription.datasources.length) {
const gatewayId = this.ctx.defaultSubscription.datasources[0].entity.id; const gatewayId = this.ctx.defaultSubscription.datasources[0].entity.id;
this.attributeService.getEntityAttributes(gatewayId, AttributeScope.SHARED_SCOPE, ["configuration"]).subscribe(resp=>{ this.attributeService.getEntityAttributes(gatewayId, AttributeScope.SHARED_SCOPE, ["general_configuration"]).subscribe(resp => {
if (resp && resp.length) { if (resp && resp.length) {
this.commands = resp[0].value.thingsboard.thingsboard.statistics.commands; this.commands = resp[0].value.statistics.commands;
if (!this.statisticForm.get('statisticKey').value ) { if (!this.statisticForm.get('statisticKey').value) {
this.statisticForm.get('statisticKey').setValue(this.commands[0].attributeOnGateway); this.statisticForm.get('statisticKey').setValue(this.commands[0].attributeOnGateway);
this.changeSubscription(true); this.changeSubscription(true);
} }
@ -126,7 +126,7 @@ export class GatewayStatisticsComponent extends PageComponent implements AfterVi
changeSubscription(init?: boolean) { changeSubscription(init?: boolean) {
if (this.ctx.datasources[0].entity) { if (this.ctx.datasources[0].entity) {
if (this.flot && init) { if (this.flot && init) {
this.flot.destroy(); this.flot.destroy();
delete this.flot; delete this.flot;
} }
@ -138,10 +138,14 @@ export class GatewayStatisticsComponent extends PageComponent implements AfterVi
}]; }];
this.ctx.defaultSubscription.unsubscribe(); this.ctx.defaultSubscription.unsubscribe();
this.ctx.defaultSubscription.updateDataSubscriptions(); this.ctx.defaultSubscription.updateDataSubscriptions();
if (init) this.initChart(); this.ctx.defaultSubscription.options.callbacks.dataLoading = () => {
this.ctx.defaultSubscription.options.callbacks.dataLoading = ()=>{}; };
this.ctx.defaultSubscription.callbacks.onDataUpdated = () => { this.ctx.defaultSubscription.callbacks.onDataUpdated = () => {
this.updateChart(); if (init) {
this.initChart();
} else {
this.updateChart();
}
} }
this.cd.detectChanges(); this.cd.detectChanges();
} }

Loading…
Cancel
Save