summaryrefslogtreecommitdiff
path: root/www/js
diff options
context:
space:
mode:
authorPliable Pixels <pliablepixels@gmail.com>2018-10-21 18:49:32 -0400
committerPliable Pixels <pliablepixels@gmail.com>2018-10-21 18:49:32 -0400
commite3076881b748fff53690373f02211706b60fab79 (patch)
treeb417ca52d1be5198bd5f7aefe646782b0d60b4db /www/js
parent3f549f3d6ea3dac1fbf862e236549ce0dd7fd570 (diff)
#725 moved evaluate tapped notification to service,trapped handler in all controllers
Diffstat (limited to 'www/js')
-rw-r--r--www/js/DataModel.js61
-rw-r--r--www/js/DevOptionsCtrl.js11
-rw-r--r--www/js/EventCtrl.js19
-rw-r--r--www/js/EventServer.js10
-rw-r--r--www/js/LogCtrl.js11
-rw-r--r--www/js/LoginCtrl.js11
-rw-r--r--www/js/MomentCtrl.js11
-rw-r--r--www/js/MonitorCtrl.js11
-rw-r--r--www/js/MontageCtrl.js19
-rw-r--r--www/js/MontageHistoryCtrl.js12
-rw-r--r--www/js/NewsCtrl.js11
-rw-r--r--www/js/PortalLoginCtrl.js104
-rw-r--r--www/js/StateCtrl.js12
-rw-r--r--www/js/TimelineCtrl.js14
14 files changed, 209 insertions, 108 deletions
diff --git a/www/js/DataModel.js b/www/js/DataModel.js
index 71062b57..168c29f1 100644
--- a/www/js/DataModel.js
+++ b/www/js/DataModel.js
@@ -675,6 +675,67 @@ angular.module('zmApp.controllers')
debug(val);
},
+ evaluateTappedNotification: function() {
+
+ var state = "";
+ var stateParams1 = {};
+ var stateParams2 = {};
+
+ debug ("Inside evaluateNotifications");
+
+ if ($rootScope.tappedNotification == 2) { // url launch
+ debug("Came via app url launch with mid=" + $rootScope.tappedMid);
+ debug("Came via app url launch with eid=" + $rootScope.tappedEid);
+
+
+ if (parseInt($rootScope.tappedMid) > 0) {
+ debug("Going to live view ");
+ state = "app.monitors";
+
+ } else if (parseInt($rootScope.tappedEid) > 0) {
+ debug("Going to events with EID=" + $rootScope.tappedEid);
+ state = "app.events";
+ stateParams1 = {
+ "id": 0,
+ "playEvent": true
+ };
+ stateParams2 = {
+ reload: true
+ };
+
+ }
+
+
+ } // 2
+ else if ($rootScope.tappedNotification == 1) // push
+ {
+
+
+ debug("Came via push tap. onTapScreen=" + loginData.onTapScreen);
+ if (loginData.onTapScreen == $translate.instant('kTapMontage')) {
+ debug("Going to montage");
+ state = "app.montage";
+
+
+ } else if (loginData.onTapScreen == $translate.instant('kTapEvents')) {
+ debug("Going to events");
+ state = "app.events";
+ stateParams1 = {
+ "id": 0,
+ "playEvent": true
+ };
+
+ } else // we go to live
+ {
+ debug("Going to live view ");
+ state = "app.monitors";
+
+ }
+ }
+ $rootScope.tappedNotification = 0;
+ return [state, stateParams1, stateParams2];
+ },
+
setLastUpdateCheck: function (val) {
lastUpdateCheck = val;
localforage.setItem("lastUpdateCheck", lastUpdateCheck);
diff --git a/www/js/DevOptionsCtrl.js b/www/js/DevOptionsCtrl.js
index dab4570b..5592baa3 100644
--- a/www/js/DevOptionsCtrl.js
+++ b/www/js/DevOptionsCtrl.js
@@ -10,6 +10,17 @@ angular.module('zmApp.controllers').controller('zmApp.DevOptionsCtrl', ['$scope'
};
+ $scope.$on ( "process-push", function () {
+ NVRDataModel.debug (">> DevOptionsCtrl: push handler");
+ var s = NVRDataModel.evaluateTappedNotification();
+ NVRDataModel.debug("tapped Notification evaluation:"+ JSON.stringify(s));
+ $ionicHistory.nextViewOptions({
+ disableAnimate:true,
+ disableBack: true
+ });
+ $state.go(s[0],s[1],s[2]);
+ });
+
//----------------------------------------------------------------
// Alarm notification handling
//----------------------------------------------------------------
diff --git a/www/js/EventCtrl.js b/www/js/EventCtrl.js
index 2c64ce70..cce81b3a 100644
--- a/www/js/EventCtrl.js
+++ b/www/js/EventCtrl.js
@@ -71,6 +71,19 @@ angular.module('zmApp.controllers')
// initial code
//---------------------------------------------------
+
+ $scope.$on ( "process-push", function () {
+ NVRDataModel.debug (">> EventCtrl: push handler");
+ var s = NVRDataModel.evaluateTappedNotification();
+ NVRDataModel.debug("tapped Notification evaluation:"+ JSON.stringify(s));
+ $ionicHistory.nextViewOptions({
+ disableAnimate:true,
+ disableBack: true
+ });
+ $state.go(s[0],s[1],s[2]);
+ });
+
+
//we come here is TZ is updated after the view loads
var tzu = $scope.$on('tz-updated', function () {
$scope.tzAbbr = NVRDataModel.getTimeZoneNow();
@@ -115,8 +128,8 @@ angular.module('zmApp.controllers')
footerExpand();
// now do event playback if asked
- if (parseInt($rootScope.tappedEid) > 0) {
- NVRDataModel.debug(" Trying ot live play " + $rootScope.tappedEid);
+ if (parseInt($rootScope.tappedEid) > 0 && $stateParams.playEvent == 'true') {
+ NVRDataModel.debug(" Trying to play event due to push:" + $rootScope.tappedEid);
playSpecificEvent($rootScope.tappedEid);
}
@@ -148,7 +161,7 @@ angular.module('zmApp.controllers')
window.removeEventListener("resize", recomputeThumbSize, false);
NVRDataModel.debug("EventCtrl: Deregistering broadcast handles");
for (var i = 0; i < broadcastHandles.length; i++) {
- // broadcastHandles[i]();
+ // broadcastHandles[i]();
}
broadcastHandles = [];
});
diff --git a/www/js/EventServer.js b/www/js/EventServer.js
index 1340b88d..da1e07a3 100644
--- a/www/js/EventServer.js
+++ b/www/js/EventServer.js
@@ -598,13 +598,13 @@ angular.module('zmApp.controllers')
$rootScope.tappedMid = mid;
$rootScope.tappedEid = eid;
- NVRDataModel.log("Push notification: Tapped Monitor taken as:" + $rootScope.tappedMid);
+ NVRDataModel.log("ES:Push notification: Tapped Monitor taken as:" + $rootScope.tappedMid);
if ($rootScope.platformOS == 'ios') {
- NVRDataModel.debug("iOS only: clearing background push");
+ NVRDataModel.debug("ES:iOS only: clearing background push");
push.finish(function () {
- NVRDataModel.debug("processing of push data is finished");
+ NVRDataModel.debug("ES:processing of push data is finished");
});
}
@@ -616,7 +616,9 @@ angular.module('zmApp.controllers')
}
// keep this emit not broadcast
// see Portal latch for reason
- $rootScope.$emit('process-push');
+
+ NVRDataModel.debug ("EventServer: broadvasting process-push");
+ $rootScope.$broadcast('process-push');
} else // app is foreground
{
diff --git a/www/js/LogCtrl.js b/www/js/LogCtrl.js
index 46db4304..9a84661a 100644
--- a/www/js/LogCtrl.js
+++ b/www/js/LogCtrl.js
@@ -26,6 +26,17 @@ angular.module('zmApp.controllers').controller('zmApp.LogCtrl', ['$scope', '$roo
loadLogs();
}
+ $scope.$on ( "process-push", function () {
+ NVRDataModel.debug (">> LogCtrl: push handler");
+ var s = NVRDataModel.evaluateTappedNotification();
+ NVRDataModel.debug("tapped Notification evaluation:"+ JSON.stringify(s));
+ $ionicHistory.nextViewOptions({
+ disableAnimate:true,
+ disableBack: true
+ });
+ $state.go(s[0],s[1],s[2]);
+ });
+
$scope.flipLogs = function () {
if ($scope.logEntity == 'ZoneMinder')
$scope.logEntity = $rootScope.appName;
diff --git a/www/js/LoginCtrl.js b/www/js/LoginCtrl.js
index a9a09433..568b67ed 100644
--- a/www/js/LoginCtrl.js
+++ b/www/js/LoginCtrl.js
@@ -33,6 +33,17 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r
}
+ $scope.$on ( "process-push", function () {
+ NVRDataModel.debug (">> LoginCtrl: push handler");
+ var s = NVRDataModel.evaluateTappedNotification();
+ NVRDataModel.debug("tapped Notification evaluation:"+ JSON.stringify(s));
+ $ionicHistory.nextViewOptions({
+ disableAnimate:true,
+ disableBack: true
+ });
+ $state.go(s[0],s[1],s[2]);
+ });
+
//----------------------------------------------------------------
// Alarm notification handling
//----------------------------------------------------------------
diff --git a/www/js/MomentCtrl.js b/www/js/MomentCtrl.js
index ace5d218..d108010d 100644
--- a/www/js/MomentCtrl.js
+++ b/www/js/MomentCtrl.js
@@ -23,6 +23,17 @@ angular.module('zmApp.controllers').controller('zmApp.MomentCtrl', ['$scope', '$
$ionicSideMenuDelegate.toggleLeft();
};
+ $scope.$on ( "process-push", function () {
+ NVRDataModel.debug (">> MomentCtrl: push handler");
+ var s = NVRDataModel.evaluateTappedNotification();
+ NVRDataModel.debug("tapped Notification evaluation:"+ JSON.stringify(s));
+ $ionicHistory.nextViewOptions({
+ disableAnimate:true,
+ disableBack: true
+ });
+ $state.go(s[0],s[1],s[2]);
+ });
+
//----------------------------------------------------------------
// Alarm notification handling
//----------------------------------------------------------------
diff --git a/www/js/MonitorCtrl.js b/www/js/MonitorCtrl.js
index dbc4a7f3..6e2ce019 100644
--- a/www/js/MonitorCtrl.js
+++ b/www/js/MonitorCtrl.js
@@ -48,6 +48,17 @@ angular.module('zmApp.controllers')
$ionicSideMenuDelegate.toggleLeft();
};
+ $scope.$on ( "process-push", function () {
+ NVRDataModel.debug (">> MonitorCtrl: push handler");
+ var s = NVRDataModel.evaluateTappedNotification();
+ NVRDataModel.debug("tapped Notification evaluation:"+ JSON.stringify(s));
+ $ionicHistory.nextViewOptions({
+ disableAnimate:true,
+ disableBack: true
+ });
+ $state.go(s[0],s[1],s[2]);
+ });
+
//----------------------------------------------------------------
// Alarm notification handling
//----------------------------------------------------------------
diff --git a/www/js/MontageCtrl.js b/www/js/MontageCtrl.js
index 003e1168..dd574704 100644
--- a/www/js/MontageCtrl.js
+++ b/www/js/MontageCtrl.js
@@ -47,6 +47,20 @@ angular.module('zmApp.controllers')
var broadcastHandles = [];
+ $scope.$on ( "process-push", function () {
+ NVRDataModel.debug (">> MontageCtrl: push handler");
+ var s = NVRDataModel.evaluateTappedNotification();
+ NVRDataModel.debug("tapped Notification evaluation:"+ JSON.stringify(s));
+ $ionicHistory.nextViewOptions({
+ disableAnimate:true,
+ disableBack: true
+ });
+ $state.go(s[0],s[1],s[2]);
+ });
+
+
+
+
var as = $scope.$on("auth-success", function () {
/* var tnow = new Date();
@@ -2012,6 +2026,11 @@ angular.module('zmApp.controllers')
currentStreamState = streamState.STOPPED;
viewCleanup();
viewCleaned = true;
+ NVRDataModel.debug("Deregistering broadcast handles");
+ for (var i = 0; i < broadcastHandles.length; i++) {
+ broadcastHandles[i]();
+ }
+ broadcastHandles = [];
});
diff --git a/www/js/MontageHistoryCtrl.js b/www/js/MontageHistoryCtrl.js
index e2782387..ea9f7f2f 100644
--- a/www/js/MontageHistoryCtrl.js
+++ b/www/js/MontageHistoryCtrl.js
@@ -11,6 +11,18 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc
var viewCleaned = false;
$scope.isScreenReady = false;
+
+ $scope.$on ( "process-push", function () {
+ NVRDataModel.debug (">> MontageHistoryCtrl: push handler");
+ var s = NVRDataModel.evaluateTappedNotification();
+ NVRDataModel.debug("tapped Notification evaluation:"+ JSON.stringify(s));
+ $ionicHistory.nextViewOptions({
+ disableAnimate:true,
+ disableBack: true
+ });
+ $state.go(s[0],s[1],s[2]);
+ });
+
//--------------------------------------------------------------------------------------
// Handles bandwidth change, if required
//
diff --git a/www/js/NewsCtrl.js b/www/js/NewsCtrl.js
index ba45fb0e..d9850080 100644
--- a/www/js/NewsCtrl.js
+++ b/www/js/NewsCtrl.js
@@ -27,6 +27,17 @@ angular.module('zmApp.controllers').controller('zmApp.NewsCtrl', ['$scope', '$ro
}
};
+ $scope.$on ( "process-push", function () {
+ NVRDataModel.debug (">> NewsCtrl: push handler");
+ var s = NVRDataModel.evaluateTappedNotification();
+ NVRDataModel.debug("tapped Notification evaluation:"+ JSON.stringify(s));
+ $ionicHistory.nextViewOptions({
+ disableAnimate:true,
+ disableBack: true
+ });
+ $state.go(s[0],s[1],s[2]);
+ });
+
//-------------------------------------------------------------------------
// Lets make sure we set screen dim properly as we enter
// The problem is we enter other states before we leave previous states
diff --git a/www/js/PortalLoginCtrl.js b/www/js/PortalLoginCtrl.js
index 592e2c43..9789ed56 100644
--- a/www/js/PortalLoginCtrl.js
+++ b/www/js/PortalLoginCtrl.js
@@ -5,7 +5,7 @@
/* global vis,cordova,StatusBar,angular,console,moment */
angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionicPlatform', '$scope', 'zm', 'NVRDataModel', '$ionicSideMenuDelegate', '$rootScope', '$http', '$q', '$state', '$ionicLoading', '$ionicPopover', '$ionicScrollDelegate', '$ionicModal', '$timeout', 'zmAutoLogin', '$ionicHistory', 'EventServer', '$translate', '$ionicPopup', function ($ionicPlatform, $scope, zm, NVRDataModel, $ionicSideMenuDelegate, $rootScope, $http, $q, $state, $ionicLoading, $ionicPopover, $ionicScrollDelegate, $ionicModal, $timeout, zmAutoLogin, $ionicHistory, EventServer, $translate, $ionicPopup) {
- var processPush = false;
+
var broadcastHandles = [];
$scope.$on('$ionicView.beforeLeave', function () {
@@ -270,95 +270,8 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic
}
- //this needs to be rootScope so it lives even when we are out of view
- var pp = $rootScope.$on("process-push", function () {
- processPush = true;
- NVRDataModel.debug("processPush set to true, but will act after login is complete...");
-
-
-
-
- });
- broadcastHandles.push(pp);
-
- function evaluateTappedNotification() {
- NVRDataModel.debug (">>>Inside evaluateNotifications");
- var ld = NVRDataModel.getLogin();
-
-
- if ($rootScope.tappedNotification == 2) { // url launch
- NVRDataModel.debug("Came via app url launch with mid=" + $rootScope.tappedMid);
- NVRDataModel.debug("Came via app url launch with eid=" + $rootScope.tappedEid);
- $rootScope.tappedNotification = 0;
- $ionicHistory.nextViewOptions({
- disableBack: true
- });
-
- if (parseInt($rootScope.tappedMid) > 0) {
- NVRDataModel.debug("Going to live view ");
- $state.go("app.monitors");
- return;
-
- } else if (parseInt($rootScope.tappedEid) > 0) {
- NVRDataModel.debug("Going to events with EID=" + $rootScope.tappedEid);
- $state.go("app.events", {
- //"id": $rootScope.tappedEid,
- "id": 0,
- "playEvent": true
- }, {
- reload: true
- });
- return;
- }
- // go with monitor first, then event - just because I feel like ;)
-
-
- } else if ($rootScope.tappedNotification == 1) // push
- {
-
-
- NVRDataModel.log("Came via push tap. onTapScreen=" + ld.onTapScreen);
- $rootScope.pushOverride = true;
- //console.log ("***** NOTIFICATION TAPPED ");
- $rootScope.tappedNotification = 0;
- $ionicHistory.nextViewOptions({
- disableBack: true
- });
-
- if (ld.onTapScreen == $translate.instant('kTapMontage')) {
- NVRDataModel.debug("Going to montage");
- $state.go("app.montage");
-
- return;
- } else if (ld.onTapScreen == $translate.instant('kTapEvents')) {
- NVRDataModel.debug("Going to events");
- $state.go("app.events", {
- "id": 0,
- "playEvent": false
- });
- return;
- } else // we go to live
- {
- NVRDataModel.debug("Going to live view ");
- $state.go("app.monitors");
- return;
- }
- } else {
- /* NVRDataModel.debug ("Inside evaluateTapped, but no tap occured.");
- NVRDataModel.debug ("This can happen if timing mismatch and holy foo happens");
- $state.go("app.montage",
- {},
- {
- reload: true
- });
- return;*/
-
- }
-
- }
-
-
+ //broadcastHandles.push(pp);
function unlock(idVerified) {
/*
@@ -455,7 +368,7 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic
// if push happens AFTER this, then while going to
// lastState, it will interrupt and go to onTap
// (I HOPE...)
- if (!processPush) {
+
//console.log ("NOTIFICATION TAPPED INSIDE CHECK IS "+$rootScope.tappedNotification);
var statetoGo = $rootScope.lastState ? $rootScope.lastState : 'app.montage';
// NVRDataModel.debug("logging state transition");
@@ -465,16 +378,7 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic
$state.go(statetoGo, $rootScope.lastStateParam);
return;
- }
- else {
- NVRDataModel.debug ("Authentication over, now processing push...");
- evaluateTappedNotification();
- processPush = false;
- }
- // else
- // evaluateTappedNotification();
-
-
+
},
function (error) { // API Error
NVRDataModel.log("API Error handler: going to login getAPI returned error: " + JSON.stringify(error));
diff --git a/www/js/StateCtrl.js b/www/js/StateCtrl.js
index 62bffb81..096df1e0 100644
--- a/www/js/StateCtrl.js
+++ b/www/js/StateCtrl.js
@@ -34,6 +34,18 @@ angular.module('zmApp.controllers').controller('zmApp.StateCtrl', ['$ionicPopup'
var inProgress = 0; // prevents user from another op if one is in progress
getRunStatus();
+
+ $scope.$on ( "process-push", function () {
+ NVRDataModel.debug (">> StateCtrl: push handler");
+ var s = NVRDataModel.evaluateTappedNotification();
+ NVRDataModel.debug("tapped Notification evaluation:"+ JSON.stringify(s));
+ $ionicHistory.nextViewOptions({
+ disableAnimate:true,
+ disableBack: true
+ });
+ $state.go(s[0],s[1],s[2]);
+ });
+
// Let's stagger this by 500ms each to see if Chrome lets these through
// This may also help if your Apache is not configured to let multiple connections through
diff --git a/www/js/TimelineCtrl.js b/www/js/TimelineCtrl.js
index 4a144092..a75199f4 100644
--- a/www/js/TimelineCtrl.js
+++ b/www/js/TimelineCtrl.js
@@ -20,6 +20,18 @@ angular.module('zmApp.controllers').controller('zmApp.TimelineCtrl', ['$ionicPla
$ionicSideMenuDelegate.toggleLeft();
};
+
+ $scope.$on ( "process-push", function () {
+ NVRDataModel.debug (">> TimelineCtrl: push handler");
+ var s = NVRDataModel.evaluateTappedNotification();
+ NVRDataModel.debug("tapped Notification evaluation:"+ JSON.stringify(s));
+ $ionicHistory.nextViewOptions({
+ disableAnimate:true,
+ disableBack: true
+ });
+ $state.go(s[0],s[1],s[2]);
+ });
+
//---------------------------------------f-------------------------
// Alarm notification handling
//----------------------------------------------------------------
@@ -285,7 +297,7 @@ angular.module('zmApp.controllers').controller('zmApp.TimelineCtrl', ['$ionicPla
NVRDataModel.debug("Timeline: Deregistering broadcast handles");
for (var i = 0; i < broadcastHandles.length; i++) {
- // broadcastHandles[i]();
+ broadcastHandles[i]();
}
broadcastHandles = [];