diff options
Diffstat (limited to 'www/js/PortalLoginCtrl.js')
| -rw-r--r-- | www/js/PortalLoginCtrl.js | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/www/js/PortalLoginCtrl.js b/www/js/PortalLoginCtrl.js index c8e92be6..ec9d345a 100644 --- a/www/js/PortalLoginCtrl.js +++ b/www/js/PortalLoginCtrl.js @@ -3,14 +3,14 @@ /*This is for the loop closure I am using in line 143 */ /* jslint browser: true*/ /* global vis,cordova,StatusBar,angular,console,moment */ -angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionicPlatform', '$scope', 'zm', 'ZMDataModel', '$ionicSideMenuDelegate', '$rootScope', '$http', '$q', '$state', '$ionicLoading', '$ionicPopover', '$ionicScrollDelegate', '$ionicModal', '$timeout', 'zmAutoLogin', '$ionicHistory', '$cordovaTouchID', 'EventServer', '$translate', function ($ionicPlatform, $scope, zm, ZMDataModel, $ionicSideMenuDelegate, $rootScope, $http, $q, $state, $ionicLoading, $ionicPopover, $ionicScrollDelegate, $ionicModal, $timeout, zmAutoLogin, $ionicHistory, $cordovaTouchID, EventServer, $translate) { +angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionicPlatform', '$scope', 'zm', 'NVRDataModel', '$ionicSideMenuDelegate', '$rootScope', '$http', '$q', '$state', '$ionicLoading', '$ionicPopover', '$ionicScrollDelegate', '$ionicModal', '$timeout', 'zmAutoLogin', '$ionicHistory', '$cordovaTouchID', 'EventServer', '$translate', function ($ionicPlatform, $scope, zm, NVRDataModel, $ionicSideMenuDelegate, $rootScope, $http, $q, $state, $ionicLoading, $ionicPopover, $ionicScrollDelegate, $ionicModal, $timeout, zmAutoLogin, $ionicHistory, $cordovaTouchID, EventServer, $translate) { $scope.$on('$ionicView.enter', function () { - ZMDataModel.zmDebug("Inside Portal login Enter handler"); - loginData = ZMDataModel.getLogin(); + NVRDataModel.debug("Inside Portal login Enter handler"); + loginData = NVRDataModel.getLogin(); $ionicHistory.nextViewOptions({ disableBack: true @@ -20,14 +20,14 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic $scope.pindata = {}; if ($ionicSideMenuDelegate.isOpen()) { $ionicSideMenuDelegate.toggleLeft(); - ZMDataModel.zmDebug("Sliding menu close"); + NVRDataModel.debug("Sliding menu close"); } $scope.pinPrompt = false; // if true, then PIN is displayed else skip - if (ZMDataModel.isLoggedIn()) { - ZMDataModel.zmLog("User credentials are provided"); + if (NVRDataModel.isLoggedIn()) { + NVRDataModel.log("User credentials are provided"); @@ -38,20 +38,20 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic // success, TouchID supported $cordovaTouchID.authenticate("") .then(function () { - ZMDataModel.zmLog("Touch Success"); + NVRDataModel.log("Touch Success"); // Don't assign pin as it may be alphanum unlock(true); }, function () { - ZMDataModel.zmLog("Touch Failed"); + NVRDataModel.log("Touch Failed"); }); }, function (error) { - ZMDataModel.zmLog("TouchID not supported"); + NVRDataModel.log("TouchID not supported"); }); } else // touch was not used { - ZMDataModel.zmLog("not checking for touchID"); + NVRDataModel.log("not checking for touchID"); } if (loginData.usePin) { @@ -67,9 +67,9 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic } else // login creds are not present { - ZMDataModel.zmDebug("PortalLogin: Not logged in, so going to login"); - if (ZMDataModel.isFirstUse()) { - ZMDataModel.zmDebug("First use, showing warm and fuzzy..."); + NVRDataModel.debug("PortalLogin: Not logged in, so going to login"); + if (NVRDataModel.isFirstUse()) { + NVRDataModel.debug("First use, showing warm and fuzzy..."); $ionicHistory.nextViewOptions({ disableAnimate: true, disableBack: true @@ -122,21 +122,21 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic zmAutoLogin.doLogin("<button class='button button-clear' style='line-height: normal; min-height: 0; min-width: 0;color:#fff;' ng-click='$root.cancelAuth()'><i class='ion-close-circled'></i> " + $translate.instant('kAuthenticating') + "...</button>") .then(function (data) // success { - ZMDataModel.zmDebug("2nd auth login worked"); - ZMDataModel.getAPIversion() + NVRDataModel.debug("2nd auth login worked"); + NVRDataModel.getAPIversion() .then(function (data) { - ZMDataModel.getKeyConfigParams(1); - ZMDataModel.zmLog("2nd auth:Got API version: " + data); + NVRDataModel.getKeyConfigParams(1); + NVRDataModel.log("2nd auth:Got API version: " + data); $rootScope.apiVersion = data; - var ld = ZMDataModel.getLogin(); - if (ZMDataModel.versionCompare(data, zm.minAppVersion) == -1 && data != "0.0.0") { + var ld = NVRDataModel.getLogin(); + if (NVRDataModel.versionCompare(data, zm.minAppVersion) == -1 && data != "0.0.0") { $state.go('lowversion', { "ver": data }); } - if (ZMDataModel.versionCompare(data, zm.recommendedAppVersion) == -1 && data != "0.0.0") { + if (NVRDataModel.versionCompare(data, zm.recommendedAppVersion) == -1 && data != "0.0.0") { $state.go('importantmessage', { "ver": data @@ -145,8 +145,8 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic if (data == "0.0.0") { - ZMDataModel.zmLog("2nd Auth:API getVersion succeeded but returned 0.0.0 " + JSON.stringify(data)); - ZMDataModel.displayBanner('error', ['ZoneMinder authentication failed']); + NVRDataModel.log("2nd Auth:API getVersion succeeded but returned 0.0.0 " + JSON.stringify(data)); + NVRDataModel.displayBanner('error', ['ZoneMinder authentication failed']); $state.go("login", { "wizard": false }); @@ -155,14 +155,14 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic // coming here means continue EventServer.refresh(); var statetoGo = $rootScope.lastState ? $rootScope.lastState : 'montage'; - //ZMDataModel.zmDebug ("logging state transition"); - ZMDataModel.zmDebug("2nd Auth: Transitioning state to: " + + //NVRDataModel.debug ("logging state transition"); + NVRDataModel.debug("2nd Auth: Transitioning state to: " + statetoGo + " with param " + JSON.stringify($rootScope.lastStateParam)); $state.go(statetoGo, $rootScope.lastStateParam); }, function (error) { - ZMDataModel.zmDebug("2nd auth API failed, going to login"); + NVRDataModel.debug("2nd auth API failed, going to login"); d.reject("failed 2nd auth"); return (d.promise); @@ -171,7 +171,7 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic }, function (error) { - ZMDataModel.zmDebug("2nd auth hack failed, going to login"); + NVRDataModel.debug("2nd auth hack failed, going to login"); d.reject("failed 2nd auth"); return (d.promise); }); @@ -185,9 +185,9 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic == false means check PIN */ - ZMDataModel.zmDebug("unlock called with check PIN=" + idVerified); + NVRDataModel.debug("unlock called with check PIN=" + idVerified); if (idVerified || ($scope.pindata.pin == loginData.pinCode)) { - ZMDataModel.zmDebug("PIN code entered is correct, or there is no PIN set"); + NVRDataModel.debug("PIN code entered is correct, or there is no PIN set"); $rootScope.rand = Math.floor((Math.random() * 100000) + 1); zmAutoLogin.stop(); //safety zmAutoLogin.start(); @@ -196,23 +196,23 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic zmAutoLogin.doLogin("<button class='button button-clear' style='line-height: normal; min-height: 0; min-width: 0;color:#fff;' ng-click='$root.cancelAuth()'><i class='ion-close-circled'></i> " + $translate.instant('kAuthenticating') + "...</button>") .then(function (data) // success { - ZMDataModel.zmDebug("PortalLogin: auth success"); - ZMDataModel.getKeyConfigParams(1); + NVRDataModel.debug("PortalLogin: auth success"); + NVRDataModel.getKeyConfigParams(1); // $state.go("login" ,{"wizard": false}); //login was ok, so get API details - ZMDataModel.getAPIversion() + NVRDataModel.getAPIversion() .then(function (data) { - ZMDataModel.zmLog("Got API version: " + data); + NVRDataModel.log("Got API version: " + data); $rootScope.apiVersion = data; - var ld = ZMDataModel.getLogin(); - if (ZMDataModel.versionCompare(data, zm.minAppVersion) == -1 && data != "0.0.0") { + var ld = NVRDataModel.getLogin(); + if (NVRDataModel.versionCompare(data, zm.minAppVersion) == -1 && data != "0.0.0") { $state.go('lowversion', { "ver": data }); } - if (ZMDataModel.versionCompare(data, zm.recommendedAppVersion) == -1 && data != "0.0.0") { + if (NVRDataModel.versionCompare(data, zm.recommendedAppVersion) == -1 && data != "0.0.0") { $state.go('importantmessage', { "ver": data @@ -221,8 +221,8 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic if (data == "0.0.0") { - ZMDataModel.zmLog("API getVersion succeeded but returned 0.0.0 " + JSON.stringify(data)); - ZMDataModel.displayBanner('error', ['ZoneMinder authentication failed']); + NVRDataModel.log("API getVersion succeeded but returned 0.0.0 " + JSON.stringify(data)); + NVRDataModel.displayBanner('error', ['ZoneMinder authentication failed']); $state.go("login", { "wizard": false }); @@ -231,21 +231,21 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic // coming here means continue EventServer.refresh(); var statetoGo = $rootScope.lastState ? $rootScope.lastState : 'montage'; - ZMDataModel.zmDebug("logging state transition"); - ZMDataModel.zmDebug("Transitioning state to: " + + NVRDataModel.debug("logging state transition"); + NVRDataModel.debug("Transitioning state to: " + statetoGo + " with param " + JSON.stringify($rootScope.lastStateParam)); $state.go(statetoGo, $rootScope.lastStateParam); }, function (error) { // API Error - ZMDataModel.zmLog("API Error handler: going to login getAPI returned error: " + JSON.stringify(error)); - //ZMDataModel.displayBanner('error', ['ZoneMinder authentication failed']); + NVRDataModel.log("API Error handler: going to login getAPI returned error: " + JSON.stringify(error)); + //NVRDataModel.displayBanner('error', ['ZoneMinder authentication failed']); - ZMDataModel.zmDebug("Doing the Aaron Hack after 1 sec...."); + NVRDataModel.debug("Doing the Aaron Hack after 1 sec...."); $timeout(function () { tryLoggingSecondTimeHack() .then(function success(s) { - ZMDataModel.zmLog("2nd time login hack worked!, nothing to do"); + NVRDataModel.log("2nd time login hack worked!, nothing to do"); }, function error(e) { $state.go("login", { @@ -261,8 +261,8 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic if ($rootScope.tappedNotification) { - var ld = ZMDataModel.getLogin(); - ZMDataModel.zmLog("Came via push tap. onTapScreen=" + ld.onTapScreen); + var ld = NVRDataModel.getLogin(); + NVRDataModel.log("Came via push tap. onTapScreen=" + ld.onTapScreen); //console.log ("***** NOTIFICATION TAPPED "); $rootScope.tappedNotification = 0; $ionicHistory.nextViewOptions({ @@ -270,14 +270,14 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic }); if (ld.onTapScreen == $translate.instant('kTapMontage')) { - ZMDataModel.zmDebug("Going to montage"); + NVRDataModel.debug("Going to montage"); $state.go("montage", {}, { reload: true }); return; } else if (ld.onTapScreen == $translate.instant('kTapEvents')) { - ZMDataModel.zmDebug("Going to events"); + NVRDataModel.debug("Going to events"); $state.go("events", { "id": 0 }, { @@ -286,7 +286,7 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic return; } else // we go to live { - ZMDataModel.zmDebug("Going to live view "); + NVRDataModel.debug("Going to live view "); $state.go("monitors", {}, { reload: true }); @@ -299,10 +299,10 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic // coming here means auth error // so go back to login function (error) { - ZMDataModel.zmDebug("PortalLogin: error authenticating " + + NVRDataModel.debug("PortalLogin: error authenticating " + JSON.stringify(error)); if (!$rootScope.userCancelledAuth) { - ZMDataModel.displayBanner('error', ['ZoneMinder authentication failed', 'Please check API settings']); + NVRDataModel.displayBanner('error', ['ZoneMinder authentication failed', 'Please check API settings']); $ionicHistory.nextViewOptions({ disableAnimate: true, disableBack: true @@ -336,7 +336,7 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic // Controller Main //------------------------------------------------------------------------------- // console.log("************* ENTERING PORTAL MAIN "); - ZMDataModel.zmLog("Entering Portal Main"); + NVRDataModel.log("Entering Portal Main"); var loginData; $ionicSideMenuDelegate.canDragContent(true); |
