From 3ad82afc261e6c9b411544492aaecdb79c9f0b82 Mon Sep 17 00:00:00 2001 From: Timo Date: Mon, 12 Jul 2021 20:24:16 +0300 Subject: [PATCH 1/4] redaction log from backend pt. 1 --- .eslintrc.json | 2 +- .../src/app/models/file/file-data.model.ts | 222 ++---------------- .../file-preview-screen.component.ts | 15 +- .../services/pdf-viewer-data.service.ts | 21 +- .../services/file-download.service.ts | 2 +- .../services/file-upload.service.ts | 4 +- .../dossierAttributesController.service.ts | 5 +- .../src/lib/api/dossierController.service.ts | 5 +- .../api/fileManagementController.service.ts | 4 +- .../lib/api/redactionLogController.service.ts | 76 ++++++ 10 files changed, 118 insertions(+), 238 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 8d6e81f2e..32ca8c20e 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -185,7 +185,7 @@ "max-len": [ "error", { - "code": 100, + "code": 140, "tabWidth": 4, "ignorePattern": "^import .*" } 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 c207e6656..40607a165 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 @@ -1,11 +1,4 @@ -import { - IdRemoval, - ManualRedactionEntry, - ManualRedactions, - RedactionChangeLog, - RedactionLog, - ViewedPages -} from '@redaction/red-ui-http'; +import { RedactionChangeLog, RedactionLog, ViewedPages } from '@redaction/red-ui-http'; import { FileStatusWrapper } from './file-status.wrapper'; import { UserWrapper } from '@services/user.service'; import { AnnotationWrapper } from './annotation.wrapper'; @@ -24,7 +17,6 @@ export class FileDataModel { public fileData: Blob, public redactionLog: RedactionLog, public redactionChangeLog: RedactionChangeLog, - public manualRedactions: ManualRedactions, public viewedPages?: ViewedPages ) {} @@ -34,7 +26,7 @@ export class FileDataModel { viewMode: ViewMode, areDevFeaturesEnabled: boolean ): AnnotationData { - const entries: RedactionLogEntryWrapper[] = this._convertData(dictionaryData); + const entries: RedactionLogEntryWrapper[] = this._convertData(); let allAnnotations = entries .map(entry => AnnotationWrapper.fromData(entry)) .filter(ann => !this.fileStatus.excludedPages.includes(ann.pageNumber)); @@ -59,10 +51,8 @@ export class FileDataModel { }; } - private _convertData(dictionaryData: { - [p: string]: TypeValueWrapper; - }): RedactionLogEntryWrapper[] { - let result: RedactionLogEntryWrapper[] = []; + private _convertData(): RedactionLogEntryWrapper[] { + const result: RedactionLogEntryWrapper[] = []; this.redactionChangeLog?.redactionLogEntry?.forEach(changeLogEntry => { if (changeLogEntry.changeType === 'REMOVED') { @@ -80,8 +70,6 @@ export class FileDataModel { Object.assign(redactionLogEntryWrapper, changeLogEntry); - redactionLogEntryWrapper.comments = - this.manualRedactions.comments[redactionLogEntryWrapper.id]; redactionLogEntryWrapper.isChangeLogEntry = true; redactionLogEntryWrapper.changeLogType = changeLogEntry.changeType; redactionLogEntryWrapper.id = 'changed-log-removed-' + redactionLogEntryWrapper.id; @@ -89,10 +77,16 @@ export class FileDataModel { } }); + const reasonAnnotationIds = []; this.redactionLog.redactionLogEntry?.forEach(redactionLogEntry => { - // false positive entries from the redaction-log need to be skipped - if (redactionLogEntry.type?.toLowerCase() === 'false_positive') { - return; + if ( + redactionLogEntry.manual && + (redactionLogEntry.status === 'APPROVED' || + redactionLogEntry.status === 'REQUESTED') + ) { + // for dictionary entries -> I.E accepted recommendations or false positives, + // check reason + reasonAnnotationIds.push(redactionLogEntry.reason); } const existingChangeLogEntry = this.redactionChangeLog?.redactionLogEntry?.find( @@ -104,204 +98,24 @@ export class FileDataModel { actionPendingReanalysis: false }; Object.assign(redactionLogEntryWrapper, redactionLogEntry); - redactionLogEntryWrapper.comments = - this.manualRedactions.comments[redactionLogEntryWrapper.id]; redactionLogEntryWrapper.isChangeLogEntry = !!existingChangeLogEntry; redactionLogEntryWrapper.changeLogType = 'ADDED'; result.push(redactionLogEntryWrapper); }); - this.manualRedactions.forceRedactions?.forEach(forceRedaction => { - const relevantRedactionLogEntry = result.find(r => r.id === forceRedaction.id); - - if (forceRedaction.status === 'DECLINED') { - relevantRedactionLogEntry.status = 'DECLINED'; - relevantRedactionLogEntry.userId = forceRedaction.user; - relevantRedactionLogEntry.dictionaryEntry = false; - relevantRedactionLogEntry.force = true; - return; - } - - // an entry for this request already exists in the redactionLog - if (relevantRedactionLogEntry) { - relevantRedactionLogEntry.userId = forceRedaction.user; - relevantRedactionLogEntry.dictionaryEntry = false; - relevantRedactionLogEntry.force = true; - - // if statuses differ - if ( - !forceRedaction.processedDate || - forceRedaction.status !== relevantRedactionLogEntry.status - ) { - relevantRedactionLogEntry.actionPendingReanalysis = true; - relevantRedactionLogEntry.status = forceRedaction.status; - } - } - }); - - this.manualRedactions.entriesToAdd?.forEach(manual => { - const markedAsReasonRedactionLogEntry = result.find(r => r.id === manual.reason); - - const relevantRedactionLogEntry = result.find(r => r.id === manual.id); - - // a redaction-log entry is marked as a reason for another entry - hide it - if (markedAsReasonRedactionLogEntry) { - if ( - !this._hasBeenProcessed(manual) || - !['APPROVED', 'DECLINED'].includes(manual.status) - ) { - markedAsReasonRedactionLogEntry.hidden = true; - } - } - - // an entry for this request already exists in the redactionLog - if (relevantRedactionLogEntry) { - if (relevantRedactionLogEntry.status === 'DECLINED') { - relevantRedactionLogEntry.hidden = true; - return; - } - - relevantRedactionLogEntry.userId = manual.user; - relevantRedactionLogEntry.dictionaryEntry = manual.addToDictionary; - - // if statuses differ - if (relevantRedactionLogEntry.status !== manual.status) { - relevantRedactionLogEntry.actionPendingReanalysis = true; - relevantRedactionLogEntry.status = manual.status; - } - } else { - // dictionary modifying requests that have been processed already updated - // the dictionary and should not be drawn - if (manual.addToDictionary && this._hasBeenProcessed(manual)) { - return; - } - - // no entry exists in the redaction log - create it - const dictionary = dictionaryData[manual.type]; - - const redactionLogEntryWrapper: RedactionLogEntryWrapper = {}; - - redactionLogEntryWrapper.id = manual.id; - redactionLogEntryWrapper.dictionaryEntry = manual.addToDictionary; - redactionLogEntryWrapper.legalBasis = manual.legalBasis; - redactionLogEntryWrapper.positions = manual.positions; - redactionLogEntryWrapper.reason = manual.reason; - redactionLogEntryWrapper.status = manual.status; - redactionLogEntryWrapper.type = manual.type; - redactionLogEntryWrapper.userId = manual.user; - redactionLogEntryWrapper.value = manual.value; - redactionLogEntryWrapper.redacted = !dictionary.hint; - redactionLogEntryWrapper.hint = dictionary.hint; - redactionLogEntryWrapper.manualRedactionType = 'ADD'; - redactionLogEntryWrapper.manual = true; - redactionLogEntryWrapper.comments = - this.manualRedactions.comments[redactionLogEntryWrapper.id]; - if (markedAsReasonRedactionLogEntry) { - // cleanup reason if the reason is another annotationId - // it is not needed for drawing - redactionLogEntryWrapper.reason = null; - } - - result.push(redactionLogEntryWrapper); - } - }); - - this.manualRedactions.idsToRemove?.forEach(idToRemove => { - const relevantRedactionLogEntry = result.find(r => r.id === idToRemove.id); - - if (!relevantRedactionLogEntry) { - // idRemove for something that doesn't exist - skip - return; - } else { - relevantRedactionLogEntry.userId = idToRemove.user; - relevantRedactionLogEntry.dictionaryEntry = idToRemove.removeFromDictionary; - - // if statuses differ - if (relevantRedactionLogEntry.status !== idToRemove.status) { - relevantRedactionLogEntry.actionPendingReanalysis = true; - relevantRedactionLogEntry.status = idToRemove.status; - } - - if (this._hasBeenProcessed(idToRemove)) { - if (idToRemove.status === 'DECLINED') { - relevantRedactionLogEntry.status = null; - } - } - } - }); - - this.manualRedactions.legalBasisChanges?.forEach(legalBasisChange => { - const relevantRedactionLogEntry = result.find(r => r.id === legalBasisChange.id); - - if (!relevantRedactionLogEntry) { - // legalBasisChanges for something that doesn't exist - skip - return; - } else { - relevantRedactionLogEntry.legalBasisChangeValue = legalBasisChange.legalBasis; - relevantRedactionLogEntry.userId = legalBasisChange.user; - // if statuses differ - if (relevantRedactionLogEntry.status !== legalBasisChange.status) { - relevantRedactionLogEntry.actionPendingReanalysis = true; - relevantRedactionLogEntry.status = legalBasisChange.status; - } - - if (this._hasBeenProcessed(legalBasisChange)) { - if (legalBasisChange.status === 'DECLINED') { - relevantRedactionLogEntry.status = null; - } - } - } - }); + this.redactionLog.redactionLogEntry = this.redactionLog.redactionLogEntry.filter( + r => reasonAnnotationIds.indexOf(r.id) < 0 + ); result.forEach(redactionLogEntry => { redactionLogEntry.legalBasisMapping = this.redactionLog.legalBasis; if (redactionLogEntry.manual) { - if (redactionLogEntry.manualRedactionType === 'ADD') { - const foundManualEntry = this.manualRedactions.entriesToAdd.find( - me => me.id === redactionLogEntry.id - ); - - // ADD has been undone - not yet processed - if (!foundManualEntry) { - redactionLogEntry.hidden = true; - } - } - - if (redactionLogEntry.manualRedactionType === 'LEGAL_BASIS_CHANGE') { - const legalBasisChanges = this.manualRedactions.legalBasisChanges.find( - me => me.id === redactionLogEntry.id - ); - // ADD has been undone - not yet processed - if (!legalBasisChanges) { - redactionLogEntry.manual = false; - redactionLogEntry.manualRedactionType = 'UNDO'; - redactionLogEntry.status = null; - } - } - if (redactionLogEntry.manualRedactionType === 'REMOVE') { - const foundManualEntry = this.manualRedactions.idsToRemove.find( - me => me.id === redactionLogEntry.id - ); - // REMOVE has been undone - not yet processed - if (!foundManualEntry) { - redactionLogEntry.manual = false; - redactionLogEntry.manualRedactionType = 'UNDO'; - redactionLogEntry.status = null; - } - } + console.log(redactionLogEntry); } }); - // remove undone entriesToAdd and idsToRemove - result = result.filter(redactionLogEntry => !redactionLogEntry.hidden); + console.log(result); return result; } - - private _hasBeenProcessed(entry: ManualRedactionEntry | IdRemoval): boolean { - return !entry.processedDate - ? false - : new Date(entry.processedDate).getTime() < - new Date(this.fileStatus.lastProcessed).getTime(); - } } 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 7ce682727..1296fe846 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 @@ -254,7 +254,6 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach, } async ngOnAttach(previousRoute: ActivatedRouteSnapshot) { - console.log('on attach'); if (!this.permissionsService.canOpenFile(this.appStateService.activeFile)) { await this._router.navigate(['/main/dossiers/' + this.dossierId]); return; @@ -633,7 +632,6 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach, this.fileData.redactionLog = fileData.redactionLog; this.fileData.redactionChangeLog = fileData.redactionChangeLog; this.fileData.fileStatus = fileData.fileStatus; - this.fileData.manualRedactions = fileData.manualRedactions; this.rebuildFilters(true); } else { this.fileData = fileData; @@ -657,9 +655,10 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach, /* Get the documentElement () to display the page in fullscreen */ private _cleanupAndRedrawManualAnnotations() { - this._fileDownloadService.loadActiveFileManualAnnotations().subscribe(manualRedactions => { - this.fileData.manualRedactions = manualRedactions; - this.rebuildFilters(); + this._fileDownloadService + .loadActiveFileRedactionLogPreview() + .subscribe(redactionLogPreview => { + this.fileData.redactionLog = redactionLogPreview; this._annotationDrawService.drawAnnotations( this._instance, this.annotationData.allAnnotations, @@ -674,8 +673,10 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach, const currentPageAnnotationIds = currentPageAnnotations.map(a => a.id); this.fileData.fileStatus = await this.appStateService.reloadActiveFile(); - this._fileDownloadService.loadActiveFileManualAnnotations().subscribe(manualRedactions => { - this.fileData.manualRedactions = manualRedactions; + this._fileDownloadService + .loadActiveFileRedactionLogPreview() + .subscribe(redactionLogPreview => { + this.fileData.redactionLog = redactionLogPreview; this.rebuildFilters(); if (this.viewMode === 'STANDARD') { currentPageAnnotationIds.forEach(id => { 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 c02562776..6f2aa7f80 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 @@ -3,7 +3,6 @@ import { forkJoin, Observable, of } from 'rxjs'; import { catchError, map } from 'rxjs/operators'; import { FileManagementControllerService, - ManualRedactionControllerService, RedactionLogControllerService, ViewedPagesControllerService } from '@redaction/red-ui-http'; @@ -18,13 +17,12 @@ export class PdfViewerDataService { private readonly _appStateService: AppStateService, private readonly _permissionsService: PermissionsService, private readonly _fileManagementControllerService: FileManagementControllerService, - private readonly _manualRedactionControllerService: ManualRedactionControllerService, private readonly _redactionLogControllerService: RedactionLogControllerService, private readonly _viewedPagesControllerService: ViewedPagesControllerService ) {} - loadActiveFileManualAnnotations() { - return this._manualRedactionControllerService.getManualRedaction( + loadActiveFileRedactionLogPreview() { + return this._redactionLogControllerService.getRedactionLogPreview( this._appStateService.activeDossierId, this._appStateService.activeFileId ); @@ -36,23 +34,16 @@ export class PdfViewerDataService { const file$ = this.downloadOriginalFile(this._appStateService.activeFile); const reactionLog$ = this._redactionLogControllerService - .getRedactionLog(dossierId, fileId) + .getRedactionLogPreview(dossierId, fileId) .pipe(catchError(() => of({}))); const redactionChangeLog$ = this._redactionLogControllerService .getRedactionChangeLog(dossierId, fileId) .pipe(catchError(() => of({}))); - const manualRedactions$ = this._manualRedactionControllerService - .getManualRedaction(dossierId, fileId) - .pipe(catchError(() => of({}))); const viewedPages$ = this.getViewedPagesForActiveFile(); - return forkJoin([ - file$, - reactionLog$, - redactionChangeLog$, - manualRedactions$, - viewedPages$ - ]).pipe(map(data => new FileDataModel(this._appStateService.activeFile, ...data))); + return forkJoin([file$, reactionLog$, redactionChangeLog$, viewedPages$]).pipe( + map(data => new FileDataModel(this._appStateService.activeFile, ...data)) + ); } getViewedPagesForActiveFile() { 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 11ef47233..9b7287ad3 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/apps/red-ui/src/app/modules/upload-download/services/file-upload.service.ts b/apps/red-ui/src/app/modules/upload-download/services/file-upload.service.ts index fda32a8d5..0252f86ce 100644 --- a/apps/red-ui/src/app/modules/upload-download/services/file-upload.service.ts +++ b/apps/red-ui/src/app/modules/upload-download/services/file-upload.service.ts @@ -33,8 +33,8 @@ export class FileUploadService { private readonly _uploadControllerService: UploadControllerService, private readonly _dialogService: UploadDownloadDialogService ) { - this._uploadControllerService.defaultHeaders = - this._uploadControllerService.defaultHeaders.append('ngsw-bypass', 'true' ); + this._uploadControllerService.defaultHeaders = + this._uploadControllerService.defaultHeaders.append('ngsw-bypass', 'true'); interval(2500).subscribe(() => { this._handleUploads(); }); diff --git a/libs/red-ui-http/src/lib/api/dossierAttributesController.service.ts b/libs/red-ui-http/src/lib/api/dossierAttributesController.service.ts index d3cdb52e2..c50d8f8eb 100644 --- a/libs/red-ui-http/src/lib/api/dossierAttributesController.service.ts +++ b/libs/red-ui-http/src/lib/api/dossierAttributesController.service.ts @@ -11,8 +11,7 @@ */ /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; -import { HttpClient, HttpHeaders, HttpParams, HttpResponse, HttpEvent } from '@angular/common/http'; -import { CustomHttpUrlEncodingCodec } from '../encoder'; +import { HttpClient, HttpEvent, HttpHeaders, HttpResponse } from '@angular/common/http'; import { Observable } from 'rxjs'; @@ -22,7 +21,7 @@ import { DossierAttributesConfig } from '../model/dossierAttributesConfig'; import { DossierAttributesReq } from '../model/dossierAttributesReq'; import { DossierAttributesRes } from '../model/dossierAttributesRes'; -import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; +import { BASE_PATH } from '../variables'; import { Configuration } from '../configuration'; @Injectable() diff --git a/libs/red-ui-http/src/lib/api/dossierController.service.ts b/libs/red-ui-http/src/lib/api/dossierController.service.ts index c6d07a5fb..946082ffa 100644 --- a/libs/red-ui-http/src/lib/api/dossierController.service.ts +++ b/libs/red-ui-http/src/lib/api/dossierController.service.ts @@ -11,15 +11,14 @@ */ /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; -import { HttpClient, HttpHeaders, HttpParams, HttpResponse, HttpEvent } from '@angular/common/http'; -import { CustomHttpUrlEncodingCodec } from '../encoder'; +import { HttpClient, HttpEvent, HttpHeaders, HttpResponse } from '@angular/common/http'; import { Observable } from 'rxjs'; import { Dossier } from '../model/dossier'; import { DossierRequest } from '../model/dossierRequest'; -import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; +import { BASE_PATH } from '../variables'; import { Configuration } from '../configuration'; @Injectable() diff --git a/libs/red-ui-http/src/lib/api/fileManagementController.service.ts b/libs/red-ui-http/src/lib/api/fileManagementController.service.ts index 353616ea0..e65b0b80c 100644 --- a/libs/red-ui-http/src/lib/api/fileManagementController.service.ts +++ b/libs/red-ui-http/src/lib/api/fileManagementController.service.ts @@ -11,12 +11,12 @@ */ /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; -import { HttpClient, HttpHeaders, HttpParams, HttpResponse, HttpEvent } from '@angular/common/http'; +import { HttpClient, HttpEvent, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http'; import { CustomHttpUrlEncodingCodec } from '../encoder'; import { Observable } from 'rxjs'; -import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; +import { BASE_PATH } from '../variables'; import { Configuration } from '../configuration'; @Injectable() diff --git a/libs/red-ui-http/src/lib/api/redactionLogController.service.ts b/libs/red-ui-http/src/lib/api/redactionLogController.service.ts index 79a1aac09..501789180 100644 --- a/libs/red-ui-http/src/lib/api/redactionLogController.service.ts +++ b/libs/red-ui-http/src/lib/api/redactionLogController.service.ts @@ -201,6 +201,82 @@ export class RedactionLogControllerService { } ); } + /** + * Gets the redaction log preview + * None + * @param dossierId dossierId + * @param fileId fileId + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public getRedactionLogPreview( + dossierId: string, + fileId: string, + observe?: 'body', + reportProgress?: boolean + ): Observable; + public getRedactionLogPreview( + dossierId: string, + fileId: string, + observe?: 'response', + reportProgress?: boolean + ): Observable>; + public getRedactionLogPreview( + dossierId: string, + fileId: string, + observe?: 'events', + reportProgress?: boolean + ): Observable>; + public getRedactionLogPreview( + dossierId: string, + fileId: string, + observe: any = 'body', + reportProgress: boolean = false + ): Observable { + if (dossierId === null || dossierId === undefined) { + throw new Error( + 'Required parameter dossierId was null or undefined when calling getRedactionLogPreview.' + ); + } + + if (fileId === null || fileId === undefined) { + throw new Error( + 'Required parameter fileId was null or undefined when calling getRedactionLogPreview.' + ); + } + + let headers = this.defaultHeaders; + + // authentication (RED-OAUTH) required + if (this.configuration.accessToken) { + const accessToken = + typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken() + : this.configuration.accessToken; + headers = headers.set('Authorization', 'Bearer ' + accessToken); + } + + // to determine the Accept header + const httpHeaderAccepts: string[] = ['application/json']; + const httpHeaderAcceptSelected: string | undefined = + this.configuration.selectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAcceptSelected !== undefined) { + headers = headers.set('Accept', httpHeaderAcceptSelected); + } + + return this.httpClient.request( + 'get', + `${this.basePath}/sectionGrid/${encodeURIComponent( + String(dossierId) + )}/${encodeURIComponent(String(fileId))}/preview`, + { + withCredentials: this.configuration.withCredentials, + headers: headers, + observe: observe, + reportProgress: reportProgress + } + ); + } /** * Gets the section grid for a fileId From 7ccad5c34f8fba16ca63fb3db6608653af0fab2e Mon Sep 17 00:00:00 2001 From: Timo Date: Tue, 13 Jul 2021 15:29:44 +0300 Subject: [PATCH 2/4] more work on integrating backend redaction log --- apps/red-ui/src/app/models/file/file-data.model.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 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 40607a165..d68331fb9 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 @@ -52,7 +52,7 @@ export class FileDataModel { } private _convertData(): RedactionLogEntryWrapper[] { - const result: RedactionLogEntryWrapper[] = []; + let result: RedactionLogEntryWrapper[] = []; this.redactionChangeLog?.redactionLogEntry?.forEach(changeLogEntry => { if (changeLogEntry.changeType === 'REMOVED') { @@ -103,19 +103,12 @@ export class FileDataModel { result.push(redactionLogEntryWrapper); }); - this.redactionLog.redactionLogEntry = this.redactionLog.redactionLogEntry.filter( - r => reasonAnnotationIds.indexOf(r.id) < 0 - ); + result = result.filter(r => reasonAnnotationIds.indexOf(r.id) < 0); result.forEach(redactionLogEntry => { redactionLogEntry.legalBasisMapping = this.redactionLog.legalBasis; - - if (redactionLogEntry.manual) { - console.log(redactionLogEntry); - } }); - console.log(result); return result; } } From e2b3a977239f949d970c24f87679179c2407b647 Mon Sep 17 00:00:00 2001 From: Timo Date: Tue, 13 Jul 2021 16:28:59 +0300 Subject: [PATCH 3/4] OCR Fix - RED-1593 --- apps/red-ui/src/app/models/file/file-data.model.ts | 4 ++++ .../file-actions/file-actions.component.html | 2 +- .../file-preview-screen.component.ts | 10 +++++++++- 3 files changed, 14 insertions(+), 2 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 d68331fb9..440c91025 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 @@ -106,6 +106,10 @@ export class FileDataModel { result = result.filter(r => reasonAnnotationIds.indexOf(r.id) < 0); result.forEach(redactionLogEntry => { + if (redactionLogEntry.id === '96a9fad412ac0ccc340c9ee53f97986b') { + redactionLogEntry.dictionaryEntry = true; + } + redactionLogEntry.legalBasisMapping = this.redactionLog.legalBasis; }); 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 98675e10e..dc7c5b5db 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 @@ -115,7 +115,7 @@ { if (fileStatus.fileId === this.fileId) { - await this._loadFileData(true); + await this._loadFileData(!this._reloadFileOnReanalysis); + this._reloadFileOnReanalysis = false; this.viewReady = true; this._updateCanPerformActions(); this._cleanupAndRedrawManualAnnotations(); From f26cbbaa1c4c6ff76c5c263b13383734a801f5b3 Mon Sep 17 00:00:00 2001 From: Timo Date: Wed, 14 Jul 2021 11:52:46 +0300 Subject: [PATCH 4/4] minor fixes and - RED-1758 --- .../app/models/file/annotation.permissions.ts | 5 +- .../src/app/models/file/annotation.wrapper.ts | 165 ++++++++---------- .../src/app/models/file/file-data.model.ts | 8 +- .../file/redaction-log-entry.wrapper.ts | 5 +- .../src/app/modules/auth/red-role.guard.ts | 5 +- .../file-preview-screen.component.ts | 2 +- .../services/pdf-viewer-data.service.ts | 4 + 7 files changed, 87 insertions(+), 107 deletions(-) diff --git a/apps/red-ui/src/app/models/file/annotation.permissions.ts b/apps/red-ui/src/app/models/file/annotation.permissions.ts index bf2197b92..55dc11761 100644 --- a/apps/red-ui/src/app/models/file/annotation.permissions.ts +++ b/apps/red-ui/src/app/models/file/annotation.permissions.ts @@ -34,9 +34,8 @@ export class AnnotationPermissions { const permissions: AnnotationPermissions = new AnnotationPermissions(); permissions.canUndo = - annotation.isUndoableSuperType && - (annotation.userId === user.id || - (annotation.userId && isApprover && !annotation.isSuggestion)); + (!isApprover && annotation.isSuggestion) || + (isApprover && annotation.isUndoableActionForApprover); permissions.canForceRedaction = annotation.isSkipped && !permissions.canUndo; diff --git a/apps/red-ui/src/app/models/file/annotation.wrapper.ts b/apps/red-ui/src/app/models/file/annotation.wrapper.ts index e535be68f..46d25d634 100644 --- a/apps/red-ui/src/app/models/file/annotation.wrapper.ts +++ b/apps/red-ui/src/app/models/file/annotation.wrapper.ts @@ -6,10 +6,10 @@ export class AnnotationWrapper { | 'add-dictionary' | 'remove-dictionary' | 'remove-only-here' + | 'change-legal-basis' | 'suggestion-change-legal-basis' | 'suggestion-add-dictionary' | 'suggestion-force-redaction' - | 'change-legal-basis' | 'suggestion-remove-dictionary' | 'suggestion-add' | 'suggestion-remove' @@ -29,7 +29,6 @@ export class AnnotationWrapper { shortContent: string; content: string; value: string; - userId: string; typeLabel: string; pageNumber: number; hint: boolean; @@ -41,6 +40,8 @@ export class AnnotationWrapper { legalBasis: string; legalBasisChangeValue?: string; + manual?: boolean; + image?: boolean; force?: boolean; @@ -54,21 +55,8 @@ export class AnnotationWrapper { constructor() {} - get isUndoableSuperType() { - return ( - this.superType === 'add-dictionary' || - this.superType === 'remove-dictionary' || - this.superType === 'suggestion-add-dictionary' || - this.superType === 'suggestion-force-redaction' || - this.superType === 'suggestion-remove-dictionary' || - this.superType === 'suggestion-change-legal-basis' || - this.superType === 'suggestion-add' || - this.superType === 'change-legal-basis' || - this.superType === 'suggestion-remove' || - this.superType === 'skipped' || - this.superType === 'redaction' || - this.superType === 'manual-redaction' - ); + get isUndoableActionForApprover() { + return this.manual; } get isChangeLogRemoved() { @@ -219,7 +207,6 @@ export class AnnotationWrapper { annotationWrapper._origin = redactionLogEntry; annotationWrapper.annotationId = redactionLogEntry.id; - annotationWrapper.force = redactionLogEntry.force; annotationWrapper.isChangeLogEntry = redactionLogEntry.isChangeLogEntry; annotationWrapper.changeLogType = redactionLogEntry.changeLogType; annotationWrapper.redaction = redactionLogEntry.redacted; @@ -233,14 +220,14 @@ export class AnnotationWrapper { annotationWrapper.textBefore = redactionLogEntry.textBefore; annotationWrapper.textAfter = redactionLogEntry.textAfter; annotationWrapper.dictionaryOperation = redactionLogEntry.dictionaryEntry; - annotationWrapper.userId = redactionLogEntry.userId; annotationWrapper.image = redactionLogEntry.image; annotationWrapper.legalBasisChangeValue = redactionLogEntry.legalBasisChangeValue; annotationWrapper.comments = redactionLogEntry.comments || []; annotationWrapper.legalBasis = redactionLogEntry.legalBasis; + annotationWrapper.manual = redactionLogEntry.manual; + this._createContent(annotationWrapper, redactionLogEntry); this._setSuperType(annotationWrapper, redactionLogEntry); - this._handleSkippedState(annotationWrapper, redactionLogEntry); this._handleRecommendations(annotationWrapper, redactionLogEntry); annotationWrapper.typeLabel = 'annotation-type.' + annotationWrapper.superType; @@ -262,25 +249,35 @@ export class AnnotationWrapper { annotationWrapper: AnnotationWrapper, redactionLogEntryWrapper: RedactionLogEntryWrapper ) { - if (redactionLogEntryWrapper.legalBasisChangeValue) { - if (redactionLogEntryWrapper.status === 'REQUESTED') { - annotationWrapper.superType = 'suggestion-change-legal-basis'; - } else if (redactionLogEntryWrapper.actionPendingReanalysis) { - annotationWrapper.superType = 'change-legal-basis'; + if (redactionLogEntryWrapper.recommendation) { + if (redactionLogEntryWrapper.redacted) { + annotationWrapper.superType = 'recommendation'; } else { - annotationWrapper.superType = 'redaction'; + annotationWrapper.superType = 'skipped'; } return; } - if (redactionLogEntryWrapper.recommendation) { - if (redactionLogEntryWrapper.redacted) { - annotationWrapper.superType = 'recommendation'; - return; + if (redactionLogEntryWrapper.manualRedactionType === 'FORCE_REDACT') { + annotationWrapper.force = true; + + if (redactionLogEntryWrapper.status === 'REQUESTED') { + annotationWrapper.superType = 'suggestion-force-redaction'; + } else if (redactionLogEntryWrapper.status === 'APPROVED') { + annotationWrapper.superType = 'redaction'; } else { annotationWrapper.superType = 'skipped'; - return; } + return; + } + + if (redactionLogEntryWrapper.manualRedactionType === 'LEGAL_BASIS_CHANGE') { + if (redactionLogEntryWrapper.status === 'REQUESTED') { + annotationWrapper.superType = 'suggestion-change-legal-basis'; + } else { + annotationWrapper.superType = 'redaction'; + } + return; } if (redactionLogEntryWrapper.status === 'DECLINED') { @@ -295,45 +292,53 @@ export class AnnotationWrapper { if (redactionLogEntryWrapper.status === 'APPROVED') { annotationWrapper.superType = 'add-dictionary'; } - } else { - if (redactionLogEntryWrapper.redacted) { - if (redactionLogEntryWrapper.force) { + return; + } + + if (redactionLogEntryWrapper.manualRedactionType === 'ADD') { + if (redactionLogEntryWrapper.dictionaryEntry) { + if (redactionLogEntryWrapper.status === 'REQUESTED') { + annotationWrapper.superType = 'suggestion-add-dictionary'; + } + if (redactionLogEntryWrapper.status === 'APPROVED') { + annotationWrapper.superType = 'add-dictionary'; + } + } else { + if (redactionLogEntryWrapper.status === 'REQUESTED') { + annotationWrapper.superType = 'suggestion-add'; + } + if (redactionLogEntryWrapper.status === 'APPROVED') { + annotationWrapper.superType = 'manual-redaction'; + } + } + } + + if (redactionLogEntryWrapper.redacted) { + if (redactionLogEntryWrapper.status === 'REQUESTED') { + if (redactionLogEntryWrapper.dictionaryEntry) { annotationWrapper.superType = - redactionLogEntryWrapper.status === 'REQUESTED' - ? 'suggestion-add' - : 'redaction'; - } else if (redactionLogEntryWrapper.type === 'manual') { - annotationWrapper.superType = - redactionLogEntryWrapper.status === 'REQUESTED' - ? 'suggestion-add' - : 'manual-redaction'; + redactionLogEntryWrapper.manualRedactionType === 'ADD' + ? 'suggestion-add-dictionary' + : 'suggestion-remove-dictionary'; } else { - if (redactionLogEntryWrapper.status === 'REQUESTED') { - if (redactionLogEntryWrapper.dictionaryEntry) { - annotationWrapper.superType = - redactionLogEntryWrapper.manualRedactionType === 'ADD' - ? 'suggestion-add-dictionary' - : 'suggestion-remove-dictionary'; - } else { - annotationWrapper.superType = - redactionLogEntryWrapper.manualRedactionType === 'ADD' - ? 'suggestion-add' - : 'suggestion-remove'; - } - } - if (redactionLogEntryWrapper.status === 'APPROVED') { - if (redactionLogEntryWrapper.dictionaryEntry) { - annotationWrapper.superType = - redactionLogEntryWrapper.manualRedactionType === 'ADD' - ? 'add-dictionary' - : 'remove-dictionary'; - } else { - annotationWrapper.superType = - redactionLogEntryWrapper.manualRedactionType === 'ADD' - ? 'manual-redaction' - : 'remove-only-here'; - } - } + annotationWrapper.superType = + redactionLogEntryWrapper.manualRedactionType === 'ADD' + ? 'suggestion-add' + : 'suggestion-remove'; + } + } + + if (redactionLogEntryWrapper.status === 'APPROVED') { + if (redactionLogEntryWrapper.dictionaryEntry) { + annotationWrapper.superType = + redactionLogEntryWrapper.manualRedactionType === 'ADD' + ? 'add-dictionary' + : 'remove-dictionary'; + } else { + annotationWrapper.superType = + redactionLogEntryWrapper.manualRedactionType === 'ADD' + ? 'manual-redaction' + : 'remove-only-here'; } } } @@ -347,30 +352,6 @@ export class AnnotationWrapper { } } - private static _handleSkippedState( - annotationWrapper: AnnotationWrapper, - redactionLogEntryWrapper: RedactionLogEntryWrapper - ) { - if (annotationWrapper.superType !== 'skipped') return; - - if (!annotationWrapper.userId) { - if ( - redactionLogEntryWrapper.manualRedactionType === 'REMOVE' || - redactionLogEntryWrapper.manualRedactionType === 'UNDO' - ) { - annotationWrapper.superType = 'pending-analysis'; - return; - } - } else if (redactionLogEntryWrapper.status === 'REQUESTED') { - annotationWrapper.superType = 'suggestion-force-redaction'; - return; - } - - if (redactionLogEntryWrapper.actionPendingReanalysis) { - annotationWrapper.superType = 'pending-analysis'; - } - } - private static _createContent( annotationWrapper: AnnotationWrapper, entry: RedactionLogEntryWrapper 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 440c91025..2484090e8 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 @@ -64,9 +64,7 @@ export class FileDataModel { return; } - const redactionLogEntryWrapper: RedactionLogEntryWrapper = { - actionPendingReanalysis: false - }; + const redactionLogEntryWrapper: RedactionLogEntryWrapper = {}; Object.assign(redactionLogEntryWrapper, changeLogEntry); @@ -94,9 +92,7 @@ export class FileDataModel { ); // copy the redactionLog Entry - const redactionLogEntryWrapper: RedactionLogEntryWrapper = { - actionPendingReanalysis: false - }; + const redactionLogEntryWrapper: RedactionLogEntryWrapper = {}; Object.assign(redactionLogEntryWrapper, redactionLogEntry); redactionLogEntryWrapper.isChangeLogEntry = !!existingChangeLogEntry; redactionLogEntryWrapper.changeLogType = 'ADDED'; diff --git a/apps/red-ui/src/app/models/file/redaction-log-entry.wrapper.ts b/apps/red-ui/src/app/models/file/redaction-log-entry.wrapper.ts index 26253f957..a9592e82e 100644 --- a/apps/red-ui/src/app/models/file/redaction-log-entry.wrapper.ts +++ b/apps/red-ui/src/app/models/file/redaction-log-entry.wrapper.ts @@ -8,7 +8,7 @@ export interface RedactionLogEntryWrapper { legalBasis?: string; legalBasisMapping?: Array; manual?: boolean; - manualRedactionType?: 'ADD' | 'REMOVE' | 'UNDO' | 'LEGAL_BASIS_CHANGE'; + manualRedactionType?: 'ADD' | 'REMOVE' | 'UNDO' | 'LEGAL_BASIS_CHANGE' | 'FORCE_REDACT'; matchedRule?: number; positions?: Array; reason?: string; @@ -20,14 +20,11 @@ export interface RedactionLogEntryWrapper { textBefore?: string; type?: string; value?: string; - force?: boolean; image?: boolean; recommendation?: boolean; recommendationAnnotationId?: string; - actionPendingReanalysis?: boolean; - hidden?: boolean; userId?: string; diff --git a/apps/red-ui/src/app/modules/auth/red-role.guard.ts b/apps/red-ui/src/app/modules/auth/red-role.guard.ts index 6ce704eb7..5c9c0d5d5 100644 --- a/apps/red-ui/src/app/modules/auth/red-role.guard.ts +++ b/apps/red-ui/src/app/modules/auth/red-role.guard.ts @@ -27,7 +27,10 @@ export class RedRoleGuard implements CanActivate { if ( this._userService.user.isUserAdmin && !this._userService.user.isAdmin && - !state.url.startsWith('/main/admin/users') + !( + state.url.startsWith('/main/admin/users') || + state.url.startsWith('/main/my-profile') + ) ) { this._router.navigate(['/main/admin/users']); obs.next(false); 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 121bc8298..feb5bbb22 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 @@ -78,7 +78,7 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach, @ViewChild(PdfViewerComponent) viewerComponent: PdfViewerComponent; private _instance: WebViewerInstance; private _lastPage: string; - private _reloadFileOnReanalysis: boolean = false; + private _reloadFileOnReanalysis = false; @ViewChild('fileWorkloadComponent') private _workloadComponent: FileWorkloadComponent; 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 6f2aa7f80..64a9e00d5 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 @@ -3,6 +3,7 @@ import { forkJoin, Observable, of } from 'rxjs'; import { catchError, map } from 'rxjs/operators'; import { FileManagementControllerService, + ManualRedactionControllerService, RedactionLogControllerService, ViewedPagesControllerService } from '@redaction/red-ui-http'; @@ -16,6 +17,7 @@ export class PdfViewerDataService { constructor( private readonly _appStateService: AppStateService, private readonly _permissionsService: PermissionsService, + private readonly _man: ManualRedactionControllerService, private readonly _fileManagementControllerService: FileManagementControllerService, private readonly _redactionLogControllerService: RedactionLogControllerService, private readonly _viewedPagesControllerService: ViewedPagesControllerService @@ -32,6 +34,8 @@ export class PdfViewerDataService { const dossierId = this._appStateService.activeDossierId; const fileId = this._appStateService.activeFileId; + this._man.getManualRedaction(dossierId, fileId).subscribe(); + const file$ = this.downloadOriginalFile(this._appStateService.activeFile); const reactionLog$ = this._redactionLogControllerService .getRedactionLogPreview(dossierId, fileId)