Commit 18a3039bdd6f4bec45d26875af37032fa7260a0d

Authored by Igor Kulikov
Committed by GitHub
2 parents 2eeb6d43 62e17ffd

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

[3.3.2] UI: make dashboard title translatable when 'Display dashboard title' option enabled
@@ -148,7 +148,7 @@ @@ -148,7 +148,7 @@
148 <mat-drawer-content fxLayout="column" fxLayoutAlign="center start"> 148 <mat-drawer-content fxLayout="column" fxLayoutAlign="center start">
149 <section *ngIf="!widgetEditMode" class="tb-dashboard-title" 149 <section *ngIf="!widgetEditMode" class="tb-dashboard-title"
150 [ngStyle]="{'color': dashboard.configuration.settings.titleColor}"> 150 [ngStyle]="{'color': dashboard.configuration.settings.titleColor}">
151 - <h3 [fxShow]="!isEdit && displayTitle()">{{ dashboard.title }}</h3> 151 + <h3 [fxShow]="!isEdit && displayTitle()">{{ translatedDashboardTitle }}</h3>
152 <mat-form-field [fxShow]="isEdit" class="mat-block"> 152 <mat-form-field [fxShow]="isEdit" class="mat-block">
153 <mat-label translate [ngStyle]="{'color': dashboard.configuration.settings.titleColor}">dashboard.title</mat-label> 153 <mat-label translate [ngStyle]="{'color': dashboard.configuration.settings.titleColor}">dashboard.title</mat-label>
154 <input matInput class="tb-dashboard-title" 154 <input matInput class="tb-dashboard-title"
@@ -209,6 +209,8 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC @@ -209,6 +209,8 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
209 209
210 thingsboardVersion: string = env.tbVersion; 210 thingsboardVersion: string = env.tbVersion;
211 211
  212 + translatedDashboardTitle: string;
  213 +
212 currentDashboardId: string; 214 currentDashboardId: string;
213 currentCustomerId: string; 215 currentCustomerId: string;
214 currentDashboardScope: DashboardPageScope; 216 currentDashboardScope: DashboardPageScope;
@@ -375,6 +377,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC @@ -375,6 +377,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
375 this.reset(); 377 this.reset();
376 378
377 this.dashboard = data.dashboard; 379 this.dashboard = data.dashboard;
  380 + this.translatedDashboardTitle = this.getTranslatedDashboardTitle();
378 if (!this.embedded && this.dashboard.id) { 381 if (!this.embedded && this.dashboard.id) {
379 this.setStateDashboardId = true; 382 this.setStateDashboardId = true;
380 } 383 }
@@ -424,6 +427,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC @@ -424,6 +427,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
424 427
425 private reset() { 428 private reset() {
426 this.dashboard = null; 429 this.dashboard = null;
  430 + this.translatedDashboardTitle = null;
427 this.dashboardConfiguration = null; 431 this.dashboardConfiguration = null;
428 this.dashboardLogoCache = undefined; 432 this.dashboardLogoCache = undefined;
429 this.prevDashboard = null; 433 this.prevDashboard = null;
@@ -520,6 +524,10 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC @@ -520,6 +524,10 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
520 } 524 }
521 } 525 }
522 526
  527 + private getTranslatedDashboardTitle(): string {
  528 + return this.utils.customTranslation(this.dashboard.title, this.dashboard.title);
  529 + }
  530 +
523 public displayExport(): boolean { 531 public displayExport(): boolean {
524 if (this.dashboard.configuration.settings && 532 if (this.dashboard.configuration.settings &&
525 isDefined(this.dashboard.configuration.settings.showDashboardExport)) { 533 isDefined(this.dashboard.configuration.settings.showDashboardExport)) {
@@ -817,6 +825,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC @@ -817,6 +825,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
817 } 825 }
818 826
819 public saveDashboard() { 827 public saveDashboard() {
  828 + this.translatedDashboardTitle = this.getTranslatedDashboardTitle();
820 this.setEditMode(false, false); 829 this.setEditMode(false, false);
821 this.notifyDashboardUpdated(); 830 this.notifyDashboardUpdated();
822 } 831 }