1
|
import { UtilsService } from './../../../../../shared/utils/utils.service';
|
2
|
import { InvoiceProcessesService } from './../../../../../shared/services/invoice-processes.service';
|
3
|
import {Component, OnInit} from '@angular/core';
|
4
|
import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
|
5
|
import { ReceivedFiles } from 'src/app/shared/models/receivedFiles.interface';
|
6
|
|
7
|
@Component({
|
8
|
selector: 'app-file-viewer-popup',
|
9
|
templateUrl: './file-viewer-popup.component.html',
|
10
|
styleUrls: ['./file-viewer-popup.component.scss']
|
11
|
})
|
12
|
export class FileViewerPopupComponent implements OnInit {
|
13
|
|
14
|
document: ReceivedFiles;
|
15
|
url : string;
|
16
|
viewer: any;
|
17
|
|
18
|
constructor(public ref: DynamicDialogRef,
|
19
|
public config: DynamicDialogConfig,
|
20
|
public invoiceProcessesService: InvoiceProcessesService,
|
21
|
public utils: UtilsService
|
22
|
) {
|
23
|
this.config.header = 'Preview Document';
|
24
|
this.config.height = 'auto';
|
25
|
this.config.width = '50vw';
|
26
|
}
|
27
|
|
28
|
ngOnInit(): void {
|
29
|
console.log(this.config.data);
|
30
|
this.document = this.config.data as ReceivedFiles;
|
31
|
console.log(this.document);
|
32
|
if (this.document?.dmsFileType) {
|
33
|
this.viewer = 'google';
|
34
|
this.url = this.document.rtaFolderPath + this.document.dmsFileName;
|
35
|
// this.url = 'http://www.africau.edu/images/default/sample.pdf';
|
36
|
}
|
37
|
}
|
38
|
|
39
|
downloadFile(): void {
|
40
|
this.invoiceProcessesService.downloadFile(this.document.id).subscribe((base64) => {
|
41
|
const blob = this.utils.base64ToFile(base64, this.document.dmsFileType);
|
42
|
const url = window.URL.createObjectURL(blob);
|
43
|
window.open(url);
|
44
|
});
|
45
|
}
|
46
|
}
|