From e05bf8fe5a2de43266b646669cfc65d187f2f0dc Mon Sep 17 00:00:00 2001 From: Norwin Roosen Date: Sat, 29 Jun 2019 15:17:05 +0200 Subject: [PATCH] add sums prop for rain SensorWidget --- .../scripts/components/sensor-widget.js | 21 ++++++++++++-- app/assets/scripts/views/home.js | 28 +++++++++++-------- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/app/assets/scripts/components/sensor-widget.js b/app/assets/scripts/components/sensor-widget.js index 850159e..1c08a01 100644 --- a/app/assets/scripts/components/sensor-widget.js +++ b/app/assets/scripts/components/sensor-widget.js @@ -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({
diff --git a/app/assets/scripts/views/home.js b/app/assets/scripts/views/home.js index cd7ebac..0e168a3 100644 --- a/app/assets/scripts/views/home.js +++ b/app/assets/scripts/views/home.js @@ -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³'