-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1117 from megin1989/main
fix: resolve CSV file download functionality errors on the CSV via HTTPS Data Quality page #975
- Loading branch information
Showing
6 changed files
with
146 additions
and
14 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
hub-prime/src/main/resources/templates/page/interactions/httpsccda.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" | ||
layout:decorate="~{layout/prime}"> | ||
|
||
<head> | ||
<link rel="stylesheet" href="https://unpkg.com/ag-grid-community/styles/ag-grid.css"> | ||
<link rel="stylesheet" href="https://unpkg.com/ag-grid-community/styles/ag-theme-alpine.css"> | ||
|
||
<script src="https://unpkg.com/ag-grid-enterprise/dist/ag-grid-enterprise.js"></script> | ||
<!-- Include Font Awesome in your HTML --> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css"> | ||
<style> | ||
.grid-description { | ||
font-size: 14px; | ||
margin: 8px 0px 10px 15px; | ||
} | ||
</style> | ||
<script type="module"> | ||
import { AGGridAide, AGGridAideBuilder } from '@presentation/shell/aggrid-aide.js'; | ||
import ModalAide from '@presentation/shell/modal-aide.js'; | ||
|
||
const schemaName = 'techbd_udi_ingress'; | ||
const viewName = 'interaction_ccda_request'; | ||
const viewdetail = 'interaction_csv_http_fhir_request'; | ||
const pipupviewName = 'interaction_http_fhir_request'; | ||
const modalAide = new ModalAide(); | ||
|
||
|
||
// Define downloadPayload globally | ||
window.downloadPayload = async function (ccda_payload_text, tenant_id, nature) { | ||
|
||
// Decode the encoded CCDA payload text | ||
const decodedPayload = decodeURIComponent(ccda_payload_text); | ||
|
||
// Create a Blob from the CCDA payload text | ||
const blob = new Blob([decodedPayload], { type: "application/xml" }); | ||
|
||
// Get current date and time | ||
const now = new Date(); | ||
const timestamp = now.toISOString().replace(/[-:T]/g, '').split('.')[0]; // Format: YYYYMMDDHHMMSS | ||
|
||
// Create a URL for the Blob | ||
const url = URL.createObjectURL(blob); | ||
|
||
// Create a temporary link to trigger the download | ||
const tempLink = document.createElement('a'); | ||
tempLink.href = url; | ||
tempLink.download = `${tenant_id}_${nature}_${timestamp}.xml`; | ||
document.body.appendChild(tempLink); | ||
tempLink.click(); | ||
|
||
// Clean up | ||
document.body.removeChild(tempLink); | ||
URL.revokeObjectURL(url); | ||
|
||
|
||
}; | ||
|
||
|
||
document.addEventListener('DOMContentLoaded', function () { | ||
|
||
function downloadCellRenderer(params) { | ||
const ccda_payload_text = params.data.ccda_payload_text; | ||
const tenant_id = params.data.tenant_id; | ||
const nature = params.data.nature; | ||
|
||
// Create a download link placeholder | ||
const downloadLink = `<a href="#" onclick="window.downloadPayload( \`${encodeURIComponent(ccda_payload_text)}\`,'${tenant_id}','${nature}'); return false;" style="text-decoration: none; color: #007bff;"> | ||
<i class="fas fa-download"></i> | ||
</a>`; | ||
|
||
return downloadLink; | ||
} | ||
const agGridInstance = new AGGridAideBuilder() | ||
.withColumnDefs([ | ||
{ | ||
headerName: "Request Time", | ||
field: "created_at", | ||
filter: "agDateColumnFilter", | ||
headerTooltip: "The timestamp indicating when the interaction was initiated." | ||
}, | ||
{ | ||
headerName: "TechBD CCDA Interaction ID", | ||
field: "hub_interaction_id", | ||
filter: "agTextColumnFilter", | ||
headerTooltip: "The unique Interaction ID for the ccda request" | ||
}, | ||
{ headerName: "TechBD Tenant ID", field: "tenant_id", headerTooltip: "ID of the tenant involved in the interaction", filter: "agTextColumnFilter" }, | ||
{ headerName: "URI", field: "uri", headerTooltip: "The URI associated with the interaction", filter: "agTextColumnFilter" }, | ||
{ headerName: "Nature", field: "nature", headerTooltip: "The nature of the interaction", filter: "agTextColumnFilter" }, | ||
{ headerName: "Origin", field: "origin", headerTooltip: "The origin of the interaction", filter: "agTextColumnFilter" }, | ||
{ headerName: "User Agent", field: "user_agent", headerTooltip: "The user agent used in the interaction", filter: "agTextColumnFilter" }, | ||
{ headerName: "IP Address", field: "client_ip_address", headerTooltip: "The IP address of the client making the interaction", filter: "agTextColumnFilter" }, | ||
{ | ||
headerName: "Download Payload", field: "user_agent", cellClass: "flex justify-center items-center", cellRenderer: downloadCellRenderer, | ||
headerTooltip: "Download Payload", filter: false, suppressFilter: true | ||
} | ||
|
||
]) | ||
.withServerSideDatasource( | ||
window.shell.serverSideUrl(`/api/ux/tabular/jooq/${schemaName}/${viewName}.json`), | ||
(data, valueCols) => { | ||
return valueCols.map(col => ({ | ||
headerName: col.displayName, | ||
field: col.field | ||
})); | ||
}, | ||
) | ||
.withModalAide(modalAide) | ||
.withGridDivStyles({ height: "750px", width: "100%" }) | ||
.build(); | ||
|
||
agGridInstance.init('serverDataGrid'); | ||
}); | ||
</script> | ||
</head> | ||
|
||
<body> | ||
<div layout:fragment="content"> | ||
<div class="grid-description"> | ||
This widget offers a clear and concise overview of CCDA-based HTTP interactions, highlighting essential details such as the Hub Interaction ID and Tenant ID to identify and link each interaction. | ||
It provides information about the Request URI, the Nature of the interaction, and metadata like Client IP Address and User Agent to trace the origin and context of requests. | ||
Users can track State Transitions, including changes from one state to another and the reasons for those transitions. The widget also includes detailed Payload Information, such as the CCDA payload text, to provide visibility into the data being processed. | ||
Additionally, users have the option to **download the CCDA payload** as an XML file for further analysis. With interactive filtering and sorting options, users can efficiently analyze interactions, identify issues, and ensure seamless data flow for CCDA requests. | ||
</div> | ||
<div id="serverDataGrid" class="ag-theme-alpine"></div> | ||
</div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters