Skip to content

Commit

Permalink
Merge pull request #1117 from megin1989/main
Browse files Browse the repository at this point in the history
fix: resolve CSV file download functionality errors  on the CSV via HTTPS Data Quality page #975
  • Loading branch information
ratheesh-kr authored Feb 3, 2025
2 parents 33dc81d + 7633915 commit 9524e23
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 14 deletions.
Binary file modified hub-prime/lib/techbd-udi-jooq-ingress.auto.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion hub-prime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</parent>
<groupId>org.techbd</groupId>
<artifactId>hub-prime</artifactId>
<version>0.449.0</version>
<version>0.450.0</version>
<packaging>war</packaging>
<name>Tech by Design Hub (Prime)</name>
<description>Tech by Design Hub (Primary)</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ public String httpscsv(final Model model, final HttpServletRequest request) {
return presentation.populateModel("page/interactions/httpscsv", model, request);
}

// @GetMapping("/interactions/httpsccda")
// @RouteMapping(label = "CCDA via HTTPs", title = "CCDA via HTTPs", siblingOrder = 50)
// public String httpsccda(final Model model, final HttpServletRequest request) {
// return presentation.populateModel("page/interactions/httpsccda", model, request);
// }
@GetMapping("/interactions/httpsccda")
@RouteMapping(label = "CCDA via HTTPs", title = "CCDA via HTTPs", siblingOrder = 50)
public String httpsccda(final Model model, final HttpServletRequest request) {
return presentation.populateModel("page/interactions/httpsccda", model, request);
}

@Operation(summary = "Recent SFTP Interactions")
@GetMapping("/support/interaction/sftp/recent.json")
Expand Down
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>
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
const url = URL.createObjectURL(zipBlob);
const link = document.createElement('a');
link.href = url;
link.download = csvZipFileName + '.zip';
link.download = csvZipFileName ;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
Expand All @@ -131,13 +131,14 @@

// Create the URL for the API call
const apiUrl = `/api/ux/tabular/jooq/${schemaName}/${downloadviewName}/zip_file_hub_interaction_id/${zip_file_hub_interaction_id}.json`;

if (params.data.file_count === 0) {
return '<button class=" text-gray-500 cursor-not-allowed px-2 py-1 " disabled><i class="fas fa-download"></i></button>';
}
// Create a download link placeholder
const downloadLink = `<a href="#" onclick="window.downloadZipFile('${apiUrl}','${csv_zip_file_name}'); return false;" style="text-decoration: none; color: #007bff;">
<i class="fas fa-download"></i>
</a>`;

return downloadLink;
return `<a href="#" onclick="window.downloadZipFile('${apiUrl}','${csv_zip_file_name}'); return false;" style="text-decoration: none; color: #007bff;">
<i class="fas fa-download"></i>
</a>`;

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4259,7 +4259,8 @@ AS SELECT
created_at,
created_by,
provenance
FROM techbd_udi_ingress.sat_interaction_ccda_request sicr;
FROM techbd_udi_ingress.sat_interaction_ccda_request sicr
order by created_at DESC;


/*******************************************************************************************
Expand Down

0 comments on commit 9524e23

Please sign in to comment.