+ liste$: Observable<{ id: string }[]>
isOpen = false
ngOnInit(): void {
@@ -45,35 +41,4 @@ export class GpfApiDlListItemComponent implements OnInit {
.get(`${this.link['id']}?limit=50`)
.pipe(map((response) => response['entry']))
}
-
- async downloadMultipleFiles() {
- this.liste$.pipe(take(1)).subscribe(async (fileUrls: { id: string }[]) => {
- if (!fileUrls || fileUrls.length === 0) {
- console.warn('Aucun fichier à télécharger.')
- return
- }
-
- for (const fileUrl of fileUrls) {
- if (fileUrl?.id) {
- await this.downloadFile(fileUrl.id)
- } else {
- console.warn('Fichier invalide :', fileUrl)
- }
- }
- })
- }
-
- private downloadFile(url: string): Promise {
- return new Promise((resolve) => {
- setTimeout(() => {
- const link = document.createElement('a')
- link.href = url
- link.setAttribute('download', '')
- document.body.appendChild(link)
- link.click()
- document.body.removeChild(link)
- resolve()
- }, 1000) // Attendre 1s entre chaque téléchargement
- })
- }
}