move stats to dossiers service
This commit is contained in:
parent
4ba75fea07
commit
eb4b8b0f1e
@ -43,7 +43,7 @@ export class File implements IFile, IListable {
|
||||
readonly excludedPages?: number[];
|
||||
readonly hasSuggestions: boolean;
|
||||
|
||||
primaryAttribute: string;
|
||||
readonly primaryAttribute: string;
|
||||
lastOpened: boolean;
|
||||
readonly statusSort: number;
|
||||
readonly cacheIdentifier: string;
|
||||
@ -61,7 +61,7 @@ export class File implements IFile, IListable {
|
||||
readonly isWorkable: boolean;
|
||||
readonly canBeOCRed: boolean;
|
||||
|
||||
constructor(file: IFile, public reviewerName: string, fileAttributesConfig?: FileAttributesConfig) {
|
||||
constructor(file: IFile, readonly reviewerName: string, fileAttributesConfig?: FileAttributesConfig) {
|
||||
this.added = file.added;
|
||||
this.allManualRedactionsApplied = !!file.allManualRedactionsApplied;
|
||||
this.analysisDuration = file.analysisDuration;
|
||||
|
||||
@ -80,7 +80,6 @@ const components = [
|
||||
];
|
||||
|
||||
const services = [
|
||||
DossiersService,
|
||||
DossiersDialogService,
|
||||
AnnotationActionsService,
|
||||
ManualAnnotationService,
|
||||
|
||||
@ -6,11 +6,11 @@
|
||||
[subtitle]="'dossier-listing.stats.charts.dossiers' | translate"
|
||||
></redaction-simple-doughnut-chart>
|
||||
|
||||
<div class="dossier-stats-container">
|
||||
<div *ngIf="dossiersService.stats$ | async as stats" class="dossier-stats-container">
|
||||
<div class="dossier-stats-item">
|
||||
<mat-icon svgIcon="red:needs-work"></mat-icon>
|
||||
<div>
|
||||
<div class="heading">{{ appStateService.totalAnalysedPages | number }}</div>
|
||||
<div class="heading">{{ stats.totalAnalyzedPages | number }}</div>
|
||||
<div translate="dossier-listing.stats.analyzed-pages"></div>
|
||||
</div>
|
||||
</div>
|
||||
@ -18,7 +18,7 @@
|
||||
<div class="dossier-stats-item">
|
||||
<mat-icon svgIcon="red:user"></mat-icon>
|
||||
<div>
|
||||
<div class="heading">{{ appStateService.totalPeople }}</div>
|
||||
<div class="heading">{{ stats.totalPeople }}</div>
|
||||
<div translate="dossier-listing.stats.total-people"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
|
||||
import { DoughnutChartConfig } from '@shared/components/simple-doughnut-chart/simple-doughnut-chart.component';
|
||||
import { AppStateService } from '@state/app-state.service';
|
||||
import { FilterService } from '@iqser/common-ui';
|
||||
import { DossiersService } from '../../services/dossiers.service';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-dossiers-listing-details',
|
||||
@ -13,5 +13,5 @@ export class DossiersListingDetailsComponent {
|
||||
@Input() dossiersChartData: DoughnutChartConfig[];
|
||||
@Input() documentsChartData: DoughnutChartConfig[];
|
||||
|
||||
constructor(readonly appStateService: AppStateService, readonly filterService: FilterService) {}
|
||||
constructor(readonly filterService: FilterService, readonly dossiersService: DossiersService) {}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Injectable, Injector } from '@angular/core';
|
||||
import { DossierRequest, IDossier } from '@redaction/red-ui-http';
|
||||
import { EntitiesService, List, QueryParam } from '@iqser/common-ui';
|
||||
import { EntitiesService, List, QueryParam, RequiredParam, Validate } from '@iqser/common-ui';
|
||||
import { Dossier } from '@state/model/dossier';
|
||||
import { filter, map } from 'rxjs/operators';
|
||||
import { TEMPORARY_INJECTOR } from './injector';
|
||||
@ -56,7 +56,8 @@ export class DossiersService extends EntitiesService<Dossier, IDossier> {
|
||||
return dossierId ? super._getOne([dossierId]) : super.getAll();
|
||||
}
|
||||
|
||||
createOrUpdate(dossier: DossierRequest): Promise<IDossier> {
|
||||
@Validate()
|
||||
createOrUpdate(@RequiredParam() dossier: DossierRequest): Promise<IDossier> {
|
||||
return this._post(dossier).toPromise();
|
||||
}
|
||||
|
||||
@ -64,11 +65,13 @@ export class DossiersService extends EntitiesService<Dossier, IDossier> {
|
||||
return this.getAll('deleted-dossiers').toPromise();
|
||||
}
|
||||
|
||||
restore(dossierIds: List): Promise<unknown> {
|
||||
@Validate()
|
||||
restore(@RequiredParam() dossierIds: List): Promise<unknown> {
|
||||
return this._post(dossierIds, 'deleted-dossiers/restore').toPromise();
|
||||
}
|
||||
|
||||
hardDelete(dossierIds: List): Promise<unknown> {
|
||||
@Validate()
|
||||
hardDelete(@RequiredParam() dossierIds: List): Promise<unknown> {
|
||||
const body = dossierIds.map<QueryParam>(id => ({ key: 'dossierId', value: id }));
|
||||
return this.delete(body, 'deleted-dossiers/hard-delete', body).toPromise();
|
||||
}
|
||||
|
||||
@ -26,8 +26,6 @@ export interface AppState {
|
||||
activeFileId?: string;
|
||||
activeDossierTemplateId?: string;
|
||||
activeDictionaryType?: string;
|
||||
totalAnalysedPages?: number;
|
||||
totalPeople?: number;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
@ -134,14 +132,6 @@ export class AppStateService {
|
||||
return this._appState.activeFileId;
|
||||
}
|
||||
|
||||
get totalAnalysedPages(): number | undefined {
|
||||
return this._appState.totalAnalysedPages;
|
||||
}
|
||||
|
||||
get totalPeople(): number | undefined {
|
||||
return this._appState.totalPeople;
|
||||
}
|
||||
|
||||
private static _isFileOverviewRoute(event: Event) {
|
||||
return event instanceof ResolveStart && event.url.includes('/main/dossiers/') && event.url.includes('/file/');
|
||||
}
|
||||
@ -227,9 +217,6 @@ export class AppStateService {
|
||||
this._processFiles(dossier, fileData[dossierId], emitEvents);
|
||||
}
|
||||
}
|
||||
|
||||
this._appState.dossiers = mappedDossiers;
|
||||
this._computeStats();
|
||||
}
|
||||
|
||||
async reloadActiveFile() {
|
||||
@ -247,8 +234,8 @@ export class AppStateService {
|
||||
const files = this.activeDossier?.files.map(file => (file.fileId === activeFile.fileId ? activeFile : file));
|
||||
const newDossier = new Dossier(this.activeDossier, files);
|
||||
this._appState.dossiers = [...this._appState.dossiers.filter(d => d.dossierId !== newDossier.dossierId), newDossier];
|
||||
this._dossiersService.setEntities(this._appState.dossiers);
|
||||
|
||||
this._computeStats();
|
||||
if (activeFile.lastProcessed !== oldProcessedDate) {
|
||||
this.fileReanalysed$.next(activeFile);
|
||||
}
|
||||
@ -338,6 +325,7 @@ export class AppStateService {
|
||||
() => {
|
||||
const index = this.allDossiers.findIndex(p => p.id === dossier.id);
|
||||
this._appState.dossiers.splice(index, 1);
|
||||
this._dossiersService.setEntities(this._appState.dossiers);
|
||||
},
|
||||
() => this._toaster.error(_('dossier-listing.delete.delete-failed'), { params: dossier })
|
||||
);
|
||||
@ -355,6 +343,7 @@ export class AppStateService {
|
||||
}
|
||||
|
||||
this._appState.dossiers.push(foundDossier);
|
||||
this._dossiersService.setEntities(this._appState.dossiers);
|
||||
this.dossierChanged$.next(foundDossier);
|
||||
return foundDossier;
|
||||
} catch (error) {
|
||||
@ -659,8 +648,6 @@ export class AppStateService {
|
||||
})
|
||||
);
|
||||
|
||||
console.log(dictionaryData);
|
||||
|
||||
return forkJoin([typeObs, colorsObs]).pipe(map(() => dictionaryData));
|
||||
}
|
||||
|
||||
@ -729,8 +716,7 @@ export class AppStateService {
|
||||
files.forEach(file => (file.lastOpened = file.fileId === lastOpenedFileId));
|
||||
const newDossier = new Dossier(dossier, files);
|
||||
this._appState.dossiers = [...this._appState.dossiers.filter(d => d.dossierId !== dossier.dossierId), newDossier];
|
||||
|
||||
this._computeStats();
|
||||
this._dossiersService.setEntities(this._appState.dossiers);
|
||||
|
||||
if (emitEvents) {
|
||||
fileReanalysedEvent.forEach(file => this.fileReanalysed$.next(file));
|
||||
@ -739,17 +725,4 @@ export class AppStateService {
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
private _computeStats() {
|
||||
let totalAnalysedPages = 0;
|
||||
const totalPeople = new Set<string>();
|
||||
|
||||
this.allDossiers.forEach(d => {
|
||||
d.memberIds?.forEach(m => totalPeople.add(m));
|
||||
totalAnalysedPages += d.totalNumberOfPages;
|
||||
});
|
||||
|
||||
this._appState.totalPeople = totalPeople.size;
|
||||
this._appState.totalAnalysedPages = totalAnalysedPages;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user