npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dashku

v0.1.2

Published

A wrapper to the dashku API

Downloads

1

Readme

Dashku npm

A wrapper to the dashku.com API. Now made to work with Dashku open source edition.

Build Status Coverage Status NPM version Dependency Status devDependency Status Code Climate

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 = require('dashku');
    dashku.setApiKey('YOUR_API_KEY', function(){
      
      // Fetches your dashboards
      dashku.getDashboards(function(response){
        if (response.status == "success") {
          console.log(response.dashboards);
        }
      });
      
    });

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.setApiKey('YOUR_API_KEY', function(){
      // run your code here      
    });
    
    // or alternatively, you can call the command like this:
    dashku.setApiKey('YOUR_API_KEY');

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.setApiUrl('API_URL', function(){
      // run your code here      
    });
    
    // or alternatively, you can call the command like this:
    dashku.setApiUrl('API_URL');

getDashboards

Retrieve all of your dashboards.


    dashku.getDashboards(function(response){
    
      // the response object will either be:
      //   {
      //      status: 		'success',
      //      dashboards: 	[…] // an array of dashboard objects
      //   }
      // 
      //   or
      //
      //   {
      //      status: 		'failure',
      //      reason: 		'REASON MESSAGE' // a message explaining what went wrong
      //   }
    
    });

getDashboard

Retrieves a dashboard, given the id of the dashboard.


    dashku.getDashboard('DASHBOARD_ID', function(response){
    
      // the response object will either be:
      //   {
      //      status: 		'success',
      //      dashboard: 	{…} // the dashboard object
      //   }
      // 
      //   or
      //
      //   {
      //      status: 		'failure',
      //      reason: 		'REASON MESSAGE' // a message explaining what went wrong
      //   }
      
    
    });

createDashboard

Creates a dashboard, given some attributes.


    var attributes = {
      name: "Sales dashboard"
    }

    dashku.createDashboard(attributes, function(response){

      // the response object will either be:
      //   {
      //      status: 		'success',
      //      dashboard: 	{…} // the newly-created dashboard object
      //   }
      // 
      //   or
      //
      //   {
      //      status: 		'failure',
      //      reason: 		'REASON MESSAGE' // a message explaining what went wrong
      //   }

    });

updateDashboard

Updates a dashboard, given some attributes.


    var attributes = {
      _id: 'DASHBOARD_ID',
      name: "Account Management"
    }
    
    dashku.updateDashboard(attributes, function(response){
    
      // the response object will either be:
      //   {
      //      status: 		'success',
      //      dashboard: 	{…} // the updated dashboard object
      //   }
      // 
      //   or
      //
      //   {
      //      status: 		'failure',
      //      reason: 		'REASON MESSAGE' // a message explaining what went wrong
      //   }
    
    })

deleteDashboard

Deletes a dashboard, given the id of the dashboard.


    dashku.deleteDashboard('DASHBOARD_ID', function(response){

      // the response object will either be:
      //   {
      //      status: 		'success',
      //      dashboardId: 	'…' // the id of the deleted dashboard 
      //   }
      // 
      //   or
      //
      //   {
      //      status: 		'failure',
      //      reason: 		'REASON MESSAGE' // a message explaining what went wrong
      //   }      

    });

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.createWidget(attributes,function(response){
    
      // the response object will either be:
      //   {
      //      status: 	'success',
      //      widget: 	{…} // the newly-created widget 
      //   }
      // 
      //   or
      //
      //   {
      //      status: 		'failure',
      //      reason: 		'REASON MESSAGE' // a message explaining what went wrong
      //   }      
    
    });

updateWidget

Updates an existing widget, given some attributes.


	var attributes = {
		dashboardId:  'DASHBOARD_ID',
		_id:		  'WIDGET_ID',	
		name:         "King widget"
	}
    
    dashku.updateWidget(attributes,function(response){
    
      // the response object will either be:
      //   {
      //      status: 	'success',
      //      widget: 	{…} // the updated widget 
      //   }
      // 
      //   or
      //
      //   {
      //      status: 		'failure',
      //      reason: 		'REASON MESSAGE' // a message explaining what went wrong
      //   }      
    
    });

deleteWidget

Deletes an existing widget, given a dashboard id and widget id


    dashku.deleteWidget('DASHBOARD_ID','WIDGET_ID',function(response){
      
      // the response object will either be:
      //   {
      //      status: 		'success',
      //      widgetId: 	'…' // the id of the deleted widget 
      //   }
      // 
      //   or
      //
      //   {
      //      status: 		'failure',
      //      reason: 		'REASON MESSAGE' // a message explaining what went wrong
      //   }
    
    });

transmission

Transmits data to an existing widget, given an object that can be converted to JSON


    var data = {
      _id: "WIDGET_ID",
      bigNumber: 500
    }

    dashku.transmission(data, function(response){
    
      // the response object will either be:
      //   {
      //      status: 		'success'
      //   }
      // 
      //   or
      //
      //   {
      //      status: 		'failure',
      //      reason: 		'REASON MESSAGE' // a message explaining what went wrong
      //   }
    
    });

Copyright

© 2014 Anephenix Ltd. Dashku-node is licensed under the MIT License.