├── .bowerrc
├── .gitignore
├── LICENSE
├── README.md
├── app
├── images
│ └── .gitkeep
├── index.html
├── scripts
│ ├── actions
│ │ └── itemActions.js
│ ├── components
│ │ ├── rdb-board.jsx
│ │ └── rdb-sidebar.jsx
│ ├── config
│ │ └── rdb-default.config.js
│ ├── factories
│ │ ├── rdb-board-factory.jsx
│ │ ├── rdb-errorpage-factory.jsx
│ │ └── rdb-widget-factory.jsx
│ ├── helper
│ │ ├── rdb-config-validator.js
│ │ ├── rdb-font-loader.js
│ │ ├── rdb-styler.js
│ │ └── rdb-utils.js
│ ├── main.js
│ ├── mixins
│ │ ├── rdb-chart-mixin.js
│ │ └── rdb-widget-mixin.jsx
│ ├── pages
│ │ ├── rdb-app.jsx
│ │ └── rdb-errorpage.jsx
│ ├── routes.jsx
│ ├── stores
│ │ └── itemStore.js
│ └── widgets
│ │ ├── barchart
│ │ └── index.jsx
│ │ ├── iframe
│ │ └── index.jsx
│ │ ├── linechart
│ │ └── index.jsx
│ │ ├── list
│ │ └── index.jsx
│ │ ├── map
│ │ └── index.jsx
│ │ ├── rdb-base-widget.jsx
│ │ └── todos
│ │ ├── index.jsx
│ │ ├── style.css
│ │ ├── todo.jsx
│ │ ├── todosActions-factory.js
│ │ └── todosStore-factory.js
└── stylus
│ ├── helper.styl
│ ├── main.styl
│ ├── normalize.styl
│ └── widgets.styl
├── bower.json
├── gulpfile.js
├── package.json
├── rdb.config.js
└── webpack.config.js
/.bowerrc:
--------------------------------------------------------------------------------
1 | {
2 | "directory" : "app/bower_components"
3 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 | app/bower_components
4 | app/bundles
5 | *.log
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 webkid
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # React-Dashboard (RDB)
2 |
3 | **This project is at an early stage of development!**
4 |
5 | RDB helps you to generate dashboard prototypes very quickly with "configuration over code".
6 | You just need to specify the boards and the belonging widgets in the [RDB config file](#rdb-config-file) file and you are ready to build your dashboard.
7 | It's also easy to extend RDB by [writing your own widgets](#writing-your-own-widgets).
8 |
9 | RDB is based on our [react starterkit](https://github.com/wbkd/react-starterkit).
10 |
11 | * [Get Started](#get-started)
12 | * [Documentation](#documentation)
13 | * [Extend RDB](#extend-rdb)
14 |
15 |
16 | # Get Started
17 |
18 | #### Clone RDB
19 |
20 | ```
21 | $ git clone https://github.com/wbkd/react-dashboard.git && cd react-dashboard
22 | ```
23 |
24 | #### Installation
25 |
26 | Install all dependencies.
27 |
28 | ```
29 | $ npm install
30 | ```
31 |
32 | #### Development
33 |
34 | Builds the application and starts a webserver with livereload. By default the webserver starts at port 1337.
35 | You can define a port with `$ gulp --port 3333`.
36 |
37 | ```
38 | $ gulp
39 | ```
40 |
41 | #### Build
42 |
43 | Builds a minified version of the application in the dist folder.
44 |
45 | ```
46 | $ gulp build --type production
47 | ```
48 |
49 | # Documentation
50 |
51 | ### RDB config file
52 |
53 | You can find the [config file](rdb.config.js) in the root folder.
54 | It has three attributes (name, [style](#style) and [boards](#boards)).
55 | The name is displayed at the top of the sidebar as the title of the dashboard.
56 | Style indicates stuff like the font, colors etc and under boards (the important part) you configure the different boards and their related [widgets](#widgets).
57 | If you do not specify a property we use the default one, you can find in the [default config](app/scripts/config/rdb-default.config.js).
58 |
59 | **Properties:**
60 |
61 | * `name` String that defines the dashboard title. Default: 'RDB Dashboard'.
62 | * `style` Object with [style](#style) properties
63 | * `boards` Array with [boards](#boards)
64 |
65 | **Example config file:**
66 |
67 | ```javascript
68 |
69 | module.exports = {
70 | name: 'Awesome dashboard',
71 | style: {
72 | font : 'Roboto',
73 | titlebg : '#fff',
74 | titlecol : 'red'
75 | },
76 | boards: [
77 | {
78 | name: 'Site A',
79 | widgets: [
80 | {type : 'map', properties: { center : [52.25, 13.4] }},
81 | {type : 'line', properties: { data : jsonObjA }}
82 | ]
83 | },
84 | {
85 | name: 'Site B',
86 | widgets: [
87 | {type : 'map', properties: { center : [52.25, 13.4] }},
88 | {type : 'bar', properties: { data : jsonObjB }}
89 | ]
90 | }
91 | ]
92 | };
93 |
94 | ```
95 |
96 | ### Style
97 |
98 | For now it's only possible to tweak some colors and change the font type.
99 | You can find the available fonts and the font loading logic in the [Font Loader](app/scripts/helper/rdb-font-loader.js).
100 | The styles are applied in the [Styler Module](app/scripts/helper/rdb-styler.js).
101 |
102 | Available fonts are:
103 | * Droid Sans
104 | * Lato
105 | * PT Sans
106 | * Roboto
107 | * Open Sans
108 |
109 | **Properties:**
110 |
111 | * `font` Font type. Default: `'PT Sans'`
112 | * `titlebg` Background color of the title. Default: `'#eeeeee'`.
113 | * `titlecol` Font color of title. Default: `'#222222'`
114 | * `sidebarbg` Background color of the sidebar. Default: `'#303030'`
115 | * `sidebarcol` Font color of the sidebar. Default: `'#f4f4f4'`
116 | * `boardbg` Background color of the boards. Default: `'#f4f4f4'`
117 | * `boardcol` Font color of the boards. Default: `'#222222'`
118 | * `widgetbg` Background color of the widgets. Default: `'#ffffff'`
119 | * `widgetcol` Font color of the widgets. Default: `'#222222'`
120 |
121 |
122 | **Example style:**
123 |
124 | ```javascript
125 | style: {
126 | font : 'PT Sans',
127 | titlebg : '#eeeeee',
128 | titlecol : '#222222',
129 | sidebarbg : '#303030',
130 | sidebarcol : '#f4f4f4',
131 | boardbg : '#f4f4f4',
132 | boardcol : '#222222'
133 | }
134 |
135 | ```
136 |
137 |
138 | ### Boards
139 |
140 | The boards property is an array with board objects. A board object has a name and and several widgets.
141 | When you build the dashboard, the several boards are dynamically generated in [Routes](app/scripts/routes.jsx) with the help of the [Board Factory](app/scripts/factories/rdb-board-factory.jsx).
142 | The [Board Component](app/scripts/components/rdb-board.jsx) then displays the title and loads its widgets.
143 |
144 | **Example Board:**
145 |
146 | ```javascript
147 |
148 | {
149 | name: 'Site A',
150 | widgets: [
151 | {type : 'map', properties: { center : [52.25, 13.4] }},
152 | {type : 'linechart', properties: { data : jsonObj }}
153 | ]
154 | }
155 |
156 | ```
157 |
158 | ### Widgets
159 |
160 | The widgets are defined in the board objects. A widget object has a type and properties.
161 | The type specifies the widget type and the properties define all data that get passed to the widget.
162 | Widgets are created in the [Board Component](app/scripts/components/rdb-board.jsx) with the help of [Widget Factory](app/scripts/factories/rdb-widget-factory.jsx).
163 |
164 | For now there are these widgets available:
165 |
166 | * [Map Widget](#map-widget)
167 | * [Bar Chart Widget](#bar-chart-widget)
168 | * [Line Chart Widget](#line-chart-widget)
169 | * [IFrame Widget](#iframe-widget)
170 |
171 | ### Map Widget
172 |
173 | The map widget is based on [Leaflet](http://leafletjs.com). It displays a map with a certain center and markers with tooltips.
174 |
175 | **Properties:**
176 |
177 | * `title` String that defines the widget title. Default: No Title.
178 | * `center` Array with Coordinates. Default: `[0,0]`
179 | * `zoom` Integer with the starting zoom level. Default: `13`.
180 | * `wmsTileLayerUrl` String that declares the WMS tile layer. Default: `http://tile.stamen.com/toner/{z}/{x}/{y}.png`.
181 | * `marker` Array with marker objects. Default : No marker.
182 | * `latlng` Array with Coordinates.
183 | * `text` String with tooltip content. Default: No content.
184 |
185 | **Example Map Widget Configuration:**
186 |
187 | ```javascript
188 |
189 | { type: 'map',
190 | properties: {
191 | title: 'map title',
192 | center: [52.52, 13.4],
193 | zoom : 10,
194 | marker: [
195 | { latlng: [52.52, 13.4], text : 'This is a marker.'},
196 | {latlng: [52.55, 13.35]}
197 | ]
198 | }
199 | }
200 |
201 | ```
202 | Source: [Map Widget](app/scripts/widgets/map/index.jsx)
203 |
204 |
205 | #### Bar Chart Widget
206 |
207 | The bar chart widget is based on [c3](http://c3js.org).
208 |
209 | **Properties:**
210 |
211 | * `title` String that defines the widget title. Default: No Title.
212 | * `data` Array with JSON data. Default: [{ alpha: 100, beta : 120, gamma: 110 },{ alpha: 120, beta : 110, gamma: 90 },{ alpha: 75, beta : 100,gamma: 80 }]
213 | * `keys` Array with keys you want to display. Default: Every key found in the passed data.
214 |
215 | **Example Bar Chart Widget Configuration:**
216 |
217 | ```javascript
218 |
219 | {
220 | type: 'barchart',
221 | properties: {
222 | title : 'A Bar Chart \o/',
223 | data: [{ alpha: 100, beta : 120, gamma: 110 },{ alpha: 120, beta : 110, gamma: 90 },{ alpha: 75, beta : 100,gamma: 80 }],
224 | keys : ['alpha', 'gamma']
225 | }
226 | }
227 |
228 | ```
229 | Source: [Bar Chart Widget](app/scripts/widgets/bar/index.jsx)
230 |
231 | #### Line Chart Widget
232 |
233 | Almost the same configuration as the bar chart widget but type is equal `linechart` in this case.
234 |
235 | ```javascript
236 |
237 | {
238 | type: 'linechart',
239 | properties: {
240 | title : 'A Line Chart \o/',
241 | data: [{ alpha: 100, beta : 120, gamma: 110 },{ alpha: 120, beta : 110, gamma: 90 },{ alpha: 75, beta : 100,gamma: 80 }],
242 | keys : ['beta']
243 | }
244 | }
245 |
246 | ```
247 |
248 | Source: [Line Chart Widget](app/scripts/widgets/line/index.jsx)
249 |
250 | #### IFrame Widget
251 |
252 | Displays a certain webpage.
253 |
254 | **Properties:**
255 | * `title` String that defines the widget title. Default: No Title.
256 | * `src` String that defines the url you want to display. Default: 'http://news.ycombinator.com'.
257 |
258 | **Example IFrame Widget Configuration:**
259 |
260 | ```javascript
261 | {
262 | type: 'iframe',
263 | properties: {
264 | title : 'True Reddit',
265 | src: 'http://www.reddit.com/r/TrueReddit/'
266 | }
267 | }
268 | ```
269 |
270 | Source: [IFrame Widget](app/scripts/widgets/iframe/index.jsx)
271 |
272 |
273 |
274 | # Extend RDB
275 |
276 | #### Widgets
277 |
278 | Every widgets ships its own dependencies. You can use the css-loader to load CSS dependencies.
279 | The map widget for example loads leaflet.js and the related CSS file:
280 |
281 | ```javascript
282 |
283 | var L = require('leaflet');
284 | require('../../../../node_modules/leaflet/dist/leaflet.css');
285 |
286 | ```
287 |
288 | If we want to check out a widget we don't want to specify any properties. We just want to see the widget.
289 | Because of that it's important that the widget has at least some default properties, so that something get rendered if we add the widget to a board.
290 |
291 |
292 | #### Writing your own Widgets
293 |
294 | Todo
295 |
296 |
297 |
298 |
--------------------------------------------------------------------------------
/app/images/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wbkd/dashboard-prototyper/efbf098bc4c978f7ccc0f70ae1f539f4f12deacb/app/images/.gitkeep
--------------------------------------------------------------------------------
/app/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | webkid react starterkit
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/scripts/actions/itemActions.js:
--------------------------------------------------------------------------------
1 | var Reflux = require('reflux');
2 |
3 | var ItemActions = Reflux.createActions([
4 | 'loadItems',
5 | 'loadItemsSuccess',
6 | 'loadItemsError'
7 | ]);
8 |
9 | ItemActions.loadItems.preEmit = function(data){
10 | // make your api call/ async stuff here
11 | // we use setTimeout for faking async behaviour here
12 | setTimeout(function(){
13 | var items = ['Foo', 'Bar', 'Lorem'];
14 | ItemActions.loadItemsSuccess(items);
15 |
16 | // on error
17 | // ItemActions.loadItemsError('an error occured');
18 | },500);
19 | };
20 |
21 | module.exports = ItemActions;
--------------------------------------------------------------------------------
/app/scripts/components/rdb-board.jsx:
--------------------------------------------------------------------------------
1 | /**
2 | * The Board renders its title and the belonging widgets.
3 | */
4 |
5 | var React = require('react');
6 | var widgetFactory = require('../factories/rdb-widget-factory.jsx');
7 |
8 | var Board = React.createClass({
9 |
10 | render: function() {
11 |
12 | var widgets = this.props.widgets.map(function(widget,i){
13 | return widgetFactory.create(widget);
14 | });
15 |
16 | return (
17 |
18 |
{this.props.name}
19 | { widgets }
20 |
21 | );
22 | }
23 |
24 | });
25 |
26 | module.exports = Board;
--------------------------------------------------------------------------------
/app/scripts/components/rdb-sidebar.jsx:
--------------------------------------------------------------------------------
1 | /**
2 | * The Sidebar displays the links to the boards and the title of the dashboard
3 | * application.
4 | */
5 |
6 | var React = require('react');
7 | var Link = require('react-router').Link;
8 | var utils = require('rdbutils');
9 | var rdbConf = require('rdbconf');
10 |
11 | var Sidebar = React.createClass({
12 |
13 | render: function() {
14 |
15 | var navItems = rdbConf.boards.map(function(board,i){
16 |
17 | var boardName = board.name,
18 | boardUrl = utils.boardNameToUrl(boardName);
19 |
20 | return { boardName }
21 | });
22 |
23 | return (
24 |
25 |
{ rdbConf.name || 'RDB Dashboard' }
26 |
27 |
30 |
31 | );
32 | }
33 |
34 | });
35 |
36 | module.exports = Sidebar;
--------------------------------------------------------------------------------
/app/scripts/config/rdb-default.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: 'RDB Dashboard',
3 | style: {
4 | font: 'PT Sans',
5 | titlebg : '#eeeeee',
6 | titlecol : '#222222',
7 | sidebarbg : '#303030',
8 | sidebarcol : '#f4f4f4',
9 | boardbg : '#f4f4f4',
10 | boardcol : '#222222',
11 | widgetbg: '#fff',
12 | widgetcol: '#222'
13 | },
14 | boards: []
15 | };
--------------------------------------------------------------------------------
/app/scripts/factories/rdb-board-factory.jsx:
--------------------------------------------------------------------------------
1 | /**
2 | * Factory that creates Board objects.
3 | */
4 |
5 | var React = require('react');
6 | var Board = require('../components/rdb-board.jsx');
7 |
8 | module.exports.create = function(props) {
9 | return React.createClass({
10 | render: function() {
11 | return
12 | }
13 | })
14 | };
--------------------------------------------------------------------------------
/app/scripts/factories/rdb-errorpage-factory.jsx:
--------------------------------------------------------------------------------
1 | /**
2 | * Factory that creates error pages.
3 | */
4 |
5 | var React = require('react');
6 | var Error = require('../pages/rdb-errorpage.jsx');
7 |
8 | module.exports.create = function(props) {
9 | return React.createClass({
10 | render: function() {
11 | return
12 | }
13 | })
14 | };
--------------------------------------------------------------------------------
/app/scripts/factories/rdb-widget-factory.jsx:
--------------------------------------------------------------------------------
1 | /**
2 | * Factory that creates Widget objects with a unique key.
3 | */
4 |
5 | var React = require('react');
6 | var utils = require('rdbutils');
7 | var shortId = require('shortid');
8 |
9 | module.exports.create = function(widget) {
10 | var Widget = require('../widgets/' + widget.type + '/index.jsx');
11 |
12 | if(utils.isUndefined(widget.properties)){
13 | widget.properties = {};
14 | }
15 |
16 | widget.properties._id = widget.type + '-' + shortId.generate();
17 |
18 | return
19 | };
--------------------------------------------------------------------------------
/app/scripts/helper/rdb-config-validator.js:
--------------------------------------------------------------------------------
1 | // Do we need something like this?
2 |
3 | var utils = require('rdbutils');
4 |
5 | module.exports.validate = function(config){
6 |
7 | if(utils.isUndefined(config)){
8 | return false;
9 | }
10 |
11 | if(utils.isUndefined(config.boards)){
12 | config.boards = [];
13 | }
14 |
15 | if(!utils.isUndefined(config.name) && typeof config.name !== 'String' ){
16 | return false;
17 | }
18 |
19 | return config;
20 | }
--------------------------------------------------------------------------------
/app/scripts/helper/rdb-font-loader.js:
--------------------------------------------------------------------------------
1 | // available fonts
2 | var fonts = {
3 | 'Droid Sans' : 'Droid+Sans:400,700:latin',
4 | 'Lato' : 'Lato:400,700:latin',
5 | 'PT Sans': 'PT+Sans:400,700:latin',
6 | 'Roboto': 'Roboto:400,700:latin',
7 | 'Open Sans': 'Open+Sans:400,700:latin'
8 | };
9 |
10 | var defaultFont = require('rdbDefault').style.font;
11 |
12 | /**
13 | * Loads related font. If the passed font name is not in the fonts list,
14 | * we load the default font.
15 | *
16 | * @param {string} fontName Name of the font we want to load. Has to be
17 | * in the 'fonts' list.
18 | */
19 | module.exports.loadFont = function (fontName) {
20 |
21 | var fontToLoad = fonts[fontName];
22 |
23 | if (typeof fontToLoad === 'undefined') {
24 | fontName = defaultFont;
25 | fontToLoad = fonts[fontName];
26 | }
27 |
28 | loadWebfont(fontToLoad);
29 |
30 | document.body.style.fontFamily = '"' + fontName + '", sans-serif';
31 | };
32 |
33 |
34 | /**
35 | * Helper method that downloads google web font.
36 | * @param {string} font Font identifier and font weights.
37 | */
38 | function loadWebfont(font){
39 | window.WebFontConfig = {
40 | google: {
41 | families: [font]
42 | }
43 | };
44 |
45 | var wf = document.createElement('script');
46 | wf.src = ('https:' == document.location.protocol ? 'https' : 'http') + '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
47 | wf.type = 'text/javascript';
48 | wf.async = 'true';
49 |
50 | var s = document.getElementsByTagName('script')[0];
51 | s.parentNode.insertBefore(wf, s);
52 | }
--------------------------------------------------------------------------------
/app/scripts/helper/rdb-styler.js:
--------------------------------------------------------------------------------
1 | /**
2 | * This module merges the default with config style and creates a styesheet
3 | * with the certain css rules. We create a stylesheet instead of applying it
4 | * to the elements via js, because we don't want to wait until the components
5 | * got loaded.
6 | *
7 | */
8 |
9 | var dom = require('rdbutils').dom;
10 | var merge = require('merge');
11 | var fontLoader = require('./rdb-font-loader');
12 |
13 | var defaultStyle = require('rdbDefault').style;
14 |
15 | /*
16 | * Merges the default with config style and creates a styesheet with the certain
17 | * css rules.
18 | *
19 | * @param {object} newStyle Custom Style object
20 | */
21 | module.exports.applyStyles = function(newStyle){
22 |
23 | var style = merge(defaultStyle, newStyle);
24 |
25 | createStylesheet(style);
26 | fontLoader.loadFont(style.fontName);
27 | }
28 |
29 | function createStylesheet(style){
30 | // TODO: is there a better way to apply the styles?!
31 |
32 | var stylesheet = dom.create('style');
33 |
34 | stylesheet.type = 'text/css';
35 | stylesheet.innerHTML = [
36 | getCSSRule('.rdb-title', style.titlebg, style.titlecol),
37 | getCSSRule('.rdb-sidebar a', style.sidebarbg, style.sidebarcol),
38 | getCSSRule('.rdb-sidebar', style.sidebarbg, style.sidebarcol),
39 | getCSSRule('body', style.boardbg, style.boardcol),
40 | getCSSRule('.rdb-widget-content', style.widgetbg, style.widgetcol)
41 | ].join('');
42 |
43 | dom.get('head').appendChild(stylesheet);
44 | }
45 |
46 | /**
47 | * Helper method to create CSS Rule.
48 | *
49 | * @param {string} selector Name of the selector.
50 | * @param {string} bg Value of the background style
51 | * @param {string} col Value of the color style
52 | * @returns {string} CSS Rule
53 | */
54 | function getCSSRule(selector, bg, col){
55 | return selector + '{ color :' + col + '; background: ' + bg + ';}';
56 | }
57 |
58 |
--------------------------------------------------------------------------------
/app/scripts/helper/rdb-utils.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Some helper methods we use all over the application.
3 | */
4 |
5 | module.exports = {
6 |
7 | /**
8 | * Translates a name of a board to the related URL.
9 | * @param {string} boardName Name of the board
10 | * @returns {string} URL of the passed board name.
11 | */
12 | boardNameToUrl : function(boardName){
13 | return boardName.toLowerCase().replace(/\s/g,'-');
14 | },
15 |
16 | isUndefined: function(obj){
17 | return typeof obj === 'undefined';
18 | },
19 |
20 | /**
21 | * Helper methods to work with the DOM.
22 | */
23 | dom : {
24 | create: function(element){
25 | return document.createElement(element);
26 | },
27 | get : function(selector){
28 | return document.querySelector(selector);
29 | },
30 | getAll : function(selector){
31 | return document.querySelectorAll(selector);
32 | }
33 |
34 | }
35 |
36 | };
--------------------------------------------------------------------------------
/app/scripts/main.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Entry point of RDB.
3 | */
4 |
5 | var React = require('react');
6 | var Router = require('react-router');
7 | var routes = require('./routes.jsx');
8 |
9 | var style = require('rdbconf').style;
10 |
11 | require('./helper/rdb-styler').applyStyles(style);
12 |
13 | Router.run(routes, function (Handler) {
14 | React.render(, document.body);
15 | });
--------------------------------------------------------------------------------
/app/scripts/mixins/rdb-chart-mixin.js:
--------------------------------------------------------------------------------
1 | var c3 = require('c3');
2 |
3 | require('../../../node_modules/c3/c3.css');
4 |
5 | var ChartMixin = {
6 | createChart: function (options) {
7 | // TODO: find a better way to get the keys.
8 | var keys = this.props.keys || Object.keys(this.props.data[0]);
9 |
10 | return c3.generate({
11 | bindto: '#' + this.props._id,
12 | data: {
13 | json: this.props.data,
14 | type: options.type,
15 | keys: {
16 | value: keys
17 | }
18 | }
19 | });
20 | }
21 | };
22 |
23 | module.exports = ChartMixin;
--------------------------------------------------------------------------------
/app/scripts/mixins/rdb-widget-mixin.jsx:
--------------------------------------------------------------------------------
1 | /**
2 | * This Mixin holds functions and properties that are used by all widgets.
3 | *
4 | */
5 |
6 | var React = require('react');
7 |
8 | var WidgetMixin = {
9 |
10 | getDefaultProps: function(){
11 | return {
12 | title : ''
13 | }
14 | },
15 |
16 | propTypes: {
17 | title : React.PropTypes.string
18 | },
19 |
20 | getTitle : function(){
21 | return this.props.title ?