Commit 7fb88eca2045adaf4b132b4994e7107f032f2ef1

Authored by mdheer
1 parent 9b5ec2e5

added functionality that lets you specify the path to the desired custom logo from the settings menu

... ... @@ -120,6 +120,8 @@ import {
120 120 DisplayWidgetTypesPanelData,
121 121 WidgetTypes
122 122 } from '@home/components/dashboard-page/widget-types-panel.component';
  123 +import { LogoComponent } from '@app/shared/components/logo.component';
  124 +import { concat } from 'lodash';
123 125
124 126 // @dynamic
125 127 @Component({
... ... @@ -189,10 +191,10 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
189 191 currentDashboardScope: DashboardPageScope;
190 192
191 193 addingLayoutCtx: DashboardPageLayoutContext;
192   -
193   - dashboard_logo = 'assets/example_logo.png';
194   -
195 194
  195 + logo_name_local = 'example_logo.png';
  196 + dashboard_logo = 'assets/' + this.logo_name_local;
  197 +
196 198 dashboardCtx: DashboardContext = {
197 199 instanceId: this.utils.guid(),
198 200 getDashboard: () => this.dashboard,
... ... @@ -490,6 +492,11 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
490 492 return true;
491 493 }
492 494 }
  495 +
  496 + public updateLogoName(): string {
  497 + this.dashboard_logo = 'assets/' + this.dashboard.configuration.settings.logoName
  498 + return this.dashboard.configuration.settings.logoName;
  499 + }
493 500
494 501 public showRightLayoutSwitch(): boolean {
495 502 return this.isMobile && this.layouts.right.show;
... ... @@ -611,11 +618,16 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
611 618 panelClass: ['tb-dialog', 'tb-fullscreen-dialog'],
612 619 data: {
613 620 settings: deepClone(this.dashboard.configuration.settings),
614   - gridSettings
  621 + gridSettings,
615 622 }
616   - }).afterClosed().subscribe((data) => {
  623 + }
  624 + ).afterClosed().subscribe((data) => {
617 625 if (data) {
618 626 this.dashboard.configuration.settings = data.settings;
  627 + if (this.dashboard.configuration.settings)
  628 + {
  629 + this.updateLogoName();
  630 + }
619 631 const newGridSettings = data.gridSettings;
620 632 if (newGridSettings) {
621 633 const layout = this.dashboard.configuration.states[layoutKeys.state].layouts[layoutKeys.layout];
... ...
... ... @@ -51,6 +51,10 @@
51 51 openOnInput
52 52 formControlName="titleColor">
53 53 </tb-color-input>
  54 + <mat-form-field class="mat-block" fxFlex floatLabel="always">
  55 + <mat-label translate>dashboard.display-dashboard-enterLogoName</mat-label>
  56 + <input #searchInput matInput formControlName="logoName" placeholder="{{ 'dashboard.display-dashboard-exampleLogoName' | translate }}"/>
  57 + </mat-form-field>
54 58 </div>
55 59 <div fxLayout="row" fxLayoutAlign="start center" fxLayout.lt-md="column" fxLayoutAlign.lt-md fxLayoutGap="8px">
56 60 <mat-checkbox fxFlex formControlName="showDashboardLogo">
... ...
... ... @@ -34,6 +34,7 @@ export interface DashboardSettingsDialogData {
34 34 gridSettings?: GridSettings;
35 35 }
36 36
  37 +
37 38 @Component({
38 39 selector: 'tb-dashboard-settings-dialog',
39 40 templateUrl: './dashboard-settings-dialog.component.html',
... ... @@ -45,13 +46,16 @@ export class DashboardSettingsDialogComponent extends DialogComponent<DashboardS
45 46
46 47 settings: DashboardSettings;
47 48 gridSettings: GridSettings;
  49 + logo_name;
48 50
  51 +
49 52 settingsFormGroup: FormGroup;
50 53 gridSettingsFormGroup: FormGroup;
51 54
52 55 stateControllerIds: string[];
53 56
54 57 submitted = false;
  58 +
55 59
56 60 constructor(protected store: Store<AppState>,
57 61 protected router: Router,
... ... @@ -69,6 +73,7 @@ export class DashboardSettingsDialogComponent extends DialogComponent<DashboardS
69 73
70 74 this.settings = this.data.settings;
71 75 this.gridSettings = this.data.gridSettings;
  76 + this.logo_name = 'example_logo.png';
72 77
73 78 if (this.settings) {
74 79 this.settingsFormGroup = this.fb.group({
... ... @@ -80,6 +85,7 @@ export class DashboardSettingsDialogComponent extends DialogComponent<DashboardS
80 85 showEntitiesSelect: [isUndefined(this.settings.showEntitiesSelect) ? true : this.settings.showEntitiesSelect, []],
81 86 showFilters: [isUndefined(this.settings.showFilters) ? true : this.settings.showFilters, []],
82 87 showDashboardLogo: [isUndefined(this.settings.showDashboardLogo) ? true : this.settings.showDashboardLogo, []],
  88 + logoName: [isUndefined(this.settings.logoName) ? this.logo_name : this.settings.logoName, []],
83 89 showDashboardTimewindow: [isUndefined(this.settings.showDashboardTimewindow) ? true : this.settings.showDashboardTimewindow, []],
84 90 showDashboardExport: [isUndefined(this.settings.showDashboardExport) ? true : this.settings.showDashboardExport, []]
85 91 });
... ...
... ... @@ -87,6 +87,7 @@ export interface DashboardSettings {
87 87 showEntitiesSelect?: boolean;
88 88 showFilters?: boolean;
89 89 showDashboardLogo?: boolean;
  90 + logoName?: string;
90 91 showDashboardTimewindow?: boolean;
91 92 showDashboardExport?: boolean;
92 93 toolbarAlwaysOpen?: boolean;
... ...
... ... @@ -726,6 +726,8 @@
726 726 "display-dashboard-timewindow": "Display timewindow",
727 727 "display-dashboard-export": "Display export",
728 728 "display-dashboard-showDashboardLogo": "Display dashboard logo",
  729 + "display-dashboard-enterLogoName": "Enter logo filename (must be in assets folder)",
  730 + "display-dashboard-exampleLogoName": "example_logo.png",
729 731 "import": "Import dashboard",
730 732 "export": "Export dashboard",
731 733 "export-failed-error": "Unable to export dashboard: {{error}}",
... ...