move constants
This commit is contained in:
parent
9c5bf9082e
commit
ee6f8dab02
@ -7,9 +7,9 @@ import { tap } from 'rxjs/operators';
|
|||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class TextHighlightService extends GenericService<unknown> {
|
export class TextHighlightService extends GenericService<TextHighlightResponse> {
|
||||||
constructor(protected readonly _injector: Injector, private readonly _toaster: Toaster) {
|
constructor(protected readonly _injector: Injector, private readonly _toaster: Toaster) {
|
||||||
super(_injector, '');
|
super(_injector, 'texthighlights-conversion');
|
||||||
}
|
}
|
||||||
|
|
||||||
@Validate()
|
@Validate()
|
||||||
@ -20,7 +20,7 @@ export class TextHighlightService extends GenericService<unknown> {
|
|||||||
operation: TextHighlightOperation.INFO,
|
operation: TextHighlightOperation.INFO,
|
||||||
};
|
};
|
||||||
|
|
||||||
return this._post<TextHighlightResponse>(request, 'texthighlights-conversion');
|
return this._post(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Validate()
|
@Validate()
|
||||||
@ -31,10 +31,6 @@ export class TextHighlightService extends GenericService<unknown> {
|
|||||||
@RequiredParam() operation: TextHighlightOperation,
|
@RequiredParam() operation: TextHighlightOperation,
|
||||||
) {
|
) {
|
||||||
const request: TextHighlightRequest = { dossierId, fileId, colors, operation };
|
const request: TextHighlightRequest = { dossierId, fileId, colors, operation };
|
||||||
return this._post<TextHighlightResponse>(request, 'texthighlights-conversion').pipe(
|
return this._post(request).pipe(tap(() => this._toaster.success(_('highlight-action-dialog.success'), { params: { operation } })));
|
||||||
tap(() => {
|
|
||||||
this._toaster.success(_('highlight-action-dialog.success'), { params: { operation } });
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,11 +49,10 @@ import { ComponentCanDeactivate } from '../../guards/can-deactivate.guard';
|
|||||||
import { PdfViewer } from './services/pdf-viewer.service';
|
import { PdfViewer } from './services/pdf-viewer.service';
|
||||||
import { FilePreviewDialogService } from './services/file-preview-dialog.service';
|
import { FilePreviewDialogService } from './services/file-preview-dialog.service';
|
||||||
import { FileDataService } from './services/file-data.service';
|
import { FileDataService } from './services/file-data.service';
|
||||||
|
import { ALL_HOTKEYS } from './shared/constants';
|
||||||
import Annotation = Core.Annotations.Annotation;
|
import Annotation = Core.Annotations.Annotation;
|
||||||
import PDFNet = Core.PDFNet;
|
import PDFNet = Core.PDFNet;
|
||||||
|
|
||||||
const ALL_HOTKEY_ARRAY = ['Escape', 'F', 'f', 'ArrowUp', 'ArrowDown'];
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: './file-preview-screen.component.html',
|
templateUrl: './file-preview-screen.component.html',
|
||||||
styleUrls: ['./file-preview-screen.component.scss'],
|
styleUrls: ['./file-preview-screen.component.scss'],
|
||||||
@ -155,12 +154,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const textHighlightAnnotationIds = this._fileDataService.textHighlightAnnotations.map(a => a.id);
|
this._pdf.deleteAnnotations(this._fileDataService.textHighlightAnnotations.map(a => a.id));
|
||||||
const textHighlightAnnotations = this._pdf.getAnnotations((a: Core.Annotations.Annotation) =>
|
|
||||||
textHighlightAnnotationIds.includes(a.Id),
|
|
||||||
);
|
|
||||||
|
|
||||||
this._pdf.deleteAnnotations(textHighlightAnnotations);
|
|
||||||
|
|
||||||
const ocrAnnotationIds = this.allAnnotations.filter(a => a.isOCR).map(a => a.id);
|
const ocrAnnotationIds = this.allAnnotations.filter(a => a.isOCR).map(a => a.id);
|
||||||
const annotations = this._pdf.getAnnotations(a => a.getCustomData('redact-manager'));
|
const annotations = this._pdf.getAnnotations(a => a.getCustomData('redact-manager'));
|
||||||
@ -317,8 +311,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
|||||||
const response = new ManualAnnotationResponse(entryWrapper, addAnnotationResponse);
|
const response = new ManualAnnotationResponse(entryWrapper, addAnnotationResponse);
|
||||||
|
|
||||||
if (response?.annotationId) {
|
if (response?.annotationId) {
|
||||||
const annotation = this._pdf.annotationManager.getAnnotationById(response.manualRedactionEntryWrapper.rectId);
|
this._pdf.deleteAnnotations([response.manualRedactionEntryWrapper.rectId]);
|
||||||
this._pdf.deleteAnnotations([annotation]);
|
|
||||||
const distinctPages = manualRedactionEntryWrapper.manualRedactionEntry.positions
|
const distinctPages = manualRedactionEntryWrapper.manualRedactionEntry.positions
|
||||||
.map(p => p.page)
|
.map(p => p.page)
|
||||||
.filter((item, pos, self) => self.indexOf(item) === pos);
|
.filter((item, pos, self) => self.indexOf(item) === pos);
|
||||||
@ -355,7 +348,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ALL_HOTKEY_ARRAY.includes($event.key) || this.dialogRef?.getState() === MatDialogState.OPEN) {
|
if (!ALL_HOTKEYS.includes($event.key) || this.dialogRef?.getState() === MatDialogState.OPEN) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -599,7 +592,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
|||||||
console.log('skip reloading annotations');
|
console.log('skip reloading annotations');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._deleteAnnotations();
|
this._pdf.deleteAnnotations();
|
||||||
await this._cleanupAndRedrawAnnotations();
|
await this._cleanupAndRedrawAnnotations();
|
||||||
await this.updateViewMode();
|
await this.updateViewMode();
|
||||||
}
|
}
|
||||||
@ -615,23 +608,10 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
|||||||
const currentPageAnnotations = this.visibleAnnotations.filter(a => a.pageNumber === page);
|
const currentPageAnnotations = this.visibleAnnotations.filter(a => a.pageNumber === page);
|
||||||
await this._fileDataService.loadRedactionLog();
|
await this._fileDataService.loadRedactionLog();
|
||||||
|
|
||||||
this._deleteAnnotations(currentPageAnnotations);
|
this._pdf.deleteAnnotations(currentPageAnnotations.map(a => a.id));
|
||||||
await this._cleanupAndRedrawAnnotations(annotation => annotation.pageNumber === page);
|
await this._cleanupAndRedrawAnnotations(annotation => annotation.pageNumber === page);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _deleteAnnotations(annotationsToDelete?: AnnotationWrapper[]) {
|
|
||||||
if (!this._pdf.ready) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!annotationsToDelete) {
|
|
||||||
this._pdf.deleteAnnotations();
|
|
||||||
}
|
|
||||||
annotationsToDelete?.forEach(annotation => {
|
|
||||||
this._findAndDeleteAnnotation(annotation.id);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private async _cleanupAndRedrawAnnotations(newAnnotationsFilter?: (annotation: AnnotationWrapper) => boolean) {
|
private async _cleanupAndRedrawAnnotations(newAnnotationsFilter?: (annotation: AnnotationWrapper) => boolean) {
|
||||||
if (!this._pdf.ready) {
|
if (!this._pdf.ready) {
|
||||||
return;
|
return;
|
||||||
@ -671,13 +651,6 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _findAndDeleteAnnotation(id: string) {
|
|
||||||
const viewerAnnotation = this._pdf.annotationManager.getAnnotationById(id);
|
|
||||||
if (viewerAnnotation) {
|
|
||||||
this._pdf.deleteAnnotations([viewerAnnotation]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private _openFullScreen() {
|
private _openFullScreen() {
|
||||||
const documentElement = document.documentElement;
|
const documentElement = document.documentElement;
|
||||||
if (documentElement.requestFullscreen) {
|
if (documentElement.requestFullscreen) {
|
||||||
|
|||||||
@ -6,43 +6,11 @@ import { File } from '@red/domain';
|
|||||||
import { Inject, Injectable } from '@angular/core';
|
import { Inject, Injectable } from '@angular/core';
|
||||||
import { BASE_HREF } from '../../../tokens';
|
import { BASE_HREF } from '../../../tokens';
|
||||||
import { environment } from '@environments/environment';
|
import { environment } from '@environments/environment';
|
||||||
|
import { DISABLED_HOTKEYS } from '../shared/constants';
|
||||||
import Annotation = Core.Annotations.Annotation;
|
import Annotation = Core.Annotations.Annotation;
|
||||||
import DocumentViewer = Core.DocumentViewer;
|
import DocumentViewer = Core.DocumentViewer;
|
||||||
import AnnotationManager = Core.AnnotationManager;
|
import AnnotationManager = Core.AnnotationManager;
|
||||||
|
|
||||||
const DISABLED_HOTKEYS = [
|
|
||||||
'CTRL+SHIFT+EQUAL',
|
|
||||||
'COMMAND+SHIFT+EQUAL',
|
|
||||||
'CTRL+SHIFT+MINUS',
|
|
||||||
'COMMAND+SHIFT+MINUS',
|
|
||||||
'CTRL+V',
|
|
||||||
'COMMAND+V',
|
|
||||||
'CTRL+Y',
|
|
||||||
'COMMAND+Y',
|
|
||||||
'CTRL+O',
|
|
||||||
'COMMAND+O',
|
|
||||||
'CTRL+P',
|
|
||||||
'COMMAND+P',
|
|
||||||
'SPACE',
|
|
||||||
'UP',
|
|
||||||
'DOWN',
|
|
||||||
'R',
|
|
||||||
'P',
|
|
||||||
'A',
|
|
||||||
'C',
|
|
||||||
'E',
|
|
||||||
'I',
|
|
||||||
'L',
|
|
||||||
'N',
|
|
||||||
'O',
|
|
||||||
'T',
|
|
||||||
'S',
|
|
||||||
'G',
|
|
||||||
'H',
|
|
||||||
'K',
|
|
||||||
'U',
|
|
||||||
] as const;
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class PdfViewer {
|
export class PdfViewer {
|
||||||
ready = false;
|
ready = false;
|
||||||
@ -187,11 +155,18 @@ export class PdfViewer {
|
|||||||
this.annotationManager.selectAnnotations(annotationsFromViewer);
|
this.annotationManager.selectAnnotations(annotationsFromViewer);
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteAnnotations(annotations: Annotation[] = this.getAnnotations()) {
|
deleteAnnotations(annotationsIds?: readonly string[]) {
|
||||||
if (!this.ready) {
|
if (!this.ready) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let annotations: Annotation[];
|
||||||
|
if (!annotationsIds) {
|
||||||
|
annotations = this.getAnnotations();
|
||||||
|
} else {
|
||||||
|
annotations = this.getAnnotationsById(annotationsIds);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.annotationManager.deleteAnnotations(annotations, {
|
this.annotationManager.deleteAnnotations(annotations, {
|
||||||
imported: true,
|
imported: true,
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
export const ALLOWED_KEYBOARD_SHORTCUTS: readonly string[] = ['+', '-', 'p', 'r', 'Escape'] as const;
|
export const ALLOWED_KEYBOARD_SHORTCUTS: readonly string[] = ['+', '-', 'p', 'r', 'Escape'] as const;
|
||||||
|
|
||||||
|
export const ALL_HOTKEYS = ['Escape', 'F', 'f', 'ArrowUp', 'ArrowDown'];
|
||||||
|
|
||||||
export const HeaderElements = {
|
export const HeaderElements = {
|
||||||
SHAPE_TOOL_GROUP_BUTTON: 'shapeToolGroupButton',
|
SHAPE_TOOL_GROUP_BUTTON: 'shapeToolGroupButton',
|
||||||
ROTATE_LEFT_BUTTON: 'rotateLeftButton',
|
ROTATE_LEFT_BUTTON: 'rotateLeftButton',
|
||||||
@ -17,3 +20,36 @@ export const TextPopups = {
|
|||||||
ADD_RECTANGLE: 'add-rectangle',
|
ADD_RECTANGLE: 'add-rectangle',
|
||||||
ADD_FALSE_POSITIVE: 'add-false-positive',
|
ADD_FALSE_POSITIVE: 'add-false-positive',
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const DISABLED_HOTKEYS = [
|
||||||
|
'CTRL+SHIFT+EQUAL',
|
||||||
|
'COMMAND+SHIFT+EQUAL',
|
||||||
|
'CTRL+SHIFT+MINUS',
|
||||||
|
'COMMAND+SHIFT+MINUS',
|
||||||
|
'CTRL+V',
|
||||||
|
'COMMAND+V',
|
||||||
|
'CTRL+Y',
|
||||||
|
'COMMAND+Y',
|
||||||
|
'CTRL+O',
|
||||||
|
'COMMAND+O',
|
||||||
|
'CTRL+P',
|
||||||
|
'COMMAND+P',
|
||||||
|
'SPACE',
|
||||||
|
'UP',
|
||||||
|
'DOWN',
|
||||||
|
'R',
|
||||||
|
'P',
|
||||||
|
'A',
|
||||||
|
'C',
|
||||||
|
'E',
|
||||||
|
'I',
|
||||||
|
'L',
|
||||||
|
'N',
|
||||||
|
'O',
|
||||||
|
'T',
|
||||||
|
'S',
|
||||||
|
'G',
|
||||||
|
'H',
|
||||||
|
'K',
|
||||||
|
'U',
|
||||||
|
] as const;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user