dynamic react router
This commit is contained in:
19
client/dashboard/power/table/table.component.js
Normal file
19
client/dashboard/power/table/table.component.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import React from 'react';
|
||||
import Templates from 'config/templates';
|
||||
|
||||
import House from './../../../models/house';
|
||||
|
||||
class TableComponent extends React.Component {
|
||||
|
||||
render() {
|
||||
var powerTableRt = Templates.forComponent('power_table');
|
||||
return powerTableRt.call(this);
|
||||
}
|
||||
}
|
||||
|
||||
TableComponent.contextTypes = {
|
||||
house: React.PropTypes.instanceOf(House),
|
||||
router: React.PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
export default TableComponent;
|
||||
18
client/dashboard/power/table/table.rt
Normal file
18
client/dashboard/power/table/table.rt
Normal file
@@ -0,0 +1,18 @@
|
||||
<table class="table" rt-if="this.context.house">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Time</th>
|
||||
<th>Consumption (W)</th>
|
||||
<th>Production (W)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr rt-repeat="power_datum in this.context.house.power_data" key="{power_datum.scoped_id}">
|
||||
<td></td>
|
||||
<td>{power_datum.time_to_s}</td>
|
||||
<td>{power_datum.consumption_to_s}</td>
|
||||
<td>{power_datum.production_to_s}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
12
client/dashboard/power/table/table.rt.js
Normal file
12
client/dashboard/power/table/table.rt.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import React from 'react';
|
||||
import _ from 'lodash';
|
||||
function repeatPower_datum1(power_datum, power_datumIndex) {
|
||||
return React.createElement('tr', { 'key': power_datum.scoped_id }, React.createElement('td', {}), React.createElement('td', {}, power_datum.time_to_s), React.createElement('td', {}, power_datum.consumption_to_s), React.createElement('td', {}, power_datum.production_to_s));
|
||||
}
|
||||
export default function () {
|
||||
return this.context.house ? React.createElement('table', { 'className': 'table' }, React.createElement('thead', {}, React.createElement('tr', {}, React.createElement('th', {}), React.createElement('th', {}, 'Time'), React.createElement('th', {}, 'Consumption (W)'), React.createElement('th', {}, 'Production (W)'))), React.createElement.apply(this, [
|
||||
'tbody',
|
||||
{},
|
||||
_.map(this.context.house.power_data, repeatPower_datum1.bind(this))
|
||||
])) : null;
|
||||
};
|
||||
Reference in New Issue
Block a user