update design bundle for router
This commit is contained in:
1
client/config/design/component_map.js
Normal file
1
client/config/design/component_map.js
Normal file
@@ -0,0 +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"}
|
||||
@@ -1,16 +1,11 @@
|
||||
const STYLE_ROUTES = Object.freeze({
|
||||
energy: 'dashboard/energy/energy.scss',
|
||||
layout: 'dashboard/layout/layout.scss',
|
||||
power: 'dashboard/power/power.scss',
|
||||
app: 'dashboard/app.scss'
|
||||
});
|
||||
import {COMPONENT_MAP} from './component_map';
|
||||
|
||||
class Styles {
|
||||
|
||||
static sync(){
|
||||
var all = [],
|
||||
css = '';
|
||||
for (var view in STYLE_ROUTES){
|
||||
for (var view in COMPONENT_MAP){
|
||||
var done = new Promise((fnResolve, fnReject)=>{
|
||||
Styles.addCss(view, fnResolve)
|
||||
}).then((result)=>{
|
||||
@@ -26,7 +21,7 @@ class Styles {
|
||||
|
||||
static addCss(view, fnResolve){
|
||||
return jQuery.ajax({
|
||||
url: STYLE_ROUTES[view]
|
||||
url: COMPONENT_MAP[view] + '.scss'
|
||||
}).then((scss)=>{
|
||||
var sass = new Sass();
|
||||
if (!scss) return fnResolve("");
|
||||
|
||||
1
client/config/design/template_map.js
Normal file
1
client/config/design/template_map.js
Normal file
@@ -0,0 +1 @@
|
||||
export const TEMPLATE_MAP = {"about":"dashboard/about/about.rt","energy":"dashboard/energy/energy.rt","energy_graph":"dashboard/energy/graph/graph.rt","energy_table":"dashboard/energy/table/table.rt","house":"dashboard/house/house.rt","layout":"dashboard/layout/layout.rt","power_graph":"dashboard/power/graph/graph.rt","power":"dashboard/power/power.rt","power_table":"dashboard/power/table/table.rt"}
|
||||
@@ -2,14 +2,7 @@ import rt from 'react-templates';
|
||||
import React from 'react';
|
||||
import _ from 'lodash';
|
||||
|
||||
import Energy from './../../dashboard/energy/energy';
|
||||
import Power from './../../dashboard/power/power';
|
||||
|
||||
const TEMPLATE_ROUTES = Object.freeze({
|
||||
energy: 'dashboard/energy/energy.rt',
|
||||
layout: 'dashboard/layout/layout.rt',
|
||||
power: 'dashboard/power/power.rt'
|
||||
});
|
||||
import {COMPONENT_MAP} from './component_map';
|
||||
|
||||
var TEMPLATES = {};
|
||||
|
||||
@@ -17,32 +10,32 @@ class Templates {
|
||||
|
||||
static sync(){
|
||||
var all = [];
|
||||
for (var view in TEMPLATE_ROUTES){
|
||||
for (var component_name in COMPONENT_MAP){
|
||||
var done = new Promise((fnResolve, fnReject)=>{
|
||||
Templates.evalTemplate(view, fnResolve);
|
||||
Templates.evalTemplate(component_name, fnResolve);
|
||||
});
|
||||
all.push(done);
|
||||
}
|
||||
return Promise.all(all);
|
||||
}
|
||||
|
||||
static forComponent(view){
|
||||
return TEMPLATES[view];
|
||||
static forComponent(name){
|
||||
return TEMPLATES[name];
|
||||
}
|
||||
|
||||
static evalTemplate(view, fnResolve){
|
||||
static evalTemplate(component_name, fnResolve){
|
||||
jQuery.ajax({
|
||||
url: TEMPLATE_ROUTES[view]
|
||||
url: COMPONENT_MAP[component_name] + '.rt'
|
||||
}).done((template)=>{
|
||||
var code = rt.convertTemplateToReact(template, {modules: 'none', name: view}),
|
||||
var code = rt.convertTemplateToReact(template, {modules: 'none', name: component_name}),
|
||||
eval_context = {};
|
||||
code = code.replace('var ' + view + ' = ', 'eval_context.' + view + ' = ');
|
||||
code = code.replace('var ' + component_name + ' = ', 'eval_context.' + component_name + ' = ');
|
||||
new Function('with(this){ ' + code + ' } ').call({
|
||||
eval_context: eval_context,
|
||||
'_': _,
|
||||
'React': React
|
||||
});
|
||||
TEMPLATES[view] = eval_context[view];
|
||||
TEMPLATES[component_name] = eval_context[component_name];
|
||||
fnResolve();
|
||||
});
|
||||
}
|
||||
|
||||
3
client/dashboard/about/about.scss
Normal file
3
client/dashboard/about/about.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
#about {
|
||||
|
||||
}
|
||||
3
client/dashboard/energy/graph/graph.scss
Normal file
3
client/dashboard/energy/graph/graph.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
#energy_graph {
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<table rt-if="this.context.house" class="table">
|
||||
<table id="energy_table" rt-if="this.context.house" class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
|
||||
3
client/dashboard/energy/table/table.scss
Normal file
3
client/dashboard/energy/table/table.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
#energy_table {
|
||||
|
||||
}
|
||||
1
client/dashboard/house/house.scss
Normal file
1
client/dashboard/house/house.scss
Normal file
@@ -0,0 +1 @@
|
||||
#house {}
|
||||
3
client/dashboard/power/graph/graph.scss
Normal file
3
client/dashboard/power/graph/graph.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
#power_graph {
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<table class="table" rt-if="this.context.house">
|
||||
<table id="power_table" class="table" rt-if="this.context.house">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
|
||||
3
client/dashboard/power/table/table.scss
Normal file
3
client/dashboard/power/table/table.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
#power_table {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user