Browse Source

Added connector name in connector logs

pull/11149/head
mpetrov 2 years ago
parent
commit
eb2edc28ab
  1. 2
      application/src/main/data/json/tenant/dashboards/gateways.json
  2. 21
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-logs.component.ts

2
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,

21
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<GatewayLogData>([]);
}
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]) {

Loading…
Cancel
Save