summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--www/js/DevOptionsCtrl.js7
-rw-r--r--www/js/LoginCtrl.js23
-rw-r--r--www/js/app.js49
3 files changed, 65 insertions, 14 deletions
diff --git a/www/js/DevOptionsCtrl.js b/www/js/DevOptionsCtrl.js
index 5cb6e1d4..9a42ce45 100644
--- a/www/js/DevOptionsCtrl.js
+++ b/www/js/DevOptionsCtrl.js
@@ -2,7 +2,7 @@
/* jslint browser: true*/
/* global cordova,StatusBar,angular,console */
-angular.module('zmApp.controllers').controller('zmApp.DevOptionsCtrl', ['$scope', '$rootScope', '$ionicModal', 'zm', 'ZMDataModel', '$ionicSideMenuDelegate', '$ionicPopup', '$http', '$q', '$ionicLoading', '$ionicHistory','$state', function ($scope, $rootScope, $ionicModal, zm, ZMDataModel, $ionicSideMenuDelegate, $ionicPopup, $http, $q, $ionicLoading, $ionicHistory, $state) {
+angular.module('zmApp.controllers').controller('zmApp.DevOptionsCtrl', ['$scope', '$rootScope', '$ionicModal', 'zm', 'ZMDataModel', '$ionicSideMenuDelegate', '$ionicPopup', '$http', '$q', '$ionicLoading', '$ionicHistory','$state', 'SecuredPopups', function ($scope, $rootScope, $ionicModal, zm, ZMDataModel, $ionicSideMenuDelegate, $ionicPopup, $http, $q, $ionicLoading, $ionicHistory, $state, SecuredPopups) {
$scope.openMenu = function () {
@@ -57,7 +57,7 @@ angular.module('zmApp.controllers').controller('zmApp.DevOptionsCtrl', ['$scope'
ZMDataModel.zmDebug("SaveDevOptions: called");
if (parseInt($scope.loginData.maxMontage) > zm.safeMontageLimit) {
- $rootScope.zmPopup= $ionicPopup.alert({
+ $rootScope.zmPopup= SecuredPopups.show('alert',{
title: 'Note',
template: 'You have selected to view more than 10 monitors in the Montage screen. Note that this is very resource intensive and may load the server or cause issues in the application. If you are not sure, please consider limiting this value to 10'
});
@@ -99,7 +99,8 @@ angular.module('zmApp.controllers').controller('zmApp.DevOptionsCtrl', ['$scope'
$scope.saveDevOptions = function () {
saveDevOptions();
- $rootScope.zmPopup= $ionicPopup.alert({
+ $rootScope.zmPopup.close();
+ $rootScope.zmPopup= SecuredPopups.show('alert',{
title: 'Settings Saved',
template: 'Please explore the menu and enjoy zmNinja!'
}).then(function (res) {
diff --git a/www/js/LoginCtrl.js b/www/js/LoginCtrl.js
index 1f601149..ab19a751 100644
--- a/www/js/LoginCtrl.js
+++ b/www/js/LoginCtrl.js
@@ -2,7 +2,7 @@
/* jslint browser: true*/
/* global cordova,StatusBar,angular,console */
-angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$rootScope', 'zm', '$ionicModal', 'ZMDataModel', '$ionicSideMenuDelegate', '$ionicPopup', '$http', '$q', '$ionicLoading', 'zmAutoLogin', '$cordovaPinDialog', 'EventServer', '$ionicHistory', '$state', '$ionicActionSheet', function ($scope, $rootScope, zm, $ionicModal, ZMDataModel, $ionicSideMenuDelegate, $ionicPopup, $http, $q, $ionicLoading, zmAutoLogin, $cordovaPinDialog, EventServer, $ionicHistory, $state, $ionicActionSheet) {
+angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$rootScope', 'zm', '$ionicModal', 'ZMDataModel', '$ionicSideMenuDelegate', '$ionicPopup', '$http', '$q', '$ionicLoading', 'zmAutoLogin', '$cordovaPinDialog', 'EventServer', '$ionicHistory', '$state', '$ionicActionSheet', 'SecuredPopups', function ($scope, $rootScope, zm, $ionicModal, ZMDataModel, $ionicSideMenuDelegate, $ionicPopup, $http, $q, $ionicLoading, zmAutoLogin, $cordovaPinDialog, EventServer, $ionicHistory, $state, $ionicActionSheet, SecuredPopups) {
$scope.openMenu = function () {
$ionicSideMenuDelegate.toggleLeft();
};
@@ -276,12 +276,7 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r
- /*if (parseInt($scope.loginData.maxMontage) > zm.safeMontageLimit) {
- $ionicPopup.alert({
- title: 'Note',
- template: 'You have selected to view more than 10 monitors in the Montage screen. Note that this is very resource intensive and may load the server or cause issues in the application. If you are not sure, please consider limiting this value to 10'
- });
- }*/
+
// lets so some basic sanitization of the data
// I am already adding "/" so lets remove spurious ones
@@ -467,10 +462,14 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r
.success(function (data) {
ZMDataModel.zmDebug("Urk! cgi-path returned success, but it should not have come here");
loginStatus = "Login validated, but could not validate cgi-path. If live streams don't work please check your cgi-bin path";
- $rootScope.zmPopup = $ionicPopup.alert({
+
+
+
+ $rootScope.zmPopup = SecuredPopups.show('alert',{
title: 'Login validated',
template: loginStatus
}).then(function (res) {
+
$ionicSideMenuDelegate.toggleLeft();
ZMDataModel.zmDebug("Force reloading monitors...");
var refresh = ZMDataModel.getMonitors(1);
@@ -483,11 +482,12 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r
if (status < 500) {
loginStatus = "The cgi-bin path you entered may be wrong. I can't make sure, but if your live views don't work, please review your cgi path.";
}
-
- $rootScope.zmPopup = $ionicPopup.alert({
+
+ $rootScope.zmPopup = SecuredPopups.show('alert',{
title: 'Login validated',
template: loginStatus
}).then(function (res) {
+
$ionicSideMenuDelegate.toggleLeft();
ZMDataModel.zmDebug("Force reloading monitors...");
var refresh = ZMDataModel.getMonitors(1);
@@ -503,7 +503,8 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r
.error(function (error) {
ZMDataModel.displayBanner('error', ['ZoneMinder API check failed', 'Please check API settings']);
ZMDataModel.zmLog("API login error " + JSON.stringify(error));
- $rootScope.zmPopup= $ionicPopup.alert({
+
+ $rootScope.zmPopup= SecuredPopups.show('alert',{
title: 'Login validated but API failed',
template: 'Please check your API settings'
});
diff --git a/www/js/app.js b/www/js/app.js
index 0d95a502..c76546e2 100644
--- a/www/js/app.js
+++ b/www/js/app.js
@@ -296,6 +296,55 @@ angular.module('zmApp', [
}])
+//credit: https://github.com/driftyco/ionic/issues/3131
+.factory('SecuredPopups', [
+ '$ionicPopup',
+ '$q',
+ function ($ionicPopup, $q) {
+
+ var firstDeferred = $q.defer();
+ firstDeferred.resolve();
+
+ var lastPopupPromise = firstDeferred.promise;
+
+ // Change this var to true if you want that popups will automaticly close before opening another
+ var closeAndOpen = false;
+
+ return {
+ 'show': function (method, object) {
+ var deferred = $q.defer();
+ var closeMethod = null;
+ deferred.promise.isOpen = false;
+ deferred.promise.close = function () {
+ if (deferred.promise.isOpen && angular.isFunction(closeMethod)) {
+ closeMethod();
+ }
+ };
+
+ if (closeAndOpen && lastPopupPromise.isOpen) {
+ lastPopupPromise.close();
+ }
+
+ lastPopupPromise.then(function () {
+ deferred.promise.isOpen = true;
+ var popupInstance = $ionicPopup[method](object);
+
+ closeMethod = popupInstance.close;
+ popupInstance.then(function (res) {
+ deferred.promise.isOpen = false;
+ deferred.resolve(res);
+ });
+ });
+
+ lastPopupPromise = deferred.promise;
+
+ return deferred.promise;
+ }
+ };
+ }
+])
+
+
//------------------------------------------------------------------
// this directive will be called any time an image completes loading
// via img tags where this directive is added (I am using this in