notes panel auto toggle

This commit is contained in:
Timo Bejan 2020-09-22 11:55:01 +03:00
parent b7850bc496
commit 98a689de2e
2 changed files with 9 additions and 7 deletions

View File

@ -8,7 +8,7 @@
</mat-button-toggle-group>
</div>
</div>
<redaction-pdf-viewer [fileId]="fileId" [fileType]="group.value"></redaction-pdf-viewer>
<redaction-pdf-viewer [fileId]="fileId" [fileType]="group.value" [fileStatus]="appStateService.activeFile"></redaction-pdf-viewer>
<button (click)="showDetailsDialog($event)" aria-label="details" class="details-button" color="primary" mat-fab>
<mat-icon svgIcon="red:info"></mat-icon>

View File

@ -4,8 +4,8 @@ import {AppConfigService} from "../../../app-config/app-config.service";
import {FileStatus, FileUploadControllerService} from "@redaction/red-ui-http";
import {Observable, of} from "rxjs";
import {tap} from "rxjs/operators";
import WebViewer, {WebViewerInstance} from "@pdftron/webviewer";
declare const WebViewer: any;
export enum FileType {
ORIGINAL = 'ORIGINAL',
@ -25,7 +25,7 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
@Input() fileStatus: FileStatus;
@ViewChild('viewer', {static: true}) viewer: ElementRef;
wvInstance: any;
wvInstance: WebViewerInstance;
_annotatedFileData: Blob;
_originalFileData: Blob;
@ -42,8 +42,10 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
}
wvDocumentLoadedHandler(): void {
const docViewer = this.wvInstance;
const annotManager = this.wvInstance.annotManager;
this.wvInstance.setFitMode('FitWidth');
if(this.fileType === FileType.ANNOTATED){
this.wvInstance.toggleElement('notesPanel')
}
}
ngAfterViewInit(): void {
@ -55,7 +57,7 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
ngOnChanges(changes: SimpleChanges): void {
if (this.wvInstance) {
this._loadFile().subscribe(data => {
this.wvInstance.loadDocument(data, {filename: 'myfile.pdf'});
this.wvInstance.loadDocument(data, {filename: this.fileStatus.filename});
});
}
}
@ -66,7 +68,7 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
}, this.viewer.nativeElement).then(instance => {
this.wvInstance = instance;
instance.docViewer.on('documentLoaded', this.wvDocumentLoadedHandler)
instance.loadDocument(pdfBlob, {filename: 'myfile.pdf'});
instance.loadDocument(pdfBlob, {filename: this.fileStatus.filename});
})
}