From 093b3a01fc7d64d788e463fb61cd7d900e000b4b Mon Sep 17 00:00:00 2001 From: Timo Bejan Date: Wed, 14 Oct 2020 16:59:17 +0300 Subject: [PATCH] added removal request for annotations, this request however does not work at the moment --- .../base-screen/base-screen.component.html | 8 +++---- .../file-preview-screen.component.ts | 24 ++++++++++++++++++- .../manual-redaction-dialog.component.ts | 8 +++---- .../red-ui/src/app/state/app-state.service.ts | 4 ++++ apps/red-ui/src/assets/i18n/en.json | 8 +++++++ 5 files changed, 43 insertions(+), 9 deletions(-) diff --git a/apps/red-ui/src/app/screens/base-screen/base-screen.component.html b/apps/red-ui/src/app/screens/base-screen/base-screen.component.html index 289c23222..457ccdc1c 100644 --- a/apps/red-ui/src/app/screens/base-screen/base-screen.component.html +++ b/apps/red-ui/src/app/screens/base-screen/base-screen.component.html @@ -9,10 +9,10 @@ translate="top-bar.navigation-items.projects.label"> @@ -23,14 +23,14 @@ + [routerLink]="'/ui/projects/'+appStateService.activeProjectId"> {{appStateService.activeProject.project.projectName}} + [routerLink]="'/ui/projects/'+appStateService.activeProjectId+'/file/'+appStateService.activeFile.fileId"> {{appStateService.activeFile.filename}} diff --git a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts index 464c734c6..2b89a7347 100644 --- a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts @@ -2,12 +2,13 @@ import {ChangeDetectorRef, Component, ElementRef, OnInit, ViewChild} from '@angu import {ActivatedRoute, Router} from '@angular/router'; import { FileUploadControllerService, + ManualRedactionControllerService, ManualRedactionEntry, ProjectControllerService, StatusControllerService } from '@redaction/red-ui-http'; import {TranslateService} from '@ngx-translate/core'; -import {NotificationService} from '../../../notification/notification.service'; +import {NotificationService, NotificationType} from '../../../notification/notification.service'; import {MatDialog} from '@angular/material/dialog'; import {AppStateService} from '../../../state/app-state.service'; import {FileDetailsDialogComponent} from './file-details-dialog/file-details-dialog.component'; @@ -19,6 +20,7 @@ import {ManualRedactionDialogComponent} from "../manual-redaction-dialog/manual- import {UserService} from "../../../user/user.service"; import {debounce} from "../../../utils/debounce"; import scrollIntoView from 'scroll-into-view-if-needed' +import {ConfirmationDialogComponent} from "../../../common/confirmation-dialog/confirmation-dialog.component"; @Component({ selector: 'redaction-file-preview-screen', @@ -58,6 +60,7 @@ export class FilePreviewScreenComponent implements OnInit { private readonly _viewerSyncService: ViewerSyncService, private readonly _dialog: MatDialog, private readonly _router: Router, + private readonly _manualRedactionControllerService: ManualRedactionControllerService, private readonly _userService: UserService, private readonly _fileUploadControllerService: FileUploadControllerService, private readonly _projectControllerService: ProjectControllerService) { @@ -263,5 +266,24 @@ export class FilePreviewScreenComponent implements OnInit { suggestRemoveAnnotation($event: MouseEvent, annotation: Annotations.Annotation) { $event.stopPropagation(); + const dialogRef = this._dialog.open(ConfirmationDialogComponent, { + width: '400px', + maxWidth: '90vw' + }); + + dialogRef.afterClosed().subscribe(result => { + if (result) { + this._manualRedactionControllerService.updateManualRedaction({ + idsToRemove: [{ + id: annotation.Id, + removeFromDictionary: false + }] + }, this.appStateService.activeProjectId, this.appStateService.activeFile.fileId).subscribe(ok=>{ + this._notificationService.showToastNotification(this._translateService.instant('manual-redaction.remove-annotation.success.label'), null, NotificationType.SUCCESS); + },(err)=>{ + this._notificationService.showToastNotification(this._translateService.instant('manual-redaction.remove-annotation.failed.label',err), null, NotificationType.ERROR); + }); + } + }); } } diff --git a/apps/red-ui/src/app/screens/file/manual-redaction-dialog/manual-redaction-dialog.component.ts b/apps/red-ui/src/app/screens/file/manual-redaction-dialog/manual-redaction-dialog.component.ts index 1fb7598b8..05f5e3b12 100644 --- a/apps/red-ui/src/app/screens/file/manual-redaction-dialog/manual-redaction-dialog.component.ts +++ b/apps/red-ui/src/app/screens/file/manual-redaction-dialog/manual-redaction-dialog.component.ts @@ -48,11 +48,11 @@ export class ManualRedactionDialogComponent implements OnInit { saveManualRedaction() { const mre = Object.assign({}, this.manualRedactionInput); this._enhanceManualRedaction(mre); - this._manualRedactionControllerService.updateManualRedaction({entriesToAdd: [mre]}, this._appStateService.activeProject.project.projectId, this._appStateService.activeFile.fileId).subscribe(ok=>{ + this._manualRedactionControllerService.updateManualRedaction({entriesToAdd: [mre]}, this._appStateService.activeProject.project.projectId, this._appStateService.activeFile.fileId).subscribe(ok => { this._notificationService.showToastNotification(this._translateService.instant('manual-redaction.dialog.add-redaction.success.label'), null, NotificationType.SUCCESS); this.dialogRef.close(); - },(err)=>{ - this._notificationService.showToastNotification(this._translateService.instant('manual-redaction.dialog.add-redaction.failed.label',err), null, NotificationType.SUCCESS); + }, (err) => { + this._notificationService.showToastNotification(this._translateService.instant('manual-redaction.dialog.add-redaction.failed.label', err), null, NotificationType.ERROR); }); } @@ -63,7 +63,7 @@ export class ManualRedactionDialogComponent implements OnInit { mre.reason = this.redactionForm.get('reason').value; } - get showDictionary(){ + get showDictionary() { return !this.redactionForm.get('addToDictionary').value } diff --git a/apps/red-ui/src/app/state/app-state.service.ts b/apps/red-ui/src/app/state/app-state.service.ts index bc884c3e9..a7f99e0dd 100644 --- a/apps/red-ui/src/app/state/app-state.service.ts +++ b/apps/red-ui/src/app/state/app-state.service.ts @@ -44,6 +44,10 @@ export class AppStateService { } } + + get activeProjectId(): string { + return this._appState.activeProject?.project?.projectId; + } get activeProject(): ProjectWrapper { return this._appState.activeProject; } diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index 40ae3500b..f60bf4b26 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -1,5 +1,13 @@ { "manual-redaction": { + "remove-annotation": { + "success": { + "label": "Annotation Suggested for removal!" + }, + "failed": { + "label": "Error requesting Annotation removal!" + } + }, "dialog": { "header": { "label": "Add Manual Redaction"