From eb2edc28ab862f7c493dc18d681c9b0b34e4c69f Mon Sep 17 00:00:00 2001 From: mpetrov Date: Thu, 4 Jul 2024 11:41:23 +0300 Subject: [PATCH] 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]) {