UI: Refactoring dashboard logo

This commit is contained in:
Vladyslav_Prykhodko 2021-04-16 14:59:35 +03:00
parent f0413055b0
commit 9b2009a501
11 changed files with 39 additions and 79 deletions

View File

@ -46,26 +46,18 @@
<mat-icon>view_compact</mat-icon> <mat-icon>view_compact</mat-icon>
</button> </button>
</div> </div>
<tb-states-component fxFlex.lt-md
<div fxFlex.lt-md fxLayout="row" [statesControllerId]="isEdit ? 'default' : dashboardConfiguration.settings.stateControllerId"
fxLayoutAlign.gt-sm="start center" [dashboardCtrl]="this"
fxLayoutAlign="end center" fxLayoutGap="12px" class="db-logo-and-title" > [dashboardId]="(!embedded && dashboard.id) ? dashboard.id.id : ''"
[isMobile]="isMobile"
<img [fxShow]="showDashboardLogo() && isFullscreen" [src]="dashboard_logo" [state]="dashboardCtx.state"
aria-label="white_label_logo" class="whitelabel-logo-db"/> [currentState]="currentState"
[syncStateWithQueryParam]="syncStateWithQueryParam"
<tb-states-component fxFlex.lt-md [states]="dashboardConfiguration.states">
[statesControllerId]="isEdit ? 'default' : dashboardConfiguration.settings.stateControllerId" </tb-states-component>
[dashboardCtrl]="this" <img *ngIf="showDashboardLogo() && isFullscreen" [src]="dashboardLogo"
[dashboardId]="(!embedded && dashboard.id) ? dashboard.id.id : ''" aria-label="dashboard_logo" class="dashboard_logo"/>
[isMobile]="isMobile"
[state]="dashboardCtx.state"
[currentState]="currentState"
[syncStateWithQueryParam]="syncStateWithQueryParam"
[states]="dashboardConfiguration.states">
</tb-states-component>
</div>
</div> </div>
<div class="tb-dashboard-action-panel" fxFlex="1 0 auto" fxLayout="row-reverse" <div class="tb-dashboard-action-panel" fxFlex="1 0 auto" fxLayout="row-reverse"
fxLayoutAlign.gt-sm="start center" fxLayoutAlign="space-between center" fxLayoutGap="12px"> fxLayoutAlign.gt-sm="start center" fxLayoutAlign="space-between center" fxLayoutGap="12px">
@ -297,4 +289,4 @@
</mat-drawer> </mat-drawer>
</mat-drawer-container> </mat-drawer-container>
</section> </section>
</div> </div>

View File

@ -54,12 +54,9 @@ div.tb-dashboard-page {
z-index: 13; z-index: 13;
pointer-events: none; pointer-events: none;
.db-logo-and-title { .dashboard_logo{
height: $toolbar-height; height: 75%;
.whitelabel-logo-db{ margin-right: 16px;
height: 100%;
width: auto;
}
} }
&.tb-dashboard-toolbar-opened { &.tb-dashboard-toolbar-opened {
@ -71,9 +68,8 @@ div.tb-dashboard-page {
right: 18px; right: 18px;
transition: right .3s cubic-bezier(.55, 0, .55, .2) .2s; transition: right .3s cubic-bezier(.55, 0, .55, .2) .2s;
} }
}
}
.tb-dashboard-container { .tb-dashboard-container {
&.tb-dashboard-toolbar-opened { &.tb-dashboard-toolbar-opened {
&.is-fullscreen { &.is-fullscreen {

View File

@ -121,8 +121,6 @@ import {
DisplayWidgetTypesPanelData, DisplayWidgetTypesPanelData,
WidgetTypes WidgetTypes
} from '@home/components/dashboard-page/widget-types-panel.component'; } from '@home/components/dashboard-page/widget-types-panel.component';
import { LogoComponent } from '@app/shared/components/logo.component';
import { concat } from 'lodash';
import { DashboardWidgetSelectComponent } from '@home/components/dashboard-page/dashboard-widget-select.component'; import { DashboardWidgetSelectComponent } from '@home/components/dashboard-page/dashboard-widget-select.component';
// @dynamic // @dynamic
@ -192,9 +190,8 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
addingLayoutCtx: DashboardPageLayoutContext; addingLayoutCtx: DashboardPageLayoutContext;
logo_name_local = 'example_logo.png'; logo = 'assets/logo_title_white.svg';
dashboard_logo = 'assets/' + this.logo_name_local;
dashboardCtx: DashboardContext = { dashboardCtx: DashboardContext = {
instanceId: this.utils.guid(), instanceId: this.utils.guid(),
getDashboard: () => this.dashboard, getDashboard: () => this.dashboard,
@ -490,15 +487,14 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
isDefined(this.dashboard.configuration.settings.showDashboardLogo)) { isDefined(this.dashboard.configuration.settings.showDashboardLogo)) {
return this.dashboard.configuration.settings.showDashboardLogo; return this.dashboard.configuration.settings.showDashboardLogo;
} else { } else {
return true; return false;
} }
} }
public updateLogoName(): string { public get dashboardLogo(): string {
this.dashboard_logo = 'assets/' + this.dashboard.configuration.settings.logoName return this.dashboard.configuration.settings.dashboardLogoUrl || this.logo;
return this.dashboard.configuration.settings.logoName;
} }
public showRightLayoutSwitch(): boolean { public showRightLayoutSwitch(): boolean {
return this.isMobile && this.layouts.right.show; return this.isMobile && this.layouts.right.show;
} }
@ -621,14 +617,9 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
settings: deepClone(this.dashboard.configuration.settings), settings: deepClone(this.dashboard.configuration.settings),
gridSettings, gridSettings,
} }
} }).afterClosed().subscribe((data) => {
).afterClosed().subscribe((data) => {
if (data) { if (data) {
this.dashboard.configuration.settings = data.settings; this.dashboard.configuration.settings = data.settings;
if (this.dashboard.configuration.settings)
{
this.updateLogoName();
}
const newGridSettings = data.gridSettings; const newGridSettings = data.gridSettings;
if (newGridSettings) { if (newGridSettings) {
const layout = this.dashboard.configuration.states[layoutKeys.state].layouts[layoutKeys.layout]; const layout = this.dashboard.configuration.states[layoutKeys.state].layouts[layoutKeys.layout];

View File

@ -51,15 +51,9 @@
openOnInput openOnInput
formControlName="titleColor"> formControlName="titleColor">
</tb-color-input> </tb-color-input>
<mat-form-field class="mat-block" fxFlex floatLabel="always">
<mat-label translate>dashboard.display-dashboard-enterLogoName</mat-label>
<input #searchInput matInput formControlName="logoName" placeholder="{{ 'dashboard.display-dashboard-exampleLogoName' | translate }}"/>
</mat-form-field>
</div> </div>
<div fxLayout="row" fxLayoutAlign="start center" fxLayout.lt-md="column" fxLayoutAlign.lt-md fxLayoutGap="8px"> <div fxLayout="row" fxLayoutAlign="start center" style="margin-bottom: 8px;"
<mat-checkbox fxFlex formControlName="showDashboardLogo"> fxLayout.lt-md="column" fxLayoutAlign.lt-md fxLayoutGap="8px">
{{ 'dashboard.display-dashboard-showDashboardLogo' | translate }}
</mat-checkbox>
<mat-checkbox fxFlex formControlName="showDashboardsSelect"> <mat-checkbox fxFlex formControlName="showDashboardsSelect">
{{ 'dashboard.display-dashboards-selection' | translate }} {{ 'dashboard.display-dashboards-selection' | translate }}
</mat-checkbox> </mat-checkbox>
@ -76,6 +70,13 @@
{{ 'dashboard.display-dashboard-export' | translate }} {{ 'dashboard.display-dashboard-export' | translate }}
</mat-checkbox> </mat-checkbox>
</div> </div>
<mat-checkbox formControlName="showDashboardLogo">
{{ 'dashboard.display-dashboard-toolbar-logo' | translate }}
</mat-checkbox>
<tb-image-input fxFlex *ngIf="settingsFormGroup.get('showDashboardLogo').value"
label="{{'dashboard.dashboard-logo-image' | translate}}"
formControlName="dashboardLogoUrl">
</tb-image-input>
</div> </div>
<div *ngIf="gridSettings" [formGroup]="gridSettingsFormGroup"> <div *ngIf="gridSettings" [formGroup]="gridSettingsFormGroup">
<tb-color-input fxFlex <tb-color-input fxFlex

View File

@ -34,7 +34,6 @@ export interface DashboardSettingsDialogData {
gridSettings?: GridSettings; gridSettings?: GridSettings;
} }
@Component({ @Component({
selector: 'tb-dashboard-settings-dialog', selector: 'tb-dashboard-settings-dialog',
templateUrl: './dashboard-settings-dialog.component.html', templateUrl: './dashboard-settings-dialog.component.html',
@ -46,16 +45,13 @@ export class DashboardSettingsDialogComponent extends DialogComponent<DashboardS
settings: DashboardSettings; settings: DashboardSettings;
gridSettings: GridSettings; gridSettings: GridSettings;
logo_name;
settingsFormGroup: FormGroup; settingsFormGroup: FormGroup;
gridSettingsFormGroup: FormGroup; gridSettingsFormGroup: FormGroup;
stateControllerIds: string[]; stateControllerIds: string[];
submitted = false; submitted = false;
constructor(protected store: Store<AppState>, constructor(protected store: Store<AppState>,
protected router: Router, protected router: Router,
@ -73,7 +69,6 @@ export class DashboardSettingsDialogComponent extends DialogComponent<DashboardS
this.settings = this.data.settings; this.settings = this.data.settings;
this.gridSettings = this.data.gridSettings; this.gridSettings = this.data.gridSettings;
this.logo_name = 'example_logo.png';
if (this.settings) { if (this.settings) {
this.settingsFormGroup = this.fb.group({ this.settingsFormGroup = this.fb.group({
@ -84,8 +79,8 @@ export class DashboardSettingsDialogComponent extends DialogComponent<DashboardS
showDashboardsSelect: [isUndefined(this.settings.showDashboardsSelect) ? true : this.settings.showDashboardsSelect, []], showDashboardsSelect: [isUndefined(this.settings.showDashboardsSelect) ? true : this.settings.showDashboardsSelect, []],
showEntitiesSelect: [isUndefined(this.settings.showEntitiesSelect) ? true : this.settings.showEntitiesSelect, []], showEntitiesSelect: [isUndefined(this.settings.showEntitiesSelect) ? true : this.settings.showEntitiesSelect, []],
showFilters: [isUndefined(this.settings.showFilters) ? true : this.settings.showFilters, []], showFilters: [isUndefined(this.settings.showFilters) ? true : this.settings.showFilters, []],
showDashboardLogo: [isUndefined(this.settings.showDashboardLogo) ? true : this.settings.showDashboardLogo, []], showDashboardLogo: [isUndefined(this.settings.showDashboardLogo) ? false : this.settings.showDashboardLogo, []],
logoName: [isUndefined(this.settings.logoName) ? this.logo_name : this.settings.logoName, []], dashboardLogoUrl: [isUndefined(this.settings.dashboardLogoUrl) ? null : this.settings.dashboardLogoUrl, []],
showDashboardTimewindow: [isUndefined(this.settings.showDashboardTimewindow) ? true : this.settings.showDashboardTimewindow, []], showDashboardTimewindow: [isUndefined(this.settings.showDashboardTimewindow) ? true : this.settings.showDashboardTimewindow, []],
showDashboardExport: [isUndefined(this.settings.showDashboardExport) ? true : this.settings.showDashboardExport, []] showDashboardExport: [isUndefined(this.settings.showDashboardExport) ? true : this.settings.showDashboardExport, []]
}); });

View File

@ -76,18 +76,6 @@ tb-dashboard-toolbar {
height: $mobile-toolbar-height; height: $mobile-toolbar-height;
min-height: $mobile-toolbar-height; min-height: $mobile-toolbar-height;
} }
& > div {
height: $toolbar-height;
.whitelabel-logo-db {
width: auto;
max-width: 100%;
height: 30px;
max-height: 100%;
margin-left: 20px;
margin-top: 5px;
margin-right: 30px;
}
}
@media #{$mat-gt-sm} { @media #{$mat-gt-sm} {
height: $toolbar-height; height: $toolbar-height;

View File

@ -43,6 +43,4 @@ export class DashboardToolbarComponent implements OnInit {
this.triggerClick.emit(); this.triggerClick.emit();
} }
white_label_logo = 'assets/white_label_logo.png';
} }

View File

@ -86,8 +86,8 @@ export interface DashboardSettings {
showDashboardsSelect?: boolean; showDashboardsSelect?: boolean;
showEntitiesSelect?: boolean; showEntitiesSelect?: boolean;
showFilters?: boolean; showFilters?: boolean;
showDashboardLogo?: boolean; showDashboardLogo?: boolean;
logoName?: string; dashboardLogoUrl?: string;
showDashboardTimewindow?: boolean; showDashboardTimewindow?: boolean;
showDashboardExport?: boolean; showDashboardExport?: boolean;
toolbarAlwaysOpen?: boolean; toolbarAlwaysOpen?: boolean;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

View File

@ -725,9 +725,8 @@
"display-filters": "Display filters", "display-filters": "Display filters",
"display-dashboard-timewindow": "Display timewindow", "display-dashboard-timewindow": "Display timewindow",
"display-dashboard-export": "Display export", "display-dashboard-export": "Display export",
"display-dashboard-showDashboardLogo": "Display dashboard logo", "display-dashboard-toolbar-logo": "Display dashboard logo in fullscreen mode",
"display-dashboard-enterLogoName": "Enter logo filename (must be in assets folder)", "dashboard-logo-image": "Dashboard image logo",
"display-dashboard-exampleLogoName": "example_logo.png",
"import": "Import dashboard", "import": "Import dashboard",
"export": "Export dashboard", "export": "Export dashboard",
"export-failed-error": "Unable to export dashboard: {{error}}", "export-failed-error": "Unable to export dashboard: {{error}}",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB