Skip to content

Commit 2cfb09b

Browse files
[DSC-2815] fix statistics update
1 parent 3c05320 commit 2cfb09b

3 files changed

Lines changed: 17 additions & 7 deletions

File tree

src/app/statistics-page/cris-statistics-page/cris-statistics-page.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ import {
2727
} from '@ngrx/store';
2828
import { TranslateModule } from '@ngx-translate/core';
2929
import {
30+
BehaviorSubject,
3031
combineLatest,
3132
Observable,
3233
of,
33-
Subject,
3434
} from 'rxjs';
3535
import {
3636
finalize,
@@ -150,7 +150,7 @@ export class CrisStatisticsPageComponent implements OnInit, OnDestroy {
150150
/**
151151
* The fully loaded report (with points) for the currently selected chart report.
152152
*/
153-
private selectedFullReportSubject = new Subject<UsageReport | null>();
153+
private selectedFullReportSubject = new BehaviorSubject<UsageReport | null>(null);
154154
selectedFullReport$ = this.selectedFullReportSubject.asObservable();
155155

156156
constructor(

src/app/statistics-page/cris-statistics-page/statistics-chart/statistics-chart-wrapper/statistics-chart-wrapper.component.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,25 @@ export class StatisticsChartWrapperComponent implements OnInit, OnChanges {
5757
*/
5858
ngOnInit(): void {
5959
this.chartData = this.getStatistics();
60-
this.objectInjector = Injector.create({
60+
this.objectInjector = this.createInjector();
61+
}
62+
63+
ngOnChanges(changes: SimpleChanges): void {
64+
this.chartData = this.getStatistics();
65+
this.objectInjector = this.createInjector();
66+
}
67+
68+
private createInjector(): Injector {
69+
const report = this.report;
70+
return Injector.create({
6171
providers: [
62-
{ provide: REPORT_DATA, useFactory: () => (this.report), deps: [] },
72+
{ provide: REPORT_DATA, useFactory: () => report, deps: [] },
6373
{ provide: 'categoryType', useValue: this.categoryType },
6474
],
6575
parent: this.injector,
6676
});
6777
}
6878

69-
ngOnChanges(changes: SimpleChanges): void {
70-
this.ngOnInit();
71-
}
7279

7380
/**
7481
* Find the correct component based on the filter config's type

src/app/statistics-page/cris-statistics-page/statistics-map/statistics-map.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
NgIf,
77
} from '@angular/common';
88
import {
9+
ChangeDetectorRef,
910
Component,
1011
Inject,
1112
Input,
@@ -105,6 +106,7 @@ export class StatisticsMapComponent implements OnInit {
105106
private usageReportService: UsageReportDataService,
106107
@Inject(NativeWindowService) private _window: NativeWindowRef,
107108
@Inject(DOCUMENT) private document: any,
109+
private changeDetectorRef: ChangeDetectorRef,
108110
) {
109111
if (isPlatformBrowser(this.platformId)) {
110112
import('../../../core/export-service/browser-export.service').then((s) => {
@@ -161,6 +163,7 @@ export class StatisticsMapComponent implements OnInit {
161163
],
162164
options: { 'title': this.report.reportType },
163165
};
166+
this.changeDetectorRef.detectChanges();
164167
}
165168

166169
/**

0 commit comments

Comments
 (0)