summaryrefslogtreecommitdiff
path: root/www/js/EventCtrl.js
diff options
context:
space:
mode:
authorPliable Pixels <pliablepixels@gmail.com>2016-12-29 17:26:23 -0500
committerPliable Pixels <pliablepixels@gmail.com>2016-12-29 17:26:23 -0500
commit4590992c3670836d6d04293d855f05dee8e8c339 (patch)
treeec734de1c551dedc9972f2f92b1ee9b812b6eaee /www/js/EventCtrl.js
parentb8e3c2c1f15740f4de47298983083865b5754e39 (diff)
swipe left to flag/unflag events (archive/un-archive) - still some UI work to be done #388
Diffstat (limited to 'www/js/EventCtrl.js')
-rw-r--r--www/js/EventCtrl.js87
1 files changed, 87 insertions, 0 deletions
diff --git a/www/js/EventCtrl.js b/www/js/EventCtrl.js
index 32f8b119..a3958501 100644
--- a/www/js/EventCtrl.js
+++ b/www/js/EventCtrl.js
@@ -1556,6 +1556,91 @@ angular.module('zmApp.controllers')
);
}
+ $scope.archiveUnarchiveEvent = function (ndx,eid)
+ {
+ //https://server/zm/api/events/11902.json -XPUT -d"Event[Archived]=1"
+ 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 +1661,8 @@ angular.module('zmApp.controllers')
duration: zm.httpTimeout
});
+
+
$http.delete(apiDelete)
.success(function(data)
{