diff --git a/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.ts b/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.ts index 04e7e56bd..36feeea1e 100644 --- a/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.ts +++ b/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.ts @@ -12,7 +12,7 @@ import { DocumentService } from 'src/app/services/rest/document.service'; templateUrl: './saved-view-widget.component.html', styleUrls: ['./saved-view-widget.component.scss'] }) -export class SavedViewWidgetComponent implements OnInit { +export class SavedViewWidgetComponent implements OnInit, OnDestroy { constructor( private documentService: DocumentService, diff --git a/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.ts b/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.ts index c3f45d63c..5207d56ab 100644 --- a/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.ts +++ b/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.ts @@ -1,6 +1,7 @@ import { HttpClient } from '@angular/common/http'; -import { Component, OnInit } from '@angular/core'; -import { Observable } from 'rxjs'; +import { Component, OnDestroy, OnInit } from '@angular/core'; +import { Observable, Subscription } from 'rxjs'; +import { ConsumerStatusService } from 'src/app/services/consumer-status.service'; import { environment } from 'src/environments/environment'; export interface Statistics { @@ -14,20 +15,34 @@ export interface Statistics { templateUrl: './statistics-widget.component.html', styleUrls: ['./statistics-widget.component.scss'] }) -export class StatisticsWidgetComponent implements OnInit { +export class StatisticsWidgetComponent implements OnInit, OnDestroy { - constructor(private http: HttpClient) { } + constructor(private http: HttpClient, + private consumerStatusService: ConsumerStatusService) { } statistics: Statistics = {} - getStatistics(): Observable { + subscription: Subscription + + private getStatistics(): Observable { return this.http.get(`${environment.apiBaseUrl}statistics/`) } - ngOnInit(): void { + reload() { this.getStatistics().subscribe(statistics => { this.statistics = statistics }) } + ngOnInit(): void { + this.reload() + this.subscription = this.consumerStatusService.onDocumentConsumptionFinished().subscribe(status => { + this.reload() + }) + } + + ngOnDestroy(): void { + this.subscription.unsubscribe() + } + }