From 17016e4bbffdb06416b8955349f298c60c00576c Mon Sep 17 00:00:00 2001 From: Maksym Dudnik Date: Wed, 24 May 2023 11:49:29 +0300 Subject: [PATCH] fixes --- .../components/device/gateway-logs.component.ts | 16 +++++++++++++--- .../device/gateway-statistics.component.ts | 6 +++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ui-ngx/src/app/shared/components/device/gateway-logs.component.ts b/ui-ngx/src/app/shared/components/device/gateway-logs.component.ts index 0bb262b3d0..e3b1befbfb 100644 --- a/ui-ngx/src/app/shared/components/device/gateway-logs.component.ts +++ b/ui-ngx/src/app/shared/components/device/gateway-logs.component.ts @@ -167,13 +167,22 @@ export class GatewayLogsComponent extends PageComponent implements AfterViewInit updateData(sort?) { if (this.ctx.defaultSubscription.data.length) { + console.log(this.ctx.defaultSubscription.data[0].dataKey.name === "LOGS") let attrData = this.ctx.defaultSubscription.data[0].data.map(data => { - return { + let result = { ts: data[0], key: this.activeLink.key, - status: data[1].match(/\|(\w+)\|/)? data[1].match(/\|(\w+)\|/)[1] : "", - message: /\[(.*)/.exec(data[1])[0] + message: /\[(.*)/.exec(data[1])[0], + status: 'INVALID LOG FORMAT' }; + + try { + result.status= data[1].match(/\|(\w+)\|/)[1]; + } catch (e) { + result.status = 'INVALID LOG FORMAT' + } + + return result; }); if (this.activeLink.filterFn) { attrData = attrData.filter(data => this.activeLink.filterFn(data)); @@ -202,6 +211,7 @@ export class GatewayLogsComponent extends PageComponent implements AfterViewInit case GatewayLogLevel.info: default: return "status status-info" + return "status status-info" } } diff --git a/ui-ngx/src/app/shared/components/device/gateway-statistics.component.ts b/ui-ngx/src/app/shared/components/device/gateway-statistics.component.ts index acba210e28..b375273f88 100644 --- a/ui-ngx/src/app/shared/components/device/gateway-statistics.component.ts +++ b/ui-ngx/src/app/shared/components/device/gateway-statistics.component.ts @@ -64,7 +64,7 @@ export class GatewayStatisticsComponent extends PageComponent implements AfterVi public dialog: MatDialog) { super(store); this.statisticForm = this.fb.group({ - statisticKey: [this.statisticsKeys[0], []] + statisticKey: [null, []] }) this.statisticForm.get('statisticKey').valueChanges.subscribe(value=>{ @@ -126,7 +126,7 @@ export class GatewayStatisticsComponent extends PageComponent implements AfterVi changeSubscription(init?: boolean) { if (this.ctx.datasources[0].entity) { - if (this.flot) { + if (this.flot && init) { this.flot.destroy(); delete this.flot; } @@ -143,7 +143,7 @@ export class GatewayStatisticsComponent extends PageComponent implements AfterVi this.ctx.defaultSubscription.callbacks.onDataUpdated = () => { this.updateChart(); } - + this.cd.detectChanges(); } }