diff --git a/apps/red-ui/src/app/dialogs/assign-project-members-dialog/assign-project-members-dialog.component.ts b/apps/red-ui/src/app/dialogs/assign-project-members-dialog/assign-project-members-dialog.component.ts index 479db7b09..73be0b81a 100644 --- a/apps/red-ui/src/app/dialogs/assign-project-members-dialog/assign-project-members-dialog.component.ts +++ b/apps/red-ui/src/app/dialogs/assign-project-members-dialog/assign-project-members-dialog.component.ts @@ -1,7 +1,7 @@ import { Component, Inject } from '@angular/core'; import { Project, ProjectControllerService } from '@redaction/red-ui-http'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { AppStateService, ProjectWrapper } from '../../state/app-state.service'; +import { AppStateService } from '../../state/app-state.service'; import { UserService } from '../../user/user.service'; import { MatSelectionListChange } from '@angular/material/list'; import { NotificationService, NotificationType } from '../../notification/notification.service'; @@ -12,25 +12,24 @@ import { NotificationService, NotificationType } from '../../notification/notifi styleUrls: ['./assign-project-members-dialog.component.scss'] }) export class AssignProjectMembersDialogComponent { - private _project: Project; public memberIds: string[]; constructor(private readonly _projectControllerService: ProjectControllerService, private readonly _notificationService: NotificationService, public readonly userService: UserService, private readonly _appStateService: AppStateService, - public dialogRef: MatDialogRef) { - this._loadProject(); + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public _project: Project) { + this._loadMembers(); } - private _loadProject() { - this._project = this._appStateService.activeProject.project; + private _loadMembers() { this.memberIds = [...this._project.memberIds]; } private _reloadProject() { this._appStateService.addOrUpdateProject(this._project).then(() => { - this._loadProject(); + this._loadMembers(); }); } diff --git a/apps/red-ui/src/app/dialogs/dialog.service.ts b/apps/red-ui/src/app/dialogs/dialog.service.ts index 31e6fa6e7..7d0a56300 100644 --- a/apps/red-ui/src/app/dialogs/dialog.service.ts +++ b/apps/red-ui/src/app/dialogs/dialog.service.ts @@ -1,7 +1,13 @@ import { Injectable } from '@angular/core'; import { FileDetailsDialogComponent } from './file-details-dialog/file-details-dialog.component'; import { MatDialog } from '@angular/material/dialog'; -import { FileStatus, FileUploadControllerService, Project } from '@redaction/red-ui-http'; +import { + FileStatus, + FileUploadControllerService, + ManualRedactionControllerService, + ManualRedactionEntry, + Project +} from '@redaction/red-ui-http'; import { ConfirmationDialogComponent } from '../common/confirmation-dialog/confirmation-dialog.component'; import { NotificationService, NotificationType } from '../notification/notification.service'; import { TranslateService } from '@ngx-translate/core'; @@ -9,10 +15,14 @@ import { AppStateService, ProjectWrapper } from '../state/app-state.service'; import { AddEditProjectDialogComponent } from './add-edit-project-dialog/add-edit-project-dialog.component'; import { AssignOwnerDialogComponent } from './assign-owner-dialog/assign-owner-dialog.component'; import { ProjectDetailsDialogComponent } from './project-details-dialog/project-details-dialog.component'; +import { AssignProjectMembersDialogComponent } from './assign-project-members-dialog/assign-project-members-dialog.component'; +import { ManualRedactionDialogComponent } from './manual-redaction-dialog/manual-redaction-dialog.component'; +import { Annotations } from '@pdftron/webviewer'; const dialogConfig = { width: '600px', - maxWidth: '90vw' + maxWidth: '90vw', + autoFocus: false, }; @Injectable({ @@ -24,7 +34,8 @@ export class DialogService { private readonly _translateService: TranslateService, private readonly _appStateService: AppStateService, private readonly _fileUploadControllerService: FileUploadControllerService, - private readonly _notificationService: NotificationService) { + private readonly _notificationService: NotificationService, + private readonly _manualRedactionControllerService: ManualRedactionControllerService) { } @@ -38,11 +49,7 @@ export class DialogService { public openDeleteFileDialog($event: MouseEvent, projectId: string, fileId: string, cb?: Function) { $event.stopPropagation(); - const dialogRef = this._dialog.open(ConfirmationDialogComponent, { - ...dialogConfig, - autoFocus: false - }); - + const dialogRef = this._dialog.open(ConfirmationDialogComponent, dialogConfig); dialogRef.afterClosed().subscribe(result => { if (result) { const file = this._appStateService.getFileById(projectId, fileId); @@ -59,10 +66,59 @@ export class DialogService { }); } + public openManualRedactionDialog($event: ManualRedactionEntry) { + this._dialog.open(ManualRedactionDialogComponent, { + ...dialogConfig, + autoFocus: true, + data: $event + }); + } + + public acceptSuggestionAnnotation($event: MouseEvent, annotation: Annotations.Annotation, projectId: string, fileId: string) { + $event.stopPropagation(); + const dialogRef = this._dialog.open(ConfirmationDialogComponent, dialogConfig); + + const parts = annotation.Id.split(':'); + const annotationId = parts[parts.length - 1]; + + dialogRef.afterClosed().subscribe(result => { + if (result) { + this._manualRedactionControllerService.approveRequest(projectId, fileId, annotationId).subscribe(() => { + this._notificationService.showToastNotification(this._translateService.instant('manual-redaction.confirm-annotation.success.label'), null, NotificationType.SUCCESS); + }, (err) => { + this._notificationService.showToastNotification(this._translateService.instant('manual-redaction.confirm-annotation.failed.label', err), null, NotificationType.ERROR); + }); + } + }); + } + + public suggestRemoveAnnotation($event: MouseEvent, annotation: Annotations.Annotation, projectId: string, fileId: string) { + $event.stopPropagation(); + const dialogRef = this._dialog.open(ConfirmationDialogComponent, { + width: '400px', + maxWidth: '90vw' + }); + + const parts = annotation.Id.split(':'); + const annotationId = parts[parts.length - 1]; + + dialogRef.afterClosed().subscribe(result => { + if (result) { + this._manualRedactionControllerService.undo(projectId, fileId, annotationId).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); + }); + } + }); + + } + public openEditProjectDialog($event: MouseEvent, project: Project) { $event.stopPropagation(); this._dialog.open(AddEditProjectDialogComponent, { ...dialogConfig, + autoFocus: true, data: project }); } @@ -95,9 +151,19 @@ export class DialogService { } public openAddProjectDialog(cb?: Function): void { - const dialogRef = this._dialog.open(AddEditProjectDialogComponent, dialogConfig); + const dialogRef = this._dialog.open(AddEditProjectDialogComponent, { + ...dialogConfig, + autoFocus: true, + }); dialogRef.afterClosed().subscribe(result => { if (result && cb) cb(); }); } + + public openAssignProjectMembersDialog(project: Project) { + this._dialog.open(AssignProjectMembersDialogComponent, { + ...dialogConfig, + data: project + }); + } } diff --git a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html index d217227b9..3a283814e 100644 --- a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html +++ b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html @@ -20,7 +20,7 @@ - - - - + + +