From c4cddca5d88b35ef52a401965fc045e600a9b159 Mon Sep 17 00:00:00 2001 From: Bamboo Date: Tue, 18 May 2021 08:35:13 +0200 Subject: [PATCH] merged backfixes into main --- .../src/app/models/file/file-data.model.ts | 4 - .../app/models/file/file-status.wrapper.ts | 8 +- .../file-actions/file-actions.component.html | 2 +- .../file-workload.component.scss | 1 + .../pdf-viewer/pdf-viewer.component.ts | 1 - .../dossier-overview-screen.component.html | 1 + .../file-preview-screen.component.ts | 99 ++++++++++--------- .../services/pdf-viewer-data.service.ts | 2 +- .../services/file-download.service.ts | 2 +- bamboo-specs/bamboo-specs.iml | 2 +- libs/red-cache/src/lib/caches/cache-utils.ts | 1 + 11 files changed, 60 insertions(+), 63 deletions(-) diff --git a/apps/red-ui/src/app/models/file/file-data.model.ts b/apps/red-ui/src/app/models/file/file-data.model.ts index 20ae8e150..e1803b7bb 100644 --- a/apps/red-ui/src/app/models/file/file-data.model.ts +++ b/apps/red-ui/src/app/models/file/file-data.model.ts @@ -29,10 +29,6 @@ export class FileDataModel { public viewedPages?: ViewedPages ) {} - get redactionLogEntry(): RedactionLogEntry[] { - return this.redactionLog.redactionLogEntry; - } - getAnnotations( dictionaryData: { [p: string]: TypeValueWrapper }, currentUser: UserWrapper, diff --git a/apps/red-ui/src/app/models/file/file-status.wrapper.ts b/apps/red-ui/src/app/models/file/file-status.wrapper.ts index f3c722b20..2a30f521b 100644 --- a/apps/red-ui/src/app/models/file/file-status.wrapper.ts +++ b/apps/red-ui/src/app/models/file/file-status.wrapper.ts @@ -193,11 +193,7 @@ export class FileStatusWrapper { return this.status === 'UNDER_REVIEW' || this.status === 'UNDER_APPROVAL'; } - get newestDate() { - const uploadedDate = new Date(this.fileStatus.lastUploaded); - const updatedDate = new Date(this.fileStatus.lastUpdated); - return updatedDate && updatedDate.getTime() > uploadedDate.getTime() - ? updatedDate - : uploadedDate; + get cacheIdentifier() { + return btoa(this.fileStatus.lastUploaded + this.fileStatus.lastOCRTime); } } diff --git a/apps/red-ui/src/app/modules/dossier/components/file-actions/file-actions.component.html b/apps/red-ui/src/app/modules/dossier/components/file-actions/file-actions.component.html index 328ae5050..a139218a4 100644 --- a/apps/red-ui/src/app/modules/dossier/components/file-actions/file-actions.component.html +++ b/apps/red-ui/src/app/modules/dossier/components/file-actions/file-actions.component.html @@ -117,7 +117,7 @@ {{ fileStatus.numberOfPages }} + {{ fileStatus.fileId }} diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts index a3977530e..7be0cfb40 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts @@ -102,10 +102,6 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach, reviewer: [this.appStateService.activeFile.currentReviewer] }); - this._loadFileData().subscribe(() => { - this._updateCanPerformActions(); - }); - document.documentElement.addEventListener('fullscreenchange', () => { if (!document.fullscreenElement) { this.fullScreen = false; @@ -218,19 +214,22 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach, this._unsubscribeFromFileUpdates(); } - ngOnAttach(previousRoute: ActivatedRouteSnapshot) { - this.ngOnInit(); + async ngOnAttach(previousRoute: ActivatedRouteSnapshot) { + await this.ngOnInit(); this._lastPage = previousRoute.queryParams.page; } - ngOnInit(): void { + async ngOnInit() { + await this._loadFileData(false); this.displayPDFViewer = true; + this._updateCanPerformActions(); - const key = 'Dossier-Recent-' + this.dossierId; - this._userPreferenceControllerService - .savePreferences([this.fileId], key) - .toPromise() - .then(); + try { + const key = 'Dossier-Recent-' + this.dossierId; + await this._userPreferenceControllerService + .savePreferences([this.fileId], key) + .toPromise(); + } catch (error) {} this._subscribeToFileUpdates(); } @@ -242,13 +241,15 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach, rebuildFilters(deletePreviousAnnotations: boolean = false) { const startTime = new Date().getTime(); if (deletePreviousAnnotations) { - this.activeViewer.annotManager.deleteAnnotations( - this.activeViewer.annotManager.getAnnotationsList(), - { + const annotationsToDelete = this.activeViewer?.annotManager?.getAnnotationsList() || []; + try { + this.activeViewer?.annotManager?.deleteAnnotations(annotationsToDelete, { imported: true, force: true - } - ); + }); + } catch (error) { + // nothing + } } console.log( '[REDACTION] Delete previous annotations time: ' + @@ -433,7 +434,7 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach, this.viewReady = false; this._startAnalysisTimer(); this.loadingMessage = 'file-preview.reanalyse-file'; - await this._loadFileData().toPromise(); + await this._loadFileData(); this._updateCanPerformActions(); await this.appStateService.reloadActiveDossierFiles(); return; @@ -536,15 +537,14 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach, ) .subscribe(); this.fileReanalysedSubscription = this.appStateService.fileReanalysed.subscribe( - (fileStatus: FileStatusWrapper) => { + async (fileStatus: FileStatusWrapper) => { if (fileStatus.fileId === this.fileId) { - this._loadFileData(true).subscribe(() => { - this.viewReady = true; - this.loadingMessage = null; - this._stopAnalysisTimer(); - this._updateCanPerformActions(); - this._cleanupAndRedrawManualAnnotations(); - }); + await this._loadFileData(true); + this.viewReady = true; + this.loadingMessage = null; + this._stopAnalysisTimer(); + this._updateCanPerformActions(); + this._cleanupAndRedrawManualAnnotations(); } } ); @@ -561,30 +561,33 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach, } private _loadFileData(performUpdate: boolean = false) { - return this._fileDownloadService.loadActiveFileData().pipe( - tap(fileDataModel => { - if (fileDataModel.fileStatus.isWorkable) { - if (performUpdate) { - this.fileData.redactionLog = fileDataModel.redactionLog; - this.fileData.redactionChangeLog = fileDataModel.redactionChangeLog; - this.fileData.fileStatus = fileDataModel.fileStatus; - this.fileData.manualRedactions = fileDataModel.manualRedactions; - this.rebuildFilters(true); + return this._fileDownloadService + .loadActiveFileData() + .pipe( + tap(fileDataModel => { + if (fileDataModel.fileStatus.isWorkable) { + if (performUpdate) { + this.fileData.redactionLog = fileDataModel.redactionLog; + this.fileData.redactionChangeLog = fileDataModel.redactionChangeLog; + this.fileData.fileStatus = fileDataModel.fileStatus; + this.fileData.manualRedactions = fileDataModel.manualRedactions; + this.rebuildFilters(true); + } else { + this.fileData = fileDataModel; + this.rebuildFilters(); + } } else { - this.fileData = fileDataModel; - this.rebuildFilters(); + if (fileDataModel.fileStatus.isError) { + this._router.navigate([ + '/main/dossiers/' + this.appStateService.activeDossierId + ]); + } else { + this.loadingMessage = 'file-preview.reanalyse-file'; + } } - } else { - if (fileDataModel.fileStatus.isError) { - this._router.navigate([ - '/main/dossiers/' + this.appStateService.activeDossierId - ]); - } else { - this.loadingMessage = 'file-preview.reanalyse-file'; - } - } - }) - ); + }) + ) + .toPromise(); } @debounce() diff --git a/apps/red-ui/src/app/modules/dossier/services/pdf-viewer-data.service.ts b/apps/red-ui/src/app/modules/dossier/services/pdf-viewer-data.service.ts index 1bc61ed9c..7c4d32f1c 100644 --- a/apps/red-ui/src/app/modules/dossier/services/pdf-viewer-data.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/pdf-viewer-data.service.ts @@ -78,7 +78,7 @@ export class PdfViewerDataService { fileStatus.dossierId, fileStatus.fileId, true, - fileStatus.lastUploaded, + fileStatus.cacheIdentifier, 'body' ); } diff --git a/apps/red-ui/src/app/modules/upload-download/services/file-download.service.ts b/apps/red-ui/src/app/modules/upload-download/services/file-download.service.ts index 9b7287ad3..1160e27eb 100644 --- a/apps/red-ui/src/app/modules/upload-download/services/file-download.service.ts +++ b/apps/red-ui/src/app/modules/upload-download/services/file-download.service.ts @@ -29,7 +29,7 @@ export class FileDownloadService { ) { interval(5000).subscribe(() => { if (_permissionsService.isUser()) { - this.getDownloadStatus().subscribe(() => {}); + // this.getDownloadStatus().subscribe(() => {}); } }); } diff --git a/bamboo-specs/bamboo-specs.iml b/bamboo-specs/bamboo-specs.iml index 840c09c04..9d0588475 100644 --- a/bamboo-specs/bamboo-specs.iml +++ b/bamboo-specs/bamboo-specs.iml @@ -5,8 +5,8 @@ - + diff --git a/libs/red-cache/src/lib/caches/cache-utils.ts b/libs/red-cache/src/lib/caches/cache-utils.ts index 5a54c9be8..3f97633f2 100644 --- a/libs/red-cache/src/lib/caches/cache-utils.ts +++ b/libs/red-cache/src/lib/caches/cache-utils.ts @@ -4,6 +4,7 @@ export const DYNAMIC_CACHES = [ { urls: ['/assets/icons', '/assets/wv-resources'], name: 'cached-assets', + clearOnLogout: false, maxAge: 24 * 3600, maxSize: 1000, methods: ['GET']