diff --git a/app/CNAME b/app/CNAME deleted file mode 100644 index 9fa9ef8..0000000 --- a/app/CNAME +++ /dev/null @@ -1 +0,0 @@ -sense.devseed.com \ No newline at end of file diff --git a/app/assets/scripts/actions/action-creators.js b/app/assets/scripts/actions/action-creators.js index 5101a04..3b08198 100644 --- a/app/assets/scripts/actions/action-creators.js +++ b/app/assets/scripts/actions/action-creators.js @@ -31,14 +31,20 @@ export function fetchSensorData (sensor, toDate) { } return response.json(); }) + .then(json => { + return json.sort((a, b) => { + return new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime(); + }); + }) .then(json => { dispatch(receiveSensorData(sensor, json)); // setTimeout(() => { // dispatch(receiveSensorData(sensor, json)); - // }, Math.ceil(Math.random() * 5000)); - }, e => { + // }, Math.ceil(Math.random() * 2000)); + }) + .catch(e => { console.log('e', e); - return dispatch(receiveSensorData(null, null, 'Data not available')); + return dispatch(receiveSensorData(sensor, null, 'Data not available')); }); }; } diff --git a/app/assets/scripts/actions/action-types.js b/app/assets/scripts/actions/action-types.js index 8ff729d..4549a0a 100644 --- a/app/assets/scripts/actions/action-types.js +++ b/app/assets/scripts/actions/action-types.js @@ -13,3 +13,9 @@ export const RECEIVE_SENSOR_DATA_UV = 'RECEIVE_SENSOR_DATA_UV'; export const REQUEST_SENSOR_DATA_HUMIDITY = 'REQUEST_SENSOR_DATA_HUMIDITY'; export const RECEIVE_SENSOR_DATA_HUMIDITY = 'RECEIVE_SENSOR_DATA_HUMIDITY'; + +export const REQUEST_SENSOR_DATA_PM10 = 'REQUEST_SENSOR_DATA_PM10'; +export const RECEIVE_SENSOR_DATA_PM10 = 'RECEIVE_SENSOR_DATA_PM10'; + +export const REQUEST_SENSOR_DATA_PM25 = 'REQUEST_SENSOR_DATA_PM25'; +export const RECEIVE_SENSOR_DATA_PM25 = 'RECEIVE_SENSOR_DATA_PM25'; diff --git a/app/assets/scripts/components/charts/chart-line.js b/app/assets/scripts/components/charts/chart-line.js index 25d9d07..0985b5d 100644 --- a/app/assets/scripts/components/charts/chart-line.js +++ b/app/assets/scripts/components/charts/chart-line.js @@ -23,7 +23,6 @@ var LineChart = React.createClass({ }, componentDidMount: function () { - // console.log('LineChart componentDidMount'); // Debounce event. this.onWindowResize = _.debounce(this.onWindowResize, 200); @@ -38,13 +37,11 @@ var LineChart = React.createClass({ }, componentWillUnmount: function () { - // console.log('LineChart componentWillUnmount'); window.removeEventListener('resize', this.onWindowResize); this.chart.destroy(); }, - componentDidUpdate: function (prevProps/* prevState */) { - console.log('LineChart componentDidUpdate'); + componentDidUpdate: function (prevProps) { this.chart.pauseUpdate(); if (prevProps.data !== this.props.data) { this.chart.data(this.props.data); diff --git a/app/assets/scripts/components/sensor-widget.js b/app/assets/scripts/components/sensor-widget.js index 76fb8b7..850159e 100644 --- a/app/assets/scripts/components/sensor-widget.js +++ b/app/assets/scripts/components/sensor-widget.js @@ -60,12 +60,14 @@ var SensorWidget = React.createClass({ data={plotData} /> ) : null} - {!plotData.length && fetching ?
Loading Data...
: null} + {!plotData.length ?+ {fetching ? 'Lade Daten...' : 'Keine Daten verfügbar'} +
: null}