From b962f08301bb731da2c8b294ad903761e4d84834 Mon Sep 17 00:00:00 2001 From: Timo Bejan Date: Wed, 11 Nov 2020 11:12:57 +0200 Subject: [PATCH] lint fix --- .../file-preview-screen.component.ts | 5 ++--- .../app/screens/file/model/file-data.model.ts | 3 ++- .../file/service/annotation-draw.service.ts | 22 ++++++++++++++----- .../file/service/file-download.service.ts | 10 ++++++--- 4 files changed, 28 insertions(+), 12 deletions(-) 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 95f2edb40..8538a7fce 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 @@ -21,7 +21,6 @@ import { tap } from 'rxjs/operators'; import { NotificationService } from '../../../notification/notification.service'; import { TranslateService } from '@ngx-translate/core'; import { FileStatusWrapper } from '../model/file-status.wrapper'; -import { MatTooltip } from '@angular/material/tooltip'; import { PermissionsService } from '../../../common/service/permissions.service'; const KEY_ARRAY = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown']; @@ -97,7 +96,7 @@ export class FilePreviewScreenComponent implements OnInit { } get canNotSwitchToRedactedView() { - return this.permissionsService.fileRequiresReanalysis(); + return this.permissionsService.fileRequiresReanalysis() || !this.fileData?.redactedFileData; } ngOnInit(): void { @@ -367,7 +366,7 @@ export class FilePreviewScreenComponent implements OnInit { } } - private _cleanupAndRedrawManualAnnotations(singleAnnotation: AnnotationWrapper) { + private _cleanupAndRedrawManualAnnotations(singleAnnotation?: AnnotationWrapper) { this._fileDownloadService.loadActiveFileManualAnnotations().subscribe((manualRedactions) => { this.fileData.manualRedactions = manualRedactions; this._rebuildFilters(); diff --git a/apps/red-ui/src/app/screens/file/model/file-data.model.ts b/apps/red-ui/src/app/screens/file/model/file-data.model.ts index 61981343d..c2faadc88 100644 --- a/apps/red-ui/src/app/screens/file/model/file-data.model.ts +++ b/apps/red-ui/src/app/screens/file/model/file-data.model.ts @@ -11,10 +11,11 @@ export interface AnnotationPair { } export class FileDataModel { + redactedFileData: Blob; + constructor( public fileStatus: FileStatusWrapper, public annotatedFileData: Blob, - public redactedFileData: Blob, public redactionLog: RedactionLog, public manualRedactions: ManualRedactions, public viewedPages?: ViewedPages diff --git a/apps/red-ui/src/app/screens/file/service/annotation-draw.service.ts b/apps/red-ui/src/app/screens/file/service/annotation-draw.service.ts index a590745e9..05402c42a 100644 --- a/apps/red-ui/src/app/screens/file/service/annotation-draw.service.ts +++ b/apps/red-ui/src/app/screens/file/service/annotation-draw.service.ts @@ -32,11 +32,23 @@ export class AnnotationDrawService { } private _getColor(activeViewer: WebViewerInstance, annotationWrapper: AnnotationWrapper) { - const color = - annotationWrapper.superType === 'suggestion' || annotationWrapper.superType === 'suggestion-remove' - ? this._appStateService.getDictionaryColor(annotationWrapper.superType) - : this._appStateService.getDictionaryColor(annotationWrapper.dictionary); - + let color; + switch (annotationWrapper.superType) { + case 'suggestion': + case 'suggestion-remove': + color = annotationWrapper.modifyDictionary ? '#5B97DB' : this._appStateService.getDictionaryColor(annotationWrapper.superType); + break; + case 'hint': + case 'redaction': + color = this._appStateService.getDictionaryColor(annotationWrapper.dictionary); + break; + case 'ignore': + color = this._appStateService.getDictionaryColor('ignore'); + break; + default: + color = this._appStateService.getDictionaryColor('default'); + break; + } const rgbColor = hexToRgb(color); return new activeViewer.Annotations.Color(rgbColor.r, rgbColor.g, rgbColor.b); } diff --git a/apps/red-ui/src/app/screens/file/service/file-download.service.ts b/apps/red-ui/src/app/screens/file/service/file-download.service.ts index 5687c3872..a337213d2 100644 --- a/apps/red-ui/src/app/screens/file/service/file-download.service.ts +++ b/apps/red-ui/src/app/screens/file/service/file-download.service.ts @@ -31,7 +31,6 @@ export class FileDownloadService { public loadActiveFileData(): Observable { const annotatedObs = this.loadFile('ORIGINAL', this._appStateService.activeFileId); - const redactedObs = this.loadFile('REDACTED', this._appStateService.activeFileId); const reactionLogObs = this._redactionLogControllerService.getRedactionLog(this._appStateService.activeFileId); const manualRedactionsObs = this._manualRedactionControllerService.getManualRedaction( this._appStateService.activeProjectId, @@ -39,8 +38,13 @@ export class FileDownloadService { ); const viewedPagesObs = this.getViewedPagesForActiveFile(); - return forkJoin([annotatedObs, redactedObs, reactionLogObs, manualRedactionsObs, viewedPagesObs]).pipe( - map((data) => new FileDataModel(this._appStateService.activeFile, ...data)) + return forkJoin([annotatedObs, reactionLogObs, manualRedactionsObs, viewedPagesObs]).pipe( + map((data) => { + const fileData = new FileDataModel(this._appStateService.activeFile, ...data); + // lazy load redacted data + this.loadFile('REDACTED', this._appStateService.activeFileId).subscribe((redactedFileData) => (fileData.redactedFileData = redactedFileData)); + return fileData; + }) ); }