| 'use strict'; | |
| /* Controllers */ | |
| app.controller('FlotChartDemoCtrl', FlotChartDemoCtrl); | |
| function FlotChartDemoCtrl($scope,$http,$rootScope,$state,$auth,toaster,$timeout,$window) | |
| { | |
| $auth.getToken(); | |
| var uid = $rootScope.user.id; | |
| $scope.getData = function(uid , mid){ | |
| $http.get('/smartfarm/getdata/'+uid+'/'+mid).then(function(response){ | |
| if(response.data=="") | |
| { | |
| alert("No Farm Data Available !!"); | |
| } | |
| else | |
| { | |
| $scope.humidity = response.data[response.data.length - 1].humidity; | |
| $scope.temp = []; | |
| for (var j = 1; j < response.data.length; ++j) | |
| { | |
| $scope.temp.push([j , angular.fromJson(response.data[j].temperature) ] ); | |
| } | |
| $scope.light = []; | |
| for (var j = 1; j < response.data.length; ++j) | |
| { | |
| $scope.light.push([j , angular.fromJson(response.data[j].light) ] ); | |
| } | |
| $scope.ph = []; | |
| for (var j = 1; j < response.data.length; ++j) | |
| { | |
| $scope.ph.push([j , angular.fromJson(response.data[j].ph) ] ); | |
| } | |
| $scope.moisture = []; | |
| for (var j = 1; j < response.data.length; ++j) | |
| { | |
| $scope.moisture.push([j , angular.fromJson(response.data[j].moisture) ] ); | |
| } | |
| $scope.d = [ [1,6.5],[2,6.5],[3,7],[4,8],[5,7.5],[6,7],[7,6.8],[8,7],[9,7.2],[10,7],[11,6.8],[12,7] ]; | |
| } | |
| }); | |
| }; | |
| $http.get('/smartfarm/getalldata/'+uid).then(function(response) | |
| { | |
| $scope.humidity = response.data[response.data.length - 1].humidity; | |
| $scope.temp = []; | |
| for (var j = 1; j < response.data.length; ++j) | |
| { | |
| $scope.temp.push([j , angular.fromJson(response.data[j].temperature) ] ); | |
| } | |
| $scope.light = []; | |
| for (var j = 1; j < response.data.length; ++j) | |
| { | |
| $scope.light.push([j , angular.fromJson(response.data[j].light) ] ); | |
| } | |
| $scope.ph = []; | |
| for (var j = 1; j < response.data.length; ++j) | |
| { | |
| $scope.ph.push([j , angular.fromJson(response.data[j].ph) ] ); | |
| } | |
| $scope.moisture = []; | |
| for (var j = 1; j < response.data.length; ++j) | |
| { | |
| $scope.moisture.push([j , angular.fromJson(response.data[j].moisture) ] ); | |
| } | |
| }); | |
| $scope.d = [ [1,6.5],[2,6.5],[3,7],[4,8],[5,7.5],[6,7],[7,6.8],[8,7],[9,7.2],[10,7],[11,6.8],[12,7] ]; | |
| $http.get('/smartfarm/showconfiguredmasters/'+uid).then(function(response) | |
| { | |
| $scope.configuredmasters = response.data; | |
| $rootScope.cmid = response.data[0].id; | |
| }); | |
| $scope.refreshdata = function(){ | |
| $http.get('/smartfarm/getalldata/'+uid).then(function(response) | |
| { console.log('/smartfarm/getalldata/'+uid); | |
| $scope.humidity = response.data[response.data.length - 1].humidity; | |
| $scope.temp = []; | |
| for (var j = 1; j < response.data.length; ++j) | |
| { | |
| $scope.temp.push([j , angular.fromJson(response.data[j].temperature) ] ); | |
| } | |
| $scope.light = []; | |
| for (var j = 1; j < response.data.length; ++j) | |
| { | |
| $scope.light.push([j , angular.fromJson(response.data[j].light) ] ); | |
| } | |
| $scope.ph = []; | |
| for (var j = 1; j < response.data.length; ++j) | |
| { | |
| $scope.ph.push([j , angular.fromJson(response.data[j].ph) ] ); | |
| } | |
| $scope.moisture = []; | |
| for (var j = 1; j < response.data.length; ++j) | |
| { | |
| $scope.moisture.push([j , angular.fromJson(response.data[j].moisture) ] ); | |
| } | |
| }); | |
| }; | |
| } | |
| app.controller('GetAllLatLongController', GetAllLatLongController); | |
| function GetAllLatLongController($scope,$http,$state,$rootScope,$auth) | |
| { | |
| $auth.getToken(); | |
| var uid = $rootScope.user.id; | |
| $http.get('/smartfarm/getalllatlong/'+uid).then(function(response){ | |
| $scope.markers = response.data; | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment