repcombinator
v1.1.0
Published
[![Build Status](https://travis-ci.org/Markionium/Repcombinator.svg?branch=master)](https://travis-ci.org/Markionium/Repcombinator) [![npm version](https://badge.fury.io/js/repcombinator.svg)](https://badge.fury.io/js/repcombinator) [![Coverage Status](ht
Downloads
5
Readme
Repcombinator for DHIS2
How do i start Repcombinating?
Take the Repcombinator.js
file and include it in your html page.
<script src="Repcombinator.js"></script>
A repcombinator that is created by the Repcombinator
object on the window will allow you to load and render tables.
Creating the repcombinator instance
First we'll create one of those:
const repcombinator = Repcombinator({
apiUrl: 'https://play.dhis2.org/dev/api',
headers: {
Authorization: `Basic ${btoa('admin:district')}`
}
});
| Option | Default | Description |
|--------|----------| ---------|
| apiUrl
|../api
| Optional api url if you're not working against the same server, user it in a node script, or the api is not located at ../api
|
| render
| {}
| Placeholder for future render options. |
Additionally any other options will be used as Request init options.
Loading and rendering tables
From there we can ask for reports to combine by providing an array of valid UIDs.
repcombinator
// Load reports and combine them into a single report object
.getCombinedReportForReportUids(['GAfj7O21i26', 'osMFFm0FzWO'])
.then((report) => {
// Use the repcombinator.renderer to render the report into an element with the ID `report`
repcombinator.renderer
.into('#report') // Specify where to render with a DOM selector
.render(report); // render the report
})
.catch(error => {
// TODO: Handling errors is up to you!
});
CDN
<script src="https://unpkg.com/[email protected]/dist/Repcombinator.js"></script>
IE10+ Compatibility
To make it work on IE we'll need to add a fetch
and a Promise
polyfill.
https://github.com/github/fetch#installation
<script src="https://unpkg.com/[email protected]/promise.js"></script>
<script src="https://unpkg.com/[email protected]/fetch.js"></script>
<script src="https://unpkg.com/[email protected]/dist/Repcombinator.js"></script>