Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- </head>
- <body>
- <div id="gridDiv" style="height:800px;width:100%;" class="ag-theme-balham"></div>
- <script src="/static/js/ag-grid-enterprise.min.js"></script>
- <script>
- // License function -> used in production.
- var license_key = "";
- async function license() {
- license_key = await ReportApp.utils.getAgGridLicense();
- agGrid.LicenseManager.setLicenseKey(license_key);
- return license_key;
- }
- // license();
- // Need to handle child samples data
- function samplesChildTable(sample_key, sample_value, row,wf, tech) {
- if (Object.getOwnPropertyNames(row).length === 0){
- row['Relation'] = 'N/A'
- row["STR Result"] = 'N/A'
- row["QC"] = 'N/A'
- row["Interpretation"] = 'N/A'
- row["NGS Result"] = 'N/A'
- row["Sample #"] = 'N/A'
- row['Parent ID'] = 'N/A'
- row["Sample ID"] = sample_value[0]["sample_name"]
- }
- if (wf === "Data Analysis"){
- for (var i = 0; i < sample_value.length; i++) {
- if (sample_value[i]["tag_name"] !== null ) {
- if (sample_value[i]["tag_name"].includes('chr_result') && sample_value[i]["value"] !== null){
- let raw = sample_value[i]["value"].split(':');
- if (raw.length === 1){
- row['NGS Result'] = 'Euploid'
- }
- else {
- row['NGS Result'] = raw[1]
- }
- }
- if (sample_value[i]["tag_name"].includes('illumina_qc_result' && sample_value[i]["value"] !== null)) {
- row["QC"] = sample_value[i]["value"];
- }
- if (sample_value[i]["tag_name"].includes('chr_interpretation') || sample_value[i]["tag_name"].includes('res_interpretation') && sample_value[i]["value"] !== null) {
- row["Interpretation"] = sample_value[i]["value"];
- }
- if (sample_value[i]["tag_name"].includes('embryo_number') && sample_value[i]["value"] !== null){
- row["Sample #"] = sample_value[i]["value"]
- }
- }
- if (sample_value[i]['resource_var_name']==='Parent ID' && sample_value[i]["value"] !== null){
- row["Parent ID"] = sample_value[i]["value"]
- }
- }
- }
- if (wf === "Identifiler"){
- for (var i = 0; i < sample_value.length; i++) {
- if (sample_value[i]["tag_name"] !== null ) {
- if (sample_value[i]["tag_name"].includes('dna_relation')){
- row["Relation"] = sample_value[i]["value"];
- }
- if (sample_value[i]["tag_name"].includes('str_result')) {
- row["STR Result"] = sample_value[i]["value"];
- }
- }
- }
- }
- if (wf === 'Collect and Extract Buccal Swab'){
- for (var i = 0; i < sample_value.length; i++) {
- if (sample_value[i]["tag_name"] !== null ) {
- if (sample_value[i]["tag_name"].includes('dna_relation')){
- row["Relation"] = sample_value[i]["value"];
- }
- }
- if (sample_value[i]['resource_var_name']==='Parent ID'){
- row["Parent ID"] = sample_value[i]["value"]
- }
- }
- }
- if (wf === "Veriseq NGS"){
- for (var i = 0; i < sample_value.length; i++) {
- if (sample_value[i]["tag_name"] !== null ) {
- if (sample_value[i]["tag_name"].includes('embryo_number')){
- row["Sample #"] = sample_value[i]["value"]
- }
- }
- if (sample_value[i]['resource_var_name']==='Sample Number'){
- row["Sample #"] = sample_value[i]["value"]
- }
- if (sample_value[i]['resource_var_name']==='Parent ID'){
- row["Parent ID"] = sample_value[i]["value"]
- }
- }
- }
- if (wf === "Extract DNA"){
- for (var i = 0; i < sample_value.length; i++) {
- if (sample_value[i]['resource_var_name']==='Sample Number'){
- row["Sample #"] = sample_value[i]["value"]
- }
- if (sample_value[i]['resource_var_name']==='Parent ID'){
- row["Parent ID"] = sample_value[i]["value"]
- }
- }
- }
- const child_sample_row = row;
- return child_sample_row;
- }
- async function hexPayload(payload) {
- //function from MDN docs for getting hex of hash of text
- const msgUint8 = new TextEncoder().encode(payload); // encode as (utf-8) Uint8Array
- const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8); // hash the message
- const hashArray = Array.from(new Uint8Array(hashBuffer)); // convert buffer to byte array
- const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); // convert bytes to hex string
- return hashHex;
- }
- function groupDuplicates(propertyName, data) {
- var grouped = {};
- data.map(function(item) {
- var itemPropertyName = item[propertyName];
- if (itemPropertyName in grouped) {
- grouped[itemPropertyName].push(item)
- }
- else {
- grouped[itemPropertyName] = [];
- grouped[itemPropertyName].push(item)
- }
- });
- return grouped
- }
- try {
- ReportApp.utils.registerRefreshCallback(run);
- ReportApp.utils.registerPrintCallback(print);
- } catch(e) {
- console.error(e);
- }
- run();
- function run() {
- ReportApp.utils.getApiQueryResults("patient_summary", { name: "POC Chain"}, onSuccess, function onError (error) {
- console.error(error)
- });
- }
- function print() {
- ReportApp.utils.print('printDiv');
- }
- function onSuccess(data) {
- const key = "L7_Informatics_Enterprise_Science_Platform_3Devs_5OEM_8_August_2019__MTU2NTIxODgwMDAwMA==02c676ec74743c60bbd1471e0c9fed9f";
- agGrid.LicenseManager.setLicenseKey(key);
- let rowData = [];
- let dateParams = {
- // provide comparator function
- comparator: function (filterLocalDateAtMidnight, cellValue) {
- var dateAsString = cellValue;
- if (dateAsString == null) return 0;
- // In the example application, dates are stored as dd/mm/yyyy
- // We create a Date object for comparison against the filter date
- var dateParts = dateAsString.split("/");
- var day = Number(dateParts[2]);
- var month = Number(dateParts[1]) - 1;
- var year = Number(dateParts[0]);
- var cellDate = new Date(day, month, year);
- // Now that both parameters are Date objects, we can compare
- if (cellDate < filterLocalDateAtMidnight) {
- return -1;
- } else if (cellDate > filterLocalDateAtMidnight) {
- return 1;
- } else {
- return 0;
- }
- }
- }
- // Gradalis defined columns they would like to see.
- let columnDefs = [
- {headerName: 'pat_id', field: 'pat_id', hide: true},
- {headerName: "Patient ID", field: "Patient ID", filter: 'agTextColumnFilter', cellRenderer: 'agGroupCellRenderer', pinned: 'left'},
- {headerName: "Patient Last Name", field: "Last Name", filter: 'agTextColumnFilter'},
- {headerName: "Patient First Name", field: "First Name", filter: 'agTextColumnFilter'},
- {headerName: "Chart Number", field: "Chart Number", filter: 'agTextColumnFilter'},
- {headerName: "Patient DOB", field: "DOB", filter: 'agDateColumnFilter', filterParams: dateParams},
- {headerName: "Patient Gender", field: "Patient Gender"},
- {headerName: "Partner Last Name", field: "Partner Last Name", filter: 'agTextColumnFilter'},
- {headerName: "Partner First Name", field: "Partner First Name", filter: 'agTextColumnFilter'},
- {headerName: "Partner DOB", field: "Partner DOB", filter: 'agDateColumnFilter', filterParams: dateParams},
- {headerName: "Partner Gender", field: "Partner Gender"},
- {headerName: "Partner Chart Number", field: "Partner Chart Number", filter: 'agTextColumnFilter'},
- {headerName: "Partner Comments", field: "Partner Comments", editable: true},
- {headerName: "Date Received", field: "Date Received", filter: 'agDateColumnFilter', filterParams: dateParams},
- {headerName: "GA by Date", field: "GA by Dates", filter: 'agDateColumnFilter', filterParams: dateParams},
- {headerName: "GA by Size", field: "GA by Size"},
- {headerName: "Method of Conception", field: "Method of Conception"},
- {headerName: "Comments & Special Requests", field: "Comments & Special Requests", editable: true},
- {headerName: "# Controls", field: "# Controls", editable: true, type: "numericColumn"},
- {headerName: "# of Tested Samples", field: "# of Tested Samples", editable: true},
- {headerName: "Referring Physician", field: "MD"},
- {headerName: "Technician", field: 'Technician',editable: true},
- {headerName: "Analysed by", field: "Analysed by", editable: true},
- {headerName: "Approved by", field: 'Approved by', editable: true},
- {headerName: "Workflow Chain", field: "Workflow Chain"},
- {headerName: "Generate Report", field: "Generate Report", cellRenderer: reportCellRendererFunc, pinned: 'right'},
- {
- headerName: "Download",
- field: "Download",
- cellRenderer: function(params) {
- if (params.value && params.value.url) {
- return '<a href="' + params.value.url + '" target="_blank">' + params.value.name + '</a>'
- }
- /* if (){
- }*/
- //var storage = localStorage.getItem(params.node.id)
- //if (storage !== null){
- // let link = JSON.parse(storage)
- // return '<a href="' + link.url + '" target="_blank">' + link.name + '</a>'
- //}
- return ' '
- }
- },
- ];
- // let the grid know which columns and what data to use
- var gridOptions = {
- columnDefs: columnDefs,
- enableFilter: true,
- masterDetail: true,
- filter: true,
- enableCellChangeFlash: true,
- getRowNodeId: function(data) { return data['pat_id']; },
- detailCellRendererParams: {
- detailGridOptions: {
- enableFilter: true,
- filter: true,
- columnDefs: [
- {headerName: "Sample #", field: "Sample #"},
- {headerName: "Sample ID", field: "Sample ID"},
- {headerName: "STR Result", field: 'STR Result'},
- {headerName: "NGS Result", field: "NGS Result"},
- {headerName: "Relation", field: 'Relation'},
- {headerName: "QC", field: "QC"},
- {headerName: "Interpretation", field: "Interpretation", editable: true},
- {headerName: "Include in Report", field: 'Include in Report', pinned: 'right',
- cellRenderer: function(params) {
- var input = document.createElement('input');
- input.type="checkbox";
- input.addEventListener('click', function (event) {
- params.value= !params.value;
- params.node.data.fieldName = params.value;
- gridOptions.api.refreshCells()
- });
- return input;
- }},
- ],
- onFirstDataRendered(params) {
- params.api.sizeColumnsToFit();
- }
- },
- getDetailRowData: function (params) {
- params.successCallback(params.data.Samples);
- },
- },
- onFirstDataRendered(params) {
- params.api.sizeColumnsToFit();
- }
- };
- // lookup the container we want the Grid to use
- var gridDiv = document.querySelector('#gridDiv');
- // create the grid passing in the div to use together with the columns & data we want to use
- new agGrid.Grid(gridDiv, gridOptions);
- // Get Grouped Experiments
- const getGroupedChainExperiments = groupDuplicates('chain_uuid', data.results);
- var dna_dict = {}
- for (const [chain_key, chain_value] of Object.entries(getGroupedChainExperiments)) {
- // Initialize the row as an object
- var row = {};
- // Child Table data to be held.
- row["Samples"] = [];
- row["Patient ID"] = chain_value[0]['sample_name'];
- let row_storage = new Object()
- row["Workflow Chain"] = "POC Chain"
- let pat_uuid = chain_value[0]['sample_uuid']
- const getsGroupedExperiments = groupDuplicates('workflow_definition_name', chain_value);
- let patient_headers = ["Last Name", "First Name", "Chart Number", "DOB",
- "Partner Last Name", "Partner First Name", "Partner DOB", "MD", "Patient Gender", "Partner Gender", "Partner Chart Number", "Partner Comments", "Date Received", "GA by Dates", "GA by Size", "Method of Conception", "Comments & Special Requests"]
- for (const [workflow_key, workflow_value] of Object.entries(getsGroupedExperiments)) {
- if (workflow_key.includes("Receive POC Request")) {
- let getGroupedProtocols = groupDuplicates('protocol_name', workflow_value);
- for (const [protocol_key, protocol_value] of Object.entries(getGroupedProtocols)) {
- // Initialize the row as an object
- if (protocol_key === "Receive POC Request") {
- Object.values(protocol_value).find((item) => {
- if (patient_headers.includes(item.resource_var_name)) {
- if (item.value !== null) {
- row[item.resource_var_name] = item.value
- }
- }
- })
- }
- }
- }
- row["# Controls"] = "N/A";
- let patient = row['Patient ID'];
- let pcn = row['Partner Chart Number'];
- let pln = row['Partner Last Name'];
- let pfn = row['Partner First Name'];
- let ln_fn = pln + ' ' + pfn;
- $.ajax({
- method: "GET",
- url: '/api/samples/' + pat_uuid,
- async: true,
- success: function(data){
- let meta = data[0].meta
- if (meta.reports.POC.ln_fn){
- row['Download'] ='<a href="' + meta.reports.POC.ln_fn.url[length(meta.reports.POC.ln_fn.url.length-1)] + '" target="_blank">' + 'Download Report' + '</a>'
- }
- },
- error: function (error) {
- console.error(error);
- //ReportApp.utils.showNotification(error, 'error')
- }
- })
- row['pat_id'] = pat_uuid.concat(' ', pcn, ' ',ln_fn, ' POC');
- if (workflow_key.includes("Create Fetus")){
- let getGroupedProtocols = groupDuplicates('protocol_name', workflow_value);
- let fetus_dict = getGroupedProtocols['Create Sub-samples']
- let ss_dict = {}
- let getGroupedSS = groupDuplicates('sample_uuid', fetus_dict)
- for (const [sample_key, sample_values] of Object.entries(getGroupedSS)){
- Object.values(sample_values).find((item) => {
- if (sample_key in ss_dict){
- if (item.resource_var_name === "Relation"){
- ss_dict[sample_key]['Relation'] = item.value
- }
- if (item.resource_var_name === "Fetus ID"){
- ss_dict[sample_key]['Fetus ID'] = item.value
- }
- }
- else {
- if (item.resource_var_name === "Relation"){
- ss_dict[sample_key] = {}
- ss_dict[sample_key]['Relation'] = item.value
- }
- if (item.resource_var_name === "Fetus ID"){
- ss_dict[sample_key] = {}
- ss_dict[sample_key]['Fetus ID'] = item.value
- }
- }
- })
- }
- }
- if (workflow_key.includes("Veriseq NGS")){
- let getGroupedProtocols = groupDuplicates('protocol_name', workflow_value);
- let ngs_dict = getGroupedProtocols['NGS Testing List']
- let getGroupedDNA = groupDuplicates('sample_uuid', ngs_dict)
- for (const [sample_key, sample_values] of Object.entries(getGroupedDNA)){
- Object.values(sample_values).find((item) => {
- if (sample_key in dna_dict){
- if (item.tag_name==='seq_tech' && item.value !== null){
- row["Technician"] = item.value
- }
- if (item.resource_var_name === "Sample Number"){
- dna_dict[sample_key]['Sample_Number'] = item.value
- }
- }
- else {
- if (item.resource_var_name === "Sample Number"){
- dna_dict[sample_key] = {}
- dna_dict[sample_key]['Sample Number'] = item.value
- }
- }
- })
- }
- }
- if (workflow_key.includes("Extract DNA")){
- let getGroupedProtocols = groupDuplicates('protocol_name', workflow_value);
- let ex_dict = getGroupedProtocols['Extract gDNA']
- let getGroupedEx = groupDuplicates('sample_uuid', ex_dict)
- for (const [sample_key, sample_values] of Object.entries(getGroupedDNA)){
- Object.values(sample_values).find((item) => {
- if (sample_key in dna_dict){
- if (item.resource_var_name === "Parent ID"){
- dna_dict[sample_key]['Parent ID'] = item.value
- }
- }
- else {
- if (item.resource_var_name === "Parent ID"){
- dna_dict[sample_key] = {}
- dna_dict[sample_key]['Parent ID'] = item.value
- }
- }
- })
- }
- }
- const getsGroupedSamples = groupDuplicates("sample_uuid", workflow_value);
- for (const [sample_key, sample_value] of Object.entries(getsGroupedSamples)) {
- if (sample_value[0]['sample_name'].includes("PAT")){
- continue
- }
- const workflows_tag_values = ['Data Analysis', 'Identifiler', 'Collect and Extract Buccal Swab', 'Veriseq NGS', 'Extract DNA'];
- if (workflows_tag_values.includes(sample_value[0]["workflow_definition_name"])) {
- if (sample_key in row_storage){
- row_storage[sample_key] = samplesChildTable(sample_key, sample_value, row_storage[sample_key], sample_value[0]['workflow_definition_name'])
- }
- else {
- let row_dict = new Object()
- row_storage[sample_key] = samplesChildTable(sample_key,sample_value, row_dict, sample_value[0]['workflow_definition_name'])
- }
- }
- }
- }
- for (let [s_key, s_values] of Object.entries(row_storage)){
- if (dna_dict[s_values['Parent ID']]){
- row_storage[s_key]['Sample #'] = dna_dict[s_values['Parent ID']]['Sample Number']
- }
- row['Samples'].push(s_values)
- }
- rowData.push(row);
- }
- gridOptions.api.setRowData(rowData);
- // Cell Renderers
- function reportCellRendererFunc() {}
- // Handle the the gui element inside of the cell
- reportCellRendererFunc.prototype.getGui = function() {
- return this.eGui;resource
- };
- // Report Cell Renderer for generating reports
- reportCellRendererFunc.prototype.init = function(params) {
- this.eGui = document.createElement('div');
- this.eGui.innerHTML = '<button class="generate-button">Generate</button>';
- this.eButton = this.eGui.querySelector('.generate-button');
- this.eventListener = function() {
- reportClicked(params.node.data, params.node.rowIndex, this);
- this.setAttribute("style", "color: #ffffff;\n" +
- " border-color: #0e76ba;\n" +
- " background-color: lightgrey;font-size: 13px;\n" +
- " font-weight: 600;\n" +
- " min-width: 0;\n" +
- " min-height: 26px;\n" +
- " border-radius: 2px;\n" +
- " cursor: pointer;\n" +
- " display: inline-flex;\n" +
- " border: 1px solid;\n" +
- " vertical-align: middle;" )
- };
- this.eButton.addEventListener('click', this.eventListener);
- this.eButton.setAttribute("style", "color: #ffffff;\n" +
- " border-color: #0e76ba;\n" +
- " background-color: #0e76ba;font-size: 13px;\n" +
- " font-weight: 600;\n" +
- " min-width: 0;\n" +
- " min-height: 26px;\n" +
- " border-radius: 2px;\n" +
- " cursor: pointer;\n" +
- " display: inline-flex;\n" +
- " border: 1px solid;\n" +
- " vertical-align: middle;" )
- };
- function reportClicked(params,rowIndex, button) {
- var pipelineName = 'POC%20Report';
- let url = '/api/pipelines?name=' + pipelineName;
- let generateButtonElements = document.getElementsByClassName('generate-button');
- for (var i = 0; i < generateButtonElements.length; i ++) {
- generateButtonElements[i].disabled = true
- }
- ReportApp.utils.startSpinner();
- ReportApp.utils.get(
- url,
- "",
- function (json) {
- var sample_selection = params.Samples //gridOptions.api.getModel().rowsToDisplay[0].data.Samples;
- var sample_list = [];
- var sample_number = [];
- var str_results = [];
- var ngs_results = [];
- var relations = [];
- var qc_results = [];
- var interpretations = [];
- for (var i = 0; i < sample_selection.length; i++ ) {
- if (sample_selection[i]["fieldName"] === true) {
- sample_number.push((sample_selection[i]["Sample #"]))
- str_results.push((sample_selection[i]["STR Result"]))
- ngs_results.push((sample_selection[i]["NGS Result"]))
- relations.push((sample_selection[i]["Relation"]))
- qc_results.push((sample_selection[i]["QC"]))
- sample_list.push(sample_selection[i]["Sample ID"])
- interpretations.push((sample_selection[i]["Interpretation"]))
- }
- }
- if (sample_number.length === 0) {
- window.reportInteractionApi.toast("No samples selected!", "Please select at least one sample to generate a report.")
- return;
- }
- var payload = {};
- payload["samples"] = sample_list;
- payload["sample_number"] = sample_number;
- payload["str_results"] = str_results;
- payload["ngs_results"] = ngs_results;
- payload["relations"] = relations;
- payload["qc_results"] = qc_results;
- payload["interpretations"] = interpretations;
- payload["last_name"] = params['Last Name'];
- payload["first_name"] = params['First Name'];
- payload["chart_number"] = params['Chart Number'];
- payload["patient_id"] = params['Patient ID'];
- payload["report_wfc"] = params['Workflow Chain'];
- payload["partner_last_name"] = params['Partner Last Name'];
- payload["partner_first_name"] = params['Partner First Name'];
- payload["patient_dob"] = params['DOB'];
- payload["partner_dob"] = params['Partner DOB'];
- payload["patient_gender"] = params['Patient Gender'];
- payload["partner_gender"] = params['Partner Gender'];
- payload["partner_comments"] = params['Partner Comments'];
- payload["partner_chart_number"] = params['Partner Chart Number'];
- payload["poc_receiving_date"] = params['Date Received'];
- payload["poc_ga_by_size"] = params['GA by Size'];
- payload["poc_ga_by_date"] = params['GA by Dates'];
- payload["method_of_conception"] = params['Method of Conception'];
- payload["poc_special_requests"] = params['Comments & Special Requests'];
- payload["tested"] = params["# of Tested Samples"];
- payload["controls"] = params['# Controls'];
- payload["tech"] = params['Technician'];
- payload["analyzer"] = params['Analysed by'];
- payload["approver"] = params['Approved by'];
- payload["referring_physician"] = params['MD'];
- var payload_hex= hexPayload(payload);
- payload_hex.then(function(value){
- var hex = value;
- })
- url = '/api/pipeline_instances';
- let data = {
- 'pipeline': json[0]['uuid'],
- 'instances': true,
- "env": {"samples": JSON.stringify(payload)},
- };
- var rowNode = gridOptions.api.getDisplayedRowAtIndex(rowIndex);
- var sample_url = '/api/samples/' + params[pat_id].split(' ')[0];
- var partner = params[pat_id].split(' ')[1] + ' ' params[pat_id].split(' ')[2];
- if (params['Download']){
- $.ajax({
- method: "GET",
- url: sample_url
- async: true,
- success: function(data){
- let meta = data[0].meta;
- hexes = meta.reports.POC.partner.hex;
- urls = meta.reports.POC.partner.url;
- if (hex.includes(hexes)){
- hex_index = hexes.findIndex(_hex)
- old_report = urls[hex_index]
- var link = {
- 'name': 'Download Report',
- 'url': old_report
- }
- rowNode.setDataValue('Download', link);
- };
- $.ajax({
- method: "POST",
- url: url,
- contentType:"application/json; charset=utf-8",
- dataType: "json",
- data: JSON.stringify(data), //posting the pipeline uuid
- success: function (data) {
- monitorPipeline(data[0].uuid, rowIndex, button, sample_url, partner, hex);
- },
- error: function (error) {
- console.error(error);
- ReportApp.utils.showNotification(error, 'error')
- },
- processData: false
- });
- },
- error: function (error) {
- console.error(error);
- //ReportApp.utils.showNotification(error, 'error')
- }
- });
- };
- $.ajax({
- method: "POST",
- url: url,
- contentType:"application/json; charset=utf-8",
- dataType: "json",
- data: JSON.stringify(data), //posting the pipeline uuid
- success: function (data) {
- monitorPipeline(data[0].uuid, rowIndex, button, sample_url, partner, hex);
- },
- error: function (error) {
- console.error(error);
- ReportApp.utils.showNotification(error, 'error')
- },
- processData: false
- });
- },
- function (error) {
- console.error(error)
- ReportApp.utils.showNotification(error, 'error')
- }
- )
- }
- function monitorPipeline(uuid, rowIndex, button, sample_url, partner, new_hex) {
- monitorInterval = setInterval(function() {
- ReportApp.utils.get(
- '/api/pipeline_instances/' + uuid,
- {},
- function(json) {
- if (json.state === 'done'){
- clearInterval(monitorInterval);
- var task_uuid = json.steps[0]['uuid'];
- $.ajax({
- url: '/api/task_instances/' + task_uuid,
- type: 'GET',
- success: function(data) {
- var task_files = data['task_files'];
- for (var i = 0; i < task_files.length; i++) {
- if (task_files[i]['taskfile_name'] === 'poc-report') {
- var file_uuid = task_files[i]['uuid']
- }
- }
- //var url = '/api/files/' + file_uuid + '/export' //add in var
- var link = {
- 'name': 'Download Report',
- 'url': '/api/files/' + file_uuid + '/export'
- }
- console.log(new_hex);
- console.log(link.url);
- /* $.ajax({
- method: "POST",
- url: sample_url,
- //contentType:"application/json; charset=utf-8",
- async: true,
- //dataType: "json",
- //data: JSON.stringify(data),
- success: function (data) {
- meta = data[0].meta;
- //meta.reports.POC.partner.hex.push(hex);
- //meta.reports.POC.partner.url.push(link.url);
- },
- error: function (error) {
- console.error(error);
- ReportApp.utils.showNotification(error, 'error')
- },
- processData: false
- });*/
- //var rowNode = gridOptions.api.getDisplayedRowAtIndex(rowIndex);
- rowNode.setDataValue('Download', link);
- ReportApp.utils.stopSpinner();
- button.setAttribute("style", "color: #ffffff;\n" +
- " border-color: #0e76ba;\n" +
- " background-color: #0e76ba;font-size: 13px;\n" +
- " font-weight: 600;\n" +
- " min-width: 0;\n" +
- " min-height: 26px;\n" +
- " border-radius: 2px;\n" +
- " cursor: pointer;\n" +
- " display: inline-flex;\n" +
- " border: 1px solid;\n" +
- " vertical-align: middle;" );
- let generateButtonElements = document.getElementsByClassName('generate-button');
- for (var j = 0; j < generateButtonElements.length; j++) {
- generateButtonElements[j].disabled = false;
- };
- },
- error: function(error) {
- window.reportInteractionApi.toast({
- status: 'error',
- title: 'Report Error',
- description: 'Error Generating Report'
- });
- console.log(error)
- }
- })
- } else if (json.state === 'failed') {
- clearInterval(monitorInterval);
- window.reportInteractionApi.toast({
- status: 'error',
- title: 'Report Error',
- description: 'Error Generating Report'
- });
- console.log(error)
- }
- },
- function (error) {
- clearInterval(monitorInterval);
- var rowNode = gridOptions.api.getRowNode(row);
- var rowData = rowNode.data;
- window.reportInteractionApi.toast({
- status: 'error',
- title: 'Report Error',
- description: 'Error Generating Report'
- });
- })
- }, 1000);
- }
- gridOptions.api.redrawRows()
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement