From 5b9f1d5b586e0fc12fbcd547546be5c45bd9711d Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Thu, 30 Nov 2023 11:21:50 +0200 Subject: [PATCH 1/4] UI: Add copy dashboard state --- .../dashboard-page.component.ts | 18 +++-- ...age-dashboard-states-dialog.component.html | 11 ++- ...anage-dashboard-states-dialog.component.ts | 72 ++++++++++++++++--- 3 files changed, 85 insertions(+), 16 deletions(-) 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 6f6e39c52c..83981f2b61 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 @@ -55,7 +55,7 @@ import { } from '@app/shared/models/dashboard.models'; import { WINDOW } from '@core/services/window.service'; import { WindowMessage } from '@shared/models/window-message.model'; -import { deepClone, guid, isDefined, isDefinedAndNotNull, isNotEmptyStr } from '@app/core/utils'; +import { deepClone, guid, isDefined, isDefinedAndNotNull, isEqual, isNotEmptyStr } from '@app/core/utils'; import { DashboardContext, DashboardPageInitData, @@ -872,15 +872,21 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC $event.stopPropagation(); } this.dialog.open(ManageDashboardStatesDialogComponent, { + {states: {[id: string]: DashboardState}; widgets: {[id: string]: Widget}}>(ManageDashboardStatesDialogComponent, { disableClose: true, panelClass: ['tb-dialog', 'tb-fullscreen-dialog'], data: { - states: deepClone(this.dashboard.configuration.states) + states: deepClone(this.dashboard.configuration.states), + widgets: deepClone(this.dashboard.configuration.widgets) as {[id: string]: Widget} } - }).afterClosed().subscribe((states) => { - if (states) { - this.updateStates(states); + }).afterClosed().subscribe((result) => { + if (result) { + if (!isEqual(result.widgets, this.dashboard.configuration.widgets)) { + this.dashboard.configuration.widgets = result.widgets; + } + if (result.states) { + this.updateStates(result.states); + } } }); } diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/states/manage-dashboard-states-dialog.component.html b/ui-ngx/src/app/modules/home/components/dashboard-page/states/manage-dashboard-states-dialog.component.html index 8e6bf449e7..b6528c4cb2 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/states/manage-dashboard-states-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/states/manage-dashboard-states-dialog.component.html @@ -15,7 +15,7 @@ limitations under the License. --> -
+

dashboard.manage-states

@@ -96,7 +96,7 @@ - +
@@ -107,6 +107,13 @@ (click)="editState($event, state)"> edit +