From 7d72064b0d3eb304b85400f2f06fd602d519b780 Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Sat, 24 Feb 2024 20:45:21 -0800 Subject: [PATCH] working IPS export open in new window. --- .../report-header.component.html | 2 +- .../report-header/report-header.component.ts | 4 ++ .../src/app/services/fasten-api.service.ts | 50 +++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/components/report-header/report-header.component.html b/frontend/src/app/components/report-header/report-header.component.html index 58723ec34..148fcd645 100644 --- a/frontend/src/app/components/report-header/report-header.component.html +++ b/frontend/src/app/components/report-header/report-header.component.html @@ -33,7 +33,7 @@
All Sources
diff --git a/frontend/src/app/components/report-header/report-header.component.ts b/frontend/src/app/components/report-header/report-header.component.ts index b77053c0b..86db49a75 100644 --- a/frontend/src/app/components/report-header/report-header.component.ts +++ b/frontend/src/app/components/report-header/report-header.component.ts @@ -41,5 +41,9 @@ export class ReportHeaderComponent implements OnInit { } }) } + getIPSExport(event: Event){ + event.preventDefault() + return this.fastenApi.getIPSExport() + } } diff --git a/frontend/src/app/services/fasten-api.service.ts b/frontend/src/app/services/fasten-api.service.ts index acf5bccbe..8b6d2944e 100644 --- a/frontend/src/app/services/fasten-api.service.ts +++ b/frontend/src/app/services/fasten-api.service.ts @@ -368,4 +368,54 @@ export class FastenApiService { ); } + getIPSExport(exportType?: string) { + // // PDF + // + // // function openPdf($event) { + // // Prevent default behavior when clicking a link + // $event.preventDefault(); + // + // // Get filename from href + // var filename = $event.target.href; + // + // $http.get('/api/secure/summary/ips?format=html', {responseType: 'arraybuffer'}) + // .success(function (data) { + // var file = new Blob([data], {type: 'application/pdf'}); + // var fileURL = URL.createObjectURL(file); + // + // // Open new windows and show PDF + // window.open(fileURL); + // }); + // + // $vent. + // // } + + let httpHeaders = new HttpHeaders(); + //.set('Content-Type' + httpHeaders.set('Accept', 'text/html'); + + + let queryParams = { + "format": exportType || "html" + } + console.log("requesting", `${GetEndpointAbsolutePath(globalThis.location, environment.fasten_api_endpoint_base)}/secure/summary/ips`) + return this._httpClient.get(`${GetEndpointAbsolutePath(globalThis.location, environment.fasten_api_endpoint_base)}/secure/summary/ips`, { + params: queryParams, + headers: httpHeaders, + // observe: 'response', + // @ts-ignore + responseType: 'arraybuffer' + }) + .subscribe((data) => { + + var file = new Blob([data]); + var fileURL = URL.createObjectURL(file); + + // Open new windows and show PDF or HTML file + window.open(fileURL, "_blank"); + + }); + + } + }