Skip to content

Commit

Permalink
Have report template load external job json if specified in query.
Browse files Browse the repository at this point in the history
Useful in powering a single application that can build many reports depending on the data - http://galaxyproject.github.io/planemo/tool_test_viewer.html?test_data_url=.
  • Loading branch information
jmchilton committed Dec 9, 2014
1 parent feb0b3f commit 03f8e39
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
16 changes: 16 additions & 0 deletions planemo/reports/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,19 @@ var TestResult = function(data) {
this.problemLog = data["data"]["problem_log"];
this.passed = (this.status == "success");
}


// http://stackoverflow.com/questions/19491336/get-url-parameter-jquery
function getUrlParameter(sParam)
{
var sPageURL = window.location.search.substring(1);
var sURLVariables = sPageURL.split('&');
for (var i = 0; i < sURLVariables.length; i++)
{
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == sParam)
{
return sParameterName[1];
}
}
}
15 changes: 13 additions & 2 deletions planemo/reports/report_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,19 @@ <h2 id="tests">Tests</h2>
${bootstrap_script}
${custom_script}
<script>
var test_data = ${json_test_data};
renderTestResults(test_data);
var testDataUrl = getUrlParameter("test_data_url");
if(testDataUrl) {
$.ajax(
{'url': testDataUrl,
'type': 'GET',
}
)
.success(function(content) { renderTestResults( $.parseJSON(content) ); })
.failure(function() { alert("Failed to load test data.")} );
} else {
var test_data = ${json_test_data};
renderTestResults(test_data);
}
</script>
</body>
</html>

0 comments on commit 03f8e39

Please sign in to comment.