mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	update statistics when new documents are added
This commit is contained in:
		| @@ -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, | ||||
|   | ||||
| @@ -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<Statistics> { | ||||
|   subscription: Subscription | ||||
|    | ||||
|   private getStatistics(): Observable<Statistics> { | ||||
|     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() | ||||
|   } | ||||
|  | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 jonaswinkler
					jonaswinkler