diff --git a/client/config/design/app.js b/client/config/design/app.js
index 07a045d..b42887f 100644
--- a/client/config/design/app.js
+++ b/client/config/design/app.js
@@ -1,6 +1,7 @@
import Styles from 'config/styles';
import Templates from 'config/templates';
-import {hashHistory} from 'react-router';
+import createHistory from 'history/lib/createHashHistory';
+import { useQueries } from 'history';
import app from './../../app';
Promise.all([
@@ -8,5 +9,5 @@ Promise.all([
Styles.sync()
]).then(()=>{
jQuery('#compiling_layouts').remove();
- app(hashHistory);
+ app(useQueries(createHistory));
});
diff --git a/client/config/design/component_map.js b/client/config/design/component_map.js
index f599bcd..49e8dc3 100644
--- a/client/config/design/component_map.js
+++ b/client/config/design/component_map.js
@@ -1 +1 @@
-export const COMPONENT_MAP = {"about":"dashboard/about/about","energy":"dashboard/energy/energy","energy_graph":"dashboard/energy/graph/graph","energy_table":"dashboard/energy/table/table","house":"dashboard/house/house","layout":"dashboard/layout/layout","power_graph":"dashboard/power/graph/graph","power":"dashboard/power/power","power_table":"dashboard/power/table/table"}
\ No newline at end of file
+export const COMPONENT_MAP = {"energy":"dashboard/energy/energy","energy_graph":"dashboard/energy/graph/graph","energy_table":"dashboard/energy/table/table","layout":"dashboard/layout/layout","power_graph":"dashboard/power/graph/graph","power":"dashboard/power/power","power_table":"dashboard/power/table/table"}
\ No newline at end of file
diff --git a/client/config/design/style.js b/client/config/design/style.js
index 5a41f1a..5e71106 100644
--- a/client/config/design/style.js
+++ b/client/config/design/style.js
@@ -1,5 +1,4 @@
// Vendor Stylesheets
require('bootstrap/dist/css/bootstrap.min.css');
-require('font-awesome/css/font-awesome.min.css');
require(__dirname + '/../../d3/chart.scss');
diff --git a/client/config/design/styles.js b/client/config/design/styles.js
index 544c90f..741356b 100644
--- a/client/config/design/styles.js
+++ b/client/config/design/styles.js
@@ -9,10 +9,13 @@ class Styles {
var done = new Promise((fnResolve, fnReject)=>{
Styles.addCss(view, fnResolve)
}).then((result)=>{
- css += result;
+ if (result) css += result;
});
all.push(done);
}
+ var app_styles =
+ all.push(Styles.addAppCss()
+ .then((result)=>{ if(result)css += result; }));
return Promise.all(all)
.then(()=>{
jQuery('head').append(``);
@@ -31,6 +34,19 @@ class Styles {
});
}
+ static addAppCss(){
+ return new Promise((fnResolve, fnReject)=>{
+ jQuery.ajax({
+ url: '/dashboard/app.scss'
+ }).then((scss)=>{
+ var sass = new Sass();
+ sass.compile(scss, (result, a)=>{
+ fnResolve(result.text);
+ });
+ });
+ });
+ }
+
}
export default Styles;
diff --git a/client/config/design/templates.js b/client/config/design/templates.js
index 7a94949..d647df7 100644
--- a/client/config/design/templates.js
+++ b/client/config/design/templates.js
@@ -1,4 +1,4 @@
-import rt from 'react-templates';
+import react_templates from 'react-templates/dist/reactTemplates';
import React from 'react';
import _ from 'lodash';
@@ -8,33 +8,36 @@ var TEMPLATES = {};
class Templates {
+ static forComponent(name){
+ return TEMPLATES[name];
+ }
+
static sync(){
- var all = [];
+ var all = [],
+ eval_context = {
+ '_': _,
+ 'React': React
+ };
+ for (var component_name in COMPONENT_MAP){
+ var component = require('./../../' + COMPONENT_MAP[component_name] + '.component');
+ eval_context[component.NAME] = component;
+ }
for (var component_name in COMPONENT_MAP){
var done = new Promise((fnResolve, fnReject)=>{
- Templates.evalTemplate(component_name, fnResolve);
+ Templates.evalTemplate(component_name, eval_context, fnResolve);
});
all.push(done);
}
return Promise.all(all);
}
- static forComponent(name){
- return TEMPLATES[name];
- }
-
- static evalTemplate(component_name, fnResolve){
+ static evalTemplate(component_name, eval_context, fnResolve){
jQuery.ajax({
url: COMPONENT_MAP[component_name] + '.rt'
}).done((template)=>{
- var code = rt.convertTemplateToReact(template, {modules: 'none', name: component_name}),
- eval_context = {};
- code = code.replace('var ' + component_name + ' = ', 'eval_context.' + component_name + ' = ');
- new Function('with(this){ ' + code + ' } ').call({
- eval_context: eval_context,
- '_': _,
- 'React': React
- });
+ var code = react_templates.convertTemplateToReact(template, {modules: 'none', name: component_name}),
+ code = code.replace('var ' + component_name + ' = ', 'this.' + component_name + ' = ');
+ new Function('with(this){ ' + code + ' } ').call(eval_context);
TEMPLATES[component_name] = eval_context[component_name];
fnResolve();
});
diff --git a/client/config/test/webpack.js b/client/config/test/webpack.js
deleted file mode 100644
index c71a86c..0000000
--- a/client/config/test/webpack.js
+++ /dev/null
@@ -1,55 +0,0 @@
-import webpack from 'webpack';
-
-module.exports = {
- entry: {
- app: __dirname + '/../../config/development/app',
- style: __dirname + '/../../config/development/style'
- },
- output: {
- filename: '[name].js',
- path: __dirname + '/../../build/development'
- },
- module: {
- loaders: [
- {
- test: /\.scss$/,
- loaders: ['style', 'raw', 'sass']
- }, {
- test: /\.css$/,
- loaders: ['style', 'raw']
- }, {
- test: /\.js$/,
- loader: 'babel'
- }, {
- test: /\.json$/,
- loader: 'json'
- }, {
- test: /\.rt/,
- loader: "react-templates-loader?targetVersion=0.14.0"
- }
- ]
- },
- sassLoader: {
- includePaths: [__dirname + '/../..', __dirname + '/../../../node_modules']
- },
- plugins: [
- new webpack.ProvidePlugin({
- $: "jquery",
- jQuery: "jquery",
- "window.jQuery": "jquery"
- }),
- new webpack.ProvidePlugin({
- d3: "d3",
- "window.d3": "d3"
- })
- ],
- node: {
- fs: "empty"
- },
- resolve: {
- alias: {
- api: __dirname + '/../../api/development',
- config: __dirname + '/../../config/development'
- }
- }
-}
diff --git a/client/dashboard/energy/energy.component.js b/client/dashboard/energy/energy.component.js
index 36d31d0..162ff31 100644
--- a/client/dashboard/energy/energy.component.js
+++ b/client/dashboard/energy/energy.component.js
@@ -35,6 +35,6 @@ class EnergyComponent extends React.Component {
return energyRt.call(this);
}
}
-EnergyComponent.NAME = 'EnergyComponent'
+EnergyComponent.NAME = 'Energy';
module.exports = EnergyComponent;
diff --git a/client/dashboard/energy/graph/graph.component.js b/client/dashboard/energy/graph/graph.component.js
index 9c3ce72..7a76d79 100644
--- a/client/dashboard/energy/graph/graph.component.js
+++ b/client/dashboard/energy/graph/graph.component.js
@@ -70,4 +70,6 @@ class GraphComponent extends React.Component {
}
+GraphComponent.NAME = 'EnergyGraph';
+
module.exports = GraphComponent;
diff --git a/client/dashboard/energy/table/table.component.js b/client/dashboard/energy/table/table.component.js
index ed6b20c..1ca20e1 100644
--- a/client/dashboard/energy/table/table.component.js
+++ b/client/dashboard/energy/table/table.component.js
@@ -20,4 +20,6 @@ class TableComponent extends React.Component {
}
+TableComponent.NAME = 'EnergyTable';
+
module.exports = TableComponent;
diff --git a/client/dashboard/layout/layout.component.js b/client/dashboard/layout/layout.component.js
index 32799bb..7a04d09 100644
--- a/client/dashboard/layout/layout.component.js
+++ b/client/dashboard/layout/layout.component.js
@@ -26,6 +26,14 @@ class LayoutComponent extends React.Component {
return this.state_manager && this.state_manager.state.house;
}
+ get should_show_energy_data(){
+ return this.state.dataset === 'energy' && this.house && this.house.energy_data;
+ }
+
+ get should_show_power_data(){
+ return this.state.dataset === 'power' && this.house && this.house.power_data;
+ }
+
componentDidMount() {
var layout = this;
House.ensureHouses().then((houses)=>{
@@ -83,4 +91,6 @@ class LayoutComponent extends React.Component {
}
}
-export default LayoutComponent;
+LayoutComponent.NAME = 'Layout';
+
+module.exports = LayoutComponent;
diff --git a/client/dashboard/layout/layout.rt b/client/dashboard/layout/layout.rt
index 956db9d..46db55a 100644
--- a/client/dashboard/layout/layout.rt
+++ b/client/dashboard/layout/layout.rt
@@ -1,5 +1,5 @@
-