api reporting stuff

This commit is contained in:
John Woodlock
2012-05-15 10:09:04 +10:00
parent d7b39edaeb
commit 81e04b66d2
3 changed files with 135 additions and 177 deletions
@@ -19,7 +19,7 @@ $.stretchyReporting.clearLoadingImg = function() {
}; };
$.stretchyReporting.nothingCallback = function() { $.stretchyReporting.nothingCallback = function() {
//nothing // nothing
}; };
$.stretchyReporting.changeLanguage = function(newLanguage) { $.stretchyReporting.changeLanguage = function(newLanguage) {
@@ -35,9 +35,10 @@ $.stretchyReporting.changeSeparator= function(sepChar, decChar, indFormat) {
}; };
function fnRecordsDisplay(){ function fnRecordsDisplay(){
//oSettings isn't defined when table first created but coding around to not call this method until after it is. // oSettings isn't defined when table first created but coding around to not
//if (typeof(oSettings) != "undefined") return oSettings.fnRecordsDisplay() // call this method until after it is.
//else return 0; // if (typeof(oSettings) != "undefined") return oSettings.fnRecordsDisplay()
// else return 0;
return oSettings.fnRecordsDisplay(); return oSettings.fnRecordsDisplay();
} }
@@ -136,9 +137,9 @@ function initialiseReporting(params) {
} }
//google charts // google charts
google.load("visualization", "1", {packages:["corechart"]}); google.load("visualization", "1", {packages:["corechart"]});
//google.load('visualization', '1', {packages:['table']}); // google.load('visualization', '1', {packages:['table']});
reportListing = []; reportListing = [];
listOfParameters = []; listOfParameters = [];
@@ -180,7 +181,7 @@ function pad2(number) {
function formatNumber(nStr) function formatNumber(nStr)
{ {
//format no. of decimal places // format no. of decimal places
var mainNum; var mainNum;
if (decimalsNo < 0) if (decimalsNo < 0)
{ {
@@ -192,7 +193,7 @@ function formatNumber(nStr)
else return generalFormatNumber(mainNum); else return generalFormatNumber(mainNum);
} }
//function for converting string into indian currency format // function for converting string into indian currency format
function indianFormatNumber(inNum) { function indianFormatNumber(inNum) {
var mainNum = inNum + ''; var mainNum = inNum + '';
@@ -270,7 +271,7 @@ function getOrigTitleNumericValue(titleNumericValue) {
} }
function invalidDate(checkDate) { function invalidDate(checkDate) {
//validates for yyyy-mm-dd returns true if invalid, false is valid // validates for yyyy-mm-dd returns true if invalid, false is valid
var dateformat = /^\d{4}(\-|\/|\.)\d{1,2}\1\d{1,2}$/; var dateformat = /^\d{4}(\-|\/|\.)\d{1,2}\1\d{1,2}$/;
if(!(dateformat.test(checkDate))) { if(!(dateformat.test(checkDate))) {
@@ -458,7 +459,7 @@ function runTheReport()
if (reportListing[reportListingIndex].type == 'Pentaho') reportParameterName = reportListing[reportListingIndex].parameters[i][0] if (reportListing[reportListingIndex].type == 'Pentaho') reportParameterName = reportListing[reportListingIndex].parameters[i][0]
else reportParameterName = paramDetails.variable; else reportParameterName = paramDetails.variable;
//alert("Variable: " + reportParameterName + " Value: " + pValue); // alert("Variable: " + reportParameterName + " Value: " + pValue);
theParams[reportParameterName] = pValue ; theParams[reportParameterName] = pValue ;
} }
@@ -529,7 +530,7 @@ var parameterTableHtml = '<table><tr>';
$(inputParametersDiv).html(parameterTableHtml); $(inputParametersDiv).html(parameterTableHtml);
//set the initial values for parameters // set the initial values for parameters
for (var i in listOfParameters) for (var i in listOfParameters)
{ {
parameterTableHtml = parameterTableHtml + '<td width="20">&nbsp;</td>'; parameterTableHtml = parameterTableHtml + '<td width="20">&nbsp;</td>';
@@ -568,7 +569,7 @@ var parameterTableHtml = '<table><tr>';
hideAllParameters(); hideAllParameters();
//Populate all select (drop down list box) parameters // Populate all select (drop down list box) parameters
for (var i in listOfParameters) for (var i in listOfParameters)
{ {
if (listOfParameters[i].displayType == 'select') if (listOfParameters[i].displayType == 'select')
@@ -671,8 +672,8 @@ setupReportListSuccess = function(data, textStatus, jqXHR){
function copyXLSon() { function copyXLSon() {
showMsg("Turning them on"); showMsg("Turning them on");
$('#ToolTables_MRPshowTable_0').css('display', 'inline'); $('#ToolTables_FRshowTable_0').css('display', 'inline');
$('#ToolTables_MRPshowTable_1').css('display', 'inline'); $('#ToolTables_FRshowTable_1').css('display', 'inline');
ttInstances = TableTools.fnGetMasters(); ttInstances = TableTools.fnGetMasters();
for (i in ttInstances) { for (i in ttInstances) {
ttInstances[i].that.fnResizeButtons(); ttInstances[i].that.fnResizeButtons();
@@ -683,8 +684,8 @@ function copyXLSon() {
function copyXLSoff() { function copyXLSoff() {
showMsg("Turning them off"); showMsg("Turning them off");
$('#ToolTables_MRPshowTable_0').css('display', 'none'); $('#ToolTables_FRshowTable_0').css('display', 'none');
$('#ToolTables_MRPshowTable_1').css('display', 'none'); $('#ToolTables_FRshowTable_1').css('display', 'none');
filteredCopyXLSon = false; filteredCopyXLSon = false;
} }
@@ -717,7 +718,7 @@ function applyFilterRules() {
function initialiseDataTableDef() { function initialiseDataTableDef() {
dataTableDef = { dataTableDef = {
//"sDom": 'lfTip<"top"<"clear">>rtlfTip<"bottom"<"clear">>', // "sDom": 'lfTip<"top"<"clear">>rtlfTip<"bottom"<"clear">>',
"sDom": 'lfTip<"top"<"clear">>rt', "sDom": 'lfTip<"top"<"clear">>rt',
"oTableTools": { "oTableTools": {
"aButtons": [{ "sExtends": "copy", "aButtons": [{ "sExtends": "copy",
@@ -726,10 +727,10 @@ dataTableDef = {
{ "sExtends": "xls", { "sExtends": "xls",
"sButtonText": doI18N("Save to CSV") "sButtonText": doI18N("Save to CSV")
} }
//{ // {
// "sExtends": "print", // "sExtends": "print",
// "sButtonText": doI18N("Print") // "sButtonText": doI18N("Print")
//} // }
], ],
"sSwfPath": resValue + "DataTables-1.8.2/extras/TableTools/media/swf/copy_cvs_xls.swf" "sSwfPath": resValue + "DataTables-1.8.2/extras/TableTools/media/swf/copy_cvs_xls.swf"
}, },
@@ -740,7 +741,7 @@ dataTableDef = {
"bDeferRender": true, "bDeferRender": true,
"bProcessing": true, "bProcessing": true,
"aLengthMenu": [[5, 10, 25, 50, 100, -1], [5, 10, 25, 50, 100, "All"]] "aLengthMenu": [[5, 10, 25, 50, 100, -1], [5, 10, 25, 50, 100, "All"]]
//"bJQueryUI": true // "bJQueryUI": true
} }
} }
@@ -767,22 +768,22 @@ return 'var selectSuccess = function(data, textStatus,jqXHR){' +
function createChart(theData) { function createChart(theData) {
MRPData = new google.visualization.DataTable(); FRData = new google.visualization.DataTable();
MRPData.addColumn('string', dataTableDef.aoColumns[0].sTitle); FRData.addColumn('string', dataTableDef.aoColumns[0].sTitle);
MRPData.addColumn('number', dataTableDef.aoColumns[1].sTitle); FRData.addColumn('number', dataTableDef.aoColumns[1].sTitle);
MRPData.addRows(dataTableDef.aaData.length); FRData.addRows(dataTableDef.aaData.length);
var ii = 0; var ii = 0;
var numberData; var numberData;
var dblQuotePos; var dblQuotePos;
for (var i in dataTableDef.aaData) for (var i in dataTableDef.aaData)
{ {
MRPData.setValue(ii, 0, dataTableDef.aaData[i][0]); FRData.setValue(ii, 0, dataTableDef.aaData[i][0]);
if (dataTableDef.aoColumns[1].sType == "title-numeric" && dataTableDef.aaData[i][1].substr(0, 11) == '<span title') numberData = getOrigTitleNumericValue(dataTableDef.aaData[i][1]) if (dataTableDef.aoColumns[1].sType == "title-numeric" && dataTableDef.aaData[i][1].substr(0, 11) == '<span title') numberData = getOrigTitleNumericValue(dataTableDef.aaData[i][1])
else numberData = dataTableDef.aaData[i][1]; else numberData = dataTableDef.aaData[i][1];
MRPData.setValue(ii, 1, numberData); FRData.setValue(ii, 1, numberData);
ii = ii + 1; ii = ii + 1;
}; };
} }
@@ -826,7 +827,7 @@ function createTable(theData) {
} }
tableColumns.push({ "sTitle": doI18N(theData.columnHeaders[i].columnName), tableColumns.push({ "sTitle": doI18N(theData.columnHeaders[i].columnName),
"sOriginalHeading": theData.columnHeaders[i].columnName, "sOriginalHeading": theData.columnHeaders[i].columnName,
//"dataType": tmpSType, // "dataType": tmpSType,
"sType": tmpSType, "sType": tmpSType,
"sClass": tmpSClass "sClass": tmpSClass
}); });
@@ -888,8 +889,8 @@ function convertCRtoBR(str) {
function showTableReport() { function showTableReport() {
isNewTable = true; isNewTable = true;
$('#StretchyReportOutput').html( '<table cellpadding="0" cellspacing="1" border="0" class="display" id="MRPshowTable" width=100%></table>' ); $('#StretchyReportOutput').html( '<table cellpadding="0" cellspacing="1" border="0" class="display" id="FRshowTable" width=100%></table>' );
oTable = $('#MRPshowTable').dataTable(dataTableDef); oTable = $('#FRshowTable').dataTable(dataTableDef);
oSettings = oTable.fnSettings(); oSettings = oTable.fnSettings();
showMsg("1st recs displayed is: " + fnRecordsDisplay()); showMsg("1st recs displayed is: " + fnRecordsDisplay());
@@ -899,15 +900,18 @@ function showTableReport() {
function showChartReport(rptSubType) { function showChartReport(rptSubType) {
/* /*
$('#StretchyReportOutput').html( '<table><tr><td width="25%" valign="top"><table cellpadding="0" cellspacing="1" border="0" class="display" id="MRPshowTable" width=100%></table></td><td width="75%" align="right"><div id=MRPshowChart></div></td></tr></table>' ); * $('#StretchyReportOutput').html( '<table><tr><td width="25%" valign="top"><table
$('#MRPshowTable').dataTable(dataTableDef); * cellpadding="0" cellspacing="1" border="0" class="display" id="FRshowTable"
*/ * width=100%></table></td><td width="75%" align="right"><div
* id=FRshowChart></div></td></tr></table>' );
* $('#FRshowTable').dataTable(dataTableDef);
*/
$('#StretchyReportOutput').html( '<table><tr></td><td width="100%" align="center"><div id=MRPshowChart></div></td></tr></table>' ); $('#StretchyReportOutput').html( '<table><tr></td><td width="100%" align="center"><div id=FRshowChart></div></td></tr></table>' );
var options; var options;
var MRPchart; var FRchart;
switch(rptSubType) switch(rptSubType)
{ {
@@ -915,21 +919,22 @@ var MRPchart;
options = { options = {
legend: 'right', is3D: true, legend: 'right', is3D: true,
width: 1000, height: 600 width: 1000, height: 600
//chartArea: {left:0,top:0, width:"100%",height:"100%"} // chartArea: {left:0,top:0, width:"100%",height:"100%"}
}; };
MRPchart = new google.visualization.PieChart(document.getElementById('MRPshowChart')); FRchart = new google.visualization.PieChart(document.getElementById('FRshowChart'));
MRPchart.draw(MRPData, options); FRchart.draw(FRData, options);
break; break;
case "Bar": case "Bar":
options = { options = {
width: 1000, height: 600 width: 1000, height: 600
//vAxis: {title: 'xxxxxxx', titleTextStyle: {color: 'red'}} // vAxis: {title: 'xxxxxxx', titleTextStyle: {color:
//chartArea: {left:0,top:0, width:"100%",height:"100%"} // 'red'}}
// chartArea: {left:0,top:0, width:"100%",height:"100%"}
}; };
MRPchart = new google.visualization.BarChart(document.getElementById('MRPshowChart')); FRchart = new google.visualization.BarChart(document.getElementById('FRshowChart'));
MRPchart.draw(MRPData, options); FRchart.draw(FRData, options);
break; break;
default: default:
alert("System Error: Unknown Chart Type: " + rptSubType); alert("System Error: Unknown Chart Type: " + rptSubType);
@@ -940,75 +945,31 @@ var MRPchart;
/* /*
var MRPchart = new google.visualization.PieChart(document.getElementById('MRPshowChart')); * var FRchart = new
MRPchart.draw(MRPData, {legend: 'right', is3D: true, width: 400, height: 500, chartArea: {left:0,top:0, width:"100%",height:"100%"}}); * google.visualization.PieChart(document.getElementById('FRshowChart'));
*/ * FRchart.draw(FRData, {legend: 'right', is3D: true, width: 400, height: 500,
* chartArea: {left:0,top:0, width:"100%",height:"100%"}});
*/
/* /*
var chartCategories = []; * var chartCategories = []; for (var i in dataTableDef.aaData) {
for (var i in dataTableDef.aaData) * chartCategories.push(dataTableDef.aaData[i][0]); }
{ *
chartCategories.push(dataTableDef.aaData[i][0]); * var chartSeries = [];
} *
* for (var i in dataTableDef.aaData) { chartSeries.push({data:
var chartSeries = []; * dataTableDef.aaData[i][1]}); }
*
for (var i in dataTableDef.aaData) *
{ * var FRchart = new Highcharts.Chart({ chart: { renderTo: 'FRshowChart',
chartSeries.push({data: dataTableDef.aaData[i][1]}); * defaultSeriesType: 'bar' }, title: { text: 'Historic World Population by
} * Region' }, xAxis: { categories: chartCategories, title: { text: null } },
* yAxis: { min: -5000000, title: { text: 'Population (millions)', align: 'high' } },
* tooltip: { formatter: function() { return ''+ this.series.name +': '+ this.y +'
var MRPchart = new Highcharts.Chart({ * millions'; } }, plotOptions: { bar: { dataLabels: { enabled: true } } },
chart: { * legend: { layout: 'vertical', align: 'right', verticalAlign: 'top', x: -100,
renderTo: 'MRPshowChart', * y: 100, floating: true, borderWidth: 1, backgroundColor: '#FFFFFF', shadow:
defaultSeriesType: 'bar' * true }, credits: { enabled: false }, series: chartSeries });
}, */
title: {
text: 'Historic World Population by Region'
},
xAxis: {
categories: chartCategories,
title: {
text: null
}
},
yAxis: {
min: -5000000,
title: {
text: 'Population (millions)',
align: 'high'
}
},
tooltip: {
formatter: function() {
return ''+
this.series.name +': '+ this.y +' millions';
}
},
plotOptions: {
bar: {
dataLabels: {
enabled: true
}
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -100,
y: 100,
floating: true,
borderWidth: 1,
backgroundColor: '#FFFFFF',
shadow: true
},
credits: {
enabled: false
},
series: chartSeries
});
*/
} }
@@ -1023,9 +984,8 @@ function getReportData(inParams, successFunction) {
function getReportDataAuth(inParams, successFunction) { function getReportDataAuth(inParams, successFunction) {
var inQueryParameters = {}; var inQueryParameters = {};
inQueryParameters["MRP_rptDB"] = rptDB; for (var i in inParams ) inQueryParameters["FR_" + i] = inParams[i];
for (var i in inParams ) inQueryParameters["MRP_" + i] = inParams[i]; if (rptDB > "") inQueryParameters["FR_rptDB"] = rptDB;
OAuthSimple().reset(); OAuthSimple().reset();
var OAuthProcess = (new OAuthSimple()).sign({ var OAuthProcess = (new OAuthSimple()).sign({
@@ -1054,19 +1014,36 @@ function getReportDataAuth(inParams, successFunction) {
error:function(jqXHR, textStatus, errorThrown){ error:function(jqXHR, textStatus, errorThrown){
showMsgE("getReportData IS Auth Error: "); showMsgE("getReportData IS Auth Error: ");
var jsonValue = jQuery.parseJSON(jqXHR.responseText); var jsonValue = jQuery.parseJSON(jqXHR.responseText);
alert(jqXHR.responseText); alert("Response Text: " + jqXHR.responseText + " Text Status: " + textStatus);
alert(textStatus);
} }
}); });
} }
function buildReportParms(inParams) {
var paramCount = 1;
var reportParams = "";
for (var i in inParams )
{
if (paramCount > 1) reportParams += "&"
reportParams += encodeURIComponent("FR_" + i) + "=" + encodeURIComponent(inParams[i]);
paramCount = paramCount + 1;
}
if (rptDB > "")
{
if (paramCount > 1) reportParams += "&"
reportParams = encodeURIComponent("FR_rptDB") + "=" + encodeURIComponent(rptDB);
}
return reportParams
}
function getReportDataNoAuth(inParams, successFunction) { function getReportDataNoAuth(inParams, successFunction) {
var inQueryParameters = "MRP_rptDB=" + rptDB; var inQueryParameters = buildReportParms(inParams);
for (var i in inParams ) inQueryParameters += "&" + encodeURIComponent("MRP_" + i) + "=" + encodeURIComponent(inParams[i]);
showMsgE("getReportDataNoAuth: " + inQueryParameters); showMsgE("getReportDataNoAuth: " + inQueryParameters);
$.ajax({ $.ajax({
url: RESTUrl, url: RESTUrl,
@@ -1075,36 +1052,26 @@ function getReportDataNoAuth(inParams, successFunction) {
data: inQueryParameters, data: inQueryParameters,
contentType: "application/json; charset=utf-8", contentType: "application/json; charset=utf-8",
crossDomain: false, crossDomain: false,
//cache: true, // cache: true,
beforeSend: function( xhr ) { beforeSend: function( xhr ) {
xhr.setRequestHeader("Accept", "application/json"); xhr.setRequestHeader("Accept", "application/json");
}, },
success: successFunction, success: successFunction,
error:function(jqXHR, textStatus, errorThrown){ error:function(jqXHR, textStatus, errorThrown){
showMsgE("getReportDataNoAuth: "); showMsgE("getReportDataNoAuth: ");
alert(jqXHR.responseText); alert("Response Text: " + jqXHR.responseText + " Text Status: " + textStatus + " Error Thrown: " + errorThrown);
alert(textStatus);
alert(errorThrown);
var jsonValue = jQuery.parseJSON(jqXHR.responseText); var jsonValue = jQuery.parseJSON(jqXHR.responseText);
alert(jsonValue.value + "for " + jsonValue.field + " : " + jsonValue.code); alert("Last Alert - " + jsonValue.value + "for " + jsonValue.field + " : " + jsonValue.code);
} }
}); });
} }
function getExportCSV(inParams) { function getExportCSV(inParams) {
var inQueryParameters = "?" + encodeURIComponent("MRP_rptDB") + "=" + encodeURIComponent(rptDB); var inQueryParameters = buildReportParms(inParams);
//var paramCount = 1; var fullExportUrl = RESTUrl + "?" + inQueryParameters + "&exportCSV=true";
for (var i in inParams )
{
//if (paramCount > 1) inQueryParameters += "&"
//else inQueryParameters += "?";
inQueryParameters += "&" + encodeURIComponent("MRP_" + i) + "=" + encodeURIComponent(inParams[i]);
//paramCount = paramCount + 1;
}
var fullExportUrl = RESTUrl + inQueryParameters + "&exportCSV=true";
showMsg("full export url: " + fullExportUrl); showMsg("full export url: " + fullExportUrl);
var loadHTML = '<iframe id=rptLoadingFrame src="' + fullExportUrl + '" frameborder="0" onload="jQuery.stretchyReporting.clearLoadingImg();" width="100%" height="600px" style="background:url('; var loadHTML = '<iframe id=rptLoadingFrame src="' + fullExportUrl + '" frameborder="0" onload="jQuery.stretchyReporting.clearLoadingImg();" width="100%" height="600px" style="background:url(';
loadHTML += "'" + loadingImg + "'" + ') no-repeat scroll 50% 100px;"><p>Your browser does not support iframes.</p></iframe>'; loadHTML += "'" + loadingImg + "'" + ') no-repeat scroll 50% 100px;"><p>Your browser does not support iframes.</p></iframe>';
@@ -1117,13 +1084,13 @@ function getExportCSV(inParams) {
function getPentahoReport(inParams) { function getPentahoReport(inParams) {
var inQueryParameters = "?output-type=" + $('#rptOutputType option:selected').val(); var inQueryParameters = "?output-type=" + $('#rptOutputType option:selected').val();
//var paramCount = 1; // var paramCount = 1;
for (var i in inParams ) for (var i in inParams )
{ {
//if (paramCount > 1) inQueryParameters += "&" // if (paramCount > 1) inQueryParameters += "&"
//else inQueryParameters += "?"; // else inQueryParameters += "?";
inQueryParameters += "&" + encodeURIComponent(i) + "=" + encodeURIComponent(inParams[i]); inQueryParameters += "&" + encodeURIComponent(i) + "=" + encodeURIComponent(inParams[i]);
//paramCount = paramCount + 1; // paramCount = paramCount + 1;
} }
var fullReportUrl = pentahoUrl + inQueryParameters; var fullReportUrl = pentahoUrl + inQueryParameters;
@@ -1146,7 +1113,7 @@ var tmpStartDate = "";
var tmpEndDate = ""; var tmpEndDate = "";
for (var i in reportParams) for (var i in reportParams)
{ {
//alert("rpt param:" + reportParams[i][1]); // alert("rpt param:" + reportParams[i][1]);
var paramDetails = getParameterDetailsUsingName(reportParams[i][1]); var paramDetails = getParameterDetailsUsingName(reportParams[i][1]);
switch(paramDetails.displayType) switch(paramDetails.displayType)
@@ -1231,12 +1198,12 @@ function initI18N(lang) {
function changeLanguage(newLanguage) { function changeLanguage(newLanguage) {
initI18N(newLanguage); initI18N(newLanguage);
//run and clear buttons // run and clear buttons
$(runReportDiv).button({ label: doI18N("rpt_run") }); $(runReportDiv).button({ label: doI18N("rpt_run") });
$(clearReportDiv).button({ label: doI18N("rpt_clear") }); $(clearReportDiv).button({ label: doI18N("rpt_clear") });
//report listing // report listing
$(reportsListDiv + ' div').text(doI18N(reportsListDivLabel)); $(reportsListDiv + ' div').text(doI18N(reportsListDivLabel));
$(reportsListDiv + ' option').each(function(index) { $(reportsListDiv + ' option').each(function(index) {
if ($(this).val() == "0") $(this).text(doI18N('rpt_select_one')) if ($(this).val() == "0") $(this).text(doI18N('rpt_select_one'))
@@ -1250,12 +1217,12 @@ function changeLanguage(newLanguage) {
} }
}); });
//parameter labels // parameter labels
for (var i in listOfParameters) for (var i in listOfParameters)
{ {
$('#' + listOfParameters[i].name + ' div').text(doI18N(listOfParameters[i].label)); $('#' + listOfParameters[i].name + ' div').text(doI18N(listOfParameters[i].label));
//parameter options select one/all // parameter options select one/all
if (listOfParameters[i].displayType == 'select') if (listOfParameters[i].displayType == 'select')
{ {
$('#' + listOfParameters[i].name + ' option').each(function(index) { $('#' + listOfParameters[i].name + ' option').each(function(index) {
@@ -1268,7 +1235,7 @@ function changeLanguage(newLanguage) {
} }
} }
//Data output (if any) // Data output (if any)
if ($('#StretchyReportOutput').html() > "" ) if ($('#StretchyReportOutput').html() > "" )
{ {
for (var i in dataTableDef.aoColumns) for (var i in dataTableDef.aoColumns)
@@ -1319,7 +1286,7 @@ function changeSeparator(sepChar, decChar, indFormat) {
function updateNumberData() { function updateNumberData() {
//Data output (if any) // Data output (if any)
if ($('#StretchyReportOutput').html() > "" ) if ($('#StretchyReportOutput').html() > "" )
{ {
var tmpVal; var tmpVal;
@@ -1364,8 +1331,9 @@ function redrawOutput() {
} }
function setTableSizeLimit() { function setTableSizeLimit() {
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x; if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ // test for MSIE x.x;
var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number var ieversion=new Number(RegExp.$1) // capture x.x portion and store as
// a number
if (ieversion>=9) return 50000 if (ieversion>=9) return 50000
else return 3000; else return 3000;
} }
@@ -1378,7 +1346,7 @@ function showMsg(msg) {
} }
function showMsgE(msg) { function showMsgE(msg) {
//console.log(msg); // console.log(msg);
} }
@@ -16,6 +16,6 @@
<script type="text/javascript" src="${resValue}/libs/DataTables-1.8.2/extras/TableTools/media/js/TableTools.min.js"></script> <script type="text/javascript" src="${resValue}/libs/DataTables-1.8.2/extras/TableTools/media/js/TableTools.min.js"></script>
<script type="text/javascript" src="${resValue}/libs/jquery.i18n.properties-min-1.0.9.js"></script> <script type="text/javascript" src="${resValue}/libs/jquery.i18n.properties-min-1.0.9.js"></script>
<script type="text/javascript" src="${resValue}/libs/OAuthSimple.js"></script> <script type="text/javascript" src="${resValue}/libs/OAuthSimple.js"></script>
<script type="text/javascript" src="${resValue}/stretchyreporting/stretchyreporting-0.966.js"></script> <script type="text/javascript" src="${resValue}/stretchyreporting/stretchyreporting-0.967.js"></script>
<script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript" src="https://www.google.com/jsapi"></script>
@@ -34,21 +34,6 @@ public class ReportingApiResource {
@Autowired @Autowired
private ReadExtraDataAndReportingService ReadExtraDataAndReportingService; private ReadExtraDataAndReportingService ReadExtraDataAndReportingService;
// private Response makeCORSExport(ResponseBuilder req, String exportFilename,
// String returnMethod) {
// ResponseBuilder rb = req
// .header("Access-Control-Allow-Origin", "*")
// .header("Access-Control-Allow-Methods", "GET, POST, OPTIONS")
// .header("Content-Disposition",
// "attachment;filename=" + exportFilename);
//
// if (!"".equals(returnMethod)) {
// rb.header("Access-Control-Allow-Headers", returnMethod);
// }
//
// return rb.build();
// }
@GET @GET
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, "application/x-msdownload" }) @Produces({ MediaType.APPLICATION_JSON, "application/x-msdownload" })
@@ -56,8 +41,8 @@ public class ReportingApiResource {
MultivaluedMap<String, String> queryParams = uriInfo MultivaluedMap<String, String> queryParams = uriInfo
.getQueryParameters(); .getQueryParameters();
String name = queryParams.getFirst("MRP_Name"); String name = queryParams.getFirst("FR_Name");
String type = queryParams.getFirst("MRP_Type"); String type = queryParams.getFirst("FR_Type");
String exportCSV = queryParams.getFirst("exportCSV"); String exportCSV = queryParams.getFirst("exportCSV");
Map<String, String> extractedQueryParams = new HashMap<String, String>(); Map<String, String> extractedQueryParams = new HashMap<String, String>();
@@ -67,10 +52,9 @@ public class ReportingApiResource {
String pValue; String pValue;
for (String k : keys) { for (String k : keys) {
if (k.startsWith("MRP_")) { if (k.startsWith("FR_")) {
pKey = "${" + k.substring(4) + "}"; pKey = "${" + k.substring(3) + "}";
pValue = queryParams.get(k).get(0); pValue = queryParams.get(k).get(0);
extractedQueryParams.put(pKey, pValue); extractedQueryParams.put(pKey, pValue);
} }
} }
@@ -83,9 +67,15 @@ public class ReportingApiResource {
return Response.ok().entity(result).build(); return Response.ok().entity(result).build();
} }
StreamingOutput result = this.ReadExtraDataAndReportingService.retrieveReportCSV(name, type, extractedQueryParams); StreamingOutput result = this.ReadExtraDataAndReportingService
.retrieveReportCSV(name, type, extractedQueryParams);
return Response.ok().entity(result).header("Content-Disposition","attachment;filename=" + name.replaceAll(" ", "") + ".csv").build(); return Response
.ok()
.entity(result)
.header("Content-Disposition",
"attachment;filename=" + name.replaceAll(" ", "")
+ ".csv").build();
} }
@GET @GET