render energy savings table

This commit is contained in:
Eric Hulburd
2016-02-10 18:57:15 -06:00
parent 9996dfc54e
commit c75ae9030c
10 changed files with 28 additions and 25 deletions

View File

@@ -35,8 +35,9 @@ var Layout = React.createClass({
var layout = this,
view = event.target.value;
layout.view_name = event.target.innerText;
layout.setState({view: view});
layout.ensureHouseViewData();
layout.setState({view: view}, function(){
layout.ensureHouseViewData();
});
},
setHouse: function(event){

View File

@@ -19,8 +19,8 @@
<tr>
<th></th>
<th>Day</th>
<th>Consumption (Wh)</th>
<th>Production (Wh)</th>
<th>Consumption (kWh)</th>
<th>Production (kWh)</th>
</tr>
</thead>
<tbody>

View File

@@ -33,7 +33,7 @@ export default function () {
'onChange': this.setHouse
},
_.map(this.state.houses, repeatHouse2.bind(this))
])) : null, this.state.view === 'energy' && this.state.house ? React.createElement('table', { 'className': 'table' }, React.createElement('thead', {}, React.createElement('tr', {}, React.createElement('th', {}), React.createElement('th', {}, 'Day'), React.createElement('th', {}, 'Consumption (Wh)'), React.createElement('th', {}, 'Production (Wh)'))), React.createElement.apply(this, [
])) : null, this.state.view === 'energy' && this.state.house ? React.createElement('table', { 'className': 'table' }, React.createElement('thead', {}, React.createElement('tr', {}, React.createElement('th', {}), React.createElement('th', {}, 'Day'), React.createElement('th', {}, 'Consumption (kWh)'), React.createElement('th', {}, 'Production (kWh)'))), React.createElement.apply(this, [
'tbody',
{},
_.map(this.state.house.energy_data, repeatEnergy_datum3.bind(this))

View File

@@ -82,7 +82,7 @@ class House {
if (date_range.length === 0) return house.getEnergyData({dates: [[opts.start_date, opts.end_date]]})
query_ranges = MathUtil.minusRange([start_date, end_date], [min_date, max_date]);
query_ranges = MathUtil.minusRange([opts.start_date, opts.end_date], [min_date, max_date]);
cache = ArrayUtil.selectMap(date_range, (datum_day)=>{
return ArrayUtil.all(query_ranges, (query_range)=>{
@@ -105,7 +105,7 @@ class House {
return EnergyDataApi.index(params).then((energy_data)=>{
return energy_data.map((energy_datum_data)=>{
var energy_datum = EnergyDatum.updateOrInitialize(energy_datum_data, house);
house.energy_data_store.set(power_datum.time, energy_datum);
house.energy_data_store.set(energy_datum.day, energy_datum);
house.energy_data.push(energy_datum);
return energy_datum;
});

View File

@@ -23,7 +23,7 @@ class PowerDatum {
get time_to_s(){
var power_datum = this;
return power_datum.data.time.format('YYYY-MM-DD HH:MM');
return power_datum.data.time.format('YYYY-MM-DD HH:mm');
}
get consumption_to_s(){
var power_datum = this;