redacted viewer sync
This commit is contained in:
parent
6a15e5e041
commit
8dd044793f
@ -30,13 +30,13 @@
|
||||
<div class="left-container">
|
||||
<redaction-pdf-viewer
|
||||
[canPerformActions]="canPerformAnnotationActions"
|
||||
[fileData]="displayData"
|
||||
[fileStatus]="appStateService.activeFile"
|
||||
(annotationSelected)="handleAnnotationSelected($event)"
|
||||
(keyUp)="handleKeyEvent($event)"
|
||||
(manualAnnotationRequested)="openManualRedactionDialog($event)"
|
||||
(pageChanged)="viewerPageChanged($event)"
|
||||
(viewerReady)="viewerReady($event)"
|
||||
[fileData]="redactedView ? fileData?.redactedFileData : fileData?.annotatedFileData"
|
||||
[fileStatus]="appStateService.activeFile"
|
||||
></redaction-pdf-viewer>
|
||||
</div>
|
||||
|
||||
|
||||
@ -110,6 +110,7 @@ export class FilePreviewScreenComponent implements OnInit {
|
||||
this.loadingMessage = null;
|
||||
this.canPerformAnnotationActions = this.permissionsService.canPerformAnnotationActions(this.fileData.fileStatus);
|
||||
this._cleanupAndRedrawManualAnnotations();
|
||||
this._fileDownloadService.loadRedactedView(this.fileData);
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -357,6 +358,9 @@ export class FilePreviewScreenComponent implements OnInit {
|
||||
this.instance = $event;
|
||||
this.viewReady = true;
|
||||
this._cleanupAndRedrawManualAnnotations();
|
||||
if (!this.fileData.redactedFileData) {
|
||||
this._fileDownloadService.loadRedactedView(this.fileData);
|
||||
}
|
||||
}
|
||||
|
||||
filtersChanged(filters: FilterModel[]) {
|
||||
@ -371,9 +375,6 @@ export class FilePreviewScreenComponent implements OnInit {
|
||||
}
|
||||
|
||||
private _cleanupAndRedrawManualAnnotations(annotationIdToDraw?: string) {
|
||||
if (!annotationIdToDraw) {
|
||||
this._fileDownloadService.loadRedactedView(this.fileData);
|
||||
}
|
||||
this._fileDownloadService.loadActiveFileManualAnnotations().subscribe((manualRedactions) => {
|
||||
this.fileData.manualRedactions = manualRedactions;
|
||||
this._rebuildFilters();
|
||||
@ -414,4 +415,8 @@ export class FilePreviewScreenComponent implements OnInit {
|
||||
isCategoryFilter(filter: FilterModel) {
|
||||
return filter.filters && filter.filters.length > 0;
|
||||
}
|
||||
|
||||
get displayData() {
|
||||
return this.fileData ? (this.redactedView ? this.fileData.redactedFileData : this.fileData.annotatedFileData) : null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,17 +53,13 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this._restoreViewerState = this._restoreViewerState.bind(this);
|
||||
this._documentLoaded = this._documentLoaded.bind(this);
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (this.instance) {
|
||||
if (changes.fileData) {
|
||||
if (!this._viewerState) {
|
||||
this._loadDocument();
|
||||
} else {
|
||||
this._changeDocument();
|
||||
}
|
||||
this._loadDocument();
|
||||
}
|
||||
if (changes.canPerformActions) {
|
||||
this._handleCustomActions();
|
||||
@ -101,7 +97,7 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
|
||||
this._ngZone.run(() => this.pageChanged.emit(p));
|
||||
});
|
||||
|
||||
instance.docViewer.on('documentLoaded', this._restoreViewerState);
|
||||
instance.docViewer.on('documentLoaded', this._documentLoaded);
|
||||
|
||||
instance.docViewer.on('keyDown', ($event) => {
|
||||
if ($event.key.startsWith('Arrow')) {
|
||||
@ -115,6 +111,9 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
|
||||
}
|
||||
});
|
||||
|
||||
// initialize state
|
||||
this._restoreState(null, instance);
|
||||
|
||||
this._loadDocument();
|
||||
});
|
||||
}
|
||||
@ -237,16 +236,19 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
|
||||
|
||||
private _loadDocument() {
|
||||
if (this.fileData) {
|
||||
console.log('load');
|
||||
this._viewerState = this._getCurrentViewerState();
|
||||
this.instance.loadDocument(this.fileData, {
|
||||
filename: this.fileStatus ? this.fileStatus.filename : 'document.pdf'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private _changeDocument() {
|
||||
// sync layout and display mode
|
||||
private _documentLoaded() {
|
||||
this.viewerReady.emit(this.instance);
|
||||
this._restoreState(this._viewerState, this.instance);
|
||||
}
|
||||
|
||||
private _getCurrentViewerState() {
|
||||
const instance = this.instance;
|
||||
const docViewer = this.instance.docViewer;
|
||||
|
||||
@ -261,16 +263,7 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
|
||||
zoom: docViewer.getZoom(),
|
||||
leftPanelState: instance.isElementOpen('leftPanel')
|
||||
};
|
||||
|
||||
this._loadDocument();
|
||||
|
||||
this._viewerState = viewerState;
|
||||
}
|
||||
|
||||
private _restoreViewerState() {
|
||||
console.log('emit viewer ready');
|
||||
this.viewerReady.emit(this.instance);
|
||||
this._restoreState(this._viewerState, this.instance);
|
||||
return viewerState;
|
||||
}
|
||||
|
||||
private _restoreState(viewerState: ViewerState, instance: WebViewerInstance) {
|
||||
@ -294,6 +287,7 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
|
||||
} else {
|
||||
instance.closeElements(['leftPanel']);
|
||||
}
|
||||
this._viewerState = viewerState;
|
||||
} else {
|
||||
// viewer init
|
||||
this.instance.setFitMode('FitPage');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user