add sums prop for rain SensorWidget

master
Norwin 5 years ago
parent 19dc2e83e1
commit e05bf8fe5a

@ -13,6 +13,7 @@ var SensorWidget = React.createClass({
title: React.PropTypes.string,
lastReading: React.PropTypes.object,
avgs: React.PropTypes.object,
sums: React.PropTypes.object,
plotData: React.PropTypes.array,
axisLineVal: React.PropTypes.number,
axisLineMax: React.PropTypes.number,
@ -25,7 +26,8 @@ var SensorWidget = React.createClass({
className,
fetching, fetched,
title,
lastReading, avgs,
lastReading,
avgs, sums,
plotData,
axisLineVal, axisLineMax, axisLineMin,
unit } = this.props;
@ -66,8 +68,21 @@ var SensorWidget = React.createClass({
</div>
<div className='metrics'>
<ul className='metrics__list'>
<li><strong>{avgs !== null ? numDisplay(avgs.today, 1, unit) : '--'}</strong> heute</li>
<li><strong>{avgs !== null ? numDisplay(avgs.yesterday, 1, unit) : '--'}</strong> gestern</li>
{sums ? (<div>
<li><strong>{numDisplay(sums.today, 1, unit)}</strong> heute</li>
<li><strong>{numDisplay(sums.yesterday, 1, unit)}</strong> gestern</li>
</div>
) : null}
{avgs ? (<div>
<li><strong>{numDisplay(avgs.today, 1, unit)}</strong> heute</li>
<li><strong>{numDisplay(avgs.yesterday, 1, unit)}</strong> gestern</li>
</div>) : null}
{!(avgs || sums) ? (<div>
<li><strong>--</strong></li>
<li><strong>--</strong></li>
</div>) : null}
</ul>
</div>
</div>

@ -115,12 +115,18 @@ var Home = React.createClass({
yesterday: _.meanBy(dataYesterday, 'value')
};
let sums = {
today: _.sumBy(dataToday, 'value'),
yesterday: _.sumBy(dataYesterday, 'value')
};
let last = _.last(dataAll) || null;
return {
data: dataAll,
last,
avgs
avgs,
sums,
};
},
@ -200,9 +206,9 @@ var Home = React.createClass({
lastReading={sensorPressureData.last}
avgs={sensorPressureData.avgs}
plotData={sensorPressureData.data}
axisLineMax={1020}
axisLineVal={1010}
axisLineMin={980}
axisLineMax={1030}
axisLineVal={1000}
axisLineMin={970}
unit=' hPa'
/>
@ -226,10 +232,10 @@ var Home = React.createClass({
fetched={this.props.sensorRain.fetched}
title='Niederschlag'
lastReading={sensorRainData.last}
avgs={sensorRainData.avgs}
sums={sensorRainData.sums}
plotData={sensorRainData.data}
axisLineMax={10}
axisLineVal={5}
axisLineMax={1}
axisLineVal={0.28}
axisLineMin={0}
unit=' L/m² / 5 Min'
/>
@ -256,8 +262,8 @@ var Home = React.createClass({
lastReading={sensorWindSpeedData.last}
avgs={sensorWindSpeedData.avgs}
plotData={sensorWindSpeedData.data}
axisLineMax={90}
axisLineVal={30}
axisLineMax={20}
axisLineVal={10}
axisLineMin={0}
unit=' km/h'
/>
@ -298,7 +304,7 @@ var Home = React.createClass({
lastReading={sensorPm10Data.last}
avgs={sensorPm10Data.avgs}
plotData={sensorPm10Data.data}
axisLineMax={30}
axisLineMax={25}
axisLineVal={10}
axisLineMin={0}
unit=' μg/m³'
@ -312,7 +318,7 @@ var Home = React.createClass({
lastReading={sensorPm25Data.last}
avgs={sensorPm25Data.avgs}
plotData={sensorPm25Data.data}
axisLineMax={30}
axisLineMax={25}
axisLineVal={10}
axisLineMin={0}
unit=' μg/m³'

Loading…
Cancel
Save