From ed6c9262925478f823ba959f0d518ad8046d779a Mon Sep 17 00:00:00 2001 From: Valentin Date: Tue, 21 Sep 2021 16:26:05 +0300 Subject: [PATCH] Triggered automatic reanalysis on document opening when 'analysRequired = true' --- .../components/file-actions/file-actions.component.ts | 6 ++++-- .../file-preview-screen/file-preview-screen.component.html | 1 + .../file-preview-screen/file-preview-screen.component.ts | 7 +++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/red-ui/src/app/modules/dossier/components/file-actions/file-actions.component.ts b/apps/red-ui/src/app/modules/dossier/components/file-actions/file-actions.component.ts index 331f285f0..63ef0cd50 100644 --- a/apps/red-ui/src/app/modules/dossier/components/file-actions/file-actions.component.ts +++ b/apps/red-ui/src/app/modules/dossier/components/file-actions/file-actions.component.ts @@ -132,8 +132,10 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnInit, OnD }); } - reanalyseFile($event: MouseEvent) { - $event.stopPropagation(); + reanalyseFile($event?: MouseEvent) { + if ($event) { + $event.stopPropagation(); + } this.addSubscription = this._fileActionService.reanalyseFile(this.fileStatus).subscribe(() => { this.reloadDossiers('reanalyse'); }); diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.html b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.html index 661e8e458..e89ac5086 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.html +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.html @@ -88,6 +88,7 @@
; + @ViewChild('fileActions') fileActions: FileActionsComponent; constructor( readonly appStateService: AppStateService, @@ -258,6 +260,10 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni this.displayPDFViewer = true; this._updateCanPerformActions(); this._subscribeToFileUpdates(); + + if (this.fileData?.fileStatus?.analysisRequired) { + this.fileActions.reanalyseFile(); + } } rebuildFilters(deletePreviousAnnotations = false): void { @@ -599,6 +605,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni private async _loadFileData(performUpdate = false): Promise { const fileData = await this._fileDownloadService.loadActiveFileData().toPromise(); + if (!fileData.fileStatus?.isPending && !fileData.fileStatus?.isError) { if (performUpdate) { this.fileData.redactionLog = fileData.redactionLog;