From 7a1bab4c44146756a60c215b55b2bb54e4b04ce2 Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Tue, 16 May 2023 20:49:59 +0300 Subject: [PATCH] RED-6466: mark annotation as redaction if re-created --- apps/red-ui/src/app/models/file/annotation.wrapper.ts | 11 +++++++++++ .../file-preview/services/file-data.service.ts | 4 ++-- apps/red-ui/src/assets/config/config.json | 4 ++-- 3 files changed, 15 insertions(+), 4 deletions(-) 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 418cdc46f..24215b242 100644 --- a/apps/red-ui/src/app/models/file/annotation.wrapper.ts +++ b/apps/red-ui/src/app/models/file/annotation.wrapper.ts @@ -4,6 +4,7 @@ import { annotationDefaultColorConfig, annotationEntityColorConfig, AnnotationIconType, + ChangeTypes, DefaultColors, Dictionary, Earmark, @@ -23,6 +24,7 @@ import { } from '@red/domain'; import { RedactionLogEntry } from '@models/file/redaction-log.entry'; import { IListable, List } from '@iqser/common-ui'; +import { chronologicallyBy, timestampOf } from '../../modules/file-preview/services/file-data.service'; export class AnnotationWrapper implements IListable, Record { [x: string]: unknown; @@ -360,6 +362,15 @@ export class AnnotationWrapper implements IListable, Record { private static _setSuperType(annotationWrapper: AnnotationWrapper, redactionLogEntryWrapper: RedactionLogEntry) { if (redactionLogEntryWrapper.manualChanges?.length) { const lastRelevantManualChange = this._getLastRelevantManualChange(redactionLogEntryWrapper.manualChanges); + const viableChanges = redactionLogEntryWrapper.changes.filter(c => c.analysisNumber > 1); + const lastChange = viableChanges.sort(chronologicallyBy(x => x.dateTime)).at(-1); + const lastChangeOccurredAfterLastManualChange = + timestampOf(lastChange.dateTime) > timestampOf(lastRelevantManualChange.processedDate); + + if (lastChangeOccurredAfterLastManualChange && lastChange.type === ChangeTypes.ADDED && redactionLogEntryWrapper.redacted) { + annotationWrapper.superType = SuperTypes.Redaction; + return; + } annotationWrapper.pending = !lastRelevantManualChange.processed; 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 d9698192d..118555d29 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 @@ -34,11 +34,11 @@ import { ViewedPagesMapService } from '@services/files/viewed-pages-map.service' const DELTA_VIEW_TIME = 10 * 60 * 1000; // 10 minutes; -function timestampOf(value: string) { +export function timestampOf(value: string) { return dayjs(value).valueOf(); } -function chronologicallyBy(property: (x: T) => string) { +export function chronologicallyBy(property: (x: T) => string) { return (a: T, b: T) => timestampOf(property(a)) - timestampOf(property(b)); } diff --git a/apps/red-ui/src/assets/config/config.json b/apps/red-ui/src/assets/config/config.json index 0f864cec1..1b83a4f2b 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://dom2.iqser.cloud/redaction-gateway-v1", + "API_URL": "https://dev-08.iqser.cloud/redaction-gateway-v1", "APP_NAME": "RedactManager", "AUTO_READ_TIME": 3, "BACKEND_APP_VERSION": "4.4.40", @@ -11,7 +11,7 @@ "MAX_RETRIES_ON_SERVER_ERROR": 3, "OAUTH_CLIENT_ID": "redaction", "OAUTH_IDP_HINT": null, - "OAUTH_URL": "https://dom2.iqser.cloud/auth", + "OAUTH_URL": "https://dev-08.iqser.cloud/auth", "RECENT_PERIOD_IN_HOURS": 24, "SELECTION_MODE": "structural", "MANUAL_BASE_URL": "https://docs.redactmanager.com/preview",