Commit 62e17ffd48ee3ef75d844174312f2c708dea5fbc

Authored by Ekaterina Chantsova
1 parent 838d6982

Save translated title as variable

@@ -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()">{{ utils.customTranslation(dashboard.title, 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;
@@ -303,7 +305,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC @@ -303,7 +305,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
303 private breakpointObserver: BreakpointObserver, 305 private breakpointObserver: BreakpointObserver,
304 private route: ActivatedRoute, 306 private route: ActivatedRoute,
305 private router: Router, 307 private router: Router,
306 - public utils: UtilsService, 308 + private utils: UtilsService,
307 private dashboardUtils: DashboardUtilsService, 309 private dashboardUtils: DashboardUtilsService,
308 private authService: AuthService, 310 private authService: AuthService,
309 private entityService: EntityService, 311 private entityService: EntityService,
@@ -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 }