viewer refresh

This commit is contained in:
Timo Bejan 2021-08-16 14:38:15 +03:00
parent b2c6f8e87a
commit ec0cb17672
3 changed files with 21 additions and 7 deletions

View File

@ -32,6 +32,7 @@ import { PdfViewerUtils } from '../../utils/pdf-viewer.utils';
import { ViewMode } from '@models/file/view-mode';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import TextTool = Tools.TextTool;
import { ActivatedRoute } from '@angular/router';
@Component({
selector: 'redaction-pdf-viewer',
@ -57,6 +58,7 @@ export class PdfViewerComponent implements OnInit, OnChanges {
instance: WebViewerInstance;
utils: PdfViewerUtils;
private _selectedText = '';
private _firstPageChange = true;
private readonly _allowedKeyboardShortcuts = ['+', '-', 'p', 'r', 'Escape'];
constructor(
@ -65,6 +67,7 @@ export class PdfViewerComponent implements OnInit, OnChanges {
private readonly _manualAnnotationService: ManualAnnotationService,
private readonly _dialogService: DossiersDialogService,
private readonly _ngZone: NgZone,
private readonly _activatedRoute: ActivatedRoute,
private readonly _userPreferenceService: UserPreferenceService,
private readonly _annotationDrawService: AnnotationDrawService,
private readonly _annotationActionsService: AnnotationActionsService,
@ -236,7 +239,15 @@ export class PdfViewerComponent implements OnInit, OnChanges {
if (this.shouldDeselectAnnotationsOnPageChange) {
this.utils.deselectAllAnnotations();
}
this._ngZone.run(() => this.pageChanged.emit(pageNumber));
if (this._firstPageChange && pageNumber === 1) {
this._firstPageChange = false;
const routePageNumber = this._activatedRoute.snapshot.queryParams.page;
if (pageNumber) {
this.utils.navigateToPage(parseInt(routePageNumber, 10));
}
} else {
this._ngZone.run(() => this.pageChanged.emit(pageNumber));
}
});
this.instance.docViewer.on('documentLoaded', this._documentLoaded);
@ -565,6 +576,7 @@ export class PdfViewerComponent implements OnInit, OnChanges {
private _documentLoaded(): void {
this._ngZone.run(() => {
this.utils.ready = true;
this._firstPageChange = true;
this.viewerReady.emit(this.instance);
this.setInitialViewerState();
});

View File

@ -245,7 +245,6 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
this.displayPDFViewer = true;
this._updateCanPerformActions();
this._subscribeToFileUpdates();
this._loadingService.stop();
}
rebuildFilters(deletePreviousAnnotations: boolean = false) {
@ -398,14 +397,17 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
await this._stampExcludedPages();
this._cleanupAndRedrawManualAnnotations();
this._updateCanPerformActions();
this._loadingService.stop();
// Go to initial page from query params
const pageNumber = this._lastPage || this._activatedRoute.snapshot.queryParams.page;
if (pageNumber) {
setTimeout(() => {
this.selectPage(parseInt(pageNumber, 10));
this._scrollViews();
}, 600);
this._loadingService.stop();
});
} else {
this._loadingService.stop();
}
}
@ -423,14 +425,14 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
case 'enable-analysis':
case 'reanalyse':
await this._loadFileData();
await this._loadFileData(true);
this._updateCanPerformActions();
await this.appStateService.reloadActiveDossierFiles();
return;
case 'exclude-pages':
await this.appStateService.reloadActiveDossierFiles();
await this._loadFileData();
await this._loadFileData(true);
this._loadingService.stop();
return;

@ -1 +1 @@
Subproject commit 0bb0e4454f3015d1c81ccd23415c8135c89eeeff
Subproject commit 1d46b21c74c07d6811a99b9de6c940c740bc8ceb