From 4e8154d96f13d4d8c53872a33f4e11b0bedbbae7 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Sun, 26 Aug 2018 20:56:07 -0400 Subject: [PATCH 01/40] Add valued for machineq in constants. --- src/components/SensorInstall/constants.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/SensorInstall/constants.js b/src/components/SensorInstall/constants.js index c1db48bd..50ae8d5b 100644 --- a/src/components/SensorInstall/constants.js +++ b/src/components/SensorInstall/constants.js @@ -28,4 +28,5 @@ export const SENSOR_TYPES = { // eslint-disable-line senseware: 1, awair: 2, other: 3, + machineq: 4 }; -- GitLab From 106ec25abb9bf30da850abd771d70403036adfb8 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Sun, 26 Aug 2018 21:05:38 -0400 Subject: [PATCH 02/40] Fetch machineq data. --- src/containers/Sensors/SensorGraph.js | 28 ++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index 1a0c0534..cf47c4b8 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -60,6 +60,7 @@ export class SensorGraph extends Component { nodes: '', data: '', from: this.state.from.toUTCString(), + to: this.state.today.toUTCString(), }); this.props.loadWeather({ measurement: 'temperature', @@ -130,6 +131,27 @@ export class SensorGraph extends Component { return oneNode; }); } + } else if (gateway.sensor_type === SENSOR_TYPES.machineq) { + if (gateway.nodes) { + gateway.nodes.filter(oneNode => ( + oneNode.data.length > 0 + )).map((oneNode) => { + // If it's an apartment node + if (oneNode.node_type === 1) { + const timeSeriesData = this.generateTimeSeriesFromSensor(oneNode, props); + Object.keys(timeSeriesData.timeseries).map((key) => { + acc[key].push(timeSeriesData.timeseries[key]); + return key; + }); + // Add the latest readings + latestReadings[ + timeSeriesData.latestReading.id + ] = timeSeriesData.latestReading.reading; + // Handle boiler nodes differently + }ß + return oneNode; + }); + } } return acc; }, { @@ -369,12 +391,13 @@ export class SensorGraph extends Component { width: 1, }) - fetchData = debounce((from) => { + fetchData = debounce((from, to) => { this.props.loadAllNodeData({ building_id: this.props.buildingId, nodes: '', data: '', from: from.toUTCString(), + to: to.toUTCString(), }); this.props.loadWeather({ measurement: 'temperature', @@ -399,6 +422,9 @@ export class SensorGraph extends Component { updateTimeRangeEnd = (momentDate) => { const date = momentDate.toDate(); + if (date > this.state.to) { + this.fetchData(this.state.from, date); + } this.setState({ timerange: new TimeRange([this.state.timerange.begin(), date]), }); -- GitLab From 05bdd8e350916624543329c6e1487c02eea6ed5c Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Sun, 26 Aug 2018 21:40:23 -0400 Subject: [PATCH 03/40] Add trailing comma. --- src/components/SensorInstall/constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/SensorInstall/constants.js b/src/components/SensorInstall/constants.js index 50ae8d5b..f1c3f124 100644 --- a/src/components/SensorInstall/constants.js +++ b/src/components/SensorInstall/constants.js @@ -28,5 +28,5 @@ export const SENSOR_TYPES = { // eslint-disable-line senseware: 1, awair: 2, other: 3, - machineq: 4 + machineq: 4, }; -- GitLab From ab90b1dd99475ede89c91f28932e11ca5fb97891 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Mon, 27 Aug 2018 00:06:22 -0400 Subject: [PATCH 04/40] Remove extra character. Crying face ;'( --- src/containers/Sensors/SensorGraph.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index cf47c4b8..283d3b88 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -148,7 +148,7 @@ export class SensorGraph extends Component { timeSeriesData.latestReading.id ] = timeSeriesData.latestReading.reading; // Handle boiler nodes differently - }ß + } return oneNode; }); } @@ -166,6 +166,7 @@ export class SensorGraph extends Component { const weatherPoints = props.weather.weatherData['New_York:NY'].hourly.map(point => ( [new Date(point.ts), point.val] )); + if (weatherPoints.length > 0) { lines.temperature.push(new TimeSeries({ name: 'Outdoor Temperature', -- GitLab From 82affc6e00cbaf85ad5e9b7841a748322803bc2d Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Mon, 27 Aug 2018 00:29:26 -0400 Subject: [PATCH 05/40] Remove trailing white space . --- src/containers/Sensors/SensorGraph.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index 283d3b88..05352608 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -166,7 +166,7 @@ export class SensorGraph extends Component { const weatherPoints = props.weather.weatherData['New_York:NY'].hourly.map(point => ( [new Date(point.ts), point.val] )); - + if (weatherPoints.length > 0) { lines.temperature.push(new TimeSeries({ name: 'Outdoor Temperature', -- GitLab From 5febf5b7835b9bf749decb0850eeeccaee766e3c Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Tue, 28 Aug 2018 17:41:05 -0400 Subject: [PATCH 06/40] Add console log statements for debugging. --- src/containers/Sensors/SensorGraph.js | 9 +++++++++ src/utils/restServices.js | 1 + 2 files changed, 10 insertions(+) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index 05352608..d7795b32 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -111,6 +111,7 @@ export class SensorGraph extends Component { )).map((oneNode) => { // If it's an apartment node if (oneNode.node_type === 1) { + console.log(oneNode); const timeSeriesData = this.generateTimeSeriesFromSensor(oneNode, props); Object.keys(timeSeriesData.timeseries).map((key) => { acc[key].push(timeSeriesData.timeseries[key]); @@ -265,7 +266,11 @@ export class SensorGraph extends Component { 'ppb': 'chemicals', 'mcg3': 'dust', }; + console.log("GenerateTimeSeriesFromSensor"); + console.log(sensor); const measurements = sensor.data.reduce((acc, i) => { + console.log("Creating Measurement"); + console.log(i); // Ignore values we don't care about like voltage if (i.unit in unitToMeasurement) { acc[unitToMeasurement[i.unit]].push(i); @@ -357,6 +362,8 @@ export class SensorGraph extends Component { generateTimeSeries = (data, deviceName) => { // Get all points let prevPoint = null; + console.log("Data in generate time series"); + console.log(data); const points = data.reduce((acc, i) => { if (prevPoint) { const curDate = new Date(i.ts); @@ -377,6 +384,8 @@ export class SensorGraph extends Component { prevPoint = i; return acc; }, []); + console.log("Points"); + console.log(points); return new TimeSeries({ diff --git a/src/utils/restServices.js b/src/utils/restServices.js index 3e763e1e..cd5c030c 100644 --- a/src/utils/restServices.js +++ b/src/utils/restServices.js @@ -46,6 +46,7 @@ export const customImpactReportURL = `${reportService}/customimpact/`; export const gatewayURL = `${iotService}/gateway/`; export const sensewareNodeURL = `${iotService}/sensewarenode/`; +export const machineqNodeURL = `${iotService}/machineqnode/`; export const sensorImageURL = `${iotService}/sensorimage/`; export const eventsURL = `${iotService}/event/`; export const alertSubscribersURL = `${iotService}/alertsubscription/`; -- GitLab From 46ee14deba9e3eef24ebbb8abcb0df36257ec6dc Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Tue, 28 Aug 2018 17:49:15 -0400 Subject: [PATCH 07/40] Make single quotes. --- src/containers/Sensors/SensorGraph.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index d7795b32..3d8edcb0 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -266,10 +266,10 @@ export class SensorGraph extends Component { 'ppb': 'chemicals', 'mcg3': 'dust', }; - console.log("GenerateTimeSeriesFromSensor"); + console.log('GenerateTimeSeriesFromSensor'); console.log(sensor); const measurements = sensor.data.reduce((acc, i) => { - console.log("Creating Measurement"); + console.log('Creating Measurement'); console.log(i); // Ignore values we don't care about like voltage if (i.unit in unitToMeasurement) { @@ -362,7 +362,7 @@ export class SensorGraph extends Component { generateTimeSeries = (data, deviceName) => { // Get all points let prevPoint = null; - console.log("Data in generate time series"); + console.log('Data in generate time series'); console.log(data); const points = data.reduce((acc, i) => { if (prevPoint) { @@ -384,7 +384,7 @@ export class SensorGraph extends Component { prevPoint = i; return acc; }, []); - console.log("Points"); + console.log('Points'); console.log(points); -- GitLab From b3fc885fdcfd3359f3072c8c4137117d5b84d60a Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Tue, 28 Aug 2018 18:40:11 -0400 Subject: [PATCH 08/40] Reduce console log statements. --- src/containers/Sensors/SensorGraph.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index 3d8edcb0..7f249860 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -269,8 +269,6 @@ export class SensorGraph extends Component { console.log('GenerateTimeSeriesFromSensor'); console.log(sensor); const measurements = sensor.data.reduce((acc, i) => { - console.log('Creating Measurement'); - console.log(i); // Ignore values we don't care about like voltage if (i.unit in unitToMeasurement) { acc[unitToMeasurement[i.unit]].push(i); @@ -362,7 +360,8 @@ export class SensorGraph extends Component { generateTimeSeries = (data, deviceName) => { // Get all points let prevPoint = null; - console.log('Data in generate time series'); + console.log('Device data'); + onsole.log(deviceName); console.log(data); const points = data.reduce((acc, i) => { if (prevPoint) { @@ -384,8 +383,6 @@ export class SensorGraph extends Component { prevPoint = i; return acc; }, []); - console.log('Points'); - console.log(points); return new TimeSeries({ -- GitLab From bd3dc894a946d093f59cbfcb0682b49e8e8eed52 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Tue, 28 Aug 2018 18:48:52 -0400 Subject: [PATCH 09/40] Another mistake. --- src/containers/Sensors/SensorGraph.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index 7f249860..7f67cd9c 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -361,7 +361,7 @@ export class SensorGraph extends Component { // Get all points let prevPoint = null; console.log('Device data'); - onsole.log(deviceName); + console.log(deviceName); console.log(data); const points = data.reduce((acc, i) => { if (prevPoint) { @@ -383,6 +383,19 @@ export class SensorGraph extends Component { prevPoint = i; return acc; }, []); + try { + let timeSeries = new TimeSeries({ + name: deviceName, + columns: ['time', deviceName], + points, + }); + return + } + catch(error) { + console.error(error); + // expected output: SyntaxError: unterminated string literal + // Note - error messages will vary depending on browser + } return new TimeSeries({ -- GitLab From 1178feba2f5db1686da392ab9eb8d44f6952e002 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Tue, 28 Aug 2018 19:13:10 -0400 Subject: [PATCH 10/40] Fix try catch. --- src/containers/Sensors/SensorGraph.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index 7f67cd9c..2e7a730c 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -389,7 +389,7 @@ export class SensorGraph extends Component { columns: ['time', deviceName], points, }); - return + return timeSeries; } catch(error) { console.error(error); -- GitLab From b22213c3cb7e5319a05858edae8766a99d72a07d Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Tue, 28 Aug 2018 19:20:09 -0400 Subject: [PATCH 11/40] Fix styling --- src/containers/Sensors/SensorGraph.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index 2e7a730c..f89c0bba 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -384,14 +384,13 @@ export class SensorGraph extends Component { return acc; }, []); try { - let timeSeries = new TimeSeries({ + const timeSeries = new TimeSeries({ name: deviceName, columns: ['time', deviceName], points, }); return timeSeries; - } - catch(error) { + } catch (error) { console.error(error); // expected output: SyntaxError: unterminated string literal // Note - error messages will vary depending on browser -- GitLab From af9a311ce4d445b867b4cc93b13f319b94277cc4 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Tue, 28 Aug 2018 19:31:10 -0400 Subject: [PATCH 12/40] Print meaurements. --- src/containers/Sensors/SensorGraph.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index f89c0bba..71ff2ee4 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -281,6 +281,8 @@ export class SensorGraph extends Component { chemicals: [], dust: [], }); + console.log('Measurements'); + console.log(measurements); const latestReading = {}; let name = ''; const timeseries = Object.keys(measurements).filter(measurement => ( @@ -291,6 +293,7 @@ export class SensorGraph extends Component { id: sensor.id, data: measurements[measurement], }; + // Find space for the node const spaceOfNode = this.findDeviceLocation(device, props); name = spaceOfNode.deviceName ? spaceOfNode.deviceName : `device ${device.id}`; @@ -300,8 +303,9 @@ export class SensorGraph extends Component { value: device.data[device.data.length - 1].value, }; latestReading.name = name; - - // Generate the time series + console.log('Latest Reading'); + console.log(latestReading); + // Generate the time series for this measurement acc[measurement] = this.generateTimeSeries( device.data, `${name} - ${measurement}`, -- GitLab From 8692bdca5eea113d278a3a1604f1916bf4fefad2 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Tue, 28 Aug 2018 19:44:18 -0400 Subject: [PATCH 13/40] Only push if date is after last pushed date. --- src/containers/Sensors/SensorGraph.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index 71ff2ee4..d86d3d95 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -382,7 +382,9 @@ export class SensorGraph extends Component { } } } - acc.push([new Date(i.ts), i.value]); + if (new DataCue(i,ts) > acc[-1]) { + acc.push([new Date(i.ts), i.value]); + } prevPoint = i; return acc; -- GitLab From e221a60820de5b2c98d8ba2872d7d1eab8bc1379 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Tue, 28 Aug 2018 19:49:45 -0400 Subject: [PATCH 14/40] Fix spelling error. --- src/containers/Sensors/SensorGraph.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index d86d3d95..afd2a11f 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -382,7 +382,8 @@ export class SensorGraph extends Component { } } } - if (new DataCue(i,ts) > acc[-1]) { + // Hack since I am expecting to have data already in order + if (new Data(i,ts) > acc[-1]) { acc.push([new Date(i.ts), i.value]); } -- GitLab From 8bb5af044b9d142d2f344727de730f55e0ead902 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Tue, 28 Aug 2018 19:53:56 -0400 Subject: [PATCH 15/40] I really need to stop with these errors. --- src/containers/Sensors/SensorGraph.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index afd2a11f..0b009f8b 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -383,7 +383,7 @@ export class SensorGraph extends Component { } } // Hack since I am expecting to have data already in order - if (new Data(i,ts) > acc[-1]) { + if (new Date(i.ts) > acc[-1]) { acc.push([new Date(i.ts), i.value]); } -- GitLab From e89e1bc6395c4a31f2007cbf736c85aa1b4331d6 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Tue, 28 Aug 2018 20:00:38 -0400 Subject: [PATCH 16/40] Fix trailing space. --- src/containers/Sensors/SensorGraph.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index 0b009f8b..72e62557 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -382,7 +382,7 @@ export class SensorGraph extends Component { } } } - // Hack since I am expecting to have data already in order + // Hack since I am expecting to have data already in order if (new Date(i.ts) > acc[-1]) { acc.push([new Date(i.ts), i.value]); } -- GitLab From c38316da693ecb9ed7f5f7f7e54c8c6579ad7b3d Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Tue, 28 Aug 2018 20:02:48 -0400 Subject: [PATCH 17/40] View last element of array. --- src/containers/Sensors/SensorGraph.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index 72e62557..5bb61c26 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -383,7 +383,7 @@ export class SensorGraph extends Component { } } // Hack since I am expecting to have data already in order - if (new Date(i.ts) > acc[-1]) { + if (new Date(i.ts) > acc[acc.length-1]) { acc.push([new Date(i.ts), i.value]); } -- GitLab From 62656afd2bd57baaa87b24fb4cac75a77e1f198d Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Tue, 28 Aug 2018 20:13:00 -0400 Subject: [PATCH 18/40] Fix infix issue. --- src/containers/Sensors/SensorGraph.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index 5bb61c26..96771e30 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -383,7 +383,7 @@ export class SensorGraph extends Component { } } // Hack since I am expecting to have data already in order - if (new Date(i.ts) > acc[acc.length-1]) { + if (new Date(i.ts) > acc[acc.length - 1]) { acc.push([new Date(i.ts), i.value]); } -- GitLab From 1c8d949c54198163a2d5af7727e3b7d9191661a7 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Wed, 29 Aug 2018 00:08:51 -0400 Subject: [PATCH 19/40] Prev point should only change if value is actually checked. --- src/containers/Sensors/SensorGraph.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index 96771e30..2850ba11 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -310,6 +310,7 @@ export class SensorGraph extends Component { device.data, `${name} - ${measurement}`, ); + console.log(acc); return acc; }, {}); return { @@ -382,12 +383,11 @@ export class SensorGraph extends Component { } } } - // Hack since I am expecting to have data already in order + // Hack since I am expecting to have data already in order ignore that value for now if (new Date(i.ts) > acc[acc.length - 1]) { acc.push([new Date(i.ts), i.value]); + prevPoint = i; } - - prevPoint = i; return acc; }, []); try { -- GitLab From fa6c64a804f9bf71fd87ec9a1a9ac56c5c162070 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Wed, 29 Aug 2018 00:43:57 -0400 Subject: [PATCH 20/40] Artificial limit of 10 lines. --- src/containers/Sensors/SensorGraph.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index 2850ba11..0fb1c158 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -180,10 +180,15 @@ export class SensorGraph extends Component { return; } const styles = {}; + lines_max = 10; + lines_so_far = 0; Object.keys(lines).forEach((type) => { - lines[type].forEach((line, index) => { - styles[line.name()] = this.generateLineStyle(line, index); - }); + if (lines_so_far = lines_max){ + lines[type].forEach((line, index) => { + styles[line.name()] = this.generateLineStyle(line, index); + }); + lines_so_far ++; + } }); this.setState({ -- GitLab From 8677d7b98213820e20616ac968be2aac8904eae4 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Wed, 29 Aug 2018 00:49:50 -0400 Subject: [PATCH 21/40] Fix style issues. --- src/containers/Sensors/SensorGraph.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index 0fb1c158..f9814c15 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -180,14 +180,14 @@ export class SensorGraph extends Component { return; } const styles = {}; - lines_max = 10; - lines_so_far = 0; + const linesMax = 10; + let lines_so_far = 0; Object.keys(lines).forEach((type) => { - if (lines_so_far = lines_max){ + if (lines_so_far < lines_max){ lines[type].forEach((line, index) => { styles[line.name()] = this.generateLineStyle(line, index); }); - lines_so_far ++; + lines_so_far++; } }); -- GitLab From 599851b9895969e459e7633ecc556b53e47d4243 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Wed, 29 Aug 2018 11:02:05 -0400 Subject: [PATCH 22/40] Fix style issues in line limits --- src/containers/Sensors/SensorGraph.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index f9814c15..e0a939a9 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -181,13 +181,13 @@ export class SensorGraph extends Component { } const styles = {}; const linesMax = 10; - let lines_so_far = 0; + let linesSoFar = 0; Object.keys(lines).forEach((type) => { - if (lines_so_far < lines_max){ + if (linesSoFar < lines_max){ lines[type].forEach((line, index) => { styles[line.name()] = this.generateLineStyle(line, index); }); - lines_so_far++; + linesSoFar++; } }); -- GitLab From d83b54b34f0c1ef4eb30535b2284e8a93c909a94 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Wed, 29 Aug 2018 11:10:03 -0400 Subject: [PATCH 23/40] Final style changes. --- src/containers/Sensors/SensorGraph.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index e0a939a9..702214dd 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -183,11 +183,11 @@ export class SensorGraph extends Component { const linesMax = 10; let linesSoFar = 0; Object.keys(lines).forEach((type) => { - if (linesSoFar < lines_max){ + if (linesSoFar < linesMax) { lines[type].forEach((line, index) => { styles[line.name()] = this.generateLineStyle(line, index); }); - linesSoFar++; + linesSoFar += 1; } }); -- GitLab From e2a5d5e40f5728075207b45f9bf55146cbce04a9 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Wed, 29 Aug 2018 11:38:01 -0400 Subject: [PATCH 24/40] Reduce console log statements. --- src/containers/Sensors/SensorGraph.js | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index 702214dd..141bdae7 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -111,7 +111,6 @@ export class SensorGraph extends Component { )).map((oneNode) => { // If it's an apartment node if (oneNode.node_type === 1) { - console.log(oneNode); const timeSeriesData = this.generateTimeSeriesFromSensor(oneNode, props); Object.keys(timeSeriesData.timeseries).map((key) => { acc[key].push(timeSeriesData.timeseries[key]); @@ -138,6 +137,8 @@ export class SensorGraph extends Component { oneNode.data.length > 0 )).map((oneNode) => { // If it's an apartment node + console.log('Apartment Node'); + console.log(oneNode); if (oneNode.node_type === 1) { const timeSeriesData = this.generateTimeSeriesFromSensor(oneNode, props); Object.keys(timeSeriesData.timeseries).map((key) => { @@ -271,8 +272,6 @@ export class SensorGraph extends Component { 'ppb': 'chemicals', 'mcg3': 'dust', }; - console.log('GenerateTimeSeriesFromSensor'); - console.log(sensor); const measurements = sensor.data.reduce((acc, i) => { // Ignore values we don't care about like voltage if (i.unit in unitToMeasurement) { @@ -286,8 +285,6 @@ export class SensorGraph extends Component { chemicals: [], dust: [], }); - console.log('Measurements'); - console.log(measurements); const latestReading = {}; let name = ''; const timeseries = Object.keys(measurements).filter(measurement => ( @@ -315,6 +312,7 @@ export class SensorGraph extends Component { device.data, `${name} - ${measurement}`, ); + console.log('Response so far'); console.log(acc); return acc; }, {}); @@ -370,9 +368,6 @@ export class SensorGraph extends Component { generateTimeSeries = (data, deviceName) => { // Get all points let prevPoint = null; - console.log('Device data'); - console.log(deviceName); - console.log(data); const points = data.reduce((acc, i) => { if (prevPoint) { const curDate = new Date(i.ts); @@ -392,22 +387,12 @@ export class SensorGraph extends Component { if (new Date(i.ts) > acc[acc.length - 1]) { acc.push([new Date(i.ts), i.value]); prevPoint = i; + } else { + console.log('Skipping value its out of order'); + console.log(i); } return acc; }, []); - try { - const timeSeries = new TimeSeries({ - name: deviceName, - columns: ['time', deviceName], - points, - }); - return timeSeries; - } catch (error) { - console.error(error); - // expected output: SyntaxError: unterminated string literal - // Note - error messages will vary depending on browser - } - return new TimeSeries({ name: deviceName, -- GitLab From 39bb07d2dd053bb670c57938569f0a36dea4cab8 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Wed, 29 Aug 2018 13:18:43 -0400 Subject: [PATCH 25/40] Show dates that are messed up. --- src/containers/Sensors/SensorGraph.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index 141bdae7..0bb25b3b 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -389,7 +389,10 @@ export class SensorGraph extends Component { prevPoint = i; } else { console.log('Skipping value its out of order'); - console.log(i); + console.log('New Date'); + console.log(new Date(i.ts)); + console.log('Old Date'); + console.log(acc[acc.length-1]); } return acc; }, []); -- GitLab From fe0000725142e0f5ba9f3eb2bfe926fca0e39d5a Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Wed, 29 Aug 2018 13:24:26 -0400 Subject: [PATCH 26/40] Fix infix issue. --- src/containers/Sensors/SensorGraph.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index 0bb25b3b..dcab2992 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -392,7 +392,7 @@ export class SensorGraph extends Component { console.log('New Date'); console.log(new Date(i.ts)); console.log('Old Date'); - console.log(acc[acc.length-1]); + console.log(acc[acc.length - 1]); } return acc; }, []); -- GitLab From 14a1418a3c76d598e818c0c02113889e6690b87c Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Wed, 29 Aug 2018 14:51:22 -0400 Subject: [PATCH 27/40] Only check if out of order if prevPoint exists. --- src/containers/Sensors/SensorGraph.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index dcab2992..dfa4b88a 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -384,15 +384,17 @@ export class SensorGraph extends Component { } } // Hack since I am expecting to have data already in order ignore that value for now - if (new Date(i.ts) > acc[acc.length - 1]) { + if (prevPoint && new Date(i.ts) > new Date(prevPoint.ts)) { acc.push([new Date(i.ts), i.value]); prevPoint = i; + } else if (!prevPoint) { + acc.push([new Date(i.ts), i.value]); } else { console.log('Skipping value its out of order'); console.log('New Date'); console.log(new Date(i.ts)); console.log('Old Date'); - console.log(acc[acc.length - 1]); + console.log(new Date(prevPoint.ts)); } return acc; }, []); -- GitLab From 4ca6b3aeef0d441cb8dc8de49b6890cd185c522f Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Wed, 29 Aug 2018 15:26:56 -0400 Subject: [PATCH 28/40] Fix control statement. --- src/containers/Sensors/SensorGraph.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index dfa4b88a..3e2c0a64 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -382,19 +382,20 @@ export class SensorGraph extends Component { newDate = new Date(newDate.getTime() + (300 * 1000)); } } - } - // Hack since I am expecting to have data already in order ignore that value for now - if (prevPoint && new Date(i.ts) > new Date(prevPoint.ts)) { + // Hack since I am expecting to have data already in order ignore that value for now + if (new Date(i.ts) > new Date(prevPoint.ts)) { + acc.push([new Date(i.ts), i.value]); + prevPoint = i; + } else { + console.log('Skipping value its out of order'); + console.log('New Date'); + console.log(new Date(i.ts)); + console.log('Old Date'); + console.log(new Date(prevPoint.ts)); + } + } else { acc.push([new Date(i.ts), i.value]); prevPoint = i; - } else if (!prevPoint) { - acc.push([new Date(i.ts), i.value]); - } else { - console.log('Skipping value its out of order'); - console.log('New Date'); - console.log(new Date(i.ts)); - console.log('Old Date'); - console.log(new Date(prevPoint.ts)); } return acc; }, []); -- GitLab From 982bf4b3c5d2f5f13245f113114a96f8326d9245 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Wed, 29 Aug 2018 20:58:00 -0400 Subject: [PATCH 29/40] Add more log statements to clear up some parsing issues. --- src/containers/Sensors/SensorGraph.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index 3e2c0a64..1edeae5a 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -272,6 +272,8 @@ export class SensorGraph extends Component { 'ppb': 'chemicals', 'mcg3': 'dust', }; + console.log('Generating time series for sensor'); + console.log(sensor); const measurements = sensor.data.reduce((acc, i) => { // Ignore values we don't care about like voltage if (i.unit in unitToMeasurement) { @@ -305,15 +307,11 @@ export class SensorGraph extends Component { value: device.data[device.data.length - 1].value, }; latestReading.name = name; - console.log('Latest Reading'); - console.log(latestReading); // Generate the time series for this measurement acc[measurement] = this.generateTimeSeries( device.data, `${name} - ${measurement}`, ); - console.log('Response so far'); - console.log(acc); return acc; }, {}); return { @@ -368,6 +366,7 @@ export class SensorGraph extends Component { generateTimeSeries = (data, deviceName) => { // Get all points let prevPoint = null; + console.log(deviceName); const points = data.reduce((acc, i) => { if (prevPoint) { const curDate = new Date(i.ts); @@ -390,8 +389,10 @@ export class SensorGraph extends Component { console.log('Skipping value its out of order'); console.log('New Date'); console.log(new Date(i.ts)); + console.log(i.value); console.log('Old Date'); console.log(new Date(prevPoint.ts)); + console.log(new Date(prevPoint.value)); } } else { acc.push([new Date(i.ts), i.value]); -- GitLab From 7018c7e4a11b1c369890849e5849deb818755c9f Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Wed, 29 Aug 2018 22:33:33 -0400 Subject: [PATCH 30/40] Add to date to fetch data when start date is updated. --- src/containers/Sensors/SensorGraph.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index 1edeae5a..47fb9d4f 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -434,7 +434,7 @@ export class SensorGraph extends Component { updateTimeRangeStart = (momentDate) => { const date = momentDate.toDate(); if (date < this.state.from) { - this.fetchData(date); + this.fetchData(date, this.state.to); } this.setState({ -- GitLab From e0fe4adb94be28e64ea742a9ed39e69282dc009a Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Wed, 29 Aug 2018 23:20:57 -0400 Subject: [PATCH 31/40] Print escaped values. --- src/containers/Sensors/SensorGraph.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index 47fb9d4f..19dd536b 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -392,7 +392,7 @@ export class SensorGraph extends Component { console.log(i.value); console.log('Old Date'); console.log(new Date(prevPoint.ts)); - console.log(new Date(prevPoint.value)); + console.log(prevPoint.value); } } else { acc.push([new Date(i.ts), i.value]); -- GitLab From d0b1715d777ad45b26ed13a72f6c2b17927a804f Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Wed, 29 Aug 2018 23:52:47 -0400 Subject: [PATCH 32/40] Remove console.loge statements. --- src/containers/Sensors/SensorGraph.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index 19dd536b..0c345686 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -387,12 +387,6 @@ export class SensorGraph extends Component { prevPoint = i; } else { console.log('Skipping value its out of order'); - console.log('New Date'); - console.log(new Date(i.ts)); - console.log(i.value); - console.log('Old Date'); - console.log(new Date(prevPoint.ts)); - console.log(prevPoint.value); } } else { acc.push([new Date(i.ts), i.value]); -- GitLab From 8afd5c2e53ca372e698e1a6fa4e205605cef64f9 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Thu, 30 Aug 2018 00:16:35 -0400 Subject: [PATCH 33/40] Remove print statements for values that we are skipping. --- src/containers/Sensors/SensorGraph.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index 0c345686..de4a2626 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -385,9 +385,7 @@ export class SensorGraph extends Component { if (new Date(i.ts) > new Date(prevPoint.ts)) { acc.push([new Date(i.ts), i.value]); prevPoint = i; - } else { - console.log('Skipping value its out of order'); - } + } } else { acc.push([new Date(i.ts), i.value]); prevPoint = i; -- GitLab From 13f5751cc63f82ec8a9c042e23a0ddfa97df64aa Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Thu, 30 Aug 2018 00:21:41 -0400 Subject: [PATCH 34/40] Remove trailing space.' --- src/containers/Sensors/SensorGraph.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index de4a2626..e78dee28 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -385,7 +385,7 @@ export class SensorGraph extends Component { if (new Date(i.ts) > new Date(prevPoint.ts)) { acc.push([new Date(i.ts), i.value]); prevPoint = i; - } + } } else { acc.push([new Date(i.ts), i.value]); prevPoint = i; -- GitLab From 4e3e15720d473af02e6cb8359f62c5fdf23669d2 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Thu, 30 Aug 2018 07:43:20 -0400 Subject: [PATCH 35/40] Reduce the date range of the initial graph to last 3 days. --- src/containers/Sensors/SensorGraph.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index e78dee28..e995c7f7 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -30,7 +30,7 @@ import { TEMPERATURE_PROBE_LOCATION_REVERSE, SENSOR_TYPES } from '../../componen import Loading from '../../components/Loading'; export class SensorGraph extends Component { - NUM_DAYS = 10; // eslint-disable-line + NUM_DAYS = 3; // eslint-disable-line constructor(props) { super(props); -- GitLab From a35821e25e7f5691caf6b540a5368ecf4bdbe33f Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Wed, 5 Sep 2018 13:19:01 -0400 Subject: [PATCH 36/40] Limit base num days to last two days. --- src/containers/Sensors/SensorGraph.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index e995c7f7..d059753b 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -30,7 +30,7 @@ import { TEMPERATURE_PROBE_LOCATION_REVERSE, SENSOR_TYPES } from '../../componen import Loading from '../../components/Loading'; export class SensorGraph extends Component { - NUM_DAYS = 3; // eslint-disable-line + NUM_DAYS = 2; // eslint-disable-line constructor(props) { super(props); -- GitLab From eddfbea7b837ed58afd5fddd3405662d935a3fee Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Wed, 5 Sep 2018 13:32:13 -0400 Subject: [PATCH 37/40] Remove console print statements. --- src/containers/Sensors/SensorGraph.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index d059753b..ccbd11a6 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -137,8 +137,6 @@ export class SensorGraph extends Component { oneNode.data.length > 0 )).map((oneNode) => { // If it's an apartment node - console.log('Apartment Node'); - console.log(oneNode); if (oneNode.node_type === 1) { const timeSeriesData = this.generateTimeSeriesFromSensor(oneNode, props); Object.keys(timeSeriesData.timeseries).map((key) => { @@ -272,8 +270,6 @@ export class SensorGraph extends Component { 'ppb': 'chemicals', 'mcg3': 'dust', }; - console.log('Generating time series for sensor'); - console.log(sensor); const measurements = sensor.data.reduce((acc, i) => { // Ignore values we don't care about like voltage if (i.unit in unitToMeasurement) { @@ -366,7 +362,6 @@ export class SensorGraph extends Component { generateTimeSeries = (data, deviceName) => { // Get all points let prevPoint = null; - console.log(deviceName); const points = data.reduce((acc, i) => { if (prevPoint) { const curDate = new Date(i.ts); -- GitLab From 7d1510976ec9286fa3c0e58808c59c512834d755 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Wed, 5 Sep 2018 13:36:24 -0400 Subject: [PATCH 38/40] Log the amount of lines. --- src/containers/Sensors/SensorGraph.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index ccbd11a6..9c013110 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -174,7 +174,7 @@ export class SensorGraph extends Component { points: weatherPoints, })); } - + console.log(Object.keys(lines).length); if (Object.keys(lines).length === 0) { return; } -- GitLab From f1c5143aa3b58f96f93134a24fd5ee7f1ecc20d6 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Wed, 5 Sep 2018 14:09:55 -0400 Subject: [PATCH 39/40] Remove unnecessary hack. --- src/containers/Sensors/SensorGraph.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index 9c013110..9d9f3a49 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -179,15 +179,10 @@ export class SensorGraph extends Component { return; } const styles = {}; - const linesMax = 10; - let linesSoFar = 0; Object.keys(lines).forEach((type) => { - if (linesSoFar < linesMax) { - lines[type].forEach((line, index) => { - styles[line.name()] = this.generateLineStyle(line, index); - }); - linesSoFar += 1; - } + lines[type].forEach((line, index) => { + styles[line.name()] = this.generateLineStyle(line, index); + }); }); this.setState({ -- GitLab From 1ba5c4e6391f88fe74e3bbc86791235052fe62d9 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Wed, 5 Sep 2018 14:12:40 -0400 Subject: [PATCH 40/40] Remove unnecessary console log. --- src/containers/Sensors/SensorGraph.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/containers/Sensors/SensorGraph.js b/src/containers/Sensors/SensorGraph.js index 9d9f3a49..06574577 100644 --- a/src/containers/Sensors/SensorGraph.js +++ b/src/containers/Sensors/SensorGraph.js @@ -174,7 +174,6 @@ export class SensorGraph extends Component { points: weatherPoints, })); } - console.log(Object.keys(lines).length); if (Object.keys(lines).length === 0) { return; } -- GitLab