Cumminicate the RC value to the server
Afterwards update the frontend accordingly.
This commit is contained in:
parent
fddf4464b8
commit
6bc20016d8
1 changed files with 14 additions and 6 deletions
20
nodejs/public/javascripts/angularApp.js
vendored
20
nodejs/public/javascripts/angularApp.js
vendored
|
@ -19,7 +19,7 @@ app.config(['$stateProvider', '$urlRouterProvider',function($stateProvider, $url
|
|||
|
||||
}]);
|
||||
|
||||
app.factory('arduino', ['$http', function($http, auth){
|
||||
app.factory('arduino', ['$http', function($http){
|
||||
var o = {
|
||||
RCs: []
|
||||
};
|
||||
|
@ -30,6 +30,13 @@ app.factory('arduino', ['$http', function($http, auth){
|
|||
});
|
||||
}
|
||||
|
||||
o.sendRC = function (RC) {
|
||||
var code = (RC.state) ? RC.off_value : RC.on_value;
|
||||
return $http.post('/register', {code}).success(function (data) {
|
||||
RC.state = (RC.state) ? false : true;
|
||||
});
|
||||
}
|
||||
|
||||
o.irTest = function ( ) {
|
||||
return $http.get('/irTest');
|
||||
}
|
||||
|
@ -42,14 +49,15 @@ app.controller('MainCtrl', ['$scope', 'arduino', function ($scope, arduino){
|
|||
$scope.RCs = arduino.RCs;
|
||||
|
||||
for (var i = $scope.RCs.length - 1; i >= 0; i--) {
|
||||
$scope.RCs[i].state = true;
|
||||
$scope.RCs[i].state = false;
|
||||
}
|
||||
|
||||
$scope.irTest = function(RC){
|
||||
|
||||
arduino.irTest();
|
||||
RC.state = (RC.state) ? false : true;
|
||||
$scope.sendRC = function(RC){
|
||||
arduino.sendRC(RC);
|
||||
};
|
||||
|
||||
$scope.irTest = function(){
|
||||
arduino.irTest();
|
||||
};
|
||||
|
||||
}]);
|
Reference in a new issue