Skip to content

Commit

Permalink
feat: add qe wise description pages under needs attention tech-by-des…
Browse files Browse the repository at this point in the history
  • Loading branch information
megin1989 committed Aug 16, 2024
1 parent 22f191c commit a425eaf
Show file tree
Hide file tree
Showing 8 changed files with 808 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ public String adminDiagnostics() {
@GetMapping("/data-quality/needs-attention")
@RouteMapping(label = "Needs Attention", title = "Needs Attention", siblingOrder = 5)
public String diagnosticsFhirNeedsAttention(final Model model, final HttpServletRequest request) {
return presentation.populateModel("page/diagnostics/needs-attention", model, request);
String templateName = "page/diagnostics/needs-attention";
if (null != request.getParameter("qeName")) {
model.addAttribute("qeName", request.getParameter("qeName"));
templateName = "page/diagnostics/techbd-to-scoring-engine";
}
return presentation.populateModel(templateName, model, request);
}

@GetMapping("/data-quality/sftp")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package org.techbd.service.http.hub.prime.ux;

import java.util.Arrays;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.techbd.orchestrate.sftp.SftpManager;
import org.techbd.service.http.SandboxHelpers;
import org.techbd.service.http.hub.prime.route.RouteMapping;
import org.techbd.udi.UdiPrimeJpaConfig;

import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;



@Controller
@Tag(name = "Need Attention of Tenant")
public class NeedAttentionController {
@SuppressWarnings("unused")
private static final Logger LOG = LoggerFactory.getLogger(DataQualityController.class.getName());

private final Presentation presentation;

public NeedAttentionController(final Presentation presentation,
@SuppressWarnings("PMD.UnusedFormalParameter") final UdiPrimeJpaConfig udiPrimeJpaConfig,
@SuppressWarnings("PMD.UnusedFormalParameter") final SftpManager sftpManager,
@SuppressWarnings("PMD.UnusedFormalParameter") final SandboxHelpers sboxHelpers) {
this.presentation = presentation;
}

public List<String> getValuesForField(String field) {
List<String> values = Arrays.asList(field);
return values;
}

@GetMapping("/needs-attention")
@RouteMapping(label = "Needs Attention", title = "Needs Attention", siblingOrder = 100)
public String diagnosticsFhirNeedsAttention() {
return "redirect:/data-quality/needs-attention";
}

@GetMapping("/needs-attention/scn-to-qe")
@RouteMapping(label = "CrossRoads SCN to QE", title = "Needs Attention", siblingOrder = 5)
public String diagnosticsFhirNeedsAttentionScnToQe(final Model model, final HttpServletRequest request) {

model.addAttribute("qeName", request.getParameter("qeName"));
String templateName = "page/diagnostics/scn-to-qe";
return presentation.populateModel(templateName, model, request);

}

@GetMapping("/needs-attention/qe-to-techbd")
@RouteMapping(label = "QE to TechBD", title = "Needs Attention", siblingOrder = 6)
public String diagnosticsFhirNeedsAttentionQeToTechbd(final Model model, final HttpServletRequest request) {

model.addAttribute("qeName", request.getParameter("qeName"));
String templateName = "page/diagnostics/qe-to-techbd";
return presentation.populateModel(templateName, model, request);

}


@GetMapping("/needs-attention/techbd-to-scoring-engine")
@RouteMapping(label = "TechBD to Scoring Engine", title = "Needs Attention", siblingOrder = 7)
public String diagnosticsFhirNeedsAttentionTechbdToScoringEngine(final Model model, final HttpServletRequest request) {

model.addAttribute("qeName", request.getParameter("qeName"));
String templateName = "page/diagnostics/techbd-to-scoring-engine";
return presentation.populateModel(templateName, model, request);

}
}
130 changes: 130 additions & 0 deletions hub-prime/src/main/resources/templates/js/aggrid-aide.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,136 @@ export class AGGridAideBuilder {
};
return this;
}
withServerSideDatasourceGET(dataSourceUrl, withSecondaryColumns = null, inspect = {}) {
this.gridOptions.serverSideDatasource = {
getRows: async (params) => {
let dataAvailable = false; // Flag to track data availability

const {
includeGeneratedSqlInResp = true,
includeGeneratedSqlInErrorResp = true,

secondaryColsError = async (dataSourceUrl, serverRespPayload, error, respMetrics) => console.error("[ServerDatasource] Error in updateSecondaryColumns:", { dataSourceUrl, result: serverRespPayload, error, respMetrics }),
resultServerError = async (dataSourceUrl, serverRespPayload, respMetrics) => console.warn("[ServerDatasource] Error in server result:", { dataSourceUrl, result: serverRespPayload, respMetrics }),
fetchRespNotOK = async (dataSourceUrl, response, respMetrics) => console.error(`[ServerDatasource] Fetched response not OK: ${response.statusText}`, { dataSourceUrl, response, respMetrics }),
fetchError = async (dataSourceUrl, error) => console.error(`[ServerDatasource] Fetch error: ${error}`, { dataSourceUrl, error }),

beforeRequest = async (dataSourceUrl) => { },
beforeSuccess = async (serverRespPayload, respMetrics, dataSourceUrl) => {
console.log('Full Server Response:', serverRespPayload); // Log the full response

// Check if serverRespPayload is an array
if (!Array.isArray(serverRespPayload)) {
console.error('Error: serverRespPayload is not an array.');
params.fail();
return;
}

const data = serverRespPayload; // Assuming the response is an array of data

console.log('Extracted data:', data); // Log the extracted data

if (data.length === 0) {
console.warn('Warning: Data array is empty.');
}

// Automatically generate column definitions based on the keys in the first object
const valueCols = data.length > 0 ? Object.keys(data[0]).map(key => ({
headerName: key.replace(/_/g, ' ').toUpperCase(), // Convert key to uppercase for header name
field: key
})) : [];

console.log('Generated valueCols:', valueCols);

// Validate that valueCols is now correctly generated
if (valueCols.length === 0) {
// console.error('Error: Failed to generate valueCols from data.');
// params.fail();
// return;
}
},

customizedContent = async (success, serverRespPayload, respMetrics, dataSourceUrl) => success,
} = inspect;

try {
await beforeRequest?.(dataSourceUrl);

// Construct the full GET URL with query parameters from params.request
const queryString = new URLSearchParams(params.request).toString();
const fullUrl = `${dataSourceUrl}?${queryString}`;

const response = await fetch(fullUrl, {
method: 'GET',
headers: {
'X-Include-Generated-SQL-In-Response': includeGeneratedSqlInResp,
'X-Include-Generated-SQL-In-Error-Response': includeGeneratedSqlInErrorResp,
}
});

const respMetrics = response.headers ? {
startTime: response.headers.get("X-Observability-Metric-Interaction-Start-Time"),
finishTime: response.headers.get("X-Observability-Metric-Interaction-Finish-Time"),
durationMillisecs: response.headers.get("X-Observability-Metric-Interaction-Duration-Nanosecs"),
durationNanosecs: response.headers.get("X-Observability-Metric-Interaction-Duration-Millisecs"),
} : {};

if (respMetrics && window.layout?.observability?.metricsCollection) {
window.layout.addIdentifiableMetrics(`fetch-${dataSourceUrl}`, respMetrics);
}

if (response.ok) {
const serverRespPayload = await response.json();

// Call beforeSuccess to log and check the response structure
await beforeSuccess?.(serverRespPayload, respMetrics, dataSourceUrl);

// Since we already extracted data and generated columns in beforeSuccess, reuse them
const data = Array.isArray(serverRespPayload) ? serverRespPayload : [];
const valueCols = data.length > 0 ? Object.keys(data[0]).map(key => ({
headerName: key.replace(/_/g, ' ').toUpperCase(),
field: key
})) : [];

// Check if data is available
if (data.length > 0) {
dataAvailable = true; // Data found
}

// Check for UX reportable errors
if (serverRespPayload.uxReportableError) {
await resultServerError?.(dataSourceUrl, serverRespPayload, respMetrics);
}

// Call success or fail based on data availability
if (dataAvailable) {
params.success({
rowData: data,
columnDefs: valueCols
});
} else {

params.success({ rowData: [] });
params.api.showNoRowsOverlay();
// Save the flag in gridOptions so it can be accessed in the gridReady event
this.gridOptions.dataAvailable = dataAvailable;
}
} else {
await fetchRespNotOK?.(dataSourceUrl, response, respMetrics);
params.fail();
}
} catch (error) {
await fetchError?.(dataSourceUrl, error);
params.fail();
}
}
};
return this;
}





/**
* Sets the ModalAide instance to be used for rendering modal popups.
Expand Down
20 changes: 20 additions & 0 deletions hub-prime/src/main/resources/templates/js/shell-aide.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ export class LayoutAide {

this.#shellAide = shellAide;
this.#layoutOptions = layoutOptions;
this.hideNeedsAttentionLink();
}

get shellAide() { return this.#shellAide; }
Expand All @@ -421,6 +422,25 @@ export class LayoutAide {
get windowPropertyName() { return this.#windowPropertyName; }
get breadcrumbs() { return this.#breadcrumbs; }

/**
* Hides the "Needs Attention" link on the page by setting its display property to 'none'.
*
* This function adds an event listener to the 'DOMContentLoaded' event, which waits for the
* page to finish loading before executing the code inside the event listener. It then selects
* the first 'a' element with a 'href' attribute value of '/needs-attention' and sets its
* display property to 'none' if it exists.
*
* @return {void} This function does not return anything.
*/
hideNeedsAttentionLink() {
document.addEventListener("DOMContentLoaded", () => {
const link = document.querySelector('a[href="/needs-attention"]');
if (link) {
link.style.display = 'none';
}
});
}

debugLog(...data) {
if (this.layoutOptions.logLevel == "debug") {
console.log(...data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@

function qeNameCellRenderer(params) {
const qeName = params.data.qe_name;
const link = `/data-quality/needs-attention?qeName=${qeName}`;
//return `<a href="${link}">${qeName}</a>`;
return `${qeName}`;
const link = `/needs-attention/techbd-to-scoring-engine?qeName=${qeName}`;
return `<a href="${link}">${qeName}</a>`;
// return `${qeName}`;
}


Expand All @@ -123,6 +123,7 @@
headerName: "Interaction Id",
field: "hub_interaction_id",
filter: "agTextColumnFilter",
headerTooltip: "Unique Id For Identify The Record",
cellRenderer: params => {
const hub_interaction_id = params.value;
const error_type = params.data.error_type;
Expand Down
Loading

0 comments on commit a425eaf

Please sign in to comment.