Visualize: JRS-1563
Test plugins
by Yuriy Bablyukh
HTML
<!--Provide URL to visualize.js-->
<script type='text/javascript' src="http://code.jquery.com/jquery-2.1.0.js"></script>
<script type='text/javascript' src="http://build-master.jaspersoft.com:7580/jrs-pro-feature-amber-embedded-report/client/visualize.js"></script>
<div id="container"></div>
CSS
#container select {
margin: 10px;
}
JavaScript
visualize({
auth: {
name: "superuser",
password: "superuser"
}
}, function (v) {
buildControl("Chart types", v.report.chart.types);
buildControl("Resources types", v.resourcesSearch.types);
buildControl("Resources search sort types", v.resourcesSearch.sortBy);
// not working yet
buildControl("Resources search access types", v.reourcesSearch.accessType);
buildControl("Report export formats", v.report.exportFormats);
buildControl("Report table column types", v.report.table.column.types);
//not working yet
buildControl("Report crosstab elements types", v.report.crosstab.componentTypes);
});
function buildControl(name, options) {
function buildOptions(options) {
var template = "<option>{value}</option>";
return options.reduce(function (memo, option) {
return memo + template.replace("{value}", option);
}, "")
}
console.log(options);
if (!options.length){
console.log(options);
}
var template = "<label>{label}</label><select>{options}</select><br>",
content = template.replace("{label}", name)
.replace("{options}", buildOptions(options));
$("#container").append($(content));
}