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.
///
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<WidgetTimewindow>;
widgetTimewindowChanged$: Observable<WidgetTimewindow>;
comparisonEnabled?: boolean;
comparisonTimeWindow?: WidgetTimewindow;

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

@ -141,7 +141,7 @@ export class WidgetSubscription implements IWidgetSubscription {
subscribed = false;
widgetTimewindowChangedSubject: Subject<WidgetTimewindow> = new ReplaySubject<WidgetTimewindow>();
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]();

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) {
this.breakpointObserverSubscription.unsubscribe();
}
this.dashboardTimewindowChangedSubject.complete();
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 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 {

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 = null;
}
this.ctx.dashboard.dashboardTimewindowChangedSubject.complete();
}
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 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 {

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

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

Loading…
Cancel
Save