diff options
Diffstat (limited to 'www/js/EventCtrl.js')
| -rw-r--r-- | www/js/EventCtrl.js | 92 |
1 files changed, 91 insertions, 1 deletions
diff --git a/www/js/EventCtrl.js b/www/js/EventCtrl.js index 32f8b119..3af0de79 100644 --- a/www/js/EventCtrl.js +++ b/www/js/EventCtrl.js @@ -37,7 +37,7 @@ angular.module('zmApp.controllers') }) -.controller('zmApp.EventCtrl', ['$scope', '$rootScope', 'zm', 'NVRDataModel', 'message', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$ionicPlatform', '$ionicSlideBoxDelegate', '$ionicPosition', '$ionicPopover', '$ionicPopup', 'EventServer', '$sce', '$cordovaBadge', '$cordovaLocalNotification', '$q', 'carouselUtils', '$translate', '$cordovaFileTransfer', '$cordovaFile', function($scope, $rootScope, zm, NVRDataModel, message, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, $ionicPlatform, $ionicSlideBoxDelegate, $ionicPosition, $ionicPopover, $ionicPopup, EventServer, $sce, $cordovaBadge, $cordovaLocalNotification, $q, carouselUtils, $translate, $cordovaFileTransfer, $cordovaFile) +.controller('zmApp.EventCtrl', ['$scope', '$rootScope', 'zm', 'NVRDataModel', 'message', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$ionicPlatform', '$ionicSlideBoxDelegate', '$ionicPosition', '$ionicPopover', '$ionicPopup', 'EventServer', '$sce', '$cordovaBadge', '$cordovaLocalNotification', '$q', 'carouselUtils', '$translate', '$cordovaFileTransfer', '$cordovaFile', '$ionicListDelegate',function($scope, $rootScope, zm, NVRDataModel, message, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, $ionicPlatform, $ionicSlideBoxDelegate, $ionicPosition, $ionicPopover, $ionicPopup, EventServer, $sce, $cordovaBadge, $cordovaLocalNotification, $q, carouselUtils, $translate, $cordovaFileTransfer, $cordovaFile, $ionicListDelegate) { // events in last 5 minutes @@ -1556,6 +1556,94 @@ angular.module('zmApp.controllers') ); } + $scope.archiveUnarchiveEvent = function (ndx,eid) + { + //https://server/zm/api/events/11902.json -XPUT -d"Event[Archived]=1" + // + $ionicListDelegate.closeOptionButtons(); + + NVRDataModel.debug ("Archiving request for EID="+eid); + var loginData = NVRDataModel.getLogin(); + var apiArchive = loginData.apiurl + "/events/" + eid + ".json"; + var setArchiveBit = ($scope.events[ndx].Event.Archived == '0') ? "1":"0"; + + NVRDataModel.debug ("Calling archive with:"+apiArchive+ " and Archive="+setArchiveBit); + //put(url, data, [config]); + + // $http.put(apiArchive,"Event[Archived]="+setArchiveBit) + // + $ionicLoading.show( + { + template: "{{'kPleaseWait' | translate}}...", + noBackdrop: true, + duration: zm.httpTimeout + }); + + $http({ + + method: 'POST', + headers: + { + 'Content-Type': 'application/x-www-form-urlencoded', + 'Accept': '*/*', + }, + transformRequest: function(obj) + { + var str = []; + for (var p in obj) + str.push(encodeURIComponent(p) + "=" + + encodeURIComponent(obj[p])); + var foo = str.join("&"); + // console.log("****RETURNING " + foo); + NVRDataModel.debug("MonitorCtrl: parmeters constructed: " + foo); + return foo; + }, + url: apiArchive, + data: { + "Event[Archived]":setArchiveBit + + } + }) + .then (function (success) { + + NVRDataModel.log ("archiving response: "+ JSON.stringify(success)); + if (success.data.message == 'Error') + { + $ionicLoading.show( + { + template: "{{'kError' | translate}}...", + noBackdrop: true, + duration: 1500 + }); + + } + else + { + + + $ionicLoading.show( + { + template: "{{'kSuccess' | translate}}...", + noBackdrop: true, + duration: 1000 + }); + if ($scope.events[ndx].Event.Archived == '0') + $scope.events[ndx].Event.Archived = '1'; + else + $scope.events[ndx].Event.Archived = '0'; + } + + + + }, + function (error) { + NVRDataModel.log ("Error archiving: "+ JSON.stringify(error)); + } ); + + + + }; + //-------------------------------------------------------------------------- // Takes care of deleting individual events //-------------------------------------------------------------------------- @@ -1576,6 +1664,8 @@ angular.module('zmApp.controllers') duration: zm.httpTimeout }); + + $http.delete(apiDelete) .success(function(data) { |
