diff options
| author | Pliable Pixels <pliablepixels@users.noreply.github.com> | 2018-10-14 15:00:02 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-10-14 15:00:02 -0400 |
| commit | 3cd1ff34c0cd8412ebe07d4ba5614ec938b72456 (patch) | |
| tree | b256e275147ee495721bedeaaafb1a65f8aef98c /www/js/MenuController.js | |
| parent | ffbacb34a6a654eb1124c627320bc75131636ff7 (diff) | |
| parent | 863e507613e33cc66022ba3639f7e1a5b8eb7c96 (diff) | |
Merge pull request #709 from pliablepixels/webview
WKWebView migration resolutions and other stuff
Diffstat (limited to 'www/js/MenuController.js')
| -rw-r--r-- | www/js/MenuController.js | 72 |
1 files changed, 50 insertions, 22 deletions
diff --git a/www/js/MenuController.js b/www/js/MenuController.js index 995abba3..d9d4d114 100644 --- a/www/js/MenuController.js +++ b/www/js/MenuController.js @@ -2,14 +2,14 @@ /* jslint browser: true*/ /* global cordova,StatusBar,angular,console */ -angular.module('zmApp.controllers').controller('MenuController', ['$scope', '$ionicSideMenuDelegate', 'zm', '$stateParams', '$ionicHistory', '$state', 'NVRDataModel', '$rootScope', '$ionicPopup', '$translate', '$timeout', '$location','EventServer', 'zmAutoLogin','$http',function ($scope, $ionicSideMenuDelegate, zm, $stateParams, $ionicHistory, $state, NVRDataModel, $rootScope, $ionicPopup, $translate, $timeout, $location, EventServer, zmAutoLogin, $http) { +angular.module('zmApp.controllers').controller('MenuController', ['$scope', '$ionicSideMenuDelegate', 'zm', '$stateParams', '$ionicHistory', '$state', 'NVRDataModel', '$rootScope', '$ionicPopup', '$translate', '$timeout', '$location','EventServer', 'zmAutoLogin','$http','SecuredPopups',function ($scope, $ionicSideMenuDelegate, zm, $stateParams, $ionicHistory, $state, NVRDataModel, $rootScope, $ionicPopup, $translate, $timeout, $location, EventServer, zmAutoLogin, $http, SecuredPopups) { $scope.openMenu = function () { $ionicSideMenuDelegate.toggleLeft(); }; //---------------------------------------------------------------- // This controller sits along with the main app to bring up - // the language menu from the main menu + // the language menu from the main //---------------------------------------------------------------- @@ -83,22 +83,48 @@ angular.module('zmApp.controllers').controller('MenuController', ['$scope', '$io } - if (loginData.isUseEventServer) { - EventServer.init(); - if ($rootScope.apnsToken && loginData.disablePush != true) { - NVRDataModel.log("Making sure we get push notifications"); - EventServer.sendMessage('push', { - type: 'token', - platform: $rootScope.platformOS, - token: $rootScope.apnsToken, - state: "enabled" - }, 1); + + if (window.cordova) { + + if (loginData.isUseBasicAuth) { + NVRDataModel.debug ("Cordova HTTP: configuring basic auth"); + cordova.plugin.http.useBasicAuth(loginData.basicAuthUser, loginData.basicAuthPassword); + } + + if (!loginData.enableStrictSSL) { + + //alert("Enabling insecure SSL"); + NVRDataModel.log(">>>> Disabling strict SSL checking (turn off in Dev Options if you can't connect)"); + cordova.plugin.http.setSSLCertMode('nocheck', function() { + NVRDataModel.debug('--> SSL is permissive, will allow any certs. Use at your own risk.'); + }, function() { + console.log('-->Error setting SSL permissive'); + }); + + } else { + + NVRDataModel.log(">>>> Enabling strict SSL checking (turn off in Dev Options if you can't connect)"); + } - EventServer.sendMessage("control", { - type: 'filter', - monlist: loginData.eventServerMonitors, - intlist: loginData.eventServerInterval + + } + + + if (loginData.isUseEventServer) { + EventServer.init() + .then (function (succ) { + EventServer.sendMessage("control", { + type: 'filter', + monlist: loginData.eventServerMonitors, + intlist: loginData.eventServerInterval, + token: $rootScope.apnsToken + }); + }, + function (err) { + NVRDataModel.debug ("EventServer init failed"); }); + + } @@ -119,8 +145,9 @@ angular.module('zmApp.controllers').controller('MenuController', ['$scope', '$io NVRDataModel.log("Validating APIs at " + apiurl); $http.get(apiurl) - .success(function (data) { + .then(function (data) { + data = data.data; NVRDataModel.getTimeZone(true); var loginStatus = $translate.instant('kExploreEnjoy') + " " + $rootScope.appName + "!"; EventServer.refresh(); @@ -135,7 +162,8 @@ angular.module('zmApp.controllers').controller('MenuController', ['$scope', '$io NVRDataModel.log("ZM relative cgi-path: " + zm_cgi + ", you entered: " + user_cgi); $http.get(ld.streamingurl + "/zms") - .success(function (data) { + .then(function (data) { + data = data.data; NVRDataModel.debug("Urk! cgi-path returned success, but it should not have come here"); loginStatus = $translate.instant('kLoginStatusNoCgi'); @@ -183,8 +211,8 @@ angular.module('zmApp.controllers').controller('MenuController', ['$scope', '$io }); - }) - .error(function (error, status) { + }, + function (error, status) { // If its 5xx, then the cgi-bin path is valid // if its 4xx then the cgi-bin path is not valid @@ -233,8 +261,8 @@ angular.module('zmApp.controllers').controller('MenuController', ['$scope', '$io }); }); - }) - .error(function (error) { + }, + function (error) { NVRDataModel.displayBanner('error', [$translate.instant('kBannerAPICheckFailed'), $translate.instant('kBannerPleaseCheck')]); NVRDataModel.log("API login error " + JSON.stringify(error)); |
