diff --git a/nodejs/public/javascripts/angularApp.js b/nodejs/public/javascripts/angularApp.js
index 3202d62..f614cb2 100644
--- a/nodejs/public/javascripts/angularApp.js
+++ b/nodejs/public/javascripts/angularApp.js
@@ -101,6 +101,13 @@ app.factory('arduino', ['$http', 'auth', function($http, auth){
RCs: []
};
+ o.emptyrc = {
+ name: '',
+ on_value: '',
+ off_value:'',
+ tristate: true
+ };
+
o.getRCs = function () {
return $http.get('/getRCs',{
headers: {Authorization: 'Bearer '+auth.getToken()}
@@ -146,49 +153,35 @@ app.factory('arduino', ['$http', 'auth', function($http, auth){
return o;
}]);
-app.directive('modal', function() {
- return {
- restrict: 'E',
- scope: {
- show: '='
- },
- replace: true,
- transclude: true,
- link: function(scope, element, attrs) {
- scope.dialogStyle = {};
- if (attrs.width)
- scope.dialogStyle.width = attrs.width;
- if (attrs.height)
- scope.dialogStyle.height = attrs.height;
- scope.hideModal = function() {
- scope.show = false;
- };
- },
- templateUrl: '/modal.html'
- };
-});
-
app.controller('MainCtrl', [
'$scope',
'arduino',
function ($scope, arduino){
-
- $scope.RCs = arduino.RCs;
+
+ $scope.RCs = arduino.RCs;
$scope.sendRC = arduino.sendRC;
$scope.irTest = arduino.irTest;
+ $scope.newrc = angular.copy(arduino.emptyrc);
$scope.modal={
shown: false
};
- $scope.toggleModal = function(rc) {
+ $scope.toggleModal = function() {
$scope.modal.shown = !$scope.modal.shown;
- if(rc) {rc.name = rc.on = rc.off = rc.dec = '';}
+ $scope.newrc = angular.copy(arduino.emptyrc);
};
- $scope.addRC = function(rc){
+ $scope.addRC = function(){
+ console.log($scope.newrc);
$scope.modal.shown = !$scope.modal.shown;
- rc.name = rc.on = rc.off = rc.dec = '';
+ $scope.newrc = angular.copy(arduino.emptyrc);
+ }
+
+ $scope.deleteRC = function(RC) {
+ $scope.newrc = RC;
+ $scope.modal.shown = !$scope.modal.shown;
+ console.log($scope.newrc);
}
}]);
@@ -224,4 +217,26 @@ function($scope, auth){
$scope.isLoggedIn = auth.isLoggedIn;
$scope.currentUser = auth.currentUser;
$scope.logOut = auth.logOut;
-}]);
\ No newline at end of file
+}]);
+
+app.directive('modal', function() {
+ return {
+ restrict: 'E',
+ scope: {
+ show: '='
+ },
+ replace: true,
+ transclude: true,
+ link: function($scope, element, attrs) {
+ $scope.dialogStyle = {};
+ if (attrs.width)
+ $scope.dialogStyle.width = attrs.width;
+ if (attrs.height)
+ $scope.dialogStyle.height = attrs.height;
+ $scope.hideModal = function() {
+ $scope.show = false;
+ };
+ },
+ templateUrl: '/modal.html'
+ };
+});
\ No newline at end of file
diff --git a/nodejs/views/index.ejs b/nodejs/views/index.ejs
index c3f4c28..965f7f9 100644
--- a/nodejs/views/index.ejs
+++ b/nodejs/views/index.ejs
@@ -36,35 +36,35 @@