Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[40163] Trigger downloads after a delay, do not try to download URL

Oliver Günther1af6d84441e0
diff --git a/frontend/src/app/features/job-status/job-status-modal/job-status.modal.ts b/frontend/src/app/features/job-status/job-status-modal/job-status.modal.ts
index bf5db79ffd1..cd96c156bb2 100644
--- a/frontend/src/app/features/job-status/job-status-modal/job-status.modal.ts
+++ b/frontend/src/app/features/job-status/job-status-modal/job-status.modal.ts
@@ -19,7 +19,6 @@ import { PathHelperService } from 'core-app/core/path-helper/path-helper.service
import { JobStatusEnum, JobStatusInterface } from 'core-app/features/job-status/job-status.interface';
import { ToastService } from 'core-app/shared/components/toaster/toast.service';
import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
-import { EXTERNAL_REQUEST_HEADER } from 'core-app/features/hal/http/openproject-header-interceptor';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
@Component({
@@ -181,34 +180,14 @@ export class JobStatusModalComponent extends OpModalComponent implements OnInit
}
}
- private handleDownload(redirectionUrl?:string) {
- if (redirectionUrl !== undefined) {
- // Get the file url from the redirectionUrl
- this.httpClient
- .get(redirectionUrl, {
- observe: 'response',
- responseType: 'text',
- // This might or might not be an external request (depending on the configuration of an S3 storage)
- // But not having headers like X-CSRF-TOKEN set works in both cases.
- headers: {
- [EXTERNAL_REQUEST_HEADER]: 'true',
- },
- })
- .subscribe((response) => {
- this.downloadHref = response.url;
-
- this.cdRef.detectChanges();
- this.downloadLink.nativeElement.click();
- }, (error:HttpErrorResponse) => {
- // In this case, most typically, there is a CORS error.
- // Instead of failing completely, we show a manual link for the user to click themselves.
- if (error.status === 0) {
- this.downloadHref = redirectionUrl;
-
- this.cdRef.detectChanges();
- }
- });
+ private handleDownload(downloadUrl?:string) {
+ if (!downloadUrl) {
+ return;
}
+
+ this.downloadHref = downloadUrl;
+ this.cdRef.detectChanges();
+ setTimeout(() => this.downloadLink.nativeElement.click(), 50);
}
private performRequest():Observable<HttpResponse<JobStatusInterface>> {