diff --git a/ui-ngx/src/app/core/services/dashboard-utils.service.ts b/ui-ngx/src/app/core/services/dashboard-utils.service.ts index 7d55904768..8e64822897 100644 --- a/ui-ngx/src/app/core/services/dashboard-utils.service.ts +++ b/ui-ngx/src/app/core/services/dashboard-utils.service.ts @@ -287,35 +287,27 @@ export class DashboardUtilsService { let addedCount = 0; let removedCount = 0; for (const l of Object.keys(state.layouts)) { - if (!newLayouts[l] && l !== 'layoutDimension') { - removedCount++; - } + removedCount++; } for (const l of Object.keys(newLayouts)) { - if (!state.layouts[l] && l !== 'layoutDimension') { - addedCount++; - } + addedCount++; } state.layouts = newLayouts; const layoutsCount = Object.keys(state.layouts).length; let newColumns; if (addedCount) { for (const l of Object.keys(state.layouts)) { - if (l !== 'layoutDimension') { - newColumns = state.layouts[l].gridSettings.columns * (layoutsCount - addedCount) / layoutsCount; - if (newColumns > 0) { - state.layouts[l].gridSettings.columns = newColumns; - } + newColumns = state.layouts[l].gridSettings.columns * (layoutsCount - addedCount) / layoutsCount; + if (newColumns > 0) { + state.layouts[l].gridSettings.columns = newColumns; } } } if (removedCount) { for (const l of Object.keys(state.layouts)) { - if (l !== 'layoutDimension') { - newColumns = state.layouts[l].gridSettings.columns * (layoutsCount + removedCount) / layoutsCount; - if (newColumns > 0) { - state.layouts[l].gridSettings.columns = newColumns; - } + newColumns = state.layouts[l].gridSettings.columns * (layoutsCount + removedCount) / layoutsCount; + if (newColumns > 0) { + state.layouts[l].gridSettings.columns = newColumns; } } } @@ -339,20 +331,18 @@ export class DashboardUtilsService { if (state) { const result: DashboardLayoutsInfo = {}; for (const l of Object.keys(state.layouts)) { - if (l !== 'layoutDimension') { - const layout: DashboardLayout = state.layouts[l]; - if (layout) { - result[l] = { - widgetIds: [], - widgetLayouts: {}, - gridSettings: {} - } as DashboardLayoutInfo; - for (const id of Object.keys(layout.widgets)) { - result[l].widgetIds.push(id); - } - result[l].widgetLayouts = layout.widgets; - result[l].gridSettings = layout.gridSettings; + const layout: DashboardLayout = state.layouts[l]; + if (layout) { + result[l] = { + widgetIds: [], + widgetLayouts: {}, + gridSettings: {} + } as DashboardLayoutInfo; + for (const id of Object.keys(layout.widgets)) { + result[l].widgetIds.push(id); } + result[l].widgetLayouts = layout.widgets; + result[l].gridSettings = layout.gridSettings; } } return result; diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts index 116e1acea0..f9ecf6646b 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts @@ -43,7 +43,7 @@ import { DashboardLayoutsInfo, DashboardState, DashboardStateLayouts, - GridSettings, + GridSettings, LayoutDimension, WidgetLayout } from '@app/shared/models/dashboard.models'; import { WINDOW } from '@core/services/window.service'; @@ -135,7 +135,7 @@ import { DomSanitizer, SafeUrl } from '@angular/platform-browser'; import cssjs from '@core/css/css'; import { DOCUMENT } from '@angular/common'; import { IAliasController } from '@core/api/widget-api.models'; -import { LaouytType, LayoutWidthType } from "@home/components/dashboard-page/layout/layout.models"; +import { LayoutType, LayoutWidthType } from "@home/components/dashboard-page/layout/layout.models"; // @dynamic @Component({ @@ -267,8 +267,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC ctrl: null, dashboardCtrl: this } - }, - layoutDimension: null + } }; addWidgetFabButtons: FooterFabButtons = { @@ -653,15 +652,15 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC } public mainLayoutWidth(): string { - if (this.isEditingWidget && this.editingLayoutCtx.id === LaouytType.MAIN) { + if (this.isEditingWidget && this.editingLayoutCtx.id === LayoutType.MAIN) { return '100%'; } else { - return this.layouts.right.show && !this.isMobile ? this.calculateWidth(LaouytType.MAIN) : '100%'; + return this.layouts.right.show && !this.isMobile ? this.calculateWidth(LayoutType.MAIN) : '100%'; } } public mainLayoutHeight(): string { - if (!this.isEditingWidget || this.editingLayoutCtx.id === LaouytType.MAIN) { + if (!this.isEditingWidget || this.editingLayoutCtx.id === LayoutType.MAIN) { return '100%'; } else { return '0px'; @@ -669,18 +668,27 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC } public rightLayoutWidth(): string { - if (this.isEditingWidget && this.editingLayoutCtx.id === LaouytType.RIGHT) { + if (this.isEditingWidget && this.editingLayoutCtx.id === LayoutType.RIGHT) { return '100%'; } else { - return this.isMobile ? '100%' : this.calculateWidth(LaouytType.RIGHT); + return this.isMobile ? '100%' : this.calculateWidth(LayoutType.RIGHT); } } private calculateWidth(layout: DashboardLayoutId): string { - const layoutDimension = this.dashboard.configuration.states[this.dashboardCtx.state].layouts.layoutDimension; + let layoutDimension: LayoutDimension; + const mainLayout = this.dashboard.configuration.states[this.dashboardCtx.state].layouts.main; + const rightLayout = this.dashboard.configuration.states[this.dashboardCtx.state].layouts.right; + if (rightLayout) { + if (mainLayout.gridSettings.layoutDimension) { + layoutDimension = mainLayout.gridSettings.layoutDimension; + } else { + layoutDimension = rightLayout.gridSettings.layoutDimension; + } + } if (layoutDimension) { if (layoutDimension.type === LayoutWidthType.PERCENTAGE) { - if (layout === LaouytType.RIGHT) { + if (layout === LayoutType.RIGHT) { return (100 - layoutDimension.leftWidthPercentage) + '%'; } else { return layoutDimension.leftWidthPercentage + '%'; @@ -911,7 +919,6 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC } for (const l of Object.keys(this.layouts)) { const layout: DashboardPageLayout = this.layouts[l]; - if(l !== 'layoutDimension') { if (layoutsData[l]) { layout.show = true; const layoutInfo: DashboardLayoutInfo = layoutsData[l]; @@ -920,7 +927,6 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC layout.show = false; this.updateLayout(layout, {widgetIds: [], widgetLayouts: {}, gridSettings: null}); } - } } } @@ -968,11 +974,9 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC private resetHighlight() { for (const l of Object.keys(this.layouts)) { - if(l !== 'layoutDimension' ) { - if (this.layouts[l].layoutCtx) { - if (this.layouts[l].layoutCtx.ctrl) { - this.layouts[l].layoutCtx.ctrl.resetHighlight(); - } + if (this.layouts[l].layoutCtx) { + if (this.layouts[l].layoutCtx.ctrl) { + this.layouts[l].layoutCtx.ctrl.resetHighlight(); } } } diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.models.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.models.ts index de11bf24f2..c7ffd6f49c 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.models.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.models.ts @@ -18,7 +18,6 @@ import { Dashboard, DashboardLayoutId, GridSettings, - LayoutDimension, WidgetLayouts } from '@app/shared/models/dashboard.models'; import { Widget, WidgetPosition } from '@app/shared/models/widget.models'; @@ -74,7 +73,7 @@ export interface DashboardPageLayout { layoutCtx: DashboardPageLayoutContext; } -export declare type DashboardPageLayouts = {[key in DashboardLayoutId | 'layoutDimension']: DashboardPageLayout & LayoutDimension}; +export declare type DashboardPageLayouts = {[key in DashboardLayoutId ]: DashboardPageLayout }; export class LayoutWidgetsArray implements Iterable { diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/layout/layout.models.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/layout/layout.models.ts index a9ccd0a67f..49ff9052c2 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/layout/layout.models.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/layout/layout.models.ts @@ -28,7 +28,7 @@ export enum LayoutWidthType { FIXED = "fixed" } -export enum LaouytType { +export enum LayoutType { MAIN = "main", RIGHT = "right", LEFT = "left" diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/layout/manage-dashboard-layouts-dialog.component.html b/ui-ngx/src/app/modules/home/components/dashboard-page/layout/manage-dashboard-layouts-dialog.component.html index 1e9cbf6cff..8ac16e2bb3 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/layout/manage-dashboard-layouts-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/layout/manage-dashboard-layouts-dialog.component.html @@ -39,40 +39,40 @@
- -
+ [fxShow]="layoutsFormGroup.get(LayoutType.RIGHT).value"> - + {{ 'layout.percentage-width' | translate }} - + {{ 'layout.fixed-width' | translate }} -
+
+ [value]="layoutsFormGroup.get('leftWidthPercentage').value" + [displayWith]="formatSliderTooltipLabel"> + +
@@ -93,9 +94,9 @@ {{ 'layout.left-width' | translate }} @@ -104,16 +105,15 @@
- {{'layout.layout-min-max' | translate: { min: 10, max: 90, units: "%" } }} +
-
@@ -137,12 +137,12 @@ - {{ 'layout.layout-min-max' | translate: {min: 150, max: 1700, units: "px" } }} +
diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/layout/manage-dashboard-layouts-dialog.component.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/layout/manage-dashboard-layouts-dialog.component.ts index 928a45fbdf..32cf52a917 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/layout/manage-dashboard-layouts-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/layout/manage-dashboard-layouts-dialog.component.ts @@ -14,7 +14,7 @@ /// limitations under the License. /// -import { Component, Inject, OnInit, SkipSelf } from '@angular/core'; +import { ChangeDetectorRef, Component, Inject, OnInit, SkipSelf} from '@angular/core'; import { ErrorStateMatcher } from '@angular/material/core'; import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog'; import { Store } from '@ngrx/store'; @@ -24,14 +24,14 @@ import { Router } from '@angular/router'; import { DialogComponent } from '@app/shared/components/dialog.component'; import { UtilsService } from '@core/services/utils.service'; import { TranslateService } from '@ngx-translate/core'; -import { DashboardLayoutId, DashboardStateLayouts } from '@app/shared/models/dashboard.models'; +import { DashboardLayoutId, DashboardStateLayouts, LayoutDimension } from '@app/shared/models/dashboard.models'; import { deepClone, isDefined } from '@core/utils'; import { DashboardUtilsService } from '@core/services/dashboard-utils.service'; import { DashboardSettingsDialogComponent, DashboardSettingsDialogData } from '@home/components/dashboard-page/dashboard-settings-dialog.component'; -import { LaouytType, LayoutWidthType } from "@home/components/dashboard-page/layout/layout.models"; +import { LayoutType, LayoutWidthType } from "@home/components/dashboard-page/layout/layout.models"; export interface ManageDashboardLayoutsDialogData { layouts: DashboardStateLayouts; @@ -50,6 +50,10 @@ export class ManageDashboardLayoutsDialogComponent extends DialogComponent, @@ -61,7 +65,8 @@ export class ManageDashboardLayoutsDialogComponent extends DialogComponent this.layoutControlChange('rightWidthPercentage', value)); @@ -134,36 +146,38 @@ export class ManageDashboardLayoutsDialogComponent extends DialogComponent