Use new changes details endpoint
This commit is contained in:
parent
a2a96ad2df
commit
72504dfebc
@ -15,9 +15,8 @@ import { FileDropOverlayService } from '@upload-download/services/file-drop-over
|
|||||||
import { FileUploadModel } from '@upload-download/model/file-upload.model';
|
import { FileUploadModel } from '@upload-download/model/file-upload.model';
|
||||||
import { FileUploadService } from '@upload-download/services/file-upload.service';
|
import { FileUploadService } from '@upload-download/services/file-upload.service';
|
||||||
import { StatusOverlayService } from '@upload-download/services/status-overlay.service';
|
import { StatusOverlayService } from '@upload-download/services/status-overlay.service';
|
||||||
import * as moment from 'moment';
|
import { Observable } from 'rxjs';
|
||||||
import { combineLatest, Observable } from 'rxjs';
|
import { filter, skip, switchMap, tap } from 'rxjs/operators';
|
||||||
import { skip, switchMap, tap } from 'rxjs/operators';
|
|
||||||
import { convertFiles, Files, handleFileDrop } from '@utils/index';
|
import { convertFiles, Files, handleFileDrop } from '@utils/index';
|
||||||
import {
|
import {
|
||||||
CircleButtonTypes,
|
CircleButtonTypes,
|
||||||
@ -129,17 +128,17 @@ export class DossierOverviewScreenComponent extends ListingComponent<File> imple
|
|||||||
|
|
||||||
this._fileDropOverlayService.initFileDropHandling(this.dossierId);
|
this._fileDropOverlayService.initFileDropHandling(this.dossierId);
|
||||||
|
|
||||||
this.addSubscription = combineLatest([
|
|
||||||
this._dossiersService.getEntityChanged$(this.dossierId),
|
|
||||||
this._dossierStatsService.watch$(this.dossierId),
|
|
||||||
])
|
|
||||||
.pipe(switchMap(() => this._reloadFiles()))
|
|
||||||
.subscribe();
|
|
||||||
|
|
||||||
this.addSubscription = this.configService.listingMode$.subscribe(() => {
|
this.addSubscription = this.configService.listingMode$.subscribe(() => {
|
||||||
this._computeAllFilters();
|
this._computeAllFilters();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.addSubscription = this._dossiersService.dossierFileChanges$
|
||||||
|
.pipe(
|
||||||
|
filter(dossierId => dossierId === this.dossierId),
|
||||||
|
switchMap(dossierId => this._filesService.loadAll(dossierId)),
|
||||||
|
)
|
||||||
|
.subscribe();
|
||||||
|
|
||||||
this.addSubscription = this._dossierTemplatesService
|
this.addSubscription = this._dossierTemplatesService
|
||||||
.getEntityChanged$(this.currentDossier.dossierTemplateId)
|
.getEntityChanged$(this.currentDossier.dossierTemplateId)
|
||||||
.pipe(
|
.pipe(
|
||||||
@ -192,9 +191,6 @@ export class DossierOverviewScreenComponent extends ListingComponent<File> imple
|
|||||||
(this._fileInput as any).nativeElement.value = null;
|
(this._fileInput as any).nativeElement.value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
recentlyModifiedChecker = (file: File) =>
|
|
||||||
moment(file.lastUpdated).add(this._appConfigService.values.RECENT_PERIOD_IN_HOURS, 'hours').isAfter(moment());
|
|
||||||
|
|
||||||
private _updateFileAttributes(): void {
|
private _updateFileAttributes(): void {
|
||||||
this._fileAttributeConfigs =
|
this._fileAttributeConfigs =
|
||||||
this._fileAttributesService.getFileAttributeConfig(this.currentDossier.dossierTemplateId)?.fileAttributeConfigs || [];
|
this._fileAttributesService.getFileAttributeConfig(this.currentDossier.dossierTemplateId)?.fileAttributeConfigs || [];
|
||||||
@ -204,11 +200,6 @@ export class DossierOverviewScreenComponent extends ListingComponent<File> imple
|
|||||||
this._computeAllFilters();
|
this._computeAllFilters();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _reloadFiles() {
|
|
||||||
await this._filesService.loadAll(this.dossierId).toPromise();
|
|
||||||
this._computeAllFilters();
|
|
||||||
}
|
|
||||||
|
|
||||||
private _loadEntitiesFromState() {
|
private _loadEntitiesFromState() {
|
||||||
this.currentDossier = this._dossiersService.find(this.dossierId);
|
this.currentDossier = this._dossiersService.find(this.dossierId);
|
||||||
this._computeAllFilters();
|
this._computeAllFilters();
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
import { Injectable, Injector } from '@angular/core';
|
import { Injectable, Injector } from '@angular/core';
|
||||||
import { EntitiesService, List, log, mapEach, QueryParam, RequiredParam, shareLast, Toaster, Validate } from '@iqser/common-ui';
|
import { EntitiesService, List, mapEach, QueryParam, RequiredParam, shareLast, Toaster, Validate } from '@iqser/common-ui';
|
||||||
import { Dossier, IDossier, IDossierRequest } from '@red/domain';
|
import { Dossier, IDossier, IDossierRequest } from '@red/domain';
|
||||||
import { catchError, filter, map, mapTo, switchMap, tap } from 'rxjs/operators';
|
import { catchError, filter, map, mapTo, switchMap, tap } from 'rxjs/operators';
|
||||||
import { combineLatest, iif, Observable, of, throwError, timer } from 'rxjs';
|
import { combineLatest, Observable, of, Subject, throwError, timer } from 'rxjs';
|
||||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||||
import { HttpErrorResponse, HttpStatusCode } from '@angular/common/http';
|
import { HttpErrorResponse, HttpStatusCode } from '@angular/common/http';
|
||||||
import { DossierStatsService } from '@services/entity-services/dossier-stats.service';
|
import { DossierStatsService } from '@services/entity-services/dossier-stats.service';
|
||||||
@ -13,6 +13,16 @@ export interface IDossiersStats {
|
|||||||
totalAnalyzedPages: number;
|
totalAnalyzedPages: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ChangesDetails {
|
||||||
|
dossierChanges: [
|
||||||
|
{
|
||||||
|
dossierChanges: boolean;
|
||||||
|
dossierId: string;
|
||||||
|
fileChanges: boolean;
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
const DOSSIER_EXISTS_MSG = _('add-dossier-dialog.errors.dossier-already-exists');
|
const DOSSIER_EXISTS_MSG = _('add-dossier-dialog.errors.dossier-already-exists');
|
||||||
const GENERIC_MGS = _('add-dossier-dialog.errors.generic');
|
const GENERIC_MGS = _('add-dossier-dialog.errors.generic');
|
||||||
|
|
||||||
@ -21,6 +31,7 @@ const GENERIC_MGS = _('add-dossier-dialog.errors.generic');
|
|||||||
})
|
})
|
||||||
export class DossiersService extends EntitiesService<Dossier, IDossier> {
|
export class DossiersService extends EntitiesService<Dossier, IDossier> {
|
||||||
readonly generalStats$ = this.all$.pipe(switchMap(entities => this._generalStats$(entities)));
|
readonly generalStats$ = this.all$.pipe(switchMap(entities => this._generalStats$(entities)));
|
||||||
|
readonly dossierFileChanges$ = new Subject<string>();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly _toaster: Toaster,
|
private readonly _toaster: Toaster,
|
||||||
@ -32,7 +43,7 @@ export class DossiersService extends EntitiesService<Dossier, IDossier> {
|
|||||||
timer(CHANGED_CHECK_INTERVAL, CHANGED_CHECK_INTERVAL)
|
timer(CHANGED_CHECK_INTERVAL, CHANGED_CHECK_INTERVAL)
|
||||||
.pipe(
|
.pipe(
|
||||||
switchMap(() => this.loadAllIfChanged()),
|
switchMap(() => this.loadAllIfChanged()),
|
||||||
log(),
|
tap(changes => this._emitFileChanges(changes)),
|
||||||
)
|
)
|
||||||
.subscribe();
|
.subscribe();
|
||||||
}
|
}
|
||||||
@ -47,8 +58,15 @@ export class DossiersService extends EntitiesService<Dossier, IDossier> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
loadAllIfChanged(): Observable<boolean> {
|
loadAllIfChanged(): Observable<ChangesDetails> {
|
||||||
return this.hasChanges$().pipe(switchMap(changed => iif(() => changed, this.loadAll()).pipe(mapTo(changed))));
|
return this.hasChangesDetails$().pipe(switchMap(changes => this.loadAll().pipe(mapTo(changes))));
|
||||||
|
}
|
||||||
|
|
||||||
|
hasChangesDetails$(): Observable<ChangesDetails> {
|
||||||
|
const body = { value: this._lastCheckedForChanges.get('root') ?? '0' };
|
||||||
|
return this._post<ChangesDetails>(body, `${this._defaultModelPath}/changes/details`).pipe(
|
||||||
|
filter(changes => changes.dossierChanges.length > 0),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Validate()
|
@Validate()
|
||||||
@ -90,6 +108,10 @@ export class DossiersService extends EntitiesService<Dossier, IDossier> {
|
|||||||
return super.delete(body, 'deleted-dossiers/hard-delete', body).toPromise();
|
return super.delete(body, 'deleted-dossiers/hard-delete', body).toPromise();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _emitFileChanges(changes: ChangesDetails): void {
|
||||||
|
changes.dossierChanges.filter(change => change.fileChanges).forEach(change => this.dossierFileChanges$.next(change.dossierId));
|
||||||
|
}
|
||||||
|
|
||||||
private _computeStats(entities: List<Dossier>): IDossiersStats {
|
private _computeStats(entities: List<Dossier>): IDossiersStats {
|
||||||
let totalAnalyzedPages = 0;
|
let totalAnalyzedPages = 0;
|
||||||
const totalPeople = new Set<string>();
|
const totalPeople = new Set<string>();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user