From 4fde66ae890ee42974638331c17e5820cc448669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Mon, 22 Nov 2021 17:42:33 +0200 Subject: [PATCH] Removed reanalysis methods from file action service --- .../dossier-overview-bulk-actions.component.ts | 7 ++++++- .../file-actions/file-actions.component.ts | 14 +++++++++----- .../shared/services/file-action.service.ts | 17 ----------------- 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/bulk-actions/dossier-overview-bulk-actions.component.ts b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/bulk-actions/dossier-overview-bulk-actions.component.ts index 20e8d797a..2dd816117 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/bulk-actions/dossier-overview-bulk-actions.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/bulk-actions/dossier-overview-bulk-actions.component.ts @@ -150,7 +150,12 @@ export class DossierOverviewBulkActionsComponent { } ocr() { - this._performBulkAction(this._fileActionService.ocrFiles(this.selectedFiles)); + this._performBulkAction( + this._reanalysisService.ocrFiles( + this.selectedFiles.map(f => f.fileId), + this.dossier.id, + ), + ); } setToUnderReview() { diff --git a/apps/red-ui/src/app/modules/dossier/shared/components/file-actions/file-actions.component.ts b/apps/red-ui/src/app/modules/dossier/shared/components/file-actions/file-actions.component.ts index 313523ef5..08c7e28ab 100644 --- a/apps/red-ui/src/app/modules/dossier/shared/components/file-actions/file-actions.component.ts +++ b/apps/red-ui/src/app/modules/dossier/shared/components/file-actions/file-actions.component.ts @@ -21,6 +21,7 @@ import { FileActionService } from '../../services/file-action.service'; import { DossiersService } from '@services/entity-services/dossiers.service'; import { FileManagementService } from '../../services/file-management.service'; import { FilesService } from '@services/entity-services/files.service'; +import { ReanalysisService } from '@services/reanalysis.service'; @Component({ selector: 'redaction-file-actions', @@ -75,6 +76,7 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnDestroy, private readonly _userService: UserService, private readonly _toaster: Toaster, private readonly _userPreferenceService: UserPreferenceService, + private readonly _reanalysisService: ReanalysisService, ) { super(); } @@ -146,9 +148,11 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnDestroy, if ($event) { $event.stopPropagation(); } - this.addSubscription = this._fileActionService.reanalyseFile(this.file).subscribe(() => { - this.reloadFiles('reanalyse'); - }); + this.addSubscription = this._reanalysisService + .reanalyzeFilesForDossier([this.file.fileId], this.file.dossierId, true) + .subscribe(() => { + this.reloadFiles('reanalyse'); + }); } async setFileUnderApproval($event: MouseEvent) { @@ -184,7 +188,7 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnDestroy, async ocrFile($event: MouseEvent) { $event.stopPropagation(); - await this._fileActionService.ocrFiles([this.file]).toPromise(); + await this._reanalysisService.ocrFiles([this.file.fileId], this.file.dossierId).toPromise(); this.reloadFiles('ocr-file'); } @@ -202,7 +206,7 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnDestroy, } async toggleAnalysis() { - await this._fileActionService.toggleAnalysis(this.file).toPromise(); + await this._reanalysisService.toggleAnalysis(this.file.dossierId, this.file.fileId, !this.file.excluded).toPromise(); await this._filesService.loadAll(this.file.dossierId).toPromise(); this.actionPerformed.emit(this.file?.excluded ? 'enable-analysis' : 'disable-analysis'); } diff --git a/apps/red-ui/src/app/modules/dossier/shared/services/file-action.service.ts b/apps/red-ui/src/app/modules/dossier/shared/services/file-action.service.ts index 3feee8d19..c7778931f 100644 --- a/apps/red-ui/src/app/modules/dossier/shared/services/file-action.service.ts +++ b/apps/red-ui/src/app/modules/dossier/shared/services/file-action.service.ts @@ -6,7 +6,6 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { FilesService } from '@services/entity-services/files.service'; import { ConfirmationDialogInput, Toaster } from '@iqser/common-ui'; import { DossiersService } from '@services/entity-services/dossiers.service'; -import { ReanalysisService } from '@services/reanalysis.service'; @Injectable() export class FileActionService { @@ -14,19 +13,10 @@ export class FileActionService { private readonly _dialogService: DossiersDialogService, private readonly _userService: UserService, private readonly _filesService: FilesService, - private readonly _reanalysisService: ReanalysisService, private readonly _dossiersService: DossiersService, private readonly _toaster: Toaster, ) {} - reanalyseFile(file: File) { - return this._reanalysisService.reanalyzeFilesForDossier([file.fileId], file.dossierId, true); - } - - toggleAnalysis(file: File) { - return this._reanalysisService.toggleAnalysis(file.dossierId, file.fileId, !file.excluded); - } - async assignToMe(files: File[], callback?: Function) { return new Promise((resolve, reject) => { const atLeastOneFileHasReviewer = files.reduce((acc, fs) => acc || !!fs.currentReviewer, false); @@ -76,13 +66,6 @@ export class FileActionService { ); } - ocrFiles(files: File[]) { - return this._reanalysisService.ocrFiles( - files.map(f => f.fileId), - files[0].dossierId, - ); - } - assignFile(mode: 'reviewer' | 'approver', $event: MouseEvent, file: File, callback?: Function, ignoreChanged = false) { const dossier = this._dossiersService.find(file.dossierId); const userIds = this._getUserIds(mode, dossier);