From 01233562870907faf875eee573219961e940bc5e Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Fri, 24 Sep 2021 19:55:13 +0300 Subject: [PATCH] add engines property and show relevant messages in popover --- .../src/app/models/file/annotation.wrapper.ts | 2 + .../file/redaction-log-entry.wrapper.ts | 1 + .../annotation-source.component.html | 14 ++-- .../annotation-source.component.ts | 72 +++++++++++++------ apps/red-ui/src/assets/i18n/de.json | 5 ++ apps/red-ui/src/assets/i18n/en.json | 7 +- libs/common-ui | 2 +- .../src/lib/model/redactionLogEntry.ts | 1 + 8 files changed, 74 insertions(+), 30 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 750192ae1..357f280d6 100644 --- a/apps/red-ui/src/app/models/file/annotation.wrapper.ts +++ b/apps/red-ui/src/app/models/file/annotation.wrapper.ts @@ -57,6 +57,7 @@ export class AnnotationWrapper { isChangeLogEntry?: boolean; changeLogType?: 'ADDED' | 'REMOVED'; + engines?: string[]; private _origin: RedactionLogEntryWrapper; @@ -218,6 +219,7 @@ export class AnnotationWrapper { annotationWrapper.legalBasisValue = redactionLogEntry.legalBasis; annotationWrapper.comments = redactionLogEntry.comments || []; annotationWrapper.manual = redactionLogEntry.manual; + annotationWrapper.engines = redactionLogEntry.engines; this._createContent(annotationWrapper, redactionLogEntry); this._setSuperType(annotationWrapper, redactionLogEntry); 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 2ddc9d003..728a87532 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 @@ -35,4 +35,5 @@ export interface RedactionLogEntryWrapper { recategorizationType?: string; legalBasisChangeValue?: string; + engines?: string[]; } diff --git a/apps/red-ui/src/app/modules/dossier/components/file-workload/components/annotation-source/annotation-source.component.html b/apps/red-ui/src/app/modules/dossier/components/file-workload/components/annotation-source/annotation-source.component.html index 45ab7299d..766e23aa6 100644 --- a/apps/red-ui/src/app/modules/dossier/components/file-workload/components/annotation-source/annotation-source.component.html +++ b/apps/red-ui/src/app/modules/dossier/components/file-workload/components/annotation-source/annotation-source.component.html @@ -1,7 +1,7 @@ - +
- - + +
@@ -12,10 +12,10 @@ [cdkConnectedOverlayOpen]="isPopoverOpen" >
- -
- - Redaction based on ceva mai lung care să vină pe 2 rânduri + +
+ + {{ engine.description }}
diff --git a/apps/red-ui/src/app/modules/dossier/components/file-workload/components/annotation-source/annotation-source.component.ts b/apps/red-ui/src/app/modules/dossier/components/file-workload/components/annotation-source/annotation-source.component.ts index e2462212a..f22c9eaa9 100644 --- a/apps/red-ui/src/app/modules/dossier/components/file-workload/components/annotation-source/annotation-source.component.ts +++ b/apps/red-ui/src/app/modules/dossier/components/file-workload/components/annotation-source/annotation-source.component.ts @@ -1,35 +1,65 @@ -import { Component, Input } from '@angular/core'; +import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; import { AnnotationWrapper } from '@models/file/annotation.wrapper'; +import { OnChange } from '@iqser/common-ui'; +import { TranslateService } from '@ngx-translate/core'; -interface Source { +interface Engine { readonly icon: string; + readonly description: string; readonly show: boolean; } +type Engines = readonly Engine[]; + +const Engines = { + DICTIONARY: 'DICTIONARY', + NER: 'NER', + RULE: 'RULE' +} as const; + +type EngineName = keyof typeof Engines; + @Component({ selector: 'redaction-annotation-source', templateUrl: './annotation-source.component.html', - styleUrls: ['./annotation-source.component.scss'] + styleUrls: ['./annotation-source.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush }) export class AnnotationSourceComponent { - @Input() annotation: AnnotationWrapper; - isPopoverOpen = false; - readonly sources: readonly Source[] = [ - { - icon: 'red:dictionary', - show: true - }, - { - icon: 'red:ai', - show: true - }, - { - icon: 'red:rule', - show: true - } - ]; + @Input() + @OnChange('updateEngines') + annotation: AnnotationWrapper; - get hasSourcesToShow(): boolean { - return this.sources.length && this.sources.some(source => source.show) + isPopoverOpen = false; + engines: Engines; + + constructor(private readonly _translateService: TranslateService) {} + + get hasEnginesToShow(): boolean { + return this.engines.length && this.engines.some(source => source.show); + } + + updateEngines(): void { + this.engines = [ + { + icon: 'red:dictionary', + description: this._translateService.instant('annotation-engines.dictionary'), + show: this._isBasedOn(Engines.DICTIONARY) + }, + { + icon: 'red:ai', + description: this._translateService.instant('annotation-engines.ner'), + show: this._isBasedOn(Engines.NER) + }, + { + icon: 'red:rule', + description: this._translateService.instant('annotation-engines.rule', { rule: this.annotation.legalBasisValue }), + show: this._isBasedOn(Engines.RULE) + } + ]; + } + + private _isBasedOn(engineName: EngineName) { + return !!this.annotation.engines?.includes(engineName); } } diff --git a/apps/red-ui/src/assets/i18n/de.json b/apps/red-ui/src/assets/i18n/de.json index e2610469f..16ad8a22d 100644 --- a/apps/red-ui/src/assets/i18n/de.json +++ b/apps/red-ui/src/assets/i18n/de.json @@ -1379,5 +1379,10 @@ "text-placeholder": "Text eingeben" }, "title": "Wasserzeichen" + }, + "annotation-engines": { + "dictionary": "", + "ner": "", + "rule": "" } } diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index 1eb06a6d1..c5122764f 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -1521,5 +1521,10 @@ }, "title": "Watermark" }, - "yesterday": "Yesterday" + "yesterday": "Yesterday", + "annotation-engines": { + "dictionary": "Redaction based on dictionary", + "ner": "Redaction based on AI", + "rule": "Redaction based on rule {rule}" + } } diff --git a/libs/common-ui b/libs/common-ui index 4f0d8022e..b55e3bf0d 160000 --- a/libs/common-ui +++ b/libs/common-ui @@ -1 +1 @@ -Subproject commit 4f0d8022eddb1fa3306a653883ac5b0972f75d13 +Subproject commit b55e3bf0ddbda8e8459cb0ae23c8abd5fff46a18 diff --git a/libs/red-ui-http/src/lib/model/redactionLogEntry.ts b/libs/red-ui-http/src/lib/model/redactionLogEntry.ts index f84bd6689..c4b9745f1 100644 --- a/libs/red-ui-http/src/lib/model/redactionLogEntry.ts +++ b/libs/red-ui-http/src/lib/model/redactionLogEntry.ts @@ -40,6 +40,7 @@ export interface RedactionLogEntry { type?: string; value?: string; legalBasisChangeValue?: string; + engines?: string[]; } export namespace RedactionLogEntry {