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 1f70f65d3..88e9dc088 100644 --- a/apps/red-ui/src/app/models/file/annotation.wrapper.ts +++ b/apps/red-ui/src/app/models/file/annotation.wrapper.ts @@ -59,7 +59,7 @@ export class AnnotationWrapper implements IListable { hasBeenForcedHint: boolean; hasBeenForcedRedaction: boolean; hasBeenRemovedByManualOverride: boolean; - isIgnored = false; + isRemoved = false; get searchKey(): string { return this.id; @@ -212,7 +212,7 @@ export class AnnotationWrapper implements IListable { const annotationWrapper = new AnnotationWrapper(); annotationWrapper.id = logEntry.id; - annotationWrapper.isChangeLogEntry = !!changeLogType; + annotationWrapper.isChangeLogEntry = logEntry.state === EntryStates.REMOVED || !!changeLogType; annotationWrapper.type = logEntry.type; annotationWrapper.value = logEntry.value; annotationWrapper.firstTopLeftPoint = { x: logEntry.positions[0].rectangle[0], y: logEntry.positions[0].rectangle[1] }; @@ -232,7 +232,7 @@ export class AnnotationWrapper implements IListable { annotationWrapper.AREA = logEntry.entryType === EntityTypes.AREA; annotationWrapper.IMAGE_HINT = logEntry.entryType === EntityTypes.IMAGE_HINT; - annotationWrapper.isIgnored = logEntry.state === EntryStates.IGNORED; + annotationWrapper.isRemoved = logEntry.state === EntryStates.REMOVED; annotationWrapper.numberOfComments = logEntry.numberOfComments; annotationWrapper.imported = logEntry.imported; diff --git a/apps/red-ui/src/app/modules/file-preview/components/annotation-wrapper/annotation-wrapper.component.html b/apps/red-ui/src/app/modules/file-preview/components/annotation-wrapper/annotation-wrapper.component.html index 498cb36c9..b86f9db37 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/annotation-wrapper/annotation-wrapper.component.html +++ b/apps/red-ui/src/app/modules/file-preview/components/annotation-wrapper/annotation-wrapper.component.html @@ -1,6 +1,6 @@
-
+
!bool(a.isIgnored)); + annotations = annotations.filter(a => !a.isRemoved); } if (this.#isDocumine && !this.#isIqserDevMode) { diff --git a/apps/red-ui/src/app/modules/file-preview/services/file-data.service.ts b/apps/red-ui/src/app/modules/file-preview/services/file-data.service.ts index 1f08b8b01..35433f183 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/file-data.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/file-data.service.ts @@ -3,22 +3,11 @@ import { toObservable } from '@angular/core/rxjs-interop'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { EntitiesService, getConfig, Toaster } from '@iqser/common-ui'; import { AnnotationWrapper } from '@models/file/annotation.wrapper'; -import { - ChangeType, - ChangeTypes, - EntryStates, - File, - IEntityLog, - IEntityLogEntry, - SuperTypeMapper, - ViewedPage, - ViewMode, - ViewModes, -} from '@red/domain'; +import { ChangeType, ChangeTypes, File, IEntityLog, IEntityLogEntry, SuperTypeMapper, ViewedPage, ViewMode, ViewModes } from '@red/domain'; import { DictionaryService } from '@services/entity-services/dictionary.service'; import { EarmarksService } from '@services/files/earmarks.service'; +import { EntityLogService } from '@services/files/entity-log.service'; import { FilesService } from '@services/files/files.service'; -import { RedactionLogService } from '@services/files/redaction-log.service'; import { ViewedPagesMapService } from '@services/files/viewed-pages-map.service'; import { ViewedPagesService } from '@services/files/viewed-pages.service'; import { PermissionsService } from '@services/permissions.service'; @@ -48,6 +37,7 @@ export class FileDataService extends EntitiesService(); readonly earmarks: Signal>; @@ -59,10 +49,9 @@ export class FileDataService extends EntitiesService !a.isFalsePositive); + annotations = this.#isIqserDevMode ? annotations : annotations.filter(a => !a.isFalsePositive); this.#annotations.set(annotations); } @@ -163,24 +152,18 @@ export class FileDataService extends EntitiesService { - if (viewMode === 'STANDARD') { - return !annotation.isIgnored; - } + if (viewMode === ViewModes.STANDARD) { + return annotations.filter(annotation => !annotation.isRemoved); + } - if (viewMode === 'DELTA') { - return annotation.isChangeLogEntry; - } + if (viewMode === ViewModes.DELTA) { + return annotations.filter(annotation => annotation.isChangeLogEntry); + } - return annotation.isRedacted; - }); + return annotations.filter(annotation => annotation.isRedacted); } async #convertData(entityLog: IEntityLog) { - if (!entityLog.entityLogEntry) { - return [] as AnnotationWrapper[]; - } - const file = this._state.file(); const annotations: AnnotationWrapper[] = []; const dictionaries = this._state.dictionaries; @@ -193,12 +176,8 @@ export class FileDataService extends EntitiesService { - annotation['Opacity'] = restoreToOriginal ? parseFloat(annotation.getCustomData('opacity')) : 0.5; + annotation['Opacity'] = restoreToOriginal ? parseFloat(annotation.getCustomData('opacity')) : 1; }); } diff --git a/apps/red-ui/src/app/services/files/redaction-log.service.ts b/apps/red-ui/src/app/services/files/entity-log.service.ts similarity index 92% rename from apps/red-ui/src/app/services/files/redaction-log.service.ts rename to apps/red-ui/src/app/services/files/entity-log.service.ts index f8a4cf55f..ef5efab9a 100644 --- a/apps/red-ui/src/app/services/files/redaction-log.service.ts +++ b/apps/red-ui/src/app/services/files/entity-log.service.ts @@ -7,7 +7,7 @@ import { catchError } from 'rxjs/operators'; @Injectable({ providedIn: 'root', }) -export class RedactionLogService extends GenericService { +export class EntityLogService extends GenericService { protected readonly _defaultModelPath = ''; async getEntityLog(dossierId: string, fileId: string) { diff --git a/apps/red-ui/src/app/utils/page-stamper.ts b/apps/red-ui/src/app/utils/page-stamper.ts index 28a19fc4e..4d6602c47 100644 --- a/apps/red-ui/src/app/utils/page-stamper.ts +++ b/apps/red-ui/src/app/utils/page-stamper.ts @@ -1,12 +1,12 @@ -import { hexToRgb } from './functions'; import { Core } from '@pdftron/webviewer'; -import PDFDoc = Core.PDFNet.PDFDoc; import { WATERMARK_HORIZONTAL_ALIGNMENTS, WATERMARK_VERTICAL_ALIGNMENTS, WatermarkHorizontalAlignment, WatermarkVerticalAlignment, } from '@red/domain'; +import { hexToRgb } from './functions'; +import PDFDoc = Core.PDFNet.PDFDoc; const HORIZONTAL_TEXT_ALIGNMENT_MATRIX = [ [-1, 0, 1], @@ -62,7 +62,7 @@ export async function stampPDFPage( text: string, fontSize: number, fontType: string, - orientation: 'DIAGONAL' | 'HORIZONTAL' | 'VERTICAL' | 'TOP_LEFT', + orientation: 'DIAGONAL' | 'HORIZONTAL' | 'VERTICAL', horizontalTextAlignment: WatermarkHorizontalAlignment, verticalTextAlignment: WatermarkVerticalAlignment, opacity: number, @@ -117,17 +117,17 @@ export async function stampPDFPage( case 'VERTICAL': await stamper.setRotation(-90); await stamper.setTextAlignment(VERTICAL_TEXT_ALIGNMENT_MATRIX[verticalAlignment + 1][horizontalAlignment + 1]); - await stamper.setPosition(10, 20); + await stamper.setPosition(10, 15); break; case 'HORIZONTAL': await stamper.setTextAlignment(HORIZONTAL_TEXT_ALIGNMENT_MATRIX[verticalAlignment + 1][horizontalAlignment + 1]); - await stamper.setPosition(20, 10); + await stamper.setPosition(15, 10); break; case 'DIAGONAL': default: await stamper.setRotation(-45); await stamper.setTextAlignment(DIAGONAL_TEXT_ALIGNMENT_MATRIX[verticalAlignment + 1][horizontalAlignment + 1]); - await stamper.setPosition(20, 10); + await stamper.setPosition(15, 10); } const initialFont = await pdfNet.Font.create(document, convertFont(pdfNet, fontType)); diff --git a/libs/red-domain/src/lib/files/super-types.ts b/libs/red-domain/src/lib/files/super-types.ts index 9dbf33fae..960258c34 100644 --- a/libs/red-domain/src/lib/files/super-types.ts +++ b/libs/red-domain/src/lib/files/super-types.ts @@ -23,14 +23,28 @@ function wrongSuperTypeHandler(): never | undefined { */ export const SuperTypeMapper: Record SuperType | undefined>> = { [EntityTypes.ENTITY]: { - [EntryStates.APPLIED]: entry => (entry.manualChanges.length ? SuperTypes.ManualRedaction : SuperTypes.Redaction), + [EntryStates.APPLIED]: entry => { + const hasManualChanges = entry.manualChanges.length; + const hasEngines = entry.engines.length; + if (hasManualChanges && !hasEngines) { + return SuperTypes.ManualRedaction; + } + return SuperTypes.Redaction; + }, [EntryStates.SKIPPED]: () => SuperTypes.Skipped, - [EntryStates.IGNORED]: () => SuperTypes.Redaction, + [EntryStates.IGNORED]: () => SuperTypes.Skipped, [EntryStates.REMOVED]: wrongSuperTypeHandler, }, [EntityTypes.HINT]: { [EntryStates.APPLIED]: wrongSuperTypeHandler, - [EntryStates.SKIPPED]: entry => (entry.manualChanges.length ? SuperTypes.ManualHint : SuperTypes.Hint), + [EntryStates.SKIPPED]: entry => { + const hasManualChanges = entry.manualChanges.length; + const hasEngines = entry.engines.length; + if (hasManualChanges && !hasEngines) { + return SuperTypes.ManualHint; + } + return SuperTypes.Hint; + }, [EntryStates.IGNORED]: () => SuperTypes.IgnoredHint, [EntryStates.REMOVED]: wrongSuperTypeHandler, }, @@ -61,13 +75,13 @@ export const SuperTypeMapper: Record SuperTypes.Redaction, [EntryStates.SKIPPED]: () => SuperTypes.Skipped, - [EntryStates.IGNORED]: wrongSuperTypeHandler, + [EntryStates.IGNORED]: () => SuperTypes.Skipped, [EntryStates.REMOVED]: wrongSuperTypeHandler, }, [EntityTypes.IMAGE_HINT]: { [EntryStates.APPLIED]: wrongSuperTypeHandler, [EntryStates.SKIPPED]: () => SuperTypes.Hint, - [EntryStates.IGNORED]: wrongSuperTypeHandler, + [EntryStates.IGNORED]: () => SuperTypes.IgnoredHint, [EntryStates.REMOVED]: wrongSuperTypeHandler, }, };