From 5da318496de450d533e83a4a64b1f35c46aaf433 Mon Sep 17 00:00:00 2001 From: Timo Bejan Date: Tue, 21 Dec 2021 15:01:31 +0200 Subject: [PATCH] viewed pages cleanup --- .../src/app/models/file/file-data.model.ts | 3 ++- ...ile-attributes-listing-screen.component.ts | 1 - .../file-workload.component.html | 1 + .../file-workload/file-workload.component.ts | 7 ++++--- .../page-indicator.component.ts | 12 ++++++++---- .../pdf-viewer/pdf-viewer.component.ts | 2 +- .../file-preview-screen.component.ts | 19 ++++++++++++++----- .../modules/dossier/utils/pdf-viewer.utils.ts | 5 ++++- apps/red-ui/src/assets/config/config.json | 4 ++-- libs/red-domain/src/lib/pages/viewed-page.ts | 2 +- 10 files changed, 37 insertions(+), 19 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 6407c15fd..1c0d3b920 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 @@ -117,9 +117,10 @@ export class FileDataModel { const relevantChanges = redactionLogEntry.changes.filter(change => moment(change.dateTime).valueOf() > viewTime); // at least one unseen change if (relevantChanges.length > 0) { + // at least 1 relevant change wrapper.changeLogType = relevantChanges[relevantChanges.length - 1].type; wrapper.isChangeLogEntry = true; - viewedPage.hasChanges = true; + viewedPage.showAsUnseen = moment(viewedPage.viewedTime).valueOf() < moment(lastChange.dateTime).valueOf(); this.hasChangeLog = true; } else { // no relevant changes - hide removed anyway diff --git a/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.ts index 86390b6e1..f2e07904d 100644 --- a/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/file-attributes-listing/file-attributes-listing-screen.component.ts @@ -127,7 +127,6 @@ export class FileAttributesListingScreenComponent extends ListingComponent { - console.log('error'); if (error.status === HttpStatusCode.Conflict) { this._toaster.error(_('file-attributes-listing.error.conflict')); } else { diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.html b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.html index 7111f4d66..7cbfa2962 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.html +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.html @@ -94,6 +94,7 @@ + {{activeViewerPage}}
annotation.manual); + const hasOnlyManualRedactions = this.displayedAnnotations.get(pageNumber)?.every(annotation => annotation.manual); return hasOnlyManualRedactions && this.file.excludedPages.includes(pageNumber); } @@ -280,7 +280,7 @@ export class FileWorkloadComponent { if (!this._firstSelectedAnnotation || this.activeViewerPage !== this._firstSelectedAnnotation.pageNumber) { if (this.displayedPages.indexOf(this.activeViewerPage) !== -1) { // Displayed page has annotations - return this.selectAnnotations.emit([this.activeAnnotations[0]]); + return this.selectAnnotations.emit(this.activeAnnotations ? [this.activeAnnotations[0]] : null); } // Displayed page doesn't have annotations if ($event.key === 'ArrowDown') { @@ -337,7 +337,8 @@ export class FileWorkloadComponent { primary: INestedFilter[], secondary: INestedFilter[] = [], ): Map { - if (!primary) { + if (!primary || primary.length === 0) { + this.displayedPages = Array.from({ length: this.file?.numberOfPages }, (x, i) => i + 1); return; } this.displayedAnnotations = this._annotationProcessingService.filterAndGroupAnnotations(annotations, primary, secondary); diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/page-indicator/page-indicator.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/page-indicator/page-indicator.component.ts index dc417f73d..2b217e9d4 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/page-indicator/page-indicator.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/page-indicator/page-indicator.component.ts @@ -24,6 +24,7 @@ export class PageIndicatorComponent extends AutoUnsubscribe implements OnDestroy @Output() readonly pageSelected = new EventEmitter(); pageReadTimeout: number = null; + read = false; constructor( private readonly _viewedPagesService: ViewedPagesService, @@ -39,16 +40,17 @@ export class PageIndicatorComponent extends AutoUnsubscribe implements OnDestroy return this.viewedPages?.find(p => p.page === this.number); } - get read() { + private _setReadState() { const activePage = this.activePage; if (!activePage) { - return false; + this.read = false; } else { - return !activePage.hasChanges; + this.read = !activePage.showAsUnseen; } } ngOnChanges() { + this._setReadState(); this.handlePageRead(); } @@ -83,10 +85,11 @@ export class PageIndicatorComponent extends AutoUnsubscribe implements OnDestroy private async _markPageRead() { await this._viewedPagesService.addPage({ page: this.number }, this.file.dossierId, this.file.fileId).toPromise(); if (this.activePage) { - this.activePage.hasChanges = false; + this.activePage.showAsUnseen = false; } else { this.viewedPages?.push({ page: this.number, fileId: this.file.fileId }); } + this._setReadState(); } private async _markPageUnread() { @@ -95,5 +98,6 @@ export class PageIndicatorComponent extends AutoUnsubscribe implements OnDestroy this.viewedPages?.findIndex(p => p.page === this.number), 1, ); + this._setReadState(); } } diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/pdf-viewer/pdf-viewer.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/pdf-viewer/pdf-viewer.component.ts index 059d44dc7..9777cc816 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/pdf-viewer/pdf-viewer.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/pdf-viewer/pdf-viewer.component.ts @@ -309,7 +309,7 @@ export class PdfViewerComponent implements OnInit, OnChanges { private _setInitialDisplayMode() { this.instance.UI.setFitMode('FitPage'); const instanceDisplayMode = this.documentViewer.getDisplayModeManager().getDisplayMode(); - instanceDisplayMode.mode = this.viewModeService.isStandard ? 'Single' : 'Facing'; + instanceDisplayMode.mode = this.viewModeService.isCompare ? 'Facing' : 'Single'; this.documentViewer.getDisplayModeManager().setDisplayMode(instanceDisplayMode); } 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 226af6b17..d0d104b6f 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 @@ -74,6 +74,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni selectedAnnotations: AnnotationWrapper[] = []; hideSkipped = false; displayPdfViewer = false; + activeViewerPage : number = null; @ViewChild(PdfViewerComponent) readonly viewerComponent: PdfViewerComponent; readonly dossierId: string; readonly canPerformAnnotationActions$: Observable; @@ -145,12 +146,15 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni return this._instance; } - get activeViewerPage(): number { + + + private _setActiveViewerPage() { const currentPage = this._instance?.Core.documentViewer?.getCurrentPage(); if (!currentPage) { - return 0; + this.activeViewerPage = 0; + } else { + this.activeViewerPage = this.viewModeService.isCompare ? currentPage % 2 === 0 ? currentPage / 2 : (currentPage + 1) / 2 : currentPage; } - return this.viewModeService.isStandard ? currentPage : currentPage % 2 === 0 ? currentPage / 2 : (currentPage + 1) / 2; } private get _canPerformAnnotationActions$() { @@ -288,9 +292,9 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni @Debounce(10) selectAnnotations(annotations?: AnnotationWrapper[]) { if (annotations) { - this.viewerComponent?.utils.selectAnnotations(annotations, this.multiSelectService.isActive); + this.viewerComponent?.utils?.selectAnnotations(annotations, this.multiSelectService.isActive); } else { - this.viewerComponent?.utils.deselectAllAnnotations(); + this.viewerComponent?.utils?.deselectAllAnnotations(); } } @@ -316,6 +320,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni response.manualRedactionEntryWrapper.rectId, ); this._instance.Core.annotationManager.deleteAnnotation(annotation); + // await this._filesService.reload(this.dossierId, this.fileId).toPromise(); const distinctPages = manualRedactionEntryWrapper.manualRedactionEntry.positions .map(p => p.page) .filter((item, pos, self) => self.indexOf(item) === pos); @@ -388,6 +393,8 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni }; this._router.navigate([], extras).then(); + + this._setActiveViewerPage(); this._changeDetectorRef.markForCheck(); } @@ -407,7 +414,9 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni if (pageNumber) { setTimeout(() => { this.selectPage(parseInt(pageNumber, 10)); + this._setActiveViewerPage(); this._scrollViews(); + this._changeDetectorRef.markForCheck(); this._loadingService.stop(); }); } else { diff --git a/apps/red-ui/src/app/modules/dossier/utils/pdf-viewer.utils.ts b/apps/red-ui/src/app/modules/dossier/utils/pdf-viewer.utils.ts index 99b1fe3a8..e441e1dd1 100644 --- a/apps/red-ui/src/app/modules/dossier/utils/pdf-viewer.utils.ts +++ b/apps/red-ui/src/app/modules/dossier/utils/pdf-viewer.utils.ts @@ -120,7 +120,10 @@ export class PdfViewerUtils { this._annotationManager.deselectAllAnnotations(); } - selectAnnotations(annotations: AnnotationWrapper[], multiSelectActive: boolean) { + selectAnnotations(annotations?: AnnotationWrapper[], multiSelectActive: boolean = false) { + if (!annotations){ + return; + } if (!multiSelectActive) { this.deselectAllAnnotations(); } diff --git a/apps/red-ui/src/assets/config/config.json b/apps/red-ui/src/assets/config/config.json index c5a78443c..4c6dd7e9a 100644 --- a/apps/red-ui/src/assets/config/config.json +++ b/apps/red-ui/src/assets/config/config.json @@ -1,7 +1,7 @@ { "ADMIN_CONTACT_NAME": null, "ADMIN_CONTACT_URL": null, - "API_URL": "https://dev-08.iqser.cloud/redaction-gateway-v1", + "API_URL": "https://aks-staging.iqser.cloud/redaction-gateway-v1", "APP_NAME": "RedactManager", "AUTO_READ_TIME": 1.5, "BACKEND_APP_VERSION": "4.4.40", @@ -17,7 +17,7 @@ "MAX_RETRIES_ON_SERVER_ERROR": 3, "OAUTH_CLIENT_ID": "redaction", "OAUTH_IDP_HINT": null, - "OAUTH_URL": "https://dev-08.iqser.cloud/auth/realms/redaction", + "OAUTH_URL": "https://aks-staging.iqser.cloud/auth/realms/redaction", "RECENT_PERIOD_IN_HOURS": 24, "SELECTION_MODE": "structural" } diff --git a/libs/red-domain/src/lib/pages/viewed-page.ts b/libs/red-domain/src/lib/pages/viewed-page.ts index 7dc11fc42..4de1e3c17 100644 --- a/libs/red-domain/src/lib/pages/viewed-page.ts +++ b/libs/red-domain/src/lib/pages/viewed-page.ts @@ -3,5 +3,5 @@ export interface IViewedPage { page?: number; userId?: string; viewedTime?: string; - hasChanges?: boolean; + showAsUnseen?: boolean; }