Merge pull request #5345 from ChantsovaEkaterina/improvement/translatable-dashboard-title

[3.3.2] UI: make dashboard title translatable when 'Display dashboard title' option enabled
This commit is contained in:
Igor Kulikov 2021-10-27 15:47:12 +03:00 committed by GitHub
commit 18a3039bdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -148,7 +148,7 @@
<mat-drawer-content fxLayout="column" fxLayoutAlign="center start">
<section *ngIf="!widgetEditMode" class="tb-dashboard-title"
[ngStyle]="{'color': dashboard.configuration.settings.titleColor}">
<h3 [fxShow]="!isEdit && displayTitle()">{{ dashboard.title }}</h3>
<h3 [fxShow]="!isEdit && displayTitle()">{{ translatedDashboardTitle }}</h3>
<mat-form-field [fxShow]="isEdit" class="mat-block">
<mat-label translate [ngStyle]="{'color': dashboard.configuration.settings.titleColor}">dashboard.title</mat-label>
<input matInput class="tb-dashboard-title"

View File

@ -209,6 +209,8 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
thingsboardVersion: string = env.tbVersion;
translatedDashboardTitle: string;
currentDashboardId: string;
currentCustomerId: string;
currentDashboardScope: DashboardPageScope;
@ -375,6 +377,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
this.reset();
this.dashboard = data.dashboard;
this.translatedDashboardTitle = this.getTranslatedDashboardTitle();
if (!this.embedded && this.dashboard.id) {
this.setStateDashboardId = true;
}
@ -424,6 +427,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
private reset() {
this.dashboard = null;
this.translatedDashboardTitle = null;
this.dashboardConfiguration = null;
this.dashboardLogoCache = undefined;
this.prevDashboard = null;
@ -520,6 +524,10 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
}
}
private getTranslatedDashboardTitle(): string {
return this.utils.customTranslation(this.dashboard.title, this.dashboard.title);
}
public displayExport(): boolean {
if (this.dashboard.configuration.settings &&
isDefined(this.dashboard.configuration.settings.showDashboardExport)) {
@ -817,6 +825,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
}
public saveDashboard() {
this.translatedDashboardTitle = this.getTranslatedDashboardTitle();
this.setEditMode(false, false);
this.notifyDashboardUpdated();
}