remove fileChanged and fileReanalyzed
This commit is contained in:
parent
29c20edfa7
commit
4f8fa98e65
@ -1,21 +1,11 @@
|
|||||||
import {
|
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnDestroy, Output } from '@angular/core';
|
||||||
ChangeDetectionStrategy,
|
|
||||||
Component,
|
|
||||||
EventEmitter,
|
|
||||||
Input,
|
|
||||||
OnChanges,
|
|
||||||
OnDestroy,
|
|
||||||
OnInit,
|
|
||||||
Output,
|
|
||||||
SimpleChanges,
|
|
||||||
} from '@angular/core';
|
|
||||||
import { AppStateService } from '@state/app-state.service';
|
|
||||||
import { PermissionsService } from '@services/permissions.service';
|
import { PermissionsService } from '@services/permissions.service';
|
||||||
import { ConfigService } from '@services/config.service';
|
import { ConfigService } from '@services/config.service';
|
||||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||||
import { ViewedPagesService } from '../../shared/services/viewed-pages.service';
|
import { ViewedPagesService } from '../../shared/services/viewed-pages.service';
|
||||||
import { File, IViewedPage } from '@red/domain';
|
import { File, IViewedPage } from '@red/domain';
|
||||||
import { AutoUnsubscribe } from '@iqser/common-ui';
|
import { AutoUnsubscribe, OnChange } from '@iqser/common-ui';
|
||||||
|
import { FilesMapService } from '@services/entity-services/files-map.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'redaction-page-indicator',
|
selector: 'redaction-page-indicator',
|
||||||
@ -23,9 +13,15 @@ import { AutoUnsubscribe } from '@iqser/common-ui';
|
|||||||
styleUrls: ['./page-indicator.component.scss'],
|
styleUrls: ['./page-indicator.component.scss'],
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class PageIndicatorComponent extends AutoUnsubscribe implements OnChanges, OnInit, OnDestroy {
|
export class PageIndicatorComponent extends AutoUnsubscribe implements OnDestroy {
|
||||||
@Input() file: File;
|
@Input()
|
||||||
@Input() active: boolean;
|
@OnChange<File, PageIndicatorComponent>('handlePageRead')
|
||||||
|
file: File;
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
@OnChange<boolean, PageIndicatorComponent>('handlePageRead')
|
||||||
|
active: boolean;
|
||||||
|
|
||||||
@Input() showDottedIcon = false;
|
@Input() showDottedIcon = false;
|
||||||
@Input() number: number;
|
@Input() number: number;
|
||||||
@Input() viewedPages: IViewedPage[];
|
@Input() viewedPages: IViewedPage[];
|
||||||
@ -34,11 +30,10 @@ export class PageIndicatorComponent extends AutoUnsubscribe implements OnChanges
|
|||||||
@Output() readonly pageSelected = new EventEmitter<number>();
|
@Output() readonly pageSelected = new EventEmitter<number>();
|
||||||
|
|
||||||
pageReadTimeout: number = null;
|
pageReadTimeout: number = null;
|
||||||
canMarkPagesAsViewed: boolean;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly _viewedPagesService: ViewedPagesService,
|
private readonly _viewedPagesService: ViewedPagesService,
|
||||||
private readonly _appStateService: AppStateService,
|
private readonly _filesMapService: FilesMapService,
|
||||||
private readonly _dossiersService: DossiersService,
|
private readonly _dossiersService: DossiersService,
|
||||||
private readonly _configService: ConfigService,
|
private readonly _configService: ConfigService,
|
||||||
private readonly _permissionService: PermissionsService,
|
private readonly _permissionService: PermissionsService,
|
||||||
@ -59,23 +54,8 @@ export class PageIndicatorComponent extends AutoUnsubscribe implements OnChanges
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
|
||||||
this.addSubscription = this._appStateService.fileChanged$.subscribe(() => {
|
|
||||||
if (this.canMarkPagesAsViewed !== this._permissionService.canMarkPagesAsViewed(this.file)) {
|
|
||||||
this.canMarkPagesAsViewed = this._permissionService.canMarkPagesAsViewed(this.file);
|
|
||||||
this._handlePageRead();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges): void {
|
|
||||||
if (changes.active) {
|
|
||||||
this._handlePageRead();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async toggleReadState() {
|
async toggleReadState() {
|
||||||
if (this.canMarkPagesAsViewed) {
|
if (this._permissionService.canMarkPagesAsViewed(this.file)) {
|
||||||
if (this.read) {
|
if (this.read) {
|
||||||
await this._markPageUnread();
|
await this._markPageUnread();
|
||||||
} else {
|
} else {
|
||||||
@ -84,8 +64,8 @@ export class PageIndicatorComponent extends AutoUnsubscribe implements OnChanges
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handlePageRead() {
|
handlePageRead() {
|
||||||
if (!this.canMarkPagesAsViewed) {
|
if (!this._permissionService.canMarkPagesAsViewed(this.file)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -53,6 +53,7 @@ import { UserPreferenceService } from '@services/user-preference.service';
|
|||||||
import { saveAsCSV } from '@utils/csv-utils';
|
import { saveAsCSV } from '@utils/csv-utils';
|
||||||
import { FilesService } from '@services/entity-services/files.service';
|
import { FilesService } from '@services/entity-services/files.service';
|
||||||
import { FilesMapService } from '@services/entity-services/files-map.service';
|
import { FilesMapService } from '@services/entity-services/files-map.service';
|
||||||
|
import { ReanalysisService } from '@services/reanalysis.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: './dossier-overview-screen.component.html',
|
templateUrl: './dossier-overview-screen.component.html',
|
||||||
@ -91,6 +92,7 @@ export class DossierOverviewScreenComponent extends ListingComponent<File> imple
|
|||||||
readonly permissionsService: PermissionsService,
|
readonly permissionsService: PermissionsService,
|
||||||
private readonly _loadingService: LoadingService,
|
private readonly _loadingService: LoadingService,
|
||||||
private readonly _appStateService: AppStateService,
|
private readonly _appStateService: AppStateService,
|
||||||
|
private readonly _reanalysisService: ReanalysisService,
|
||||||
private readonly _dossiersService: DossiersService,
|
private readonly _dossiersService: DossiersService,
|
||||||
private readonly _dossierTemplatesService: DossierTemplatesService,
|
private readonly _dossierTemplatesService: DossierTemplatesService,
|
||||||
readonly routerHistoryService: RouterHistoryService,
|
readonly routerHistoryService: RouterHistoryService,
|
||||||
@ -208,7 +210,7 @@ export class DossierOverviewScreenComponent extends ListingComponent<File> imple
|
|||||||
|
|
||||||
async reanalyseDossier() {
|
async reanalyseDossier() {
|
||||||
try {
|
try {
|
||||||
await this._appStateService.reanalyzeDossier();
|
await this._reanalysisService.reanalyzeDossier(this.dossierId, true).toPromise();
|
||||||
await this.reloadFiles();
|
await this.reloadFiles();
|
||||||
this._toaster.success(_('dossier-overview.reanalyse-dossier.success'));
|
this._toaster.success(_('dossier-overview.reanalyse-dossier.success'));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -223,10 +225,6 @@ export class DossierOverviewScreenComponent extends ListingComponent<File> imple
|
|||||||
}
|
}
|
||||||
|
|
||||||
async calculateData(): Promise<void> {
|
async calculateData(): Promise<void> {
|
||||||
if (!this.dossierId) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await this._loadEntitiesFromState();
|
await this._loadEntitiesFromState();
|
||||||
this._computeAllFilters();
|
this._computeAllFilters();
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
></iqser-circle-button>
|
></iqser-circle-button>
|
||||||
|
|
||||||
<iqser-circle-button
|
<iqser-circle-button
|
||||||
(action)="reanalyseDossier($event, dossier)"
|
(action)="reanalyseDossier($event, dossier.dossierId)"
|
||||||
*ngIf="permissionsService.displayReanalyseBtn(dossier) && analysisForced"
|
*ngIf="permissionsService.displayReanalyseBtn(dossier) && analysisForced"
|
||||||
[tooltip]="'dossier-listing.reanalyse.action' | translate"
|
[tooltip]="'dossier-listing.reanalyse.action' | translate"
|
||||||
[type]="circleButtonTypes.dark"
|
[type]="circleButtonTypes.dark"
|
||||||
|
|||||||
@ -8,6 +8,8 @@ import { DossiersDialogService } from '../../../../services/dossiers-dialog.serv
|
|||||||
import { LongPressEvent } from '@shared/directives/long-press.directive';
|
import { LongPressEvent } from '@shared/directives/long-press.directive';
|
||||||
import { UserPreferenceService } from '@services/user-preference.service';
|
import { UserPreferenceService } from '@services/user-preference.service';
|
||||||
import { FilesMapService } from '@services/entity-services/files-map.service';
|
import { FilesMapService } from '@services/entity-services/files-map.service';
|
||||||
|
import { ReanalysisService } from '@services/reanalysis.service';
|
||||||
|
import { switchMapTo, tap } from 'rxjs/operators';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'redaction-dossiers-listing-actions',
|
selector: 'redaction-dossiers-listing-actions',
|
||||||
@ -26,6 +28,7 @@ export class DossiersListingActionsComponent {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
readonly appStateService: AppStateService,
|
readonly appStateService: AppStateService,
|
||||||
|
private readonly _reanalysisService: ReanalysisService,
|
||||||
private readonly _userService: UserService,
|
private readonly _userService: UserService,
|
||||||
readonly permissionsService: PermissionsService,
|
readonly permissionsService: PermissionsService,
|
||||||
readonly filesMapService: FilesMapService,
|
readonly filesMapService: FilesMapService,
|
||||||
@ -50,10 +53,9 @@ export class DossiersListingActionsComponent {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
reanalyseDossier($event: MouseEvent, dossier: Dossier): void {
|
async reanalyseDossier($event: MouseEvent, id: string): Promise<void> {
|
||||||
$event.stopPropagation();
|
$event.stopPropagation();
|
||||||
this.appStateService.reanalyzeDossier(dossier).then(() => {
|
const reanalysis$ = this._reanalysisService.reanalyzeDossier(id).pipe(switchMapTo(this.appStateService.loadAllDossiers()));
|
||||||
this.appStateService.loadAllDossiers().then(() => this.actionPerformed.emit());
|
await reanalysis$.pipe(tap(() => this.actionPerformed.emit())).toPromise();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -358,7 +358,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
|||||||
response.manualRedactionEntryWrapper.rectId,
|
response.manualRedactionEntryWrapper.rectId,
|
||||||
);
|
);
|
||||||
this._instance.Core.annotationManager.deleteAnnotation(annotation);
|
this._instance.Core.annotationManager.deleteAnnotation(annotation);
|
||||||
this.fileData.file = await this.appStateService.reloadActiveFile();
|
this.fileData.file = await this.appStateService.reloadFile(this.dossierId, this.fileId);
|
||||||
const distinctPages = entryWrapper.manualRedactionEntry.positions
|
const distinctPages = entryWrapper.manualRedactionEntry.positions
|
||||||
.map(p => p.page)
|
.map(p => p.page)
|
||||||
.filter((item, pos, self) => self.indexOf(item) === pos);
|
.filter((item, pos, self) => self.indexOf(item) === pos);
|
||||||
@ -499,7 +499,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
|||||||
|
|
||||||
async assignToMe() {
|
async assignToMe() {
|
||||||
await this._fileActionService.assignToMe([this.fileData.file], async () => {
|
await this._fileActionService.assignToMe([this.fileData.file], async () => {
|
||||||
await this.appStateService.reloadActiveFile();
|
await this.appStateService.reloadFile(this.dossierId, this.fileId);
|
||||||
this._updateCanPerformActions();
|
this._updateCanPerformActions();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -512,7 +512,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
|||||||
await this._filesService.setReviewerFor([fileId], dossierId, reviewerId).toPromise();
|
await this._filesService.setReviewerFor([fileId], dossierId, reviewerId).toPromise();
|
||||||
|
|
||||||
this._toaster.info(_('assignment.reviewer'), { params: { reviewerName, filename } });
|
this._toaster.info(_('assignment.reviewer'), { params: { reviewerName, filename } });
|
||||||
await this.appStateService.reloadActiveFile();
|
await this.appStateService.reloadFile(this.dossierId, this.fileId);
|
||||||
this._updateCanPerformActions();
|
this._updateCanPerformActions();
|
||||||
this.editingReviewer = false;
|
this.editingReviewer = false;
|
||||||
}
|
}
|
||||||
@ -585,8 +585,10 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _subscribeToFileUpdates(): void {
|
private _subscribeToFileUpdates(): void {
|
||||||
this.addSubscription = timer(0, 10000).pipe(switchMapTo(this.appStateService.reloadActiveFile())).subscribe();
|
this.addSubscription = timer(0, 10000)
|
||||||
this.addSubscription = this.appStateService.fileReanalysed$
|
.pipe(switchMapTo(this.appStateService.reloadFile(this.dossierId, this.fileId)))
|
||||||
|
.subscribe();
|
||||||
|
this.addSubscription = this._filesMapService.fileReanalysed$
|
||||||
.pipe(filter(file => file.fileId === this.fileId))
|
.pipe(filter(file => file.fileId === this.fileId))
|
||||||
.subscribe(async () => {
|
.subscribe(async () => {
|
||||||
await this._loadFileData(!this._reloadFileOnReanalysis);
|
await this._loadFileData(!this._reloadFileOnReanalysis);
|
||||||
@ -645,7 +647,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
|||||||
const currentPageAnnotations = this.annotations.filter(a => a.pageNumber === page);
|
const currentPageAnnotations = this.annotations.filter(a => a.pageNumber === page);
|
||||||
const currentPageAnnotationIds = currentPageAnnotations.map(a => a.id);
|
const currentPageAnnotationIds = currentPageAnnotations.map(a => a.id);
|
||||||
|
|
||||||
this.fileData.file = await this.appStateService.reloadActiveFile();
|
this.fileData.file = await this.appStateService.reloadFile(this.dossierId, this.fileId);
|
||||||
this.fileData.redactionLog = await this._fileDownloadService.loadRedactionLogFor(this.dossierId, this.fileId).toPromise();
|
this.fileData.redactionLog = await this._fileDownloadService.loadRedactionLogFor(this.dossierId, this.fileId).toPromise();
|
||||||
|
|
||||||
this.rebuildFilters();
|
this.rebuildFilters();
|
||||||
|
|||||||
@ -40,7 +40,7 @@ export class FilesMapService {
|
|||||||
const newEntities = entities.map(newEntity => {
|
const newEntities = entities.map(newEntity => {
|
||||||
const oldEntity = this.get(key, newEntity.id);
|
const oldEntity = this.get(key, newEntity.id);
|
||||||
|
|
||||||
if (oldEntity.lastProcessed !== newEntity.lastProcessed) {
|
if (oldEntity?.lastProcessed !== newEntity.lastProcessed) {
|
||||||
this.fileReanalysed$.next(newEntity);
|
this.fileReanalysed$.next(newEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,6 +55,11 @@ export class FilesMapService {
|
|||||||
this._map.get(key).next(newEntities);
|
this._map.get(key).next(newEntities);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
replace(entity: File) {
|
||||||
|
const all = this.get(entity.dossierId).filter(file => file.fileId !== entity.fileId);
|
||||||
|
this.set(entity.dossierId, [...all, entity]);
|
||||||
|
}
|
||||||
|
|
||||||
watch$(key: string, entityId: string): Observable<File> {
|
watch$(key: string, entityId: string): Observable<File> {
|
||||||
return this._entityChanged$.pipe(
|
return this._entityChanged$.pipe(
|
||||||
filter(entity => entity.id === entityId),
|
filter(entity => entity.id === entityId),
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
|
|||||||
import { Dictionary, Dossier, DossierTemplate, File, IColors, IDossier } from '@red/domain';
|
import { Dictionary, Dossier, DossierTemplate, File, IColors, IDossier } from '@red/domain';
|
||||||
import { ActivationEnd, Router } from '@angular/router';
|
import { ActivationEnd, Router } from '@angular/router';
|
||||||
import { UserService } from '@services/user.service';
|
import { UserService } from '@services/user.service';
|
||||||
import { forkJoin, Observable, of, Subject } from 'rxjs';
|
import { forkJoin, Observable, of } from 'rxjs';
|
||||||
import { catchError, filter, first, map, tap } from 'rxjs/operators';
|
import { catchError, filter, first, map, tap } from 'rxjs/operators';
|
||||||
import { currentComponentRoute, FALLBACK_COLOR, hexToRgb } from '@utils/functions';
|
import { currentComponentRoute, FALLBACK_COLOR, hexToRgb } from '@utils/functions';
|
||||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||||
@ -11,7 +11,6 @@ import { FilesService } from '@services/entity-services/files.service';
|
|||||||
import { DictionaryService } from '@shared/services/dictionary.service';
|
import { DictionaryService } from '@shared/services/dictionary.service';
|
||||||
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
|
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
|
||||||
import { FileAttributesService } from '@services/entity-services/file-attributes.service';
|
import { FileAttributesService } from '@services/entity-services/file-attributes.service';
|
||||||
import { ReanalysisService } from '@services/reanalysis.service';
|
|
||||||
import { DossierStatsService } from '@services/entity-services/dossier-stats.service';
|
import { DossierStatsService } from '@services/entity-services/dossier-stats.service';
|
||||||
import { FilesMapService } from '@services/entity-services/files-map.service';
|
import { FilesMapService } from '@services/entity-services/files-map.service';
|
||||||
|
|
||||||
@ -24,9 +23,6 @@ export interface AppState {
|
|||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class AppStateService {
|
export class AppStateService {
|
||||||
readonly fileChanged$ = new Subject<File>();
|
|
||||||
readonly fileReanalysed$ = new Subject<File>();
|
|
||||||
|
|
||||||
private _appState: AppState = {};
|
private _appState: AppState = {};
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@ -34,7 +30,6 @@ export class AppStateService {
|
|||||||
private readonly _userService: UserService,
|
private readonly _userService: UserService,
|
||||||
private readonly _dossiersService: DossiersService,
|
private readonly _dossiersService: DossiersService,
|
||||||
private readonly _filesService: FilesService,
|
private readonly _filesService: FilesService,
|
||||||
private readonly _reanalysisService: ReanalysisService,
|
|
||||||
private readonly _dictionaryService: DictionaryService,
|
private readonly _dictionaryService: DictionaryService,
|
||||||
private readonly _dossierTemplatesService: DossierTemplatesService,
|
private readonly _dossierTemplatesService: DossierTemplatesService,
|
||||||
private readonly _dossierStatsService: DossierStatsService,
|
private readonly _dossierStatsService: DossierStatsService,
|
||||||
@ -143,26 +138,24 @@ export class AppStateService {
|
|||||||
return Promise.all(mappedDossiers$);
|
return Promise.all(mappedDossiers$);
|
||||||
}
|
}
|
||||||
|
|
||||||
async reloadActiveFile() {
|
async reloadFile(dossierId: string, fileId: string) {
|
||||||
const activeDossier = this._dossiersService.activeDossier;
|
const dossier = this._dossiersService.find(dossierId);
|
||||||
|
const oldFile = this._filesMapService.get(dossierId, fileId);
|
||||||
|
|
||||||
if (!this.activeFile || !activeDossier) {
|
if (!oldFile || !dossier) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const oldProcessedDate = this.activeFile.lastProcessed;
|
|
||||||
const iFile = await this._filesService.get(activeDossier.dossierId, this.activeFileId).toPromise();
|
|
||||||
|
|
||||||
const activeFile = new File(
|
const iFile = await this._filesService.get(dossierId, fileId).toPromise();
|
||||||
|
|
||||||
|
const newFile = new File(
|
||||||
iFile,
|
iFile,
|
||||||
this._userService.getNameForId(iFile.currentReviewer),
|
this._userService.getNameForId(iFile.currentReviewer),
|
||||||
this._fileAttributesService.getFileAttributeConfig(activeDossier.dossierTemplateId),
|
this._fileAttributesService.getFileAttributeConfig(dossier.dossierTemplateId),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (activeFile.lastProcessed !== oldProcessedDate) {
|
this._filesMapService.replace(newFile);
|
||||||
this.fileReanalysed$.next(activeFile);
|
return newFile;
|
||||||
}
|
|
||||||
this.fileChanged$.next(activeFile);
|
|
||||||
return activeFile;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getFiles(dossier = this._dossiersService.activeDossier) {
|
async getFiles(dossier = this._dossiersService.activeDossier) {
|
||||||
@ -178,10 +171,6 @@ export class AppStateService {
|
|||||||
return newFiles;
|
return newFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
async reanalyzeDossier({ id } = this._dossiersService.activeDossier) {
|
|
||||||
await this._reanalysisService.reanalyzeDossier(id, true).toPromise();
|
|
||||||
}
|
|
||||||
|
|
||||||
async activateFile(dossierId: string, fileId: string) {
|
async activateFile(dossierId: string, fileId: string) {
|
||||||
if (this._dossiersService.activeDossierId === dossierId && this.activeFileId === fileId) {
|
if (this._dossiersService.activeDossierId === dossierId && this.activeFileId === fileId) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user