Files
old-spike/client/dashboard/layout/layout.rt.js

33 lines
1.4 KiB
JavaScript
Raw Normal View History

2016-02-09 11:16:49 -06:00
import React from 'react';
2016-02-08 18:23:40 -06:00
import _ from 'lodash';
2016-02-13 16:49:32 -06:00
import Energy from './../energy/energy';
import Power from './../power/power';
2016-02-10 16:11:56 -06:00
function repeatView1(view, viewIndex) {
return React.createElement('option', {
'value': view[0],
'key': 'view-' + view[0]
}, view[1]);
}
function repeatHouse2(house, houseIndex) {
return React.createElement('option', {
'value': house.data.id,
'key': house.react_key
}, house.data.name);
}
2016-02-08 18:23:40 -06:00
export default function () {
2016-02-13 16:49:32 -06:00
return React.createElement('div', { 'id': 'layout' }, this.state.requesting_data ? React.createElement('div', { 'className': 'alert alert-warning' }, 'Retrieving houses...') : null, this.state.house ? React.createElement('h1', {}, this.state.house.name) : null, this.state.view ? React.createElement('h3', {}, this.view_name) : null, React.createElement.apply(this, [
2016-02-10 16:11:56 -06:00
'select',
{
'className': 'form-control',
'onChange': this.setView
},
_.map(this.state.views, repeatView1.bind(this))
2016-02-13 16:49:32 -06:00
]), this.state.houses ? React.createElement.apply(this, [
2016-02-10 16:11:56 -06:00
'select',
{
'className': 'form-control',
'onChange': this.setHouse
},
_.map(this.state.houses, repeatHouse2.bind(this))
2016-02-13 16:49:32 -06:00
]) : null, this.state.house && this.state.view === 'energy' ? React.createElement(Energy, { 'house': this.state.house }) : null);
2016-02-08 18:23:40 -06:00
};