From f278ac326627ab2c5cc00a70236e47b19d568831 Mon Sep 17 00:00:00 2001 From: charithag Date: Tue, 4 Aug 2015 16:51:33 +0530 Subject: [PATCH] Fix script bug in stats display --- .../jaggeryapps/iotserver/api/stats-api.jag | 20 ++++++++----------- .../units/analytics/public/js/graph_util.js | 4 ++-- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/api/stats-api.jag b/modules/distribution/src/repository/jaggeryapps/iotserver/api/stats-api.jag index 27549d09..28c260a3 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/api/stats-api.jag +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/api/stats-api.jag @@ -101,26 +101,22 @@ function getDeviceData(deviceType, deviceId){ } function getFireAlarmData(user, device, from, to) { - if (stats['cpuTemperatureData'] == null){ - stats['cpuTemperatureData'] = []; - } if (stats['temperatureData'] == null){ stats['temperatureData'] = []; } - if (stats['fanData'] == null){ - stats['fanData'] = []; - } - if (stats['bulbData'] == null){ - stats['bulbData'] = []; - } if (stats['sonarData'] == null){ stats['sonarData'] = []; } - stats['cpuTemperatureData'].push({"device": device.name, "stats" : getSensorData("DEVICE_CPU_TEMPERATURE_SUMMARY", "TEMPERATURE", user, device.deviceIdentifier, from, to)}); + if (stats['motionData'] == null){ + stats['motionData'] = []; + } + if (stats['lightData'] == null){ + stats['lightData'] = []; + } stats['temperatureData'].push({"device": device.name, "stats" : getSensorData("DEVICE_TEMPERATURE_SUMMARY", "TEMPERATURE", user, device.deviceIdentifier, from, to)}); - stats['fanData'].push({"device": device.name, "stats" : getSensorData("DEVICE_FAN_USAGE_SUMMARY", "status", user, device.deviceIdentifier, from, to)}); - stats['bulbData'].push({"device": device.name, "stats" : getSensorData("DEVICE_BULB_USAGE_SUMMARY", "status", user, device.deviceIdentifier, from, to)}); stats['sonarData'].push({"device": device.name, "stats" : getSensorData("SONAR_SENSOR_SUMMARY", "sonar", user, device.deviceIdentifier, from, to)}); + stats['motionData'].push({"device": device.name, "stats" : getSensorData("PIR_MOTION_SENSOR_SUMMARY", "motion", user, device.deviceIdentifier, from, to)}); + stats['lightData'].push({"device": device.name, "stats" : getSensorData("LDR_LIGHT_SENSOR_SUMMARY", "light", user, device.deviceIdentifier, from, to)}); } function getSensebotData(user, device, from, to) { 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 3278f558..e1af806e 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 @@ -315,7 +315,7 @@ function drawLineGraph(graphId, chartDataRaw) { var chartData = []; if (chartDataRaw[i].stats.length > 0) { for (var j = 0; j < chartDataRaw[i].stats.length; j++) { - chartData.push({x: parseInt(chartDataRaw[i].stats[j].x), y: parseInt(chartDataRaw[i].stats[j].y)}); + chartData.push({x: parseInt(chartDataRaw[i].stats[j].time), y: parseInt(chartDataRaw[i].stats[j].value)}); } graphConfig['series'].push({'color': color[k], 'data': chartData, 'name': chartDataRaw[i].device}); } @@ -406,7 +406,7 @@ function drawBarGraph(graphId, chartDataRaw) { var chartData = []; if (chartDataRaw[i].stats.length > 0) { for (var j = 0; j < chartDataRaw[i].stats.length; j++) { - chartData.push({x: parseInt(chartDataRaw[i].stats[j].x), y: parseInt(chartDataRaw[i].stats[j].y)}); + chartData.push({x: parseInt(chartDataRaw[i].stats[j].time), y: parseInt(chartDataRaw[i].stats[j].value)}); } graphConfig['series'].push({'color': color[k], 'data': chartData, 'name': chartDataRaw[i].device}); }