|
|
@ -41,7 +41,7 @@ import { |
|
|
} from '@home/components/dashboard-page/dashboard-settings-dialog.component'; |
|
|
} from '@home/components/dashboard-page/dashboard-settings-dialog.component'; |
|
|
import { LayoutWidthType } from '@home/components/dashboard-page/layout/layout.models'; |
|
|
import { LayoutWidthType } from '@home/components/dashboard-page/layout/layout.models'; |
|
|
import { Subscription } from 'rxjs'; |
|
|
import { Subscription } from 'rxjs'; |
|
|
import { MatTooltip } from "@angular/material/tooltip"; |
|
|
import { MatTooltip } from '@angular/material/tooltip'; |
|
|
|
|
|
|
|
|
export interface ManageDashboardLayoutsDialogData { |
|
|
export interface ManageDashboardLayoutsDialogData { |
|
|
layouts: DashboardStateLayouts; |
|
|
layouts: DashboardStateLayouts; |
|
|
@ -56,23 +56,23 @@ export interface ManageDashboardLayoutsDialogData { |
|
|
export class ManageDashboardLayoutsDialogComponent extends DialogComponent<ManageDashboardLayoutsDialogComponent, DashboardStateLayouts> |
|
|
export class ManageDashboardLayoutsDialogComponent extends DialogComponent<ManageDashboardLayoutsDialogComponent, DashboardStateLayouts> |
|
|
implements ErrorStateMatcher { |
|
|
implements ErrorStateMatcher { |
|
|
|
|
|
|
|
|
@ViewChild('tooltip') tooltip: MatTooltip; |
|
|
@ViewChild('tooltip', {static: true}) tooltip: MatTooltip; |
|
|
|
|
|
|
|
|
layoutsFormGroup: FormGroup; |
|
|
layoutsFormGroup: FormGroup; |
|
|
|
|
|
|
|
|
layouts: DashboardStateLayouts; |
|
|
|
|
|
|
|
|
|
|
|
LayoutWidthType = LayoutWidthType; |
|
|
LayoutWidthType = LayoutWidthType; |
|
|
|
|
|
|
|
|
subscriptions: Array<Subscription> = []; |
|
|
private readonly layouts: DashboardStateLayouts; |
|
|
|
|
|
|
|
|
|
|
|
private subscriptions: Array<Subscription> = []; |
|
|
|
|
|
|
|
|
submitted = false; |
|
|
private submitted = false; |
|
|
|
|
|
|
|
|
constructor(protected store: Store<AppState>, |
|
|
constructor(protected store: Store<AppState>, |
|
|
protected router: Router, |
|
|
protected router: Router, |
|
|
@Inject(MAT_DIALOG_DATA) public data: ManageDashboardLayoutsDialogData, |
|
|
@Inject(MAT_DIALOG_DATA) private data: ManageDashboardLayoutsDialogData, |
|
|
@SkipSelf() private errorStateMatcher: ErrorStateMatcher, |
|
|
@SkipSelf() private errorStateMatcher: ErrorStateMatcher, |
|
|
public dialogRef: MatDialogRef<ManageDashboardLayoutsDialogComponent, DashboardStateLayouts>, |
|
|
protected dialogRef: MatDialogRef<ManageDashboardLayoutsDialogComponent, DashboardStateLayouts>, |
|
|
private fb: FormBuilder, |
|
|
private fb: FormBuilder, |
|
|
private utils: UtilsService, |
|
|
private utils: UtilsService, |
|
|
private dashboardUtils: DashboardUtilsService, |
|
|
private dashboardUtils: DashboardUtilsService, |
|
|
@ -128,7 +128,7 @@ export class ManageDashboardLayoutsDialogComponent extends DialogComponent<Manag |
|
|
fixedLayout: this.layouts.main.gridSettings.layoutDimension.fixedLayout, |
|
|
fixedLayout: this.layouts.main.gridSettings.layoutDimension.fixedLayout, |
|
|
type: LayoutWidthType.FIXED, |
|
|
type: LayoutWidthType.FIXED, |
|
|
fixedWidth: this.layouts.main.gridSettings.layoutDimension.fixedWidth, |
|
|
fixedWidth: this.layouts.main.gridSettings.layoutDimension.fixedWidth, |
|
|
sliderFixed: this.layouts.right.gridSettings.layoutDimension.fixedWidth |
|
|
sliderFixed: this.layouts.main.gridSettings.layoutDimension.fixedWidth |
|
|
}, {emitEvent: false}); |
|
|
}, {emitEvent: false}); |
|
|
} else { |
|
|
} else { |
|
|
const leftWidthPercentage: number = Number(this.layouts.main.gridSettings.layoutDimension.leftWidthPercentage); |
|
|
const leftWidthPercentage: number = Number(this.layouts.main.gridSettings.layoutDimension.leftWidthPercentage); |
|
|
@ -157,7 +157,7 @@ export class ManageDashboardLayoutsDialogComponent extends DialogComponent<Manag |
|
|
this.layoutsFormGroup.get('sliderFixed').valueChanges |
|
|
this.layoutsFormGroup.get('sliderFixed').valueChanges |
|
|
.subscribe( |
|
|
.subscribe( |
|
|
(value) => { |
|
|
(value) => { |
|
|
this.layoutsFormGroup.get('fixedWidth').patchValue(value) |
|
|
this.layoutsFormGroup.get('fixedWidth').patchValue(value); |
|
|
} |
|
|
} |
|
|
)); |
|
|
)); |
|
|
this.subscriptions.push( |
|
|
this.subscriptions.push( |
|
|
@ -180,7 +180,8 @@ export class ManageDashboardLayoutsDialogComponent extends DialogComponent<Manag |
|
|
this.layoutsFormGroup.get('fixedWidth').valueChanges |
|
|
this.layoutsFormGroup.get('fixedWidth').valueChanges |
|
|
.subscribe( |
|
|
.subscribe( |
|
|
(value) => { |
|
|
(value) => { |
|
|
this.showTooltip(this.layoutsFormGroup.get('fixedWidth'), LayoutWidthType.FIXED, this.layoutsFormGroup.get('fixedLayout').value); |
|
|
this.showTooltip(this.layoutsFormGroup.get('fixedWidth'), LayoutWidthType.FIXED, |
|
|
|
|
|
this.layoutsFormGroup.get('fixedLayout').value); |
|
|
this.layoutsFormGroup.get('sliderFixed').setValue(value, {emitEvent: false}); |
|
|
this.layoutsFormGroup.get('sliderFixed').setValue(value, {emitEvent: false}); |
|
|
} |
|
|
} |
|
|
)); |
|
|
)); |
|
|
@ -302,7 +303,7 @@ export class ManageDashboardLayoutsDialogComponent extends DialogComponent<Manag |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private showTooltip(control: AbstractControl, layoutType: LayoutWidthType, layoutSide: string): void { |
|
|
private showTooltip(control: AbstractControl, layoutType: LayoutWidthType, layoutSide: DashboardLayoutId): void { |
|
|
if (control.errors) { |
|
|
if (control.errors) { |
|
|
let message: string; |
|
|
let message: string; |
|
|
const unit = layoutType === LayoutWidthType.FIXED ? 'px' : '%'; |
|
|
const unit = layoutType === LayoutWidthType.FIXED ? 'px' : '%'; |
|
|
@ -318,9 +319,9 @@ export class ManageDashboardLayoutsDialogComponent extends DialogComponent<Manag |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} else if (control.errors.min) { |
|
|
} else if (control.errors.min) { |
|
|
message = this.translate.instant('layout.value-min-error', {min: control.errors.min.min, unit: unit}); |
|
|
message = this.translate.instant('layout.value-min-error', {min: control.errors.min.min, unit}); |
|
|
} else if (control.errors.max) { |
|
|
} else if (control.errors.max) { |
|
|
message = this.translate.instant('layout.value-max-error', {max: control.errors.max.max, unit: unit}); |
|
|
message = this.translate.instant('layout.value-max-error', {max: control.errors.max.max, unit}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (layoutSide === 'main') { |
|
|
if (layoutSide === 'main') { |
|
|
@ -352,12 +353,8 @@ export class ManageDashboardLayoutsDialogComponent extends DialogComponent<Manag |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
showPreviewInputs(side: string): boolean { |
|
|
showPreviewInputs(side: DashboardLayoutId): boolean { |
|
|
const formValues = this.layoutsFormGroup.value; |
|
|
const formValues = this.layoutsFormGroup.value; |
|
|
return formValues.right && |
|
|
return formValues.right && (formValues.type === LayoutWidthType.PERCENTAGE || formValues.fixedLayout === side); |
|
|
( |
|
|
|
|
|
formValues.type === LayoutWidthType.PERCENTAGE || |
|
|
|
|
|
(formValues.fixedLayout === side && formValues.type === LayoutWidthType.FIXED) |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|