0.28.0 • Published 8 years ago
nreports v0.28.0
NReports
A simple nodejs reporting framework that leverages template runtimes for report generation.
Features
- Template Runtimes + Jade + Handlebars
- Datasources + LiveJSON - JSON data embedded in the datasource + WebJSON - JSON data provided by a RESTful web service
- Parameters + Type - string, boolean, number + Passed to the datasource for filtering. e.g. http://someurl?param1=:param1¶m2=:param2
Limitations
Currently the framework is only designed to work with JSON data and supports Jade or Handlebars templates.
Sample Overview
The sample illustrates using the NReports reporting engine to build a report using the a handlebars template.
Sample LiveJson datasource
var NReports = require('nreports');
var params = [
new ReportParameter("postalcode", "string", "6600"),
new ReportParameter("country", "string", "AT"),
new ReportParameter("username", "string", "demo")
];
var json = {
"postalcodes":[
{"adminCode3":"70805","adminName2":"Politischer Bezirk Reutte","adminName3":"Breitenwang","adminCode2":"708","postalcode":"6600","adminCode1":"07","countryCode":"AT","lng":10.7333333,"placeName":"Breitenwang","lat":47.4833333,"adminName1":"Tirol"},
{"adminCode3":"70806","adminName2":"Politischer Bezirk Reutte","adminName3":"Ehenbichl","adminCode2":"708","postalcode":"6600","adminCode1":"07","countryCode":"AT","lng":10.7,"placeName":"Ehenbichl","lat":47.4666667,"adminName1":"Tirol"},
{"adminCode3":"70820","adminName2":"Politischer Bezirk Reutte","adminName3":"Lechaschau","adminCode2":"708","postalcode":"6600","adminCode1":"07","countryCode":"AT","lng":10.7,"placeName":"Lechaschau","lat":47.4833333,"adminName1":"Tirol"}
]
};
var ds = new NReports.LiveJsonDatasource(params, json);
Sample Template
var NReports = require('nreports');
var template = '<h1>Sample Report</h1><ul>{{#each postalcodes}}<li>{{placeName}}</li>{{/each}}</ul><h3>Report Footer here...</h3>';
Rendering the report
var NReports = require('nreports');
var rpt =
new Report("sample")
.addParameter("postalcode", "string", "6600")
.addParameter("country", "string", "AT")
.addParameter("username", "string", "demo")
.setTemplate(template); // given the sample template above
var ds = new NReports.LiveJsonDatasource(rpt.parameters, json); // given the JSON from the sample datasource above
var engine = new NReports.ReportEngine();
engine.setRuntime(new NReports.HandleBarsRuntime());
engine.render(rpt, ds, function(err, html){
if (err) console.error(err);
console.log(html);
});
0.28.0
8 years ago
0.27.0
8 years ago
0.26.2
8 years ago
0.26.1
8 years ago
0.26.0
8 years ago
0.0.25
9 years ago
0.0.24
9 years ago
0.0.23
9 years ago
0.0.22
9 years ago
0.0.21
9 years ago
0.0.20
9 years ago
0.0.19
9 years ago
0.0.18
9 years ago
0.0.17
9 years ago
0.0.16
10 years ago
0.0.15
10 years ago
0.0.14
10 years ago
0.0.13
10 years ago
0.0.12
10 years ago
0.0.11
10 years ago
0.0.10
10 years ago
0.0.9
10 years ago
0.0.8
10 years ago
0.0.7
10 years ago
0.0.6
10 years ago
0.0.5
10 years ago
0.0.4
10 years ago
0.0.2
10 years ago
0.0.1
10 years ago