Browse Source

UI: Refactoring code

pull/5330/head
Vladyslav_Prykhodko 5 years ago
parent
commit
45961519cd
  1. 4
      ui-ngx/src/app/core/api/widget-api.models.ts
  2. 3
      ui-ngx/src/app/core/api/widget-subscription.ts
  3. 1
      ui-ngx/src/app/modules/home/components/dashboard/dashboard.component.ts
  4. 11
      ui-ngx/src/app/modules/home/components/widget/lib/alarms-table-widget.component.ts
  5. 1
      ui-ngx/src/app/modules/home/components/widget/lib/date-range-navigator/date-range-navigator.component.ts
  6. 11
      ui-ngx/src/app/modules/home/components/widget/lib/timeseries-table-widget.component.ts
  7. 1
      ui-ngx/src/app/modules/home/models/dashboard-component.models.ts

4
ui-ngx/src/app/core/api/widget-api.models.ts

@ -14,7 +14,7 @@
/// limitations under the License. /// limitations under the License.
/// ///
import { Observable, Subject } from 'rxjs'; import { Observable } from 'rxjs';
import { EntityId } from '@app/shared/models/id/entity-id'; import { EntityId } from '@app/shared/models/id/entity-id';
import { import {
DataSet, DataSet,
@ -277,7 +277,7 @@ export interface IWidgetSubscription {
hiddenData?: Array<{data: DataSet}>; hiddenData?: Array<{data: DataSet}>;
timeWindowConfig?: Timewindow; timeWindowConfig?: Timewindow;
timeWindow?: WidgetTimewindow; timeWindow?: WidgetTimewindow;
widgetTimewindowChanged: Observable<WidgetTimewindow>; widgetTimewindowChanged$: Observable<WidgetTimewindow>;
comparisonEnabled?: boolean; comparisonEnabled?: boolean;
comparisonTimeWindow?: WidgetTimewindow; comparisonTimeWindow?: WidgetTimewindow;

3
ui-ngx/src/app/core/api/widget-subscription.ts

@ -141,7 +141,7 @@ export class WidgetSubscription implements IWidgetSubscription {
subscribed = false; subscribed = false;
widgetTimewindowChangedSubject: Subject<WidgetTimewindow> = new ReplaySubject<WidgetTimewindow>(); widgetTimewindowChangedSubject: Subject<WidgetTimewindow> = new ReplaySubject<WidgetTimewindow>();
widgetTimewindowChanged = this.widgetTimewindowChangedSubject.asObservable().pipe( widgetTimewindowChanged$ = this.widgetTimewindowChangedSubject.asObservable().pipe(
distinct() distinct()
); );
@ -1124,6 +1124,7 @@ export class WidgetSubscription implements IWidgetSubscription {
destroy(): void { destroy(): void {
this.unsubscribe(); this.unsubscribe();
this.widgetTimewindowChangedSubject.complete();
for (const cafId of Object.keys(this.cafs)) { for (const cafId of Object.keys(this.cafs)) {
if (this.cafs[cafId]) { if (this.cafs[cafId]) {
this.cafs[cafId](); this.cafs[cafId]();

1
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) { if (this.breakpointObserverSubscription) {
this.breakpointObserverSubscription.unsubscribe(); this.breakpointObserverSubscription.unsubscribe();
} }
this.dashboardTimewindowChangedSubject.complete();
this.gridster = null; this.gridster = null;
} }

11
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 rowStylesInfo: RowStyleInfo;
private widgetTimewindowChangedSubscription: Subscription; private widgetTimewindowChanged$: Subscription;
private searchAction: WidgetAction = { private searchAction: WidgetAction = {
name: 'action.search', name: 'action.search',
@ -247,18 +247,17 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit,
this.ctx.updateWidgetParams(); this.ctx.updateWidgetParams();
if (this.displayPagination) { if (this.displayPagination) {
this.widgetTimewindowChangedSubscription = this.ctx.defaultSubscription.widgetTimewindowChanged.subscribe( this.widgetTimewindowChanged$ = this.ctx.defaultSubscription.widgetTimewindowChanged$.subscribe(
() => this.pageLink.page = 0 () => this.pageLink.page = 0
); );
} }
} }
ngOnDestroy(): void { ngOnDestroy(): void {
if (this.widgetTimewindowChangedSubscription) { if (this.widgetTimewindowChanged$) {
this.widgetTimewindowChangedSubscription.unsubscribe(); this.widgetTimewindowChanged$.unsubscribe();
this.widgetTimewindowChangedSubscription = null; this.widgetTimewindowChanged$ = null;
} }
this.ctx.defaultSubscription.widgetTimewindowChangedSubject.complete();
} }
ngAfterViewInit(): void { ngAfterViewInit(): void {

1
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.unsubscribe();
this.dashboardTimewindowChangedSubscription = null; this.dashboardTimewindowChangedSubscription = null;
} }
this.ctx.dashboard.dashboardTimewindowChangedSubject.complete();
} }
openNavigatorPanel($event: Event) { openNavigatorPanel($event: Event) {

11
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 rowStylesInfo: RowStyleInfo;
private subscriptions: Subscription[] = []; private subscriptions: Subscription[] = [];
private widgetTimewindowChangedSubscription: Subscription; private widgetTimewindowChanged$: Subscription;
private searchAction: WidgetAction = { private searchAction: WidgetAction = {
name: 'action.search', name: 'action.search',
@ -172,7 +172,7 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI
this.ctx.updateWidgetParams(); this.ctx.updateWidgetParams();
if (this.displayPagination) { if (this.displayPagination) {
this.widgetTimewindowChangedSubscription = this.ctx.defaultSubscription.widgetTimewindowChanged.subscribe( this.widgetTimewindowChanged$ = this.ctx.defaultSubscription.widgetTimewindowChanged$.subscribe(
() => { () => {
this.sources.forEach((source) => { this.sources.forEach((source) => {
if (this.displayPagination) { if (this.displayPagination) {
@ -185,11 +185,10 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI
} }
ngOnDestroy(): void { ngOnDestroy(): void {
if (this.widgetTimewindowChangedSubscription) { if (this.widgetTimewindowChanged$) {
this.widgetTimewindowChangedSubscription.unsubscribe(); this.widgetTimewindowChanged$.unsubscribe();
this.widgetTimewindowChangedSubscription = null; this.widgetTimewindowChanged$ = null;
} }
this.ctx.defaultSubscription.widgetTimewindowChangedSubject.complete();
} }
ngAfterViewInit(): void { ngAfterViewInit(): void {

1
ui-ngx/src/app/modules/home/models/dashboard-component.models.ts

@ -67,7 +67,6 @@ export interface IDashboardComponent {
autofillHeight: boolean; autofillHeight: boolean;
dashboardTimewindow: Timewindow; dashboardTimewindow: Timewindow;
dashboardTimewindowChanged: Observable<Timewindow>; dashboardTimewindowChanged: Observable<Timewindow>;
dashboardTimewindowChangedSubject: Subject<Timewindow>;
aliasController: IAliasController; aliasController: IAliasController;
stateController: IStateController; stateController: IStateController;
onUpdateTimewindow(startTimeMs: number, endTimeMs: number, interval?: number, persist?: boolean): void; onUpdateTimewindow(startTimeMs: number, endTimeMs: number, interval?: number, persist?: boolean): void;

Loading…
Cancel
Save