From d04f8a22b7b3a586eb64d9c1315ea6982727d34d Mon Sep 17 00:00:00 2001 From: charithag Date: Mon, 6 Jul 2015 13:18:39 +0530 Subject: [PATCH] Filter analytics according to device types --- .../iotserver/units/analytics/analytics.hbs | 72 +++++++++++-------- .../units/analytics/public/js/graph_util.js | 42 +++++++++-- 2 files changed, 78 insertions(+), 36 deletions(-) diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/analytics.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/analytics.hbs index 52feb7ae..557d1a9c 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/analytics.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/analytics.hbs @@ -36,53 +36,65 @@
-
-
-

Temperature

+
+
+
+

Temperature

+
+
No data available...
+

-
No data available...
-
-
-
-

Light

+
+
+
+

Light

+
+
No data available...
+

-
No data available...
-
-
-
-

Motion

+
+
+
+

Motion

+
+
No data available...
+

-
No data available...
-
-
-
-

Sonar

+
+
+
+

Sonar

+
+
No data available...
+

-
No data available...
-
-
-
-

Fan Status

+
+
+
+

Fan Status

+
+
No data available...
+

-
No data available...
-
-
-
-

Bulb Status

+
+
+
+

Bulb Status

+
+
No data available...
+

-
No data available...
-
diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/public/js/graph_util.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/public/js/graph_util.js index c159c1ba..c49d5843 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/public/js/graph_util.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/public/js/graph_util.js @@ -148,22 +148,52 @@ function updateGraphs(stats) { console.log(stats); var temperatureData = stats['temperatureData']; - updateTemperatureGraph(convertStatsToGraphData(temperatureData)); + if (typeof temperatureData != 'undefined'){ + $('#div-temperatureData').html("").html("

Temperature



"); + updateTemperatureGraph(convertStatsToGraphData(temperatureData)); + }else{ + $('#div-temperatureData').html(""); + } var lightData = stats['lightData']; - updateLightGraph(convertStatsToGraphData(lightData)); + if (typeof lightData != 'undefined'){ + $('#div-lightData').html("").html("

Light



"); + updateLightGraph(convertStatsToGraphData(lightData)); + }else{ + $('#div-lightData').html(""); + } var motionData = stats['motionData']; - updateMotionGraph(convertStatsToGraphData(motionData)); + if (typeof motionData != 'undefined'){ + $('#div-motionData').html("").html("

Motion



"); + updateMotionGraph(convertStatsToGraphData(motionData)); + }else{ + $('#div-motionData').html(""); + } var sonarData = stats['sonarData']; - updateSonarGraph(convertStatsToGraphData(sonarData)); + if (typeof sonarData != 'undefined'){ + $('#div-sonarData').html("").html("

Sonar



"); + updateSonarGraph(convertStatsToGraphData(sonarData)); + }else{ + $('#div-sonarData').html(""); + } var fanData = stats['fanData']; - updateFanGraph(convertStateStatsToGraphData(fanData)); + if (typeof fanData != 'undefined'){ + $('#div-fanData').html("").html("

Fan Status



"); + updateFanGraph(convertStateStatsToGraphData(fanData)); + }else{ + $('#div-fanData').html(""); + } var bulbData = stats['bulbData']; - updateBulbGraph(convertStateStatsToGraphData(bulbData)); + if (typeof bulbData != 'undefined'){ + $('#div-bulbData').html("").html("

Bulb Status



"); + updateBulbGraph(convertStateStatsToGraphData(bulbData)); + }else{ + $('#div-bulbData').html(""); + } scaleGraphs(); }