import {Component, Input, OnInit} from '@angular/core'; import {AllService} from '../../../../all.service'; @Component({ selector: 'jhi-documents', templateUrl: './documents.component.html', styleUrls: ['./documents.component.css'] }) export class DocumentsComponent implements OnInit { @Input() documents: Array = []; constructor(private allService: AllService) { } ngOnInit(): void {} showFile(filePath): void { const pathEncoded = encodeURIComponent(filePath); this.allService.fileStorageManagerService.downloadDocumentByPath(pathEncoded).subscribe( blob => { const file = new Blob([blob], {type: 'application/pdf'}); const fileURL = URL.createObjectURL(file); window.open(fileURL); }, () => { alert('Une erreur est survenue durant le téléchargement'); }); } }