working IPS export open in new window.

This commit is contained in:
Jason Kulatunga 2024-02-24 20:45:21 -08:00
parent 30149c4aef
commit 2e5b84dbeb
No known key found for this signature in database
3 changed files with 55 additions and 1 deletions

View File

@ -33,7 +33,7 @@
<nav class="nav">
<a class="nav-link" routerLink="/" ngbTooltip="not yet implemented"><i class="far fa-save"></i> Save Report</a>
<a class="nav-link" routerLink="/" ngbTooltip="not yet implemented"><i class="far fa-file-pdf"></i> Export to PDF</a>
<a class="nav-link" (click)="getIPSExport($event)"><i class="far fa-file-pdf"></i> Export to PDF</a>
<a class="nav-link" routerLink="/" ngbTooltip="not yet implemented"><i class="far fa-envelope"></i>Send to Email</a>
<a class="nav-link" routerLink="/" ngbTooltip="not yet implemented"><i class="fas fa-ellipsis-h"></i></a>
</nav>

View File

@ -41,5 +41,9 @@ export class ReportHeaderComponent implements OnInit {
}
})
}
getIPSExport(event: Event){
event.preventDefault()
return this.fastenApi.getIPSExport()
}
}

View File

@ -368,4 +368,54 @@ export class FastenApiService {
);
}
getIPSExport(exportType?: string) {
// // <a href="https://somedomain.com/api/doc/somefile.pdf" ng-click="openPdf($event)">PDF</a>
//
// // 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<any>(`${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");
});
}
}