remove dossier stats from dossier
This commit is contained in:
parent
4f8fa98e65
commit
9ad4e2400a
@ -1,4 +1,4 @@
|
||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { Toaster } from '@iqser/common-ui';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
@ -9,6 +9,7 @@ import { Dossier, IDossier, IDossierRequest } from '@red/domain';
|
||||
selector: 'redaction-team-members-manager',
|
||||
templateUrl: './team-members-manager.component.html',
|
||||
styleUrls: ['./team-members-manager.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class TeamMembersManagerComponent implements OnInit {
|
||||
teamForm: FormGroup;
|
||||
|
||||
@ -12,6 +12,7 @@ import { ConfirmationDialogInput, IconButtonTypes, TitleColors, Toaster } from '
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
|
||||
import { DossierStatsService } from '@services/entity-services/dossier-stats.service';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-edit-dossier-general-info',
|
||||
@ -32,6 +33,7 @@ export class EditDossierGeneralInfoComponent implements OnInit, EditDossierSecti
|
||||
readonly permissionsService: PermissionsService,
|
||||
private readonly _dossierTemplatesService: DossierTemplatesService,
|
||||
private readonly _dossiersService: DossiersService,
|
||||
private readonly _dossierStatsService: DossierStatsService,
|
||||
private readonly _formBuilder: FormBuilder,
|
||||
private readonly _dialogService: DossiersDialogService,
|
||||
private readonly _router: Router,
|
||||
@ -71,7 +73,7 @@ export class EditDossierGeneralInfoComponent implements OnInit, EditDossierSecti
|
||||
dossierTemplateId: [
|
||||
{
|
||||
value: this.dossier.dossierTemplateId,
|
||||
disabled: this.dossier.stats.hasFiles,
|
||||
disabled: this._dossierStatsService.get(this.dossier.dossierId).hasFiles,
|
||||
},
|
||||
Validators.required,
|
||||
],
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Component, EventEmitter, Input, Output, ViewChild } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output, ViewChild } from '@angular/core';
|
||||
import { Dossier } from '@red/domain';
|
||||
import { EditDossierSectionInterface } from '../edit-dossier-section.interface';
|
||||
import { TeamMembersManagerComponent } from '../../../components/team-members-manager/team-members-manager.component';
|
||||
@ -8,6 +8,7 @@ import { UserService } from '@services/user.service';
|
||||
selector: 'redaction-edit-dossier-team-members',
|
||||
templateUrl: './edit-dossier-team-members.component.html',
|
||||
styleUrls: ['./edit-dossier-team-members.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class EditDossierTeamMembersComponent implements EditDossierSectionInterface {
|
||||
readonly currentUser = this._userService.currentUser;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<ng-container *ngIf="dossier.stats$ | async as stats">
|
||||
<ng-container *ngIf="dossierStats$ | async as stats">
|
||||
<div>
|
||||
<mat-icon svgIcon="iqser:document"></mat-icon>
|
||||
<span>{{ 'dossier-overview.dossier-details.stats.documents' | translate: { count: stats.numberOfFiles } }}</span>
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { Dossier, DossierAttributeWithValue, DossierTemplate } from '@red/domain';
|
||||
import { Dossier, DossierAttributeWithValue, DossierStats, DossierTemplate } from '@red/domain';
|
||||
import { DossiersDialogService } from '../../../../services/dossiers-dialog.service';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
|
||||
import { FilesService } from '@services/entity-services/files.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { distinctUntilChanged, map } from 'rxjs/operators';
|
||||
import { DossierStatsService } from '@services/entity-services/dossier-stats.service';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-dossier-details-stats',
|
||||
@ -15,6 +16,7 @@ import { distinctUntilChanged, map } from 'rxjs/operators';
|
||||
export class DossierDetailsStatsComponent implements OnInit {
|
||||
attributesExpanded = false;
|
||||
deletedFilesCount$: Observable<number>;
|
||||
dossierStats$: Observable<DossierStats>;
|
||||
@Input()
|
||||
dossierAttributes: DossierAttributeWithValue[];
|
||||
@Input()
|
||||
@ -26,10 +28,12 @@ export class DossierDetailsStatsComponent implements OnInit {
|
||||
private readonly _dossierTemplatesService: DossierTemplatesService,
|
||||
private readonly _dialogService: DossiersDialogService,
|
||||
private readonly _filesService: FilesService,
|
||||
private readonly _dossierStatsService: DossierStatsService,
|
||||
readonly dossiersService: DossiersService,
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.dossierStats$ = this._dossierStatsService.watch$(this.dossier.dossierId);
|
||||
this.deletedFilesCount$ = this._filesService.getDeletedFilesFor(this.dossier.id).pipe(
|
||||
map(files => files.length),
|
||||
distinctUntilChanged(),
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
></redaction-team-members>
|
||||
</div>
|
||||
|
||||
<ng-container *ngIf="dossier.stats$ | async as stats">
|
||||
<ng-container *ngIf="dossierStats$ | async as stats">
|
||||
<div *ngIf="stats.hasFiles" class="mt-24">
|
||||
<redaction-simple-doughnut-chart
|
||||
[config]="calculateChartConfig(stats.fileCountPerWorkflowStatus)"
|
||||
|
||||
@ -3,13 +3,23 @@ import { AppStateService } from '@state/app-state.service';
|
||||
import { DoughnutChartConfig } from '@shared/components/simple-doughnut-chart/simple-doughnut-chart.component';
|
||||
import { TranslateChartService } from '@services/translate-chart.service';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { FilterService, Toaster } from '@iqser/common-ui';
|
||||
import { FilterService, shareLast, Toaster } from '@iqser/common-ui';
|
||||
import { fileStatusTranslations } from '../../../../translations/file-status-translations';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { Dossier, DossierAttributeWithValue, FileCountPerWorkflowStatus, IDossierRequest, StatusSorter, User } from '@red/domain';
|
||||
import {
|
||||
Dossier,
|
||||
DossierAttributeWithValue,
|
||||
DossierStats,
|
||||
FileCountPerWorkflowStatus,
|
||||
IDossierRequest,
|
||||
StatusSorter,
|
||||
User,
|
||||
} from '@red/domain';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { Observable } from 'rxjs';
|
||||
import { DossierStatsService } from '@services/entity-services/dossier-stats.service';
|
||||
import { pluck, switchMap } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-dossier-details',
|
||||
@ -30,6 +40,7 @@ export class DossierDetailsComponent {
|
||||
readonly currentUser = this._userService.currentUser;
|
||||
readonly dossierId: string;
|
||||
readonly dossier$: Observable<Dossier>;
|
||||
readonly dossierStats$: Observable<DossierStats>;
|
||||
|
||||
constructor(
|
||||
readonly appStateService: AppStateService,
|
||||
@ -38,11 +49,16 @@ export class DossierDetailsComponent {
|
||||
readonly filterService: FilterService,
|
||||
private readonly _changeDetectorRef: ChangeDetectorRef,
|
||||
private readonly _userService: UserService,
|
||||
private readonly _dossierStatsService: DossierStatsService,
|
||||
private readonly _toaster: Toaster,
|
||||
activatedRoute: ActivatedRoute,
|
||||
) {
|
||||
this.dossierId = activatedRoute.snapshot.paramMap.get('dossierId');
|
||||
this.dossier$ = this.dossiersService.getEntityChanged$(this.dossierId);
|
||||
this.dossier$ = this.dossiersService.getEntityChanged$(this.dossierId).pipe(shareLast());
|
||||
this.dossierStats$ = this.dossier$.pipe(
|
||||
pluck('dossierId'),
|
||||
switchMap(dossierId => this._dossierStatsService.watch$(dossierId)),
|
||||
);
|
||||
}
|
||||
|
||||
get managers() {
|
||||
|
||||
@ -1,18 +1,20 @@
|
||||
<div *ngIf="dossier.stats$ | async as stats" class="needs-work">
|
||||
<div class="needs-work">
|
||||
<redaction-annotation-icon
|
||||
*ngIf="stats.hasRedactionsFilePresent"
|
||||
*ngIf="dossierStats.hasRedactionsFilePresent"
|
||||
[color]="redactionColor"
|
||||
label="R"
|
||||
type="square"
|
||||
></redaction-annotation-icon>
|
||||
|
||||
<redaction-annotation-icon
|
||||
*ngIf="stats.hasHintsNoRedactionsFilePresent"
|
||||
*ngIf="dossierStats.hasHintsNoRedactionsFilePresent"
|
||||
[color]="hintColor"
|
||||
label="H"
|
||||
type="circle"
|
||||
></redaction-annotation-icon>
|
||||
|
||||
<redaction-annotation-icon
|
||||
*ngIf="stats.hasSuggestionsFilePresent"
|
||||
*ngIf="dossierStats.hasSuggestionsFilePresent"
|
||||
[color]="suggestionColor"
|
||||
label="S"
|
||||
type="rhombus"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
|
||||
import { AppStateService } from '@state/app-state.service';
|
||||
import { Dossier } from '@red/domain';
|
||||
import { Dossier, DossierStats } from '@red/domain';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-dossier-workload-column',
|
||||
@ -10,6 +10,7 @@ import { Dossier } from '@red/domain';
|
||||
})
|
||||
export class DossierWorkloadColumnComponent {
|
||||
@Input() dossier: Dossier;
|
||||
@Input() dossierStats: DossierStats;
|
||||
|
||||
constructor(private readonly _appStateService: AppStateService) {}
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<iqser-status-bar *ngIf="dossier.stats$ | async as stats" [configs]="statusConfig(stats)"></iqser-status-bar>
|
||||
<iqser-status-bar *ngIf="dossierStats$ | async as stats" [configs]="statusConfig(stats)"></iqser-status-bar>
|
||||
|
||||
<div (longPress)="forceReanalysisAction($event)" class="action-buttons" redactionLongPress>
|
||||
<iqser-circle-button
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { CircleButtonTypes, StatusBarConfig } from '@iqser/common-ui';
|
||||
import { UserService } from '@services/user.service';
|
||||
@ -10,6 +10,8 @@ import { UserPreferenceService } from '@services/user-preference.service';
|
||||
import { FilesMapService } from '@services/entity-services/files-map.service';
|
||||
import { ReanalysisService } from '@services/reanalysis.service';
|
||||
import { switchMapTo, tap } from 'rxjs/operators';
|
||||
import { DossierStatsService } from '@services/entity-services/dossier-stats.service';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-dossiers-listing-actions',
|
||||
@ -17,7 +19,7 @@ import { switchMapTo, tap } from 'rxjs/operators';
|
||||
styleUrls: ['./dossiers-listing-actions.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class DossiersListingActionsComponent {
|
||||
export class DossiersListingActionsComponent implements OnInit {
|
||||
readonly circleButtonTypes = CircleButtonTypes;
|
||||
readonly currentUser = this._userService.currentUser;
|
||||
|
||||
@ -25,6 +27,7 @@ export class DossiersListingActionsComponent {
|
||||
|
||||
@Input() dossier: Dossier;
|
||||
@Output() readonly actionPerformed = new EventEmitter<Dossier | undefined>();
|
||||
dossierStats$: Observable<DossierStats>;
|
||||
|
||||
constructor(
|
||||
readonly appStateService: AppStateService,
|
||||
@ -33,9 +36,14 @@ export class DossiersListingActionsComponent {
|
||||
readonly permissionsService: PermissionsService,
|
||||
readonly filesMapService: FilesMapService,
|
||||
private readonly _dialogService: DossiersDialogService,
|
||||
private readonly _dossierStatsService: DossierStatsService,
|
||||
private readonly _userPreferenceService: UserPreferenceService,
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.dossierStats$ = this._dossierStatsService.watch$(this.dossier.dossierId);
|
||||
}
|
||||
|
||||
statusConfig(stats: DossierStats): readonly StatusBarConfig<string>[] {
|
||||
return Object.keys(stats.fileCountPerWorkflowStatus)
|
||||
.sort(StatusSorter.byStatus)
|
||||
|
||||
@ -8,6 +8,7 @@ import { fileStatusTranslations } from '../../../../translations/file-status-tra
|
||||
import { TranslateChartService } from '@services/translate-chart.service';
|
||||
import { filter, map, switchMap } from 'rxjs/operators';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { DossierStatsService } from '@services/entity-services/dossier-stats.service';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-dossiers-listing-details',
|
||||
@ -22,10 +23,11 @@ export class DossiersListingDetailsComponent {
|
||||
constructor(
|
||||
readonly filterService: FilterService,
|
||||
readonly dossiersService: DossiersService,
|
||||
private readonly _dossierStatsMap: DossierStatsService,
|
||||
private readonly _translateChartService: TranslateChartService,
|
||||
) {
|
||||
this.documentsChartData$ = this.dossiersService.all$.pipe(
|
||||
mapEach(dossier => dossier.stats$),
|
||||
mapEach(dossier => _dossierStatsMap.watch$(dossier.dossierId)),
|
||||
switchMap(stats$ => combineLatest(stats$)),
|
||||
filter(stats => !stats.some(s => s === undefined)),
|
||||
map(stats => this._toChartData(stats)),
|
||||
|
||||
@ -9,15 +9,15 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf="dossier.stats$ | async as stats" class="small-label stats-subtitle">
|
||||
<div class="small-label stats-subtitle">
|
||||
<div>
|
||||
<mat-icon svgIcon="iqser:document"></mat-icon>
|
||||
{{ stats.numberOfFiles }}
|
||||
{{ dossierStats.numberOfFiles }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<mat-icon svgIcon="iqser:pages"></mat-icon>
|
||||
{{ stats.numberOfPages }}
|
||||
{{ dossierStats.numberOfPages }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
|
||||
import { Dossier } from '@red/domain';
|
||||
import { Dossier, DossierStats } from '@red/domain';
|
||||
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
|
||||
import { DossierStatsService } from '@services/entity-services/dossier-stats.service';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-dossiers-listing-dossier-name',
|
||||
@ -10,8 +12,13 @@ import { DossierTemplatesService } from '@services/entity-services/dossier-templ
|
||||
})
|
||||
export class DossiersListingDossierNameComponent {
|
||||
@Input() dossier: Dossier;
|
||||
@Input() dossierStats: DossierStats;
|
||||
|
||||
constructor(private readonly _dossierTemplatesService: DossierTemplatesService) {}
|
||||
constructor(
|
||||
private readonly _dossierTemplatesService: DossierTemplatesService,
|
||||
private readonly _dossierStatsService: DossierStatsService,
|
||||
private readonly _dossiersService: DossiersService,
|
||||
) {}
|
||||
|
||||
getDossierTemplateNameFor(dossierTemplateId: string): string {
|
||||
return this._dossierTemplatesService.find(dossierTemplateId).name;
|
||||
|
||||
@ -1,12 +1,17 @@
|
||||
<div class="cell">
|
||||
<redaction-dossiers-listing-dossier-name [dossier]="dossier"></redaction-dossiers-listing-dossier-name>
|
||||
</div>
|
||||
<div class="cell">
|
||||
<redaction-dossier-workload-column [dossier]="dossier"></redaction-dossier-workload-column>
|
||||
</div>
|
||||
<ng-container *ngIf="dossierStatsService.watch$(dossier.dossierId) | async as stats">
|
||||
<div class="cell">
|
||||
<redaction-dossiers-listing-dossier-name [dossierStats]="stats" [dossier]="dossier"></redaction-dossiers-listing-dossier-name>
|
||||
</div>
|
||||
|
||||
<div class="cell">
|
||||
<redaction-dossier-workload-column [dossierStats]="stats" [dossier]="dossier"></redaction-dossier-workload-column>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
<div class="cell user-column">
|
||||
<redaction-initials-avatar [user]="dossier.ownerId" [withName]="true"></redaction-initials-avatar>
|
||||
</div>
|
||||
|
||||
<div class="cell status-container">
|
||||
<redaction-dossiers-listing-actions (actionPerformed)="calculateData.emit()" [dossier]="dossier"></redaction-dossiers-listing-actions>
|
||||
</div>
|
||||
|
||||
@ -1,13 +1,17 @@
|
||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { Dossier } from '@red/domain';
|
||||
import { Required } from '@iqser/common-ui';
|
||||
import { DossierStatsService } from '@services/entity-services/dossier-stats.service';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-table-item',
|
||||
templateUrl: './table-item.component.html',
|
||||
styleUrls: ['./table-item.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class TableItemComponent {
|
||||
@Input() @Required() dossier!: Dossier;
|
||||
@Output() readonly calculateData = new EventEmitter();
|
||||
|
||||
constructor(readonly dossierStatsService: DossierStatsService) {}
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ import { dossierMemberChecker, dossierTemplateChecker, RedactionFilterSorter } f
|
||||
import { workloadTranslations } from '../../translations/workload-translations';
|
||||
import { AppStateService } from '@state/app-state.service';
|
||||
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
|
||||
import { DossierStatsService } from '@services/entity-services/dossier-stats.service';
|
||||
|
||||
@Injectable()
|
||||
export class ConfigService {
|
||||
@ -19,6 +20,7 @@ export class ConfigService {
|
||||
private readonly _userService: UserService,
|
||||
private readonly _appStateService: AppStateService,
|
||||
private readonly _dossierTemplatesService: DossierTemplatesService,
|
||||
private readonly _dossierStatsService: DossierStatsService,
|
||||
) {}
|
||||
|
||||
get tableConfig(): TableColumnConfig<Dossier>[] {
|
||||
@ -85,23 +87,24 @@ export class ConfigService {
|
||||
entities?.forEach(entry => {
|
||||
entry.memberIds.forEach(f => allDistinctPeople.add(f));
|
||||
allDistinctDossierTemplates.add(entry.dossierTemplateId);
|
||||
const stats = this._dossierStatsService.get(entry.dossierId);
|
||||
|
||||
if (!entry.stats) {
|
||||
if (!stats) {
|
||||
return;
|
||||
}
|
||||
|
||||
Object.keys(entry.stats?.fileCountPerWorkflowStatus).forEach(status => allDistinctFileStatus.add(status));
|
||||
Object.keys(stats?.fileCountPerWorkflowStatus).forEach(status => allDistinctFileStatus.add(status));
|
||||
|
||||
if (entry.stats.hasHintsNoRedactionsFilePresent) {
|
||||
if (stats.hasHintsNoRedactionsFilePresent) {
|
||||
allDistinctNeedsWork.add('hint');
|
||||
}
|
||||
if (entry.stats.hasRedactionsFilePresent) {
|
||||
if (stats.hasRedactionsFilePresent) {
|
||||
allDistinctNeedsWork.add('redaction');
|
||||
}
|
||||
if (entry.stats.hasSuggestionsFilePresent) {
|
||||
if (stats.hasSuggestionsFilePresent) {
|
||||
allDistinctNeedsWork.add('suggestion');
|
||||
}
|
||||
if (entry.stats.hasNoFlagsFilePresent) {
|
||||
if (stats.hasNoFlagsFilePresent) {
|
||||
allDistinctNeedsWork.add('none');
|
||||
}
|
||||
});
|
||||
@ -119,7 +122,7 @@ export class ConfigService {
|
||||
label: this._translateService.instant('filters.status'),
|
||||
icon: 'red:status',
|
||||
filters: statusFilters.sort((a, b) => StatusSorter[a.id] - StatusSorter[b.id]),
|
||||
checker: this._dossierStatusChecker,
|
||||
checker: (dossier: Dossier, filter: INestedFilter) => this._dossierStatusChecker(dossier, filter),
|
||||
});
|
||||
|
||||
const peopleFilters = [...allDistinctPeople].map(
|
||||
@ -152,7 +155,7 @@ export class ConfigService {
|
||||
icon: 'red:needs-work',
|
||||
filterTemplate: needsWorkFilterTemplate,
|
||||
filters: needsWorkFilters.sort((a, b) => RedactionFilterSorter[a.id] - RedactionFilterSorter[b.id]),
|
||||
checker: this._annotationFilterChecker,
|
||||
checker: (dossier: Dossier, filter: INestedFilter) => this._annotationFilterChecker(dossier, filter),
|
||||
matchAll: true,
|
||||
});
|
||||
|
||||
@ -199,24 +202,28 @@ export class ConfigService {
|
||||
return filterGroups;
|
||||
}
|
||||
|
||||
private _dossierStatusChecker = (dossier: Dossier, filter: INestedFilter) => dossier.stats.fileCountPerWorkflowStatus[filter.id];
|
||||
private _dossierStatusChecker = (dossier: Dossier, filter: INestedFilter) => {
|
||||
const stats = this._dossierStatsService.get(dossier.dossierId);
|
||||
return stats?.fileCountPerWorkflowStatus[filter.id];
|
||||
};
|
||||
|
||||
private _annotationFilterChecker = (dossier: Dossier, filter: INestedFilter) => {
|
||||
const stats = this._dossierStatsService.get(dossier.dossierId);
|
||||
switch (filter.id) {
|
||||
// case 'analysis': {
|
||||
// return stats.reanalysisRequired;
|
||||
// }
|
||||
case 'suggestion': {
|
||||
return dossier.stats.hasSuggestionsFilePresent;
|
||||
return stats.hasSuggestionsFilePresent;
|
||||
}
|
||||
case 'redaction': {
|
||||
return dossier.stats.hasRedactionsFilePresent;
|
||||
return stats.hasRedactionsFilePresent;
|
||||
}
|
||||
case 'hint': {
|
||||
return dossier.stats.hasHintsNoRedactionsFilePresent;
|
||||
return stats.hasHintsNoRedactionsFilePresent;
|
||||
}
|
||||
case 'none': {
|
||||
return dossier.stats.hasNoFlagsFilePresent;
|
||||
return stats.hasNoFlagsFilePresent;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,26 +1,44 @@
|
||||
import { Injectable, Injector } from '@angular/core';
|
||||
import { GenericService, mapEach, RequiredParam, Validate } from '@iqser/common-ui';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HeadersConfiguration, mapEach, RequiredParam, Validate } from '@iqser/common-ui';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { DossierStats, IDossierStats } from '@red/domain';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { tap } from 'rxjs/operators';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class DossierStatsService extends GenericService<IDossierStats> {
|
||||
constructor(protected readonly _injector: Injector) {
|
||||
super(_injector, 'dossier-stats');
|
||||
}
|
||||
export class DossierStatsService {
|
||||
private readonly _map = new Map<string, BehaviorSubject<DossierStats>>();
|
||||
|
||||
constructor(private readonly _http: HttpClient) {}
|
||||
|
||||
@Validate()
|
||||
getFor(@RequiredParam() dossierIds: string[]): Observable<DossierStats[]> {
|
||||
return this._post<IDossierStats[]>(dossierIds).pipe(mapEach(entity => new DossierStats(entity)));
|
||||
const request = this._http.post<IDossierStats[]>(`/${encodeURI('dossier-stats')}`, dossierIds, {
|
||||
headers: HeadersConfiguration.getHeaders(),
|
||||
observe: 'body',
|
||||
});
|
||||
|
||||
return request.pipe(
|
||||
mapEach(entity => new DossierStats(entity)),
|
||||
tap(entities => entities.forEach(entity => this.set(entity))),
|
||||
);
|
||||
}
|
||||
|
||||
// @Validate()
|
||||
// loadFor(@RequiredParam() dossierId: string): Observable<DossierStats> {
|
||||
// return this._getOne<IDossierStats>([dossierId]).pipe(
|
||||
// map((entity: IDossierStats) => new DossierStats(entity)),
|
||||
// tap((entity: DossierStats) => this.replace(entity)),
|
||||
// );
|
||||
// }
|
||||
get(key: string): DossierStats {
|
||||
return this._map.get(key)?.value;
|
||||
}
|
||||
|
||||
set(stats: DossierStats): void {
|
||||
if (!this._map.has(stats.dossierId)) {
|
||||
this._map.set(stats.dossierId, new BehaviorSubject<DossierStats>(stats));
|
||||
} else {
|
||||
this._map.get(stats.dossierId).next(stats);
|
||||
}
|
||||
}
|
||||
|
||||
watch$(key: string): Observable<DossierStats> {
|
||||
return this._map.get(key)?.asObservable();
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,7 +94,7 @@ export class DossiersService extends EntitiesService<Dossier, IDossier> {
|
||||
const stats$ = dossier$.pipe(switchMap(updatedDossier => this._dossierStatsService.getFor([updatedDossier.dossierId])));
|
||||
|
||||
return combineLatest([dossier$, stats$]).pipe(
|
||||
map(([updatedDossier, stats]) => new Dossier(updatedDossier, stats[0])),
|
||||
map(([updatedDossier]) => new Dossier(updatedDossier)),
|
||||
tap(newDossier => this.replace(newDossier)),
|
||||
catchError(showToast),
|
||||
);
|
||||
@ -132,7 +132,7 @@ export class DossiersService extends EntitiesService<Dossier, IDossier> {
|
||||
|
||||
entities.forEach(dossier => {
|
||||
dossier.memberIds?.forEach(m => totalPeople.add(m));
|
||||
totalAnalyzedPages += dossier.stats.numberOfPages;
|
||||
totalAnalyzedPages += this._dossierStatsService.get(dossier.dossierId).numberOfPages;
|
||||
});
|
||||
|
||||
return {
|
||||
@ -142,7 +142,7 @@ export class DossiersService extends EntitiesService<Dossier, IDossier> {
|
||||
}
|
||||
|
||||
private _generalStats$(entities: List<Dossier>): Observable<IDossiersStats> {
|
||||
const stats$ = entities.map(entity => entity.stats$);
|
||||
const stats$ = entities.map(entity => this._dossierStatsService.watch$(entity.dossierId));
|
||||
return combineLatest(stats$).pipe(
|
||||
filter(stats => stats.every(s => !!s)),
|
||||
map(() => this._computeStats(entities)),
|
||||
|
||||
@ -127,13 +127,12 @@ export class AppStateService {
|
||||
}
|
||||
|
||||
const dossierIds = dossiers.map(dossier => dossier.dossierId);
|
||||
const dossierStats = await this._dossierStatsService.getFor(dossierIds).toPromise();
|
||||
await this._dossierStatsService.getFor(dossierIds).toPromise();
|
||||
|
||||
const mappedDossiers$ = dossiers.map(async p => {
|
||||
const oldDossier = this._dossiersService.find(p.dossierId);
|
||||
const type = oldDossier?.type ?? (await this._getDictionaryFor(p));
|
||||
const stats = dossierStats.find(s => s.dossierId === p.dossierId);
|
||||
this._dossiersService.replace(new Dossier(p, stats, type));
|
||||
this._dossiersService.replace(new Dossier(p, type));
|
||||
});
|
||||
return Promise.all(mappedDossiers$);
|
||||
}
|
||||
|
||||
@ -3,8 +3,6 @@ import { IDossier } from './dossier';
|
||||
import { DossierStatus } from './types';
|
||||
import { DownloadFileType } from '../shared';
|
||||
import { IDictionary } from '../dictionaries';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { DossierStats } from '../dossier-stats';
|
||||
|
||||
export class Dossier implements IDossier, IListable {
|
||||
readonly dossierId: string;
|
||||
@ -25,10 +23,7 @@ export class Dossier implements IDossier, IListable {
|
||||
readonly watermarkEnabled: boolean;
|
||||
readonly hasReviewers: boolean;
|
||||
|
||||
readonly stats$: Observable<DossierStats>;
|
||||
private readonly _stats$: BehaviorSubject<DossierStats>;
|
||||
|
||||
constructor(dossier: IDossier, stats: DossierStats, public type?: IDictionary) {
|
||||
constructor(dossier: IDossier, public type?: IDictionary) {
|
||||
this.dossierId = dossier.dossierId;
|
||||
this.approverIds = dossier.approverIds;
|
||||
this.date = dossier.date;
|
||||
@ -46,9 +41,6 @@ export class Dossier implements IDossier, IListable {
|
||||
this.status = dossier.status;
|
||||
this.watermarkEnabled = dossier.watermarkEnabled;
|
||||
this.hasReviewers = !!this.memberIds && this.memberIds.length > 1;
|
||||
|
||||
this._stats$ = new BehaviorSubject<DossierStats>(stats);
|
||||
this.stats$ = this._stats$.asObservable();
|
||||
}
|
||||
|
||||
get id(): string {
|
||||
@ -63,10 +55,6 @@ export class Dossier implements IDossier, IListable {
|
||||
return this.dossierName;
|
||||
}
|
||||
|
||||
get stats(): DossierStats {
|
||||
return this._stats$.getValue();
|
||||
}
|
||||
|
||||
hasMember(memberId: string): boolean {
|
||||
return !!this.memberIds && this.memberIds.indexOf(memberId) >= 0;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user