Skip to content

Commit

Permalink
ZoneMinder#725 moved evaluate tapped notification to service,trapped …
Browse files Browse the repository at this point in the history
…handler in all controllers
  • Loading branch information
pliablepixels committed Oct 21, 2018
1 parent 3f549f3 commit e307688
Show file tree
Hide file tree
Showing 14 changed files with 209 additions and 108 deletions.
61 changes: 61 additions & 0 deletions www/js/DataModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions www/js/DevOptionsCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
//----------------------------------------------------------------
Expand Down
19 changes: 16 additions & 3 deletions www/js/EventCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);

}
Expand Down Expand Up @@ -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 = [];
});
Expand Down
10 changes: 6 additions & 4 deletions www/js/EventServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
}

Expand All @@ -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
{
Expand Down
11 changes: 11 additions & 0 deletions www/js/LogCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions www/js/LoginCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
//----------------------------------------------------------------
Expand Down
11 changes: 11 additions & 0 deletions www/js/MomentCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
//----------------------------------------------------------------
Expand Down
11 changes: 11 additions & 0 deletions www/js/MonitorCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
//----------------------------------------------------------------
Expand Down
19 changes: 19 additions & 0 deletions www/js/MontageCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 = [];

});

Expand Down
12 changes: 12 additions & 0 deletions www/js/MontageHistoryCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand Down
11 changes: 11 additions & 0 deletions www/js/NewsCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit e307688

Please sign in to comment.