From eb244e3de97e6af8b35c248000a89aa2d13d00d6 Mon Sep 17 00:00:00 2001 From: rusikv Date: Mon, 9 Sep 2024 17:23:47 +0300 Subject: [PATCH 1/2] UI: add origUserFilters optional param for AliasController constructor --- ui-ngx/src/app/core/api/alias-controller.ts | 5 +++-- ui-ngx/src/app/core/api/widget-api.models.ts | 1 + .../components/dashboard-page/dashboard-page.component.ts | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ui-ngx/src/app/core/api/alias-controller.ts b/ui-ngx/src/app/core/api/alias-controller.ts index bf7399cf6d..1176e583ae 100644 --- a/ui-ngx/src/app/core/api/alias-controller.ts +++ b/ui-ngx/src/app/core/api/alias-controller.ts @@ -68,10 +68,11 @@ export class AliasController implements IAliasController { private translate: TranslateService, private stateControllerHolder: StateControllerHolder, private origEntityAliases: EntityAliases, - private origFilters: Filters) { + private origFilters: Filters, + private origUserFilters?: Filters) { this.entityAliases = deepClone(this.origEntityAliases) || {}; this.filters = deepClone(this.origFilters) || {}; - this.userFilters = {}; + this.userFilters = deepClone(this.origUserFilters) || {}; } updateEntityAliases(newEntityAliases: EntityAliases) { diff --git a/ui-ngx/src/app/core/api/widget-api.models.ts b/ui-ngx/src/app/core/api/widget-api.models.ts index 71bfa32ee6..5c50ea0ab3 100644 --- a/ui-ngx/src/app/core/api/widget-api.models.ts +++ b/ui-ngx/src/app/core/api/widget-api.models.ts @@ -127,6 +127,7 @@ export interface IAliasController { entityAliasesChanged: Observable>; entityAliasResolved: Observable; filtersChanged: Observable>; + userFilters: Filters; getAliasInfo(aliasId: string): Observable; getEntityAliasId(aliasName: string): string; getInstantAliasInfo(aliasId: string): AliasInfo; 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 0daabc7611..af0356f4f3 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 @@ -522,7 +522,8 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC this.translate, () => this.dashboardCtx.stateController, this.dashboardConfiguration.entityAliases, - this.dashboardConfiguration.filters); + this.dashboardConfiguration.filters, + this.parentDashboard?.aliasController.userFilters); this.updateDashboardCss(); From 625e400d2b4e89a68b0a7416b3dd6b6b45961132 Mon Sep 17 00:00:00 2001 From: rusikv Date: Mon, 9 Sep 2024 18:26:54 +0300 Subject: [PATCH 2/2] UI: refactor getting of user filters in alias controller interface --- ui-ngx/src/app/core/api/alias-controller.ts | 4 ++++ ui-ngx/src/app/core/api/widget-api.models.ts | 2 +- .../components/dashboard-page/dashboard-page.component.ts | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ui-ngx/src/app/core/api/alias-controller.ts b/ui-ngx/src/app/core/api/alias-controller.ts index 1176e583ae..83dd4e102f 100644 --- a/ui-ngx/src/app/core/api/alias-controller.ts +++ b/ui-ngx/src/app/core/api/alias-controller.ts @@ -167,6 +167,10 @@ export class AliasController implements IAliasController { return this.filters; } + getUserFilters(): Filters { + return this.userFilters; + } + getFilterInfo(filterId: string): FilterInfo { if (this.userFilters[filterId]) { return this.userFilters[filterId]; diff --git a/ui-ngx/src/app/core/api/widget-api.models.ts b/ui-ngx/src/app/core/api/widget-api.models.ts index 5c50ea0ab3..bca6a05644 100644 --- a/ui-ngx/src/app/core/api/widget-api.models.ts +++ b/ui-ngx/src/app/core/api/widget-api.models.ts @@ -127,7 +127,6 @@ export interface IAliasController { entityAliasesChanged: Observable>; entityAliasResolved: Observable; filtersChanged: Observable>; - userFilters: Filters; getAliasInfo(aliasId: string): Observable; getEntityAliasId(aliasName: string): string; getInstantAliasInfo(aliasId: string): AliasInfo; @@ -138,6 +137,7 @@ export interface IAliasController { resolveAlarmSource(alarmSource: Datasource): Observable; getEntityAliases(): EntityAliases; getFilters(): Filters; + getUserFilters(): Filters; getFilterInfo(filterId: string): FilterInfo; getKeyFilters(filterId: string): Array; updateCurrentAliasEntity(aliasId: string, currentEntity: EntityInfo): void; 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 af0356f4f3..5dacda4733 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 @@ -523,7 +523,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC () => this.dashboardCtx.stateController, this.dashboardConfiguration.entityAliases, this.dashboardConfiguration.filters, - this.parentDashboard?.aliasController.userFilters); + this.parentDashboard?.aliasController.getUserFilters()); this.updateDashboardCss();