summaryrefslogtreecommitdiff
path: root/www/js/EventCtrl.js
diff options
context:
space:
mode:
authorPliablePixels <pliablepixels@gmail.com>2015-05-24 16:16:28 -0400
committerPliablePixels <pliablepixels@gmail.com>2015-05-24 16:16:28 -0400
commitc4fa763b5b365012756cc86024982232984904c7 (patch)
tree55b050b46ee5e12f737acf144221d9f12df6354d /www/js/EventCtrl.js
parent6323ad995bc1e301e437d4cc249a1ee75a0d471f (diff)
added PTZ support (well, P for now, but framework with a cool menu is in place)
Diffstat (limited to 'www/js/EventCtrl.js')
-rw-r--r--www/js/EventCtrl.js177
1 files changed, 141 insertions, 36 deletions
diff --git a/www/js/EventCtrl.js b/www/js/EventCtrl.js
index 7422b03a..98c3b6c9 100644
--- a/www/js/EventCtrl.js
+++ b/www/js/EventCtrl.js
@@ -6,10 +6,53 @@
// This was before I got access to the new APIs. FIXME: Revisit this code to see what I am doing with it
// and whether the new API has a better mechanism
-angular.module('zmApp.controllers').controller('zmApp.EventCtrl', ['$ionicPlatform', '$scope', '$stateParams', 'message', 'ZMDataModel', '$ionicSideMenuDelegate', '$ionicModal', '$ionicLoading', '$http', '$state', '$window', function ($ionicPlatform, $scope, $stateParams, message, ZMDataModel, $ionicSideMenuDelegate, $ionicModal, $ionicLoading, $http, $state, $window) {
+angular.module('zmApp.controllers').controller('zmApp.EventCtrl', ['$ionicPlatform', '$scope', '$stateParams', 'message', 'ZMDataModel', '$ionicSideMenuDelegate', '$ionicModal', '$ionicLoading', '$http', '$state', '$window',function ($ionicPlatform, $scope, $stateParams, message, ZMDataModel, $ionicSideMenuDelegate, $ionicModal, $ionicLoading, $http, $state, $window, $rootScope) {
console.log("I got STATE PARAM " + $stateParams.id);
$scope.id = parseInt($stateParams.id, 10);
$scope.connKey = Math.floor(Math.random() * (999999 - 111111 + 1)) + 111111;
+ // These are the commands ZM uses to move around
+ // in ZMS
+ var eventCommands = {
+ next: "13",
+ previous: "12",
+ zoomin: "8",
+ zoomout: "9",
+ stop: "3",
+ pause: "1",
+ play: "2"
+ };
+
+ $scope.showSearch = false;
+ var eventsPage = 1;
+ var moreEvents = true;
+ $scope.viewTitle = {
+ title: ""
+ };
+ $scope.search = {text:""};
+ $scope.myfilter="";
+
+
+
+ // for some reason inifinite scroll is invoked
+ // before I actually load the first page with page count
+ // this makes scrolling stop as eventsPage is still 0
+ // FIXME: This is a hack
+
+ var pageLoaded = false;
+
+
+ // FIXME: Hack or elegance?
+ // to get rid of full stack event get on search
+
+ var enableLoadMore = true;
+
+ // When loading images, it sometimes takes time - the images can be quite
+ // large. What practically was happening was you'd see a blank screen for a few
+ // seconds. Not a good UX. So what I am doing is when the events modal or
+ // monitor modal is loaded, I show an ionic loading. And then when the first frame
+ // finishes loading, I take it away
+
+
$scope.openMenu = function () {
$ionicSideMenuDelegate.toggleLeft();
@@ -31,6 +74,18 @@ angular.module('zmApp.controllers').controller('zmApp.EventCtrl', ['$ionicPlatfo
};
+ $scope.tapped = function()
+ {
+ console.log ("*** TAPPED ****");
+ // if he tapped, the we are not infinite loading on ion-infinite
+ if ( enableLoadMore == false )
+ {
+ moreEvents=true;
+ enableLoadMore = true;
+ console.log ("REMOVING ARTIFICAL LOAD MORE BLOCK");
+ }
+ };
+
$scope.$on('$ionicView.loaded', function () {
console.log("**VIEW ** Events Ctrl Loaded");
});
@@ -53,43 +108,38 @@ angular.module('zmApp.controllers').controller('zmApp.EventCtrl', ['$ionicPlatfo
});
- // These are the commands ZM uses to move around
- // in ZMS
- var eventCommands = {
- next: "13",
- previous: "12",
- zoomin: "8",
- zoomout: "9",
- stop: "3",
- pause: "1",
- play: "2"
+
+ $scope.finishedLoadingImage = function () {
+ console.log("*** Events image FINISHED loading ***");
+ $ionicLoading.hide();
};
- var eventsPage = 1;
- var moreEvents = true;
- $scope.viewTitle = {
- title: ""
+ $scope.clearSearch = function()
+ {
+ $scope.search.text="";
+ console.log ("CLEAR");
};
- // for some reason inifinite scroll is invoked
- // before I actually load the first page with page count
- // this makes scrolling stop as eventsPage is still 0
- // FIXME: This is a hack
+ $scope.searchClicked = function()
+ {
+ $scope.showSearch = !$scope.showSearch;
+ // this helps greatly in repeat scroll gets
+ if ($scope.showSearch == false)
+ $scope.search.text="";
+
+ console.log ("**** Setting search view to "+$scope.showSearch+" ****");
+ if ( enableLoadMore == false && $scope.showSearch == false)
+ {
+ moreEvents=true;
+ enableLoadMore = true;
+ console.log ("REMOVING ARTIFICAL LOAD MORE BLOCK");
+ }
+ };
- var pageLoaded = false;
- // When loading images, it sometimes takes time - the images can be quite
- // large. What practically was happening was you'd see a blank screen for a few
- // seconds. Not a good UX. So what I am doing is when the events modal or
- // monitor modal is loaded, I show an ionic loading. And then when the first frame
- // finishes loading, I take it away
+ $scope.eventCommands = eventCommands;
- $scope.finishedLoadingImage = function () {
- console.log("*** Events image FINISHED loading ***");
- $ionicLoading.hide();
- };
- $scope.eventCommands = eventCommands;
// this routine handles skipping through events
// in different event views
@@ -180,7 +230,7 @@ angular.module('zmApp.controllers').controller('zmApp.EventCtrl', ['$ionicPlatfo
console.log("SUCCESS: " + JSON.stringify(resp));
var str = toast_blurb + "event:" + resp.status.event;
console.log(str);
- $ionicLoading.hide();
+ // $ionicLoading.hide();
$ionicLoading.show({
template: str,
noBackdrop: true,
@@ -257,13 +307,16 @@ angular.module('zmApp.controllers').controller('zmApp.EventCtrl', ['$ionicPlatfo
// start from the latest. If this fails, nothing displays
// FIXME: clean up error handling
+ // FIXME: call loadMore once -- to fill up page. Its possible
+ // last event page only has a few records
+
ZMDataModel.getEventsPages($scope.id)
.then(function (data) {
eventsPage = data.pageCount;
console.log("TOTAL EVENT PAGES IS " + eventsPage);
pageLoaded = true;
$scope.viewTitle.title = data.count;
- ZMDataModel.getEvents($scope.id, eventsPage)
+ ZMDataModel.getEvents($scope.id, eventsPage,"")
.then(function (data) {
console.log("EventCtrl Got events");
@@ -287,6 +340,23 @@ angular.module('zmApp.controllers').controller('zmApp.EventCtrl', ['$ionicPlatfo
return moreEvents;
};
+ $scope.cancelSearch = function()
+ {
+ $ionicLoading.hide(); //Or whatever action you want to preform
+ enableLoadMore = false;
+ console.log ("**** CANCELLED ****");
+ $ionicLoading.show({
+ template: 'Search Cancelled',
+ animation: 'fade-in',
+ showBackdrop: true,
+ duration: 2000,
+ maxWidth: 200,
+ showDelay: 0
+ });
+
+
+ };
+
$scope.loadMore = function () {
// the events API does not return an error for anything
@@ -300,9 +370,32 @@ angular.module('zmApp.controllers').controller('zmApp.EventCtrl', ['$ionicPlatfo
return;
}
+ if (!enableLoadMore)
+ {
+ moreEvents=false; // Dont ion-scroll till enableLoadMore is true;
+ $scope.$broadcast('scroll.infiniteScrollComplete');
+
+ console.log ("**** LOADMORE ARTIFICALLY DISABLED");
+ return;
+ }
+
+ var loadingStr="";
+ if ($scope.search.text != "")
+ {
+ var toastStr="Searching page "+eventsPage;
+
+
+$ionicLoading.show({ maxwidth:100, scope:$scope, template: '<button class="button button-clear icon-left ion-close-circled button-text-wrap" ng-click="cancelSearch()" >'+toastStr+'</button>' });
- ZMDataModel.getEvents($scope.id, eventsPage)
+ // toastr.info(toastStr,{"positionClass": "toast-bottom-full-width",
+ // "showMethod": "fadeIn",
+ // "hideMethod": "fadeOut",
+ // "closeButton": false,
+ // });
+ loadingStr="none";
+ }
+ ZMDataModel.getEvents($scope.id, eventsPage,loadingStr)
.then(function (data) {
console.log("Got new page of events with Page=" + eventsPage);
var myevents = data;
@@ -312,14 +405,16 @@ angular.module('zmApp.controllers').controller('zmApp.EventCtrl', ['$ionicPlatfo
}
$scope.events = $scope.events.concat(myevents);
console.log("Got new page of events");
-
+ moreEvents = true;
$scope.$broadcast('scroll.infiniteScrollComplete');
+ //toastr.clear();
},
function (error) {
console.log("*** No More Events to Load, Stop Infinite Scroll ****");
moreEvents = false;
$scope.$broadcast('scroll.infiniteScrollComplete');
+ // toastr.clear();
});
// $scope.$broadcast('scroll.infiniteScrollComplete');
@@ -330,18 +425,28 @@ angular.module('zmApp.controllers').controller('zmApp.EventCtrl', ['$ionicPlatfo
return ZMDataModel.isSimulated();
};
+ // For consistency we are keeping the refresher list
+ // but its a dummy. The reason I deviated is because
+ // refresh with infinite scroll is a UX problem - its
+ // easy to pull to refresh when scrolling up with
+ // a large list
+
+ $scope.dummyDoRefresh= function()
+ {
+ $scope.$broadcast('scroll.refreshComplete');
+ };
$scope.doRefresh = function () {
console.log("***Pull to Refresh");
$scope.events = [];
-
+ moreEvents = true;
ZMDataModel.getEventsPages($scope.id)
.then(function (data) {
eventsPage = data.pageCount;
console.log("TOTAL EVENT PAGES IS " + eventsPage);
pageLoaded = true;
$scope.viewTitle.title = data.count;
- ZMDataModel.getEvents($scope.id, eventsPage)
+ ZMDataModel.getEvents($scope.id, eventsPage,"")
.then(function (data) {
console.log("EventCtrl Got events");