summaryrefslogtreecommitdiff
path: root/www/js/MenuController.js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js/MenuController.js')
-rw-r--r--www/js/MenuController.js72
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));