Dashku npm
A wrapper to the dashku.com API. Now made to work with Dashku open source edition.
Install
npm install dashku
Running Tests
npm install
TEST_USER_PATH=/tmp npm run dashku-web generateTestUser
NODE_ENV=test npm run dashku-web regenerateApiKeyDb
NODE_ENV=test npm run dashku-web start
then
npm test
Example Usage
Require the library and set your api key.
var dashku = ; dashku;
NOTE: If you're using Dashku open source edition, make sure to call setApiUrl in order to point the API wrapper to your hosted version of Dashku.
Available Commands
- setApiKey
- setApiUrl
- getDashboards
- getDashboard
- createDashboard
- updateDashboard
- deleteDashboard
- createWidget
- updateWidget
- deleteWidget
- transmission
setApiKey
Allows you to provide your api key to the library. This needs to be called before any API request can be made. To get your API key, checkout the API docs in Dashku.
The callback function is optional.
// set the api key, then run your code dashku; // or alternatively, you can call the command like this: dashku;
setApiUrl
Allows you to define the api url to the library. This may come is useful if the API url changes, as it is currently pointing to Dashku.com's ip address.
The callback function is optional.
// set the api url, then run your code dashku; // or alternatively, you can call the command like this: dashku;
getDashboards
Retrieve all of your dashboards.
dashku;
getDashboard
Retrieves a dashboard, given the id of the dashboard.
dashku;
createDashboard
Creates a dashboard, given some attributes.
var attributes = name: "Sales dashboard" dashku;
updateDashboard
Updates a dashboard, given some attributes.
var attributes = _id: 'DASHBOARD_ID' name: "Account Management" dashku
deleteDashboard
Deletes a dashboard, given the id of the dashboard.
dashku;
createWidget
Creates a widget, given some attributes.
var attributes = dashboardId: 'DASHBOARD_ID' name: "My little widget" html: "<div id='bigNumber'></div>" css: "#bigNumber {\n padding: 10px;\n margin-top: 50px;\n font-size: 36pt;\n font-weight: bold;\n}" script: "// The widget's html as a jQuery object\nvar widget = this.widget;\n\n// This runs when the widget is loaded\nthis.on('load', function(data){\n console.log('loaded');\n});\n// This runs when the widget receives a transmission\nthis.on('transmission', function(data){\n widget.find('#bigNumber').text(data.bigNumber);\n});" json: '{\n "bigNumber":500\n}' dashku;
updateWidget
Updates an existing widget, given some attributes.
var attributes = dashboardId: 'DASHBOARD_ID' _id: 'WIDGET_ID' name: "King widget" dashku;
deleteWidget
Deletes an existing widget, given a dashboard id and widget id
dashku;
transmission
Transmits data to an existing widget, given an object that can be converted to JSON
var data = _id: "WIDGET_ID" bigNumber: 500 dashku;
Copyright
© 2014 Anephenix Ltd. Dashku-node is licensed under the MIT License.