From eb2edc28ab862f7c493dc18d681c9b0b34e4c69f Mon Sep 17 00:00:00 2001 From: mpetrov Date: Thu, 4 Jul 2024 11:41:23 +0300 Subject: [PATCH 1/5] Added connector name in connector logs --- .../data/json/tenant/dashboards/gateways.json | 2 +- .../lib/gateway/gateway-logs.component.ts | 21 +++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/application/src/main/data/json/tenant/dashboards/gateways.json b/application/src/main/data/json/tenant/dashboards/gateways.json index 11813ae878..288b5ba858 100644 --- a/application/src/main/data/json/tenant/dashboards/gateways.json +++ b/application/src/main/data/json/tenant/dashboards/gateways.json @@ -880,7 +880,7 @@ "isConnectorLog": true, "connectorLogState": "connector_logs" }, - "title": "${entityName} Logs", + "title": "${connectorName} Logs", "showTitleIcon": false, "dropShadow": true, "enableFullscreen": true, diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-logs.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-logs.component.ts index d029279c2b..dbdf0a4048 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-logs.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-logs.component.ts @@ -14,7 +14,7 @@ /// limitations under the License. /// -import { AfterViewInit, Component, ElementRef, Input, ViewChild } from '@angular/core'; +import { AfterViewInit, Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core'; import { MatDialogRef } from '@angular/material/dialog'; import { DataKeyType } from '@shared/models/telemetry/telemetry.models'; import { PageLink } from '@shared/models/page/page-link'; @@ -30,7 +30,7 @@ import { GatewayLogData, GatewayStatus, LogLink } from './gateway-widget.models' templateUrl: './gateway-logs.component.html', styleUrls: ['./gateway-logs.component.scss'] }) -export class GatewayLogsComponent implements AfterViewInit { +export class GatewayLogsComponent implements OnInit, AfterViewInit { pageLink: PageLink; @@ -81,6 +81,10 @@ export class GatewayLogsComponent implements AfterViewInit { this.dataSource = new MatTableDataSource([]); } + ngOnInit(): void { + this.updateWidgetTitle(); + } + ngAfterViewInit() { this.dataSource.sort = this.sort; this.dataSource.paginator = this.paginator; @@ -107,6 +111,19 @@ export class GatewayLogsComponent implements AfterViewInit { this.changeSubscription(); } + private updateWidgetTitle(): void { + const titlePlaceholder = '${connectorName}'; + if (this.ctx.settings.isConnectorLog && this.ctx.settings.connectorLogState) { + const connector = this.ctx.stateController.getStateParams()[this.ctx.settings.connectorLogState]; + const widgetTitle = this.ctx['widget'].config.title; + if (widgetTitle.includes(titlePlaceholder)) { + this.ctx.widgetTitle = widgetTitle.replace(titlePlaceholder, connector.key); + } else { + this.ctx.widgetTitle = widgetTitle; + } + } + } + private updateData() { if (this.ctx.defaultSubscription.data.length && this.ctx.defaultSubscription.data[0]) { From 6efe46a2495a1ca44068618e61260a60f8afd762 Mon Sep 17 00:00:00 2001 From: mpetrov Date: Thu, 4 Jul 2024 11:45:29 +0300 Subject: [PATCH 2/5] refactoring --- .../components/widget/lib/gateway/gateway-logs.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-logs.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-logs.component.ts index dbdf0a4048..7ce8cc7d72 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-logs.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-logs.component.ts @@ -114,9 +114,9 @@ export class GatewayLogsComponent implements OnInit, AfterViewInit { private updateWidgetTitle(): void { const titlePlaceholder = '${connectorName}'; if (this.ctx.settings.isConnectorLog && this.ctx.settings.connectorLogState) { - const connector = this.ctx.stateController.getStateParams()[this.ctx.settings.connectorLogState]; const widgetTitle = this.ctx['widget'].config.title; if (widgetTitle.includes(titlePlaceholder)) { + const connector = this.ctx.stateController.getStateParams()[this.ctx.settings.connectorLogState]; this.ctx.widgetTitle = widgetTitle.replace(titlePlaceholder, connector.key); } else { this.ctx.widgetTitle = widgetTitle; From 39db38051aba16670b0a071e442ff82c53cfcf0c Mon Sep 17 00:00:00 2001 From: mpetrov Date: Thu, 4 Jul 2024 12:01:25 +0300 Subject: [PATCH 3/5] refactoring --- .../components/widget/lib/gateway/gateway-logs.component.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-logs.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-logs.component.ts index 7ce8cc7d72..bb3445ad62 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-logs.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-logs.component.ts @@ -112,14 +112,12 @@ export class GatewayLogsComponent implements OnInit, AfterViewInit { } private updateWidgetTitle(): void { - const titlePlaceholder = '${connectorName}'; if (this.ctx.settings.isConnectorLog && this.ctx.settings.connectorLogState) { const widgetTitle = this.ctx['widget'].config.title; + const titlePlaceholder = '${connectorName}'; if (widgetTitle.includes(titlePlaceholder)) { const connector = this.ctx.stateController.getStateParams()[this.ctx.settings.connectorLogState]; this.ctx.widgetTitle = widgetTitle.replace(titlePlaceholder, connector.key); - } else { - this.ctx.widgetTitle = widgetTitle; } } } From 2f9adab2973ca136d85cb034e50816e4c6d879a4 Mon Sep 17 00:00:00 2001 From: Max Petrov <93397261+maxunbearable@users.noreply.github.com> Date: Thu, 4 Jul 2024 12:44:17 +0300 Subject: [PATCH 4/5] Update ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-logs.component.ts Co-authored-by: Vladyslav Prykhodko --- .../components/widget/lib/gateway/gateway-logs.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-logs.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-logs.component.ts index bb3445ad62..5fba27f86c 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-logs.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-logs.component.ts @@ -113,7 +113,7 @@ export class GatewayLogsComponent implements OnInit, AfterViewInit { private updateWidgetTitle(): void { if (this.ctx.settings.isConnectorLog && this.ctx.settings.connectorLogState) { - const widgetTitle = this.ctx['widget'].config.title; + const widgetTitle = this.ctx.widgetConfig.title; const titlePlaceholder = '${connectorName}'; if (widgetTitle.includes(titlePlaceholder)) { const connector = this.ctx.stateController.getStateParams()[this.ctx.settings.connectorLogState]; From c3c8a44862dabccfa278bd58713d758b98c1b3a5 Mon Sep 17 00:00:00 2001 From: Max Petrov <93397261+maxunbearable@users.noreply.github.com> Date: Thu, 4 Jul 2024 12:44:30 +0300 Subject: [PATCH 5/5] Update application/src/main/data/json/tenant/dashboards/gateways.json Co-authored-by: Vladyslav Prykhodko --- application/src/main/data/json/tenant/dashboards/gateways.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/src/main/data/json/tenant/dashboards/gateways.json b/application/src/main/data/json/tenant/dashboards/gateways.json index 288b5ba858..25c3c05a3d 100644 --- a/application/src/main/data/json/tenant/dashboards/gateways.json +++ b/application/src/main/data/json/tenant/dashboards/gateways.json @@ -880,7 +880,7 @@ "isConnectorLog": true, "connectorLogState": "connector_logs" }, - "title": "${connectorName} Logs", + "title": "${connectorName} logs", "showTitleIcon": false, "dropShadow": true, "enableFullscreen": true,