Skip to content

Commit 847a950

Browse files
FrancescoMolinaroAndrea Barbasso
authored andcommitted
Merged in task/dspace-cris-2025_02_x/DSC-2815 (pull request DSpace#4392)
[DSC-2815] fix statistics update Approved-by: Andrea Barbasso
2 parents 18f041f + 4f56521 commit 847a950

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
@@ -23,10 +23,10 @@ import {
2323
} from '@ngrx/store';
2424
import { TranslateModule } from '@ngx-translate/core';
2525
import {
26+
BehaviorSubject,
2627
combineLatest,
2728
Observable,
2829
of,
29-
Subject,
3030
} from 'rxjs';
3131
import {
3232
finalize,
@@ -143,7 +143,7 @@ export class CrisStatisticsPageComponent implements OnInit, OnDestroy {
143143
/**
144144
* The fully loaded report (with points) for the currently selected chart report.
145145
*/
146-
private selectedFullReportSubject = new Subject<UsageReport | null>();
146+
private selectedFullReportSubject = new BehaviorSubject<UsageReport | null>(null);
147147
selectedFullReport$ = this.selectedFullReportSubject.asObservable();
148148

149149
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
@@ -58,18 +58,25 @@ export class StatisticsChartWrapperComponent implements OnInit, OnChanges {
5858
*/
5959
ngOnInit(): void {
6060
this.chartData = this.getStatistics();
61-
this.objectInjector = Injector.create({
61+
this.objectInjector = this.createInjector();
62+
}
63+
64+
ngOnChanges(changes: SimpleChanges): void {
65+
this.chartData = this.getStatistics();
66+
this.objectInjector = this.createInjector();
67+
}
68+
69+
private createInjector(): Injector {
70+
const report = this.report;
71+
return Injector.create({
6272
providers: [
63-
{ provide: REPORT_DATA, useFactory: () => (this.report), deps: [] },
73+
{ provide: REPORT_DATA, useFactory: () => report, deps: [] },
6474
{ provide: 'categoryType', useValue: this.categoryType },
6575
],
6676
parent: this.injector,
6777
});
6878
}
6979

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

7481
/**
7582
* 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
@@ -4,6 +4,7 @@ import {
44
isPlatformBrowser,
55
} from '@angular/common';
66
import {
7+
ChangeDetectorRef,
78
Component,
89
Inject,
910
Input,
@@ -100,6 +101,7 @@ export class StatisticsMapComponent implements OnInit {
100101
private usageReportService: UsageReportDataService,
101102
@Inject(NativeWindowService) private _window: NativeWindowRef,
102103
@Inject(DOCUMENT) private document: any,
104+
private changeDetectorRef: ChangeDetectorRef,
103105
) {
104106
if (isPlatformBrowser(this.platformId)) {
105107
import('../../../core/export-service/browser-export.service').then((s) => {
@@ -156,6 +158,7 @@ export class StatisticsMapComponent implements OnInit {
156158
],
157159
options: { 'title': this.report.reportType },
158160
};
161+
this.changeDetectorRef.detectChanges();
159162
}
160163

161164
/**

0 commit comments

Comments
 (0)