Browse Source

Add hide dashboard toolbar settings. Improve dashboard setting dialog. Handle dashboard right layout toggle in mobile app.

pull/4691/head
Igor Kulikov 5 years ago
parent
commit
0b256a1d2c
  1. 1
      ui-ngx/src/app/core/services/dashboard-utils.service.ts
  2. 25
      ui-ngx/src/app/core/services/mobile.service.ts
  3. 39
      ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts
  4. 194
      ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-settings-dialog.component.html
  5. 12
      ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-settings-dialog.component.scss
  6. 96
      ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-settings-dialog.component.ts
  7. 1
      ui-ngx/src/app/modules/home/components/dashboard-page/layout/dashboard-layout.component.html
  8. 2
      ui-ngx/src/app/shared/components/color-input.component.html
  9. 2
      ui-ngx/src/app/shared/models/dashboard.models.ts
  10. 2
      ui-ngx/src/app/shared/models/window-message.model.ts
  11. 7
      ui-ngx/src/assets/locale/locale.constant-en_US.json

1
ui-ngx/src/app/core/services/dashboard-utils.service.ts

@ -231,7 +231,6 @@ export class DashboardUtilsService {
private createDefaultGridSettings(): GridSettings { private createDefaultGridSettings(): GridSettings {
return { return {
backgroundColor: '#eeeeee', backgroundColor: '#eeeeee',
color: 'rgba(0,0,0,0.870588)',
columns: 24, columns: 24,
margin: 10, margin: 10,
backgroundSizeMode: '100%' backgroundSizeMode: '100%'

25
ui-ngx/src/app/core/services/mobile.service.ts

@ -27,6 +27,7 @@ import { AuthService } from '@core/auth/auth.service';
const dashboardStateNameHandler = 'tbMobileDashboardStateNameHandler'; const dashboardStateNameHandler = 'tbMobileDashboardStateNameHandler';
const dashboardLoadedHandler = 'tbMobileDashboardLoadedHandler'; const dashboardLoadedHandler = 'tbMobileDashboardLoadedHandler';
const dashboardLayoutHandler = 'tbMobileDashboardLayoutHandler';
const navigationHandler = 'tbMobileNavigationHandler'; const navigationHandler = 'tbMobileNavigationHandler';
const mobileHandler = 'tbMobileHandler'; const mobileHandler = 'tbMobileHandler';
@ -43,6 +44,7 @@ export class MobileService {
private reloadUserObservable: Observable<boolean>; private reloadUserObservable: Observable<boolean>;
private lastDashboardId: string; private lastDashboardId: string;
private toggleLayoutFunction: () => void;
constructor(@Inject(WINDOW) private window: Window, constructor(@Inject(WINDOW) private window: Window,
private router: Router, private router: Router,
@ -65,12 +67,26 @@ export class MobileService {
} }
} }
public onDashboardLoaded() { public onDashboardLoaded(hasRightLayout: boolean, rightLayoutOpened: boolean) {
if (this.mobileApp) { if (this.mobileApp) {
this.mobileChannel.callHandler(dashboardLoadedHandler); this.mobileChannel.callHandler(dashboardLoadedHandler, hasRightLayout, rightLayoutOpened);
} }
} }
public onDashboardRightLayoutChanged(opened: boolean) {
if (this.mobileApp) {
this.mobileChannel.callHandler(dashboardLayoutHandler, opened);
}
}
public registerToggleLayoutFunction(toggleLayoutFunction: () => void) {
this.toggleLayoutFunction = toggleLayoutFunction;
}
public unregisterToggleLayoutFunction() {
this.toggleLayoutFunction = null;
}
public handleWidgetMobileAction<T extends MobileActionResult>(type: WidgetMobileActionType, ...args: any[]): public handleWidgetMobileAction<T extends MobileActionResult>(type: WidgetMobileActionType, ...args: any[]):
Observable<WidgetMobileActionResult<T>> { Observable<WidgetMobileActionResult<T>> {
if (this.mobileApp) { if (this.mobileApp) {
@ -110,6 +126,11 @@ export class MobileService {
const reloadUserMessage: ReloadUserMessage = message.data; const reloadUserMessage: ReloadUserMessage = message.data;
this.reloadUser(reloadUserMessage); this.reloadUser(reloadUserMessage);
break; break;
case 'toggleDashboardLayout':
if (this.toggleLayoutFunction) {
this.toggleLayoutFunction();
}
break;
} }
} }
} }

39
ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts

@ -149,8 +149,16 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
@Input() @Input()
currentState: string; currentState: string;
private hideToolbarValue = false;
@Input() @Input()
hideToolbar: boolean; set hideToolbar(hideToolbar: boolean) {
this.hideToolbarValue = hideToolbar;
}
get hideToolbar(): boolean {
return (this.hideToolbarValue || this.hideToolbarSetting()) && !this.isEdit;
}
@Input() @Input()
syncStateWithQueryParam = true; syncStateWithQueryParam = true;
@ -269,6 +277,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
return !this.widgetEditMode && !this.hideToolbar && return !this.widgetEditMode && !this.hideToolbar &&
(this.toolbarAlwaysOpen() || this.isToolbarOpened || this.isEdit || this.showRightLayoutSwitch()); (this.toolbarAlwaysOpen() || this.isToolbarOpened || this.isEdit || this.showRightLayoutSwitch());
} }
set toolbarOpened(toolbarOpened: boolean) { set toolbarOpened(toolbarOpened: boolean) {
} }
@ -329,7 +338,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
this.dashboardCtx.aliasController.updateAliases(); this.dashboardCtx.aliasController.updateAliases();
setTimeout(() => { setTimeout(() => {
this.mobileService.handleDashboardStateName(this.dashboardCtx.stateController.getCurrentStateName()); this.mobileService.handleDashboardStateName(this.dashboardCtx.stateController.getCurrentStateName());
this.mobileService.onDashboardLoaded(); this.mobileService.onDashboardLoaded(this.layouts.right.show, this.isRightLayoutOpened);
}); });
} }
} }
@ -340,6 +349,14 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
this.isMobile = !state.matches; this.isMobile = !state.matches;
} }
)); ));
if (this.isMobileApp) {
this.mobileService.registerToggleLayoutFunction(() => {
setTimeout(() => {
this.toggleLayouts();
this.cd.detectChanges();
});
});
}
} }
private init(data: any) { private init(data: any) {
@ -430,6 +447,9 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
} }
ngOnDestroy(): void { ngOnDestroy(): void {
if (this.isMobileApp) {
this.mobileService.unregisterToggleLayoutFunction();
}
this.rxSubscriptions.forEach((subscription) => { this.rxSubscriptions.forEach((subscription) => {
subscription.unsubscribe(); subscription.unsubscribe();
}); });
@ -469,6 +489,15 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
} }
} }
private hideToolbarSetting(): boolean {
if (this.dashboard.configuration.settings &&
isDefined(this.dashboard.configuration.settings.hideToolbar)) {
return this.dashboard.configuration.settings.hideToolbar;
} else {
return false;
}
}
public displayTitle(): boolean { public displayTitle(): boolean {
if (this.dashboard.configuration.settings && if (this.dashboard.configuration.settings &&
isDefined(this.dashboard.configuration.settings.showTitle)) { isDefined(this.dashboard.configuration.settings.showTitle)) {
@ -546,15 +575,17 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
} }
public showRightLayoutSwitch(): boolean { public showRightLayoutSwitch(): boolean {
return this.isMobile && this.layouts.right.show; return this.isMobile && !this.isMobileApp && this.layouts.right.show;
} }
public toggleLayouts() { public toggleLayouts() {
this.isRightLayoutOpened = !this.isRightLayoutOpened; this.isRightLayoutOpened = !this.isRightLayoutOpened;
this.mobileService.onDashboardRightLayoutChanged(this.isRightLayoutOpened);
} }
public openRightLayout() { public openRightLayout() {
this.isRightLayoutOpened = true; this.isRightLayoutOpened = true;
this.mobileService.onDashboardRightLayoutChanged(this.isRightLayoutOpened);
} }
public mainLayoutWidth(): string { public mainLayoutWidth(): string {
@ -782,7 +813,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
this.updateLayouts(layoutsData); this.updateLayouts(layoutsData);
} }
setTimeout(() => { setTimeout(() => {
this.mobileService.onDashboardLoaded(); this.mobileService.onDashboardLoaded(this.layouts.right.show, this.isRightLayoutOpened);
}); });
} }

194
ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-settings-dialog.component.html

@ -15,7 +15,7 @@
limitations under the License. limitations under the License.
--> -->
<form (ngSubmit)="save()"> <form (ngSubmit)="save()" style="width: 750px;">
<mat-toolbar color="primary"> <mat-toolbar color="primary">
<h2 translate>{{settings ? 'dashboard.settings' : 'layout.settings'}}</h2> <h2 translate>{{settings ? 'dashboard.settings' : 'layout.settings'}}</h2>
<span fxFlex></span> <span fxFlex></span>
@ -28,8 +28,8 @@
<mat-progress-bar color="warn" mode="indeterminate" *ngIf="isLoading$ | async"> <mat-progress-bar color="warn" mode="indeterminate" *ngIf="isLoading$ | async">
</mat-progress-bar> </mat-progress-bar>
<div mat-dialog-content> <div mat-dialog-content>
<fieldset [disabled]="isLoading$ | async" fxLayout="column" fxLayoutGap="16px"> <fieldset [disabled]="isLoading$ | async">
<div *ngIf="settings" [formGroup]="settingsFormGroup"> <div *ngIf="settings" [formGroup]="settingsFormGroup" fxLayout="column">
<mat-form-field class="mat-block"> <mat-form-field class="mat-block">
<mat-label translate>dashboard.state-controller</mat-label> <mat-label translate>dashboard.state-controller</mat-label>
<mat-select required formControlName="stateControllerId"> <mat-select required formControlName="stateControllerId">
@ -38,112 +38,116 @@
</mat-option> </mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
<div fxLayout="row" fxLayoutAlign="start center" fxLayout.lt-md="column" fxLayoutAlign.lt-md fxLayoutGap="8px"> <fieldset class="fields-group" fxLayout="column" fxLayout.gt-sm="row" fxLayoutAlign.gt-sm="start center" fxLayoutGap="8px">
<mat-checkbox fxFlex formControlName="toolbarAlwaysOpen"> <legend class="group-title" translate>dashboard.title-settings</legend>
{{ 'dashboard.toolbar-always-open' | translate }} <mat-slide-toggle fxFlex formControlName="showTitle">
</mat-checkbox>
<mat-checkbox fxFlex formControlName="showTitle">
{{ 'dashboard.display-title' | translate }} {{ 'dashboard.display-title' | translate }}
</mat-checkbox> </mat-slide-toggle>
<tb-color-input fxFlex <tb-color-input fxFlex
label="{{'dashboard.title-color' | translate}}" label="{{'dashboard.title-color' | translate}}"
icon="format_color_fill" icon="format_color_fill"
openOnInput openOnInput
formControlName="titleColor"> formControlName="titleColor">
</tb-color-input> </tb-color-input>
</div> </fieldset>
<div fxLayout="row" fxLayoutAlign="start center" style="margin-bottom: 8px;" <fieldset class="fields-group" fxLayout="column" fxLayoutGap="8px">
fxLayout.lt-md="column" fxLayoutAlign.lt-md fxLayoutGap="8px"> <legend class="group-title" translate>dashboard.dashboard-logo-settings</legend>
<mat-checkbox fxFlex formControlName="showDashboardsSelect"> <mat-slide-toggle formControlName="showDashboardLogo">
{{ 'dashboard.display-dashboard-logo' | translate }}
</mat-slide-toggle>
<tb-image-input fxFlex
label="{{'dashboard.dashboard-logo-image' | translate}}"
formControlName="dashboardLogoUrl">
</tb-image-input>
</fieldset>
<fieldset class="fields-group" fxLayout="column" fxLayoutGap="8px">
<legend class="group-title" translate>dashboard.toolbar-settings</legend>
<mat-slide-toggle formControlName="hideToolbar">
{{ 'dashboard.hide-toolbar' | translate }}
</mat-slide-toggle>
<mat-slide-toggle formControlName="toolbarAlwaysOpen">
{{ 'dashboard.toolbar-always-open' | translate }}
</mat-slide-toggle>
<mat-slide-toggle formControlName="showDashboardsSelect">
{{ 'dashboard.display-dashboards-selection' | translate }} {{ 'dashboard.display-dashboards-selection' | translate }}
</mat-checkbox> </mat-slide-toggle>
<mat-checkbox fxFlex formControlName="showEntitiesSelect"> <mat-slide-toggle formControlName="showEntitiesSelect">
{{ 'dashboard.display-entities-selection' | translate }} {{ 'dashboard.display-entities-selection' | translate }}
</mat-checkbox> </mat-slide-toggle>
<mat-checkbox fxFlex formControlName="showFilters"> <mat-slide-toggle formControlName="showFilters">
{{ 'dashboard.display-filters' | translate }} {{ 'dashboard.display-filters' | translate }}
</mat-checkbox> </mat-slide-toggle>
<mat-checkbox fxFlex formControlName="showDashboardTimewindow"> <mat-slide-toggle formControlName="showDashboardTimewindow">
{{ 'dashboard.display-dashboard-timewindow' | translate }} {{ 'dashboard.display-dashboard-timewindow' | translate }}
</mat-checkbox> </mat-slide-toggle>
<mat-checkbox fxFlex formControlName="showDashboardExport"> <mat-slide-toggle formControlName="showDashboardExport">
{{ 'dashboard.display-dashboard-export' | translate }} {{ 'dashboard.display-dashboard-export' | translate }}
</mat-checkbox> </mat-slide-toggle>
<mat-checkbox fxFlex formControlName="showUpdateDashboardImage"> <mat-slide-toggle formControlName="showUpdateDashboardImage">
{{ 'dashboard.display-update-dashboard-image' | translate }} {{ 'dashboard.display-update-dashboard-image' | translate }}
</mat-checkbox> </mat-slide-toggle>
</div> </fieldset>
<mat-checkbox formControlName="showDashboardLogo">
{{ 'dashboard.display-dashboard-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" fxLayout="column">
<tb-color-input fxFlex <fieldset class="fields-group" fxLayout="column" fxLayoutGap="8px">
label="{{'layout.color' | translate}}" <legend class="group-title" translate>dashboard.layout-settings</legend>
icon="format_color_fill" <mat-form-field class="mat-block">
openOnInput <mat-label translate>dashboard.columns-count</mat-label>
formControlName="color"> <input matInput formControlName="columns" type="number" step="any" min="10"
</tb-color-input> max="1000" required>
<mat-form-field class="mat-block"> <mat-error *ngIf="gridSettingsFormGroup.get('columns').hasError('required')">
<mat-label translate>dashboard.columns-count</mat-label> {{ 'dashboard.columns-count-required' | translate }}
<input matInput formControlName="columns" type="number" step="any" min="10" </mat-error>
max="1000" required> <mat-error *ngIf="gridSettingsFormGroup.get('columns').hasError('min')">
<mat-error *ngIf="gridSettingsFormGroup.get('columns').hasError('required')"> {{ 'dashboard.min-columns-count-message' | translate }}
{{ 'dashboard.columns-count-required' | translate }} </mat-error>
</mat-error> <mat-error *ngIf="gridSettingsFormGroup.get('columns').hasError('max')">
<mat-error *ngIf="gridSettingsFormGroup.get('columns').hasError('min')"> {{ 'dashboard.max-columns-count-message' | translate }}
{{ 'dashboard.min-columns-count-message' | translate }} </mat-error>
</mat-error> </mat-form-field>
<mat-error *ngIf="gridSettingsFormGroup.get('columns').hasError('max')"> <mat-form-field fxFlex class="mat-block">
{{ 'dashboard.max-columns-count-message' | translate }} <mat-label translate>dashboard.widgets-margins</mat-label>
</mat-error> <input matInput formControlName="margin" type="number" step="any" min="0"
</mat-form-field> max="50" required>
<mat-form-field fxFlex class="mat-block"> <mat-error *ngIf="gridSettingsFormGroup.get('margin').hasError('required')">
<mat-label translate>dashboard.widgets-margins</mat-label> {{ 'dashboard.margin-required' | translate }}
<input matInput formControlName="margin" type="number" step="any" min="0" </mat-error>
max="50" required> <mat-error *ngIf="gridSettingsFormGroup.get('margin').hasError('min')">
<mat-error *ngIf="gridSettingsFormGroup.get('margin').hasError('required')"> {{ 'dashboard.min-margin-message' | translate }}
{{ 'dashboard.margin-required' | translate }} </mat-error>
</mat-error> <mat-error *ngIf="gridSettingsFormGroup.get('margin').hasError('max')">
<mat-error *ngIf="gridSettingsFormGroup.get('margin').hasError('min')"> {{ 'dashboard.max-margin-message' | translate }}
{{ 'dashboard.min-margin-message' | translate }} </mat-error>
</mat-error> </mat-form-field>
<mat-error *ngIf="gridSettingsFormGroup.get('margin').hasError('max')"> <mat-slide-toggle fxFlex formControlName="autoFillHeight" style="display: block; padding-bottom: 12px;">
{{ 'dashboard.max-margin-message' | translate }} {{ 'dashboard.autofill-height' | translate }}
</mat-error> </mat-slide-toggle>
</mat-form-field> <tb-color-input fxFlex
<mat-checkbox fxFlex formControlName="autoFillHeight" style="display: block; padding-bottom: 12px;"> label="{{'dashboard.background-color' | translate}}"
{{ 'dashboard.autofill-height' | translate }} icon="format_color_fill"
</mat-checkbox> openOnInput
<tb-color-input fxFlex formControlName="backgroundColor">
label="{{'dashboard.background-color' | translate}}" </tb-color-input>
icon="format_color_fill" <tb-image-input fxFlex
openOnInput label="{{'dashboard.background-image' | translate}}"
formControlName="backgroundColor"> formControlName="backgroundImageUrl">
</tb-color-input> </tb-image-input>
<tb-image-input fxFlex <mat-form-field class="mat-block">
label="{{'dashboard.background-image' | translate}}" <mat-label translate>dashboard.background-size-mode</mat-label>
formControlName="backgroundImageUrl"> <mat-select formControlName="backgroundSizeMode">
</tb-image-input> <mat-option value="100%">Fit width</mat-option>
<mat-form-field class="mat-block"> <mat-option value="auto 100%">Fit height</mat-option>
<mat-label translate>dashboard.background-size-mode</mat-label> <mat-option value="cover">Cover</mat-option>
<mat-select formControlName="backgroundSizeMode"> <mat-option value="contain">Contain</mat-option>
<mat-option value="100%">Fit width</mat-option> <mat-option value="auto">Original size</mat-option>
<mat-option value="auto 100%">Fit height</mat-option> </mat-select>
<mat-option value="cover">Cover</mat-option> </mat-form-field>
<mat-option value="contain">Contain</mat-option> </fieldset>
<mat-option value="auto">Original size</mat-option> <fieldset class="fields-group" fxLayout="column" fxLayout.gt-sm="row" fxLayoutAlign.gt-sm="start center" fxLayoutGap="8px">
</mat-select> <legend class="group-title" translate>dashboard.mobile-layout</legend>
</mat-form-field> <mat-slide-toggle fxFlex formControlName="mobileAutoFillHeight">
<small translate>dashboard.mobile-layout</small>
<div fxLayout="row" fxLayoutAlign="start center" fxLayout.xs="column" fxLayoutAlign.xs fxLayoutGap="8px" style="margin-top: 8px">
<mat-checkbox fxFlex formControlName="mobileAutoFillHeight">
{{ 'dashboard.autofill-height' | translate }} {{ 'dashboard.autofill-height' | translate }}
</mat-checkbox> </mat-slide-toggle>
<mat-form-field fxFlex class="mat-block"> <mat-form-field fxFlex class="mat-block">
<mat-label translate>dashboard.mobile-row-height</mat-label> <mat-label translate>dashboard.mobile-row-height</mat-label>
<input matInput formControlName="mobileRowHeight" type="number" step="any" min="5" <input matInput formControlName="mobileRowHeight" type="number" step="any" min="5"
@ -158,7 +162,7 @@
{{ 'dashboard.max-mobile-row-height-message' | translate }} {{ 'dashboard.max-mobile-row-height-message' | translate }}
</mat-error> </mat-error>
</mat-form-field> </mat-form-field>
</div> </fieldset>
</div> </div>
</fieldset> </fieldset>
</div> </div>

12
ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-settings-dialog.component.scss

@ -14,13 +14,19 @@
* limitations under the License. * limitations under the License.
*/ */
:host { :host {
small { .fields-group {
white-space: normal; padding: 0 8px 8px;
margin: 10px 0;
border: 1px groove rgba(0, 0, 0, .25);
border-radius: 4px;
legend {
color: rgba(0, 0, 0, .7);
}
} }
} }
:host ::ng-deep { :host ::ng-deep {
.mat-checkbox-label { .mat-slide-toggle-content {
white-space: normal; white-space: normal;
} }
} }

96
ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-settings-dialog.component.ts

@ -71,19 +71,33 @@ export class DashboardSettingsDialogComponent extends DialogComponent<DashboardS
this.gridSettings = this.data.gridSettings; this.gridSettings = this.data.gridSettings;
if (this.settings) { if (this.settings) {
const showTitle = isUndefined(this.settings.showTitle) ? true : this.settings.showTitle;
const showDashboardLogo = isUndefined(this.settings.showDashboardLogo) ? false : this.settings.showDashboardLogo;
const hideToolbar = isUndefined(this.settings.hideToolbar) ? false : this.settings.hideToolbar;
this.settingsFormGroup = this.fb.group({ this.settingsFormGroup = this.fb.group({
stateControllerId: [isUndefined(this.settings.stateControllerId) ? 'entity' : this.settings.stateControllerId, []], stateControllerId: [isUndefined(this.settings.stateControllerId) ? 'entity' : this.settings.stateControllerId, []],
toolbarAlwaysOpen: [isUndefined(this.settings.toolbarAlwaysOpen) ? true : this.settings.toolbarAlwaysOpen, []], showTitle: [showTitle, []],
showTitle: [isUndefined(this.settings.showTitle) ? true : this.settings.showTitle, []], titleColor: [{value: isUndefined(this.settings.titleColor) ? 'rgba(0,0,0,0.870588)' : this.settings.titleColor,
titleColor: [isUndefined(this.settings.titleColor) ? 'rgba(0,0,0,0.870588)' : this.settings.titleColor, []], disabled: !showTitle}, []],
showDashboardsSelect: [isUndefined(this.settings.showDashboardsSelect) ? true : this.settings.showDashboardsSelect, []], showDashboardLogo: [showDashboardLogo, []],
showEntitiesSelect: [isUndefined(this.settings.showEntitiesSelect) ? true : this.settings.showEntitiesSelect, []], dashboardLogoUrl: [{value: isUndefined(this.settings.dashboardLogoUrl) ? null : this.settings.dashboardLogoUrl,
showFilters: [isUndefined(this.settings.showFilters) ? true : this.settings.showFilters, []], disabled: !showDashboardLogo}, []],
showDashboardLogo: [isUndefined(this.settings.showDashboardLogo) ? false : this.settings.showDashboardLogo, []], hideToolbar: [hideToolbar, []],
dashboardLogoUrl: [isUndefined(this.settings.dashboardLogoUrl) ? null : this.settings.dashboardLogoUrl, []], toolbarAlwaysOpen: [{value: isUndefined(this.settings.toolbarAlwaysOpen) ? true : this.settings.toolbarAlwaysOpen,
showDashboardTimewindow: [isUndefined(this.settings.showDashboardTimewindow) ? true : this.settings.showDashboardTimewindow, []], disabled: hideToolbar}, []],
showDashboardExport: [isUndefined(this.settings.showDashboardExport) ? true : this.settings.showDashboardExport, []], showDashboardsSelect: [{value: isUndefined(this.settings.showDashboardsSelect) ? true : this.settings.showDashboardsSelect,
showUpdateDashboardImage: [isUndefined(this.settings.showUpdateDashboardImage) ? true : this.settings.showUpdateDashboardImage, []] disabled: hideToolbar}, []],
showEntitiesSelect: [{value: isUndefined(this.settings.showEntitiesSelect) ? true : this.settings.showEntitiesSelect,
disabled: hideToolbar}, []],
showFilters: [{value: isUndefined(this.settings.showFilters) ? true : this.settings.showFilters,
disabled: hideToolbar}, []],
showDashboardTimewindow: [{value: isUndefined(this.settings.showDashboardTimewindow) ? true : this.settings.showDashboardTimewindow,
disabled: hideToolbar}, []],
showDashboardExport: [{value: isUndefined(this.settings.showDashboardExport) ? true : this.settings.showDashboardExport,
disabled: hideToolbar}, []],
showUpdateDashboardImage: [
{value: isUndefined(this.settings.showUpdateDashboardImage) ? true : this.settings.showUpdateDashboardImage,
disabled: hideToolbar}, []]
}); });
this.settingsFormGroup.get('stateControllerId').valueChanges.subscribe( this.settingsFormGroup.get('stateControllerId').valueChanges.subscribe(
(stateControllerId: StateControllerId) => { (stateControllerId: StateControllerId) => {
@ -92,13 +106,52 @@ export class DashboardSettingsDialogComponent extends DialogComponent<DashboardS
} }
} }
); );
this.settingsFormGroup.get('showTitle').valueChanges.subscribe(
(showTitleValue: boolean) => {
if (showTitleValue) {
this.settingsFormGroup.get('titleColor').enable();
} else {
this.settingsFormGroup.get('titleColor').disable();
}
}
);
this.settingsFormGroup.get('showDashboardLogo').valueChanges.subscribe(
(showDashboardLogoValue: boolean) => {
if (showDashboardLogoValue) {
this.settingsFormGroup.get('dashboardLogoUrl').enable();
} else {
this.settingsFormGroup.get('dashboardLogoUrl').disable();
}
}
);
this.settingsFormGroup.get('hideToolbar').valueChanges.subscribe(
(hideToolbarValue: boolean) => {
if (hideToolbarValue) {
this.settingsFormGroup.get('toolbarAlwaysOpen').disable();
this.settingsFormGroup.get('showDashboardsSelect').disable();
this.settingsFormGroup.get('showEntitiesSelect').disable();
this.settingsFormGroup.get('showFilters').disable();
this.settingsFormGroup.get('showDashboardTimewindow').disable();
this.settingsFormGroup.get('showDashboardExport').disable();
this.settingsFormGroup.get('showUpdateDashboardImage').disable();
} else {
this.settingsFormGroup.get('toolbarAlwaysOpen').enable();
this.settingsFormGroup.get('showDashboardsSelect').enable();
this.settingsFormGroup.get('showEntitiesSelect').enable();
this.settingsFormGroup.get('showFilters').enable();
this.settingsFormGroup.get('showDashboardTimewindow').enable();
this.settingsFormGroup.get('showDashboardExport').enable();
this.settingsFormGroup.get('showUpdateDashboardImage').enable();
}
}
);
} else { } else {
this.settingsFormGroup = this.fb.group({}); this.settingsFormGroup = this.fb.group({});
} }
if (this.gridSettings) { if (this.gridSettings) {
const mobileAutoFillHeight = isUndefined(this.gridSettings.mobileAutoFillHeight) ? false : this.gridSettings.mobileAutoFillHeight;
this.gridSettingsFormGroup = this.fb.group({ this.gridSettingsFormGroup = this.fb.group({
color: [this.gridSettings.color || 'rgba(0,0,0,0.870588)', []],
columns: [this.gridSettings.columns || 24, [Validators.required, Validators.min(10), Validators.max(1000)]], columns: [this.gridSettings.columns || 24, [Validators.required, Validators.min(10), Validators.max(1000)]],
margin: [isDefined(this.gridSettings.margin) ? this.gridSettings.margin : 10, margin: [isDefined(this.gridSettings.margin) ? this.gridSettings.margin : 10,
[Validators.required, Validators.min(0), Validators.max(50)]], [Validators.required, Validators.min(0), Validators.max(50)]],
@ -106,10 +159,19 @@ export class DashboardSettingsDialogComponent extends DialogComponent<DashboardS
backgroundColor: [this.gridSettings.backgroundColor || 'rgba(0,0,0,0)', []], backgroundColor: [this.gridSettings.backgroundColor || 'rgba(0,0,0,0)', []],
backgroundImageUrl: [this.gridSettings.backgroundImageUrl, []], backgroundImageUrl: [this.gridSettings.backgroundImageUrl, []],
backgroundSizeMode: [this.gridSettings.backgroundSizeMode || '100%', []], backgroundSizeMode: [this.gridSettings.backgroundSizeMode || '100%', []],
mobileAutoFillHeight: [isUndefined(this.gridSettings.mobileAutoFillHeight) ? false : this.gridSettings.mobileAutoFillHeight, []], mobileAutoFillHeight: [mobileAutoFillHeight, []],
mobileRowHeight: [isUndefined(this.gridSettings.mobileRowHeight) ? 70 : this.gridSettings.mobileRowHeight, mobileRowHeight: [{ value: isUndefined(this.gridSettings.mobileRowHeight) ? 70 : this.gridSettings.mobileRowHeight,
[Validators.required, Validators.min(5), Validators.max(200)]] disabled: mobileAutoFillHeight}, [Validators.required, Validators.min(5), Validators.max(200)]]
}); });
this.gridSettingsFormGroup.get('mobileAutoFillHeight').valueChanges.subscribe(
(mobileAutoFillHeightValue: boolean) => {
if (mobileAutoFillHeightValue) {
this.gridSettingsFormGroup.get('mobileRowHeight').disable();
} else {
this.gridSettingsFormGroup.get('mobileRowHeight').enable();
}
}
);
} else { } else {
this.gridSettingsFormGroup = this.fb.group({}); this.gridSettingsFormGroup = this.fb.group({});
} }
@ -133,10 +195,10 @@ export class DashboardSettingsDialogComponent extends DialogComponent<DashboardS
let settings: DashboardSettings = null; let settings: DashboardSettings = null;
let gridSettings: GridSettings = null; let gridSettings: GridSettings = null;
if (this.settings) { if (this.settings) {
settings = {...this.settings, ...this.settingsFormGroup.value}; settings = {...this.settings, ...this.settingsFormGroup.getRawValue()};
} }
if (this.gridSettings) { if (this.gridSettings) {
gridSettings = {...this.gridSettings, ...this.gridSettingsFormGroup.value}; gridSettings = {...this.gridSettings, ...this.gridSettingsFormGroup.getRawValue()};
} }
this.dialogRef.close({settings, gridSettings}); this.dialogRef.close({settings, gridSettings});
} }

1
ui-ngx/src/app/modules/home/components/dashboard-page/layout/dashboard-layout.component.html

@ -26,7 +26,6 @@
[style.backgroundImage]="backgroundImage" [style.backgroundImage]="backgroundImage"
[ngStyle]="dashboardStyle"> [ngStyle]="dashboardStyle">
<section *ngIf="layoutCtx.widgets.isEmpty()" fxLayoutAlign="center center" <section *ngIf="layoutCtx.widgets.isEmpty()" fxLayoutAlign="center center"
[ngStyle]="{'color': layoutCtx.gridSettings.color}"
style="display: flex; z-index: 1; pointer-events: none;" style="display: flex; z-index: 1; pointer-events: none;"
class="mat-headline tb-absolute-fill"> class="mat-headline tb-absolute-fill">
<span *ngIf="!isEdit"> <span *ngIf="!isEdit">

2
ui-ngx/src/app/shared/components/color-input.component.html

@ -20,7 +20,7 @@
<mat-icon *ngIf="icon">{{icon}}</mat-icon> <mat-icon *ngIf="icon">{{icon}}</mat-icon>
<span *ngIf="label">{{label}}</span> <span *ngIf="label">{{label}}</span>
</mat-label> </mat-label>
<div matPrefix class="tb-color-preview" (click)="showColorPicker()" style="margin-right: 5px;"> <div matPrefix class="tb-color-preview" (click)="!disabled && showColorPicker()" style="margin-right: 5px;">
<div class="tb-color-result" [ngStyle]="{background: colorFormGroup.get('color').value}"></div> <div class="tb-color-result" [ngStyle]="{background: colorFormGroup.get('color').value}"></div>
</div> </div>
<input matInput formControlName="color" (mousedown)="openOnInput && showColorPicker()" [required]="required"> <input matInput formControlName="color" (mousedown)="openOnInput && showColorPicker()" [required]="required">

2
ui-ngx/src/app/shared/models/dashboard.models.ts

@ -45,7 +45,6 @@ export interface WidgetLayouts {
export interface GridSettings { export interface GridSettings {
backgroundColor?: string; backgroundColor?: string;
color?: string;
columns?: number; columns?: number;
margin?: number; margin?: number;
backgroundSizeMode?: string; backgroundSizeMode?: string;
@ -93,6 +92,7 @@ export interface DashboardSettings {
showDashboardExport?: boolean; showDashboardExport?: boolean;
showUpdateDashboardImage?: boolean; showUpdateDashboardImage?: boolean;
toolbarAlwaysOpen?: boolean; toolbarAlwaysOpen?: boolean;
hideToolbar?: boolean;
titleColor?: string; titleColor?: string;
} }

2
ui-ngx/src/app/shared/models/window-message.model.ts

@ -14,7 +14,7 @@
/// limitations under the License. /// limitations under the License.
/// ///
export type WindowMessageType = 'widgetException' | 'widgetEditModeInited' | 'widgetEditUpdated' | 'openDashboardMessage' | 'reloadUserMessage'; export type WindowMessageType = 'widgetException' | 'widgetEditModeInited' | 'widgetEditUpdated' | 'openDashboardMessage' | 'reloadUserMessage' | 'toggleDashboardLayout';
export interface WindowMessage { export interface WindowMessage {
type: WindowMessageType; type: WindowMessageType;

7
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -721,6 +721,7 @@
"maximum-upload-file-size": "Maximum upload file size: {{ size }}", "maximum-upload-file-size": "Maximum upload file size: {{ size }}",
"cannot-upload-file": "Cannot upload file", "cannot-upload-file": "Cannot upload file",
"settings": "Settings", "settings": "Settings",
"layout-settings": "Layout settings",
"columns-count": "Columns count", "columns-count": "Columns count",
"columns-count-required": "Columns count is required.", "columns-count-required": "Columns count is required.",
"min-columns-count-message": "Only 10 minimum column count is allowed.", "min-columns-count-message": "Only 10 minimum column count is allowed.",
@ -743,15 +744,19 @@
"mobile-row-height-required": "Mobile row height value is required.", "mobile-row-height-required": "Mobile row height value is required.",
"min-mobile-row-height-message": "Only 5 pixels is allowed as minimum mobile row height value.", "min-mobile-row-height-message": "Only 5 pixels is allowed as minimum mobile row height value.",
"max-mobile-row-height-message": "Only 200 pixels is allowed as maximum mobile row height value.", "max-mobile-row-height-message": "Only 200 pixels is allowed as maximum mobile row height value.",
"title-settings": "Title settings",
"display-title": "Display dashboard title", "display-title": "Display dashboard title",
"toolbar-always-open": "Keep toolbar opened",
"title-color": "Title color", "title-color": "Title color",
"toolbar-settings": "Toolbar settings",
"hide-toolbar": "Hide toolbar",
"toolbar-always-open": "Keep toolbar opened",
"display-dashboards-selection": "Display dashboards selection", "display-dashboards-selection": "Display dashboards selection",
"display-entities-selection": "Display entities selection", "display-entities-selection": "Display entities selection",
"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-update-dashboard-image": "Display update dashboard image", "display-update-dashboard-image": "Display update dashboard image",
"dashboard-logo-settings": "Dashboard logo settings",
"display-dashboard-logo": "Display logo in dashboard fullscreen mode", "display-dashboard-logo": "Display logo in dashboard fullscreen mode",
"dashboard-logo-image": "Dashboard logo image", "dashboard-logo-image": "Dashboard logo image",
"import": "Import dashboard", "import": "Import dashboard",

Loading…
Cancel
Save