Skip to content

Commit

Permalink
working IPS export open in new window.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnalogJ committed Mar 2, 2024
1 parent a62efbe commit 7d72064
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h6>All Sources</h6>

<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,9 @@ export class ReportHeaderComponent implements OnInit {
}
})
}
getIPSExport(event: Event){
event.preventDefault()
return this.fastenApi.getIPSExport()
}

}
50 changes: 50 additions & 0 deletions frontend/src/app/services/fasten-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");

});

}

}

0 comments on commit 7d72064

Please sign in to comment.