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