clean up development config
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
import React from 'react';
|
||||
|
||||
import layoutRt from './layout.rt.js';
|
||||
|
||||
var Layout = React.createClass({
|
||||
getInitialState: function() {
|
||||
|
||||
getInitialState: function(){
|
||||
return {view: "????"};
|
||||
},
|
||||
|
||||
handleResize: function(e) {
|
||||
@@ -14,11 +18,12 @@ var Layout = React.createClass({
|
||||
|
||||
setView: function(event) {
|
||||
var layout = this;
|
||||
console.log(event.target.value)
|
||||
layout.setState({view: event.target.value});
|
||||
},
|
||||
|
||||
render: function() {
|
||||
return layoutRt.bind(this);
|
||||
return layoutRt.call(this);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<div>
|
||||
|
||||
<div id="layout">
|
||||
<h1>{this.state.view}</h1>
|
||||
<select onChange="{this.setView}">
|
||||
<option value="savings">Savings</option>
|
||||
<option value="production">Production</option>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react/addons';
|
||||
import React from 'react';
|
||||
import _ from 'lodash';
|
||||
export default function () {
|
||||
return React.createElement('div', {}, React.createElement('select', { 'onChange': this.setView }, React.createElement('option', { 'value': 'savings' }, 'Savings'), React.createElement('option', { 'value': 'production' }, 'Production')));
|
||||
return React.createElement('div', { 'id': 'layout' }, React.createElement('h1', {}, this.state.view), React.createElement('select', { 'onChange': this.setView }, React.createElement('option', { 'value': 'savings' }, 'Savings'), React.createElement('option', { 'value': 'production' }, 'Production')));
|
||||
};
|
||||
@@ -27,9 +27,9 @@ gulp.task('save_house_csv', function(done){
|
||||
});
|
||||
|
||||
gulp.task('compile_react_templates', function() {
|
||||
gulp.src('./client/react/**/*.rt')
|
||||
gulp.src('./client/dashboard/**/*.rt')
|
||||
.pipe(rtCompile(rt_config))
|
||||
.pipe(gulp.dest('./client/react'));
|
||||
.pipe(gulp.dest('./client/dashboard'));
|
||||
});
|
||||
|
||||
|
||||
|
||||
45
npm-debug.log
Normal file
45
npm-debug.log
Normal file
@@ -0,0 +1,45 @@
|
||||
0 info it worked if it ends with ok
|
||||
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
|
||||
2 info using npm@3.5.3
|
||||
3 info using node@v5.4.1
|
||||
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
|
||||
5 info lifecycle spike_proto@0.0.0~prestart: spike_proto@0.0.0
|
||||
6 silly lifecycle spike_proto@0.0.0~prestart: no script for prestart, continuing
|
||||
7 info lifecycle spike_proto@0.0.0~start: spike_proto@0.0.0
|
||||
8 verbose lifecycle spike_proto@0.0.0~start: unsafe-perm in lifecycle true
|
||||
9 verbose lifecycle spike_proto@0.0.0~start: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/home/eric/Code/spike2/node_modules/.bin:/home/eric/.rvm/gems/ruby-1.9.3-p484@oroeco_dev/bin:/home/eric/.rvm/gems/ruby-1.9.3-p484@global/bin:/home/eric/.rvm/rubies/ruby-1.9.3-p484/bin:/home/eric/.rvm/bin:/home/eric/bin:/usr/local/heroku/bin:/home/eric/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/lampp/bin
|
||||
10 verbose lifecycle spike_proto@0.0.0~start: CWD: /home/eric/Code/spike2
|
||||
11 silly lifecycle spike_proto@0.0.0~start: Args: [ '-c', 'babel-node ./server/app.express.js' ]
|
||||
12 silly lifecycle spike_proto@0.0.0~start: Returned: code: 1 signal: null
|
||||
13 info lifecycle spike_proto@0.0.0~start: Failed to exec start script
|
||||
14 verbose stack Error: spike_proto@0.0.0 start: `babel-node ./server/app.express.js`
|
||||
14 verbose stack Exit status 1
|
||||
14 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:232:16)
|
||||
14 verbose stack at emitTwo (events.js:87:13)
|
||||
14 verbose stack at EventEmitter.emit (events.js:172:7)
|
||||
14 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:24:14)
|
||||
14 verbose stack at emitTwo (events.js:87:13)
|
||||
14 verbose stack at ChildProcess.emit (events.js:172:7)
|
||||
14 verbose stack at maybeClose (internal/child_process.js:821:16)
|
||||
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
|
||||
15 verbose pkgid spike_proto@0.0.0
|
||||
16 verbose cwd /home/eric/Code/spike2
|
||||
17 error Linux 3.19.0-49-generic
|
||||
18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
|
||||
19 error node v5.4.1
|
||||
20 error npm v3.5.3
|
||||
21 error code ELIFECYCLE
|
||||
22 error spike_proto@0.0.0 start: `babel-node ./server/app.express.js`
|
||||
22 error Exit status 1
|
||||
23 error Failed at the spike_proto@0.0.0 start script 'babel-node ./server/app.express.js'.
|
||||
23 error Make sure you have the latest version of node.js and npm installed.
|
||||
23 error If you do, this is most likely a problem with the spike_proto package,
|
||||
23 error not with npm itself.
|
||||
23 error Tell the author that this fails on your system:
|
||||
23 error babel-node ./server/app.express.js
|
||||
23 error You can get information on how to open an issue for this project with:
|
||||
23 error npm bugs spike_proto
|
||||
23 error Or if that isn't available, you can get their info via:
|
||||
23 error npm owner ls spike_proto
|
||||
23 error There is likely additional logging output above.
|
||||
24 verbose exit [ 1, true ]
|
||||
@@ -3,11 +3,10 @@
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "babel-node ./app.express.js"
|
||||
"start": "babel-node ./server/app.express.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"body-parser": "~1.12.0",
|
||||
"cookie-parser": "~1.3.4",
|
||||
"debug": "~2.1.1",
|
||||
"jade": "~1.9.2",
|
||||
"morgan": "~1.5.1",
|
||||
|
||||
@@ -6,46 +6,71 @@ import express from 'express';
|
||||
import path from 'path';
|
||||
import webpack from 'webpack';
|
||||
import WebpackDevServer from 'webpack-dev-server';
|
||||
import schema from './config/graphql/schema';
|
||||
import bodyParser from 'body-parser';
|
||||
|
||||
|
||||
import DB from './config/database';
|
||||
import routes from './routes';
|
||||
|
||||
const API_PORT = 8080;
|
||||
const APP_PORT = 3000;
|
||||
const JS_PORT = 3000;
|
||||
|
||||
var app = express();
|
||||
var api = express();
|
||||
|
||||
/*
|
||||
* Serve API App
|
||||
*/
|
||||
|
||||
DB.sync().then(()=>{
|
||||
|
||||
routes(app);
|
||||
routes(api);
|
||||
|
||||
api.use(bodyParser.json());
|
||||
api.use(bodyParser.urlencoded({ extended: false }));
|
||||
|
||||
|
||||
api.listen(API_PORT, () => {
|
||||
console.log(`API is now running on http://localhost:${API_PORT}`);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
* Logging, Cookie, JSON Parsing Middleware
|
||||
* Development Server
|
||||
*/
|
||||
|
||||
import favicon from 'serve-favicon';
|
||||
import logger from 'morgan';
|
||||
import cookieParser from 'cookie-parser';
|
||||
import bodyParser from 'bodyParser';
|
||||
|
||||
// uncomment after placing your favicon in /public
|
||||
app.use(favicon(__dirname + '/public/favicon.ico'));
|
||||
app.use(logger('dev'));
|
||||
app.use(bodyParser.json());
|
||||
app.use(bodyParser.urlencoded({ extended: false }));
|
||||
var config = require('./config/webpack/development'),
|
||||
dev_server = new WebpackDevServer(webpack(config), {
|
||||
contentBase: __dirname + '/../client/build/development',
|
||||
publicPath: "/assets/",
|
||||
proxy: {
|
||||
'/data': `http://localhost:${APP_PORT}`,
|
||||
},
|
||||
stats: {colors: true}
|
||||
}),
|
||||
app = dev_server.app;
|
||||
|
||||
/*
|
||||
* Serve Vendor Scripts, CSS, and Templates
|
||||
*/
|
||||
|
||||
import favicon from 'serve-favicon';
|
||||
import logger from 'morgan';
|
||||
|
||||
// uncomment after placing your favicon in /public
|
||||
app.use(favicon(__dirname + '/public/favicon.ico'));
|
||||
app.use(logger('dev'));
|
||||
|
||||
// serve fonts in /assets/fonts
|
||||
import assets from "connect-assets";
|
||||
app.use("/assets/fonts", express.static("node_modules/bootstrap/dist/fonts"));
|
||||
app.use("/assets/fonts", express.static("node_modules/font-awesome/fonts"));
|
||||
|
||||
// TODO: These routes need to match references in the bootstrap and font awesome files.
|
||||
app.use("/assets/fonts", express.static("bootstrap/dist/fonts"));
|
||||
app.use("/assets/fonts", express.static("font-awesome/fonts"));
|
||||
// serve compiled vendor assets and application.css.
|
||||
app.use(assets({
|
||||
paths: ["./assets/js", "./assets/css", "./../node_modules"],
|
||||
paths: ["./../node_modules"],
|
||||
build: true,
|
||||
buildDir: false,
|
||||
//compile: false,
|
||||
@@ -61,9 +86,6 @@ app.get("/", (req, res, next)=>{
|
||||
res.render("index");
|
||||
});
|
||||
|
||||
app.listen(APP_PORT, () => {
|
||||
console.log(`App is now running on http://localhost:${APP_PORT}`);
|
||||
});
|
||||
|
||||
/*
|
||||
* Handle Errors
|
||||
@@ -98,55 +120,8 @@ app.use(function(err, req, res, next) {
|
||||
});
|
||||
});
|
||||
|
||||
dev_server.listen(APP_PORT, () => {
|
||||
console.log(`App is now running on http://localhost:${APP_PORT}`);
|
||||
});
|
||||
|
||||
/*
|
||||
* Development Server
|
||||
*/
|
||||
|
||||
import ExtractTextPlugin from "extract-text-webpack-plugin";
|
||||
|
||||
var compiler = webpack({
|
||||
entry: {
|
||||
app: __dirname + '/../client/app.js',
|
||||
style: __dirname + '/../client/style.scss'
|
||||
},
|
||||
output: {
|
||||
filename: '[name].js',
|
||||
path: __dirname + '/../client/build'
|
||||
},
|
||||
externals: {
|
||||
jquery: "$",
|
||||
d3: "d3"
|
||||
},
|
||||
module: {
|
||||
loaders: [
|
||||
{
|
||||
test: /\.scss$/,
|
||||
loader: ExtractTextPlugin.extract("style-loader", "css-loader!sass-loader")
|
||||
}, {
|
||||
test: /\.css$/,
|
||||
loader: ExtractTextPlugin.extract("style-loader", "css-loader")
|
||||
}
|
||||
]
|
||||
},
|
||||
// Use the plugin to specify the resulting filename (and add needed behavior to the compiler)
|
||||
plugins: [
|
||||
new ExtractTextPlugin("style.css", {
|
||||
allChunks: true
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
var dev_server = new WebpackDevServer(compiler, {
|
||||
contentBase: __dirname + '/../client/build',
|
||||
publicPath: "/assets/",
|
||||
proxy: {
|
||||
'/data': `http://localhost:${APP_PORT}`
|
||||
},
|
||||
stats: {colors: true}
|
||||
});
|
||||
|
||||
|
||||
module.exports = app;
|
||||
|
||||
17
server/config/controllers.js
Normal file
17
server/config/controllers.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import fs from 'fs';
|
||||
|
||||
const CONTROLLER_DIR = __dirname + '/../controllers';
|
||||
|
||||
class Controllers {
|
||||
|
||||
static sync(){
|
||||
fs.readdirSync(CONTROLLER_DIR).forEach(function(file) {
|
||||
var controller = require(CONTROLLER_DIR + '/' + file);
|
||||
Controllers[controller.NAME] = controller;
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default Controllers;
|
||||
@@ -10,15 +10,15 @@ var sequelize = new Sequelize("postgres://spikeuser:123456@localhost:5432/spike2
|
||||
idle: 10000
|
||||
}
|
||||
});
|
||||
const model_dir = __dirname + '/../models'
|
||||
const MODEL_DIR = __dirname + '/../models'
|
||||
|
||||
class Database {
|
||||
|
||||
static sync(){
|
||||
console.log("syncing db")
|
||||
fs.readdirSync(model_dir).forEach(function(file) {
|
||||
var model = require(model_dir + '/' + file);
|
||||
Database[model.name] = model;
|
||||
fs.readdirSync(MODEL_DIR).forEach(function(file) {
|
||||
var model = require(MODEL_DIR + '/' + file);
|
||||
Database[model.NAME] = model;
|
||||
Database.models.push(model);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
export default {
|
||||
var config = {
|
||||
modules: 'es6',
|
||||
'target-version': '0.14.3',
|
||||
'suffix': '.rt'
|
||||
targetVersion: '0.14.0',
|
||||
suffix: '.rt'
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import webpack from 'webpack';
|
||||
|
||||
const ROOT = __dirname + '/../../../';
|
||||
|
||||
module.exports = {
|
||||
@@ -17,21 +19,20 @@ module.exports = {
|
||||
loaders: [
|
||||
{
|
||||
test: /\.scss$/,
|
||||
loader: ['style', 'raw', 'sass']
|
||||
loaders: ['style', 'raw', 'sass']
|
||||
}, {
|
||||
test: /\.css$/,
|
||||
loader: ['style', 'raw']
|
||||
loaders: ['style', 'raw']
|
||||
}, {
|
||||
test: /\.js$/,
|
||||
loader: 'babel'
|
||||
}
|
||||
]
|
||||
},
|
||||
sassLoader: {
|
||||
includePaths: [ROOT + 'client', ROOT + 'node_modules']
|
||||
},
|
||||
// Use the plugin to specify the resulting filename (and add needed behavior to the compiler)
|
||||
plugins: [
|
||||
new ExtractTextPlugin("style.css", {
|
||||
allChunks: true
|
||||
}),
|
||||
new webpack.ProvidePlugin({
|
||||
$: "jquery",
|
||||
jQuery: "jquery",
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
import DB from './../config/database.js';
|
||||
|
||||
const NAME = 'EnergyController';
|
||||
|
||||
class EnergyController{
|
||||
|
||||
static index(req, res){
|
||||
DB.House.findOne({where: {name: req.housename}}).then((house)=>{
|
||||
house.getEnergyDataByTime(req.params.start_time, req.params.end_time).then((energy_data){
|
||||
house.getEnergyDataByTime(req.params.start_time, req.params.end_time).then((energy_data)=>{
|
||||
req.json(energy_data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
EnergyController.NAME = NAME;
|
||||
module.exports = EnergyController;
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
import DB from './../config/database.js';
|
||||
|
||||
const NAME = HousesController;
|
||||
|
||||
class HousesController{
|
||||
|
||||
static index(req, res){
|
||||
DB.House.findAll({attributes: ['id', 'name']}).then((houses){
|
||||
DB.House.findAll({attributes: ['id', 'name']}).then((houses)=>{
|
||||
res.json(houses);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
HousesController.NAME = NAME;
|
||||
module.exports = HousesController;
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
import DB from './../config/database.js';
|
||||
|
||||
const NAME = 'PowerController';
|
||||
|
||||
class PowerController{
|
||||
|
||||
static index(req, res){
|
||||
DB.House.findOne({where: {name: req.housename}}).then((house)=>{
|
||||
house.getPowerDataByTime(req.params.start_time, req.params.end_time).then((power_data){
|
||||
house.getPowerDataByTime(req.params.start_time, req.params.end_time).then((power_data)=>{
|
||||
res.json(power_data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PowerController.NAME = NAME;
|
||||
module.exports = PowerController;
|
||||
|
||||
@@ -34,8 +34,7 @@ export default function (opt) {
|
||||
var options = extend({
|
||||
filename: file.path,
|
||||
sourceFiles: [file.relative],
|
||||
generatedFile: replaceExtension(file.relative),
|
||||
suffix: '.rt'
|
||||
generatedFile: replaceExtension(file.relative)
|
||||
}, opt);
|
||||
|
||||
if (options.suffix && !options.name) {
|
||||
|
||||
@@ -32,5 +32,5 @@ var EnergyDatum = DB.sequelize.define(NAME, {
|
||||
}
|
||||
});
|
||||
|
||||
EnergyDatum.name = NAME;
|
||||
EnergyDatum.NAME = NAME;
|
||||
module.exports = EnergyDatum;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import moment from 'moment-timezone';
|
||||
import DB from "./../config/database";
|
||||
import {nodeInterface} from './../config/graphql/node';
|
||||
|
||||
const NAME = 'House';
|
||||
|
||||
@@ -76,5 +75,5 @@ var House = DB.sequelize.define(NAME, {
|
||||
}
|
||||
});
|
||||
|
||||
House.name = NAME;
|
||||
House.NAME = NAME;
|
||||
module.exports = House;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import DB from "./../config/database";
|
||||
|
||||
const NAME = 'PowerDatum'
|
||||
const NAME = 'PowerDatum';
|
||||
|
||||
/**
|
||||
* Define your own types here
|
||||
@@ -32,5 +32,5 @@ var PowerDatum = DB.sequelize.define(NAME, {
|
||||
}
|
||||
});
|
||||
|
||||
PowerDatum.name = NAME;
|
||||
PowerDatum.NAME = NAME;
|
||||
module.exports = PowerDatum;
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import Controllers from 'controllers'
|
||||
import Controllers from './config/controllers'
|
||||
|
||||
export default function(app){
|
||||
|
||||
app.use('/data/v1/savings/:housename', Controllers.Energy.savings);
|
||||
app.use('/data/v1/production/:housename', Controllers.Energy.production);
|
||||
app.use('/data/v1/houses/:housename');
|
||||
Controllers.sync();
|
||||
|
||||
app.use('/data/v1/savings/:housename', Controllers.PowerController.index);
|
||||
app.use('/data/v1/production/:housename', Controllers.EnergyController.index);
|
||||
app.use('/data/v1/houses/', Controllers.EnergyController.index);
|
||||
|
||||
};
|
||||
|
||||
@@ -4,8 +4,6 @@ html
|
||||
meta(charset='utf-8')
|
||||
meta(http-equiv='content-type', content='text/html; charset=UTF-8')
|
||||
meta(name='viewport', content='width=device-width, initial-scale=1')
|
||||
!= css("vendor")
|
||||
!= css("application")
|
||||
title Spike Prototype
|
||||
body
|
||||
#spike_container
|
||||
@@ -23,7 +21,7 @@ html
|
||||
ul.nav.navbar-nav.navbar-right
|
||||
li
|
||||
a(href='/') Spike
|
||||
block content
|
||||
block content
|
||||
#spike_footer
|
||||
.container Footer
|
||||
script(type='text/javascript').
|
||||
@@ -31,5 +29,5 @@ html
|
||||
// in developer tools for the native `fetch`.
|
||||
self.fetch = null;
|
||||
script(src='http://localhost:3000/webpack-dev-server.js')
|
||||
!= js("vendor")
|
||||
script(src='/assets/js/application.js')
|
||||
script(src='/assets/style.js')
|
||||
script(src='/assets/app.js')
|
||||
|
||||
Reference in New Issue
Block a user