Skip to content

Commit

Permalink
[v0.1.1]
Browse files Browse the repository at this point in the history
- Improvements for sending count data to the widget.
  • Loading branch information
rwatts3 committed Nov 5, 2015
1 parent ebf47a3 commit f092759
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 15 deletions.
33 changes: 20 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ This package is an extension of **Orion** and has a dependency on the `orionjs:b
```sh
$ meteor add rwatts:orionjs-dashboard
```
2. Register your widget by following **Example 1 Below** `Client`
2. Register your widget by following `Client`
3. Register access to the dashboard by setting `Options.set('showDashboard', true)` within your lib directory. If you have used the Example project from the Orion repository this will typically be in the *lib/options.js* file.
4. If using the default widget template follow the instructions in **Example 1 Below**
4. If using the default widget template follow the instructions below
5. Navigate to `/admin/dashboard/` to see your new widget.

## Register a custom Widget
Expand All @@ -27,19 +27,26 @@ For the best experience, if utilizing the default widgets, you will need to use

> A tutorial will be provided in the documentation demonstrating how to complete this task.
## Examples
### Example 1
## Default Widget Guide

### Publish Counts `Server`
```js
Meteor.publish('allProducts', function () {
Counts.publish(this, 'totalProducts', Products.find());
});
```

### Register Widget `Client`
```js
// Client
// Basic options passed to the default template
orion.dashboard.registerWidget({
template: 'default', // use default if you have not created a custom widget
count: Counts.get('somePublication'), // you must publish the counts from within the publication for them to be accessible from the widget.
baseColor: 'teal', // the base color of the widget
textColor: 'white', // sets the text color to white
label: 'Users', // sets the label of the widget
icon: 'books', // sets the icon for materialize use google's icon set for bootstrap use font awesome icons.
path: '/admin/users/' // sets the path the widget will navigate to upon clicking on it
template: 'default',
publication: 'allProducts',
count: 'totalProducts',
label: 'Products',
path: '/admin/products/',
baseColor: 'blue',
icon: 'shopping_cart',
textColor: 'white'
});
```

Expand Down
31 changes: 31 additions & 0 deletions orionjs_dashboard_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,36 @@ orion.dashboard.registerWidget = function (data){
ReactiveTemplates.helpers('orionDashboard', {
widgets: function () {
return orion.dashboard._widgets;
},
count: function () {
return Counter.get(this);
}
});

/**
* @property ReactiveTemplates.onCreated('orionDashboardWidget')
* @where {client}
* @public
* @return {undefined}
*
* Subscribes to the publication passed to the widget.
*/
ReactiveTemplates.onCreated('orionDashboardWidget', function () {
var data = this.data
this.subscribe(data.publication);
});

ReactiveTemplates.helpers('orionDashboardWidget', {
/**
* @method getCount
* @public
* @param {String} count The count passed to through registerWidget
* @return {Number} Returns the total counts from the publication.
*
* Returns the total count of records based on the Counter
* passed through the registerWidget function.
*/
getCount: function (count) {
return Counts.get(count);
}
});
2 changes: 1 addition & 1 deletion orionjs_dashboard_materialize.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<div class="row">
<div class="card-content {{textColor}}-text valign-wrapper">
<div class="col s6 m6">
<h3 class="valign center-align">{{count}} <small>Records</small></h3>
<h3 class="valign center-align">{{getCount count}} <small>Records</small></h3>
</div>
<div class="col s6 m6 center-align valign">
<i class="large material-icons hoverable">{{icon}}</i>
Expand Down
2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package.describe({
name: 'rwatts:orionjs-dashboard',
version: '0.1.0',
version: '0.1.1',
// Brief, one-line summary of the package.
summary: 'Adds a Dashboard and Widgets to Orion.',
// URL to the Git repository containing the source code for this package.
Expand Down

0 comments on commit f092759

Please sign in to comment.