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 eeeb73d038..91555a040a 100644 --- a/ui-ngx/src/app/core/api/widget-api.models.ts +++ b/ui-ngx/src/app/core/api/widget-api.models.ts @@ -14,7 +14,7 @@ /// limitations under the License. /// -import { Observable, Subject } from 'rxjs'; +import { Observable } from 'rxjs'; import { EntityId } from '@app/shared/models/id/entity-id'; import { DataSet, @@ -277,7 +277,7 @@ export interface IWidgetSubscription { hiddenData?: Array<{data: DataSet}>; timeWindowConfig?: Timewindow; timeWindow?: WidgetTimewindow; - widgetTimewindowChanged: Observable; + widgetTimewindowChanged$: Observable; comparisonEnabled?: boolean; comparisonTimeWindow?: WidgetTimewindow; diff --git a/ui-ngx/src/app/core/api/widget-subscription.ts b/ui-ngx/src/app/core/api/widget-subscription.ts index 0f05208981..61ada4ffd2 100644 --- a/ui-ngx/src/app/core/api/widget-subscription.ts +++ b/ui-ngx/src/app/core/api/widget-subscription.ts @@ -141,7 +141,7 @@ export class WidgetSubscription implements IWidgetSubscription { subscribed = false; widgetTimewindowChangedSubject: Subject = new ReplaySubject(); - widgetTimewindowChanged = this.widgetTimewindowChangedSubject.asObservable().pipe( + widgetTimewindowChanged$ = this.widgetTimewindowChangedSubject.asObservable().pipe( distinct() ); @@ -1124,6 +1124,7 @@ export class WidgetSubscription implements IWidgetSubscription { destroy(): void { this.unsubscribe(); + this.widgetTimewindowChangedSubject.complete(); for (const cafId of Object.keys(this.cafs)) { if (this.cafs[cafId]) { this.cafs[cafId](); diff --git a/ui-ngx/src/app/modules/home/components/dashboard/dashboard.component.ts b/ui-ngx/src/app/modules/home/components/dashboard/dashboard.component.ts index 72c242c308..b7bd51c437 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard/dashboard.component.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard/dashboard.component.ts @@ -238,6 +238,7 @@ export class DashboardComponent extends PageComponent implements IDashboardCompo if (this.breakpointObserverSubscription) { this.breakpointObserverSubscription.unsubscribe(); } + this.dashboardTimewindowChangedSubject.complete(); this.gridster = null; } diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/alarms-table-widget.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/alarms-table-widget.component.ts index 4054041c48..dd3539024b 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/alarms-table-widget.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/alarms-table-widget.component.ts @@ -188,7 +188,7 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit, private rowStylesInfo: RowStyleInfo; - private widgetTimewindowChangedSubscription: Subscription; + private widgetTimewindowChanged$: Subscription; private searchAction: WidgetAction = { name: 'action.search', @@ -247,18 +247,17 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit, this.ctx.updateWidgetParams(); if (this.displayPagination) { - this.widgetTimewindowChangedSubscription = this.ctx.defaultSubscription.widgetTimewindowChanged.subscribe( + this.widgetTimewindowChanged$ = this.ctx.defaultSubscription.widgetTimewindowChanged$.subscribe( () => this.pageLink.page = 0 ); } } ngOnDestroy(): void { - if (this.widgetTimewindowChangedSubscription) { - this.widgetTimewindowChangedSubscription.unsubscribe(); - this.widgetTimewindowChangedSubscription = null; + if (this.widgetTimewindowChanged$) { + this.widgetTimewindowChanged$.unsubscribe(); + this.widgetTimewindowChanged$ = null; } - this.ctx.defaultSubscription.widgetTimewindowChangedSubject.complete(); } ngAfterViewInit(): void { diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/date-range-navigator/date-range-navigator.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/date-range-navigator/date-range-navigator.component.ts index 640e09478c..526913af8d 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/date-range-navigator/date-range-navigator.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/date-range-navigator/date-range-navigator.component.ts @@ -119,7 +119,6 @@ export class DateRangeNavigatorWidgetComponent extends PageComponent implements this.dashboardTimewindowChangedSubscription.unsubscribe(); this.dashboardTimewindowChangedSubscription = null; } - this.ctx.dashboard.dashboardTimewindowChangedSubject.complete(); } openNavigatorPanel($event: Event) { diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/timeseries-table-widget.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/timeseries-table-widget.component.ts index 5dfd47ed83..f5b01ef39a 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/timeseries-table-widget.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/timeseries-table-widget.component.ts @@ -139,7 +139,7 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI private rowStylesInfo: RowStyleInfo; private subscriptions: Subscription[] = []; - private widgetTimewindowChangedSubscription: Subscription; + private widgetTimewindowChanged$: Subscription; private searchAction: WidgetAction = { name: 'action.search', @@ -172,7 +172,7 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI this.ctx.updateWidgetParams(); if (this.displayPagination) { - this.widgetTimewindowChangedSubscription = this.ctx.defaultSubscription.widgetTimewindowChanged.subscribe( + this.widgetTimewindowChanged$ = this.ctx.defaultSubscription.widgetTimewindowChanged$.subscribe( () => { this.sources.forEach((source) => { if (this.displayPagination) { @@ -185,11 +185,10 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI } ngOnDestroy(): void { - if (this.widgetTimewindowChangedSubscription) { - this.widgetTimewindowChangedSubscription.unsubscribe(); - this.widgetTimewindowChangedSubscription = null; + if (this.widgetTimewindowChanged$) { + this.widgetTimewindowChanged$.unsubscribe(); + this.widgetTimewindowChanged$ = null; } - this.ctx.defaultSubscription.widgetTimewindowChangedSubject.complete(); } ngAfterViewInit(): void { diff --git a/ui-ngx/src/app/modules/home/models/dashboard-component.models.ts b/ui-ngx/src/app/modules/home/models/dashboard-component.models.ts index 3ce1779bf6..ffcaef06ef 100644 --- a/ui-ngx/src/app/modules/home/models/dashboard-component.models.ts +++ b/ui-ngx/src/app/modules/home/models/dashboard-component.models.ts @@ -67,7 +67,6 @@ export interface IDashboardComponent { autofillHeight: boolean; dashboardTimewindow: Timewindow; dashboardTimewindowChanged: Observable; - dashboardTimewindowChangedSubject: Subject; aliasController: IAliasController; stateController: IStateController; onUpdateTimewindow(startTimeMs: number, endTimeMs: number, interval?: number, persist?: boolean): void;