From c05981713ed184e28da5990b9d397472db16db31 Mon Sep 17 00:00:00 2001 From: Joris Bertomeu Date: Tue, 26 Aug 2025 20:20:36 +0200 Subject: [PATCH] Fix dl issue --- src/app/app.component.ts | 29 +++++++++++------------------ src/app/video-processing.service.ts | 4 ++++ src/environments/environment.ts | 4 ++-- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 03d98a8..1525d81 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -172,24 +172,17 @@ export class AppComponent implements OnInit { } downloadFileFromAPI(filePath: string, filename: string, job: any) { - job.isDownloading = true; - this.videoProcessingService.downloadFile(`${job.data.mp4Filename}/${filename}`).subscribe({ - next: (response) => { - const blob = new Blob([response], { type: 'video/mkv' }); - const url = window.URL.createObjectURL(blob); - const a = document.createElement('a'); - a.href = url; - a.download = filename; - a.click(); - window.URL.revokeObjectURL(url); - job.isDownloading = false; - }, - error: (error) => { - console.error('Error downloading file:', error); - job.isDownloading = false; - } - }); - } + job.isDownloading = true; + + // Redirection directe vers l'URL de téléchargement + const encodedPath = encodeURIComponent(`${job.data.mp4Filename}/${filename}`); + window.open(this.videoProcessingService.getDownloadUrl(`${job.data.mp4Filename}/${filename}`), '_blank'); + + // Simuler un délai pour l'UX, puis remettre le flag à false + setTimeout(() => { + job.isDownloading = false; + }, 2000); +} processUpdate(item: any, binType: string) { item.isUpdating = true; diff --git a/src/app/video-processing.service.ts b/src/app/video-processing.service.ts index 9b6f389..ea3341c 100644 --- a/src/app/video-processing.service.ts +++ b/src/app/video-processing.service.ts @@ -35,6 +35,10 @@ export class VideoProcessingService { return this.http.get(`${this.apiUrl}/download?filename=${encodeURIComponent(filename)}`, { responseType: 'blob' }); } + getDownloadUrl(filename: string): string { + return `${this.apiUrl}/download?filename=${encodeURIComponent(filename)}`; + } + flushQueue(): Observable { return this.http.delete(`${this.apiUrl}/jobs/completed`, {}); } diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 3a08a88..3368886 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -1,4 +1,4 @@ export const environment = { - serviceEndpoint: '/api' - //serviceEndpoint: 'http://192.168.1.230:6080/api' + //serviceEndpoint: '/api' + serviceEndpoint: 'http://192.168.1.230:6080/api' };