diff --git a/app/static/index.html b/app/static/index.html index 31567ef..03eae24 100644 --- a/app/static/index.html +++ b/app/static/index.html @@ -85,6 +85,7 @@ + @@ -97,6 +98,7 @@ + diff --git a/app/static/js/backup_restore.controller.js b/app/static/js/backup_restore.controller.js index f70d2ce..cf54be2 100644 --- a/app/static/js/backup_restore.controller.js +++ b/app/static/js/backup_restore.controller.js @@ -9,10 +9,10 @@ poconsole.controller('backupRestoreCtrl', function($scope, $route, $http, $route var getBRTagList = BackupRestore.getBRTags(); getBRTagList.then(function(data) { $scope.loading = false; - $scope.bRTags = data.objects; + $scope.brTags = data.objects; }); }; - $scope.loadBRTagList(); + $scope.loadBRTagList(); //Run this function on controller startup to load list var getAllDevices = Device.getAllDevices(); getAllDevices.then(function(d){ @@ -20,73 +20,40 @@ poconsole.controller('backupRestoreCtrl', function($scope, $route, $http, $route }); $scope.submitAddBRTag = function(){ - var createStatus = Tag.createTag($scope.newTag); - $scope.createStatus = createStatus.status; - $scope.loadTagList(); - }; - - $scope.openDeleteTag = function(id){ - var getTag = Tag.getTag(id); - getTag.then(function(data){ - $scope.error = false; - $scope.dTag = data.tag; - $log.info("Thinking about deleting tag with parameters: "+ JSON.stringify($scope.dTag)); + var createStatus = BackupRestore.createBRTag($scope.newTag); + $scope.createStatus.then(function(data){ + $scope.loadBRTagList(); }); }; - $scope.deleteTag = function(id){ - var deleteTag = Tag.deleteTag(id); - deleteTag.then(function(data){ - $log.info("deleting tag "+ id + " status: " + data.status); + $scope.openDeleteBRTag = function(id){ + var getBRTag = BackupRestore.getBRTag(id); + getBRTag.then(function(data){ $scope.error = false; - $scope.loadTagList(); + $scope.dBRTag = data; }); }; - $scope.openClearTagData = function(id){ - var getTag = Tag.getTag(id); - getTag.then(function(data){ + $scope.deleteBRTag = function(id){ + var deleteBRTag = BackupRestore.deleteBRTag(id); + deleteBRTag.then(function(data){ $scope.error = false; - $scope.dTagValues = data.tag; - $log.info("Thinking about deleting tag data with parameters: "+ JSON.stringify($scope.dTagValues)); + $scope.loadBRTagList(); }); }; - $scope.deleteTagValues = function(id){ - var clearSingleTagData = Tag.clearSingleTagData(id); - clearSingleTagData.then(function(data){ - $log.info("deleting tag "+ id + " status: " + data.status); + $scope.openEditBRTag = function(id){ + var getBRTag = BackupRestore.getBRTag(id); + getBRTag.then(function(data){ $scope.error = false; - $scope.loadTagList(); + $scope.editBRTag = data; }); }; - $scope.openEditTag = function(id){ - var getTag = Tag.getTag(id); - getTag.then(function(data){ - $scope.error = false; - $scope.editTag = data.tag; - $log.info("Started editing tag with parameters: "+ JSON.stringify($scope.editTag)); + $scope.submitEditBRTag = function(){ + var updateBRTag = BackupRestore.updateBRTag($scope.editTag); + updateBRTag.then(function(data){ + $scope.loadBRTagList(); }); }; - - $scope.submitEditTag = function(){ - var editStatus = Tag.updateTag($scope.editTag); - $scope.loadTagList(); - }; - - $scope.getPlotTags = function(){ - var tags_to_plot = []; - for(var i =0; i<$scope.tags.length; i ++){ - if ($scope.tags[i].selectedForPlot){ - tags_to_plot.push($scope.tags[i]._id); - } - } - $scope.tags_to_plot = tags_to_plot.join(); - }; - - $scope.device_label = function(data_type_obj){ - return data_type_obj.address + " - " + data_type_obj.device_type.device_type; - }; - }); diff --git a/app/static/js/backup_restore.factory.js b/app/static/js/backup_restore.factory.js index 0a51370..5f0d2fe 100644 --- a/app/static/js/backup_restore.factory.js +++ b/app/static/js/backup_restore.factory.js @@ -26,6 +26,8 @@ poconsole.factory('BackupRestore', function($q, $http, $log){ }; service.updateBRTag = function(brTag){ + var deferred = $q.defer(); + var url = "/api/backup_restore/" + brTag._id; var put_obj = { tag: brTag.tag }; @@ -38,11 +40,10 @@ poconsole.factory('BackupRestore', function($q, $http, $log){ put_ojb.value = brTag.value; } - $http.put('/api/backup_restore/'+ brTag._id, data=put_obj).success(function(data){ - return data; - }).error(function(err){ - $log.warn("updateTag Error: " + err); + $http.put(url, data=put_obj).success(function(data){ + deferred.resolve(data); }); + return deferred.promise; }; service.deleteBRTag = function(id){ diff --git a/app/static/js/router.js b/app/static/js/router.js index f3312b3..a8b0b4d 100644 --- a/app/static/js/router.js +++ b/app/static/js/router.js @@ -43,6 +43,9 @@ tagserver.config([ }).when('/latest_stroke', { templateUrl: '/templates/latestcard.html', controller: 'latestStrokeCtrl' + }).when('/backup_restore', { + templateUrl: '/templates/backuprestore.html', + controller: 'backupRestoreCtrl' }).when('/multiplecards/:cardIDs', { templateUrl: '/templates/multiplecards.html', controller: 'multipleCardDataCtrl' diff --git a/app/static/templates/backuprestore.html b/app/static/templates/backuprestore.html new file mode 100644 index 0000000..af9d597 --- /dev/null +++ b/app/static/templates/backuprestore.html @@ -0,0 +1,150 @@ + + + + + + + + +
+
+
+

Loading Tags..

+ +
+
+
+ +
+
+
+
+

Error Caught!

+
{{message}}
+
+
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
TagTag TypeValue
{{tag.tag}}{{tag.tag_type}}{{tag.max_expvalueected}}
+
+
+
+