import {Component, Input, OnInit} from '@angular/core'; import {AllService} from '../../../../all.service'; import {saveAs} from 'file-saver/dist/FileSaver'; @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 filename = filePath.replace(/^.*[\\/]/, ''); saveAs(blob, filename); }, () => { alert('Une erreur est survenue durant le téléchargement'); }); } }