summaryrefslogtreecommitdiff
path: root/www/js/FirstUseCtrl.js
blob: 02d7c1772dd15439b0ad7f1517539f31a2078a90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/* jshint -W041 */
/* jslint browser: true*/
/* global cordova,StatusBar,angular,console */

angular.module('zmApp.controllers').controller('zmApp.FirstUseCtrl', ['$scope', '$ionicSideMenuDelegate', 'zm', '$stateParams', '$ionicHistory', '$state', 'NVR', '$rootScope', '$ionicPopup', '$translate', function ($scope, $ionicSideMenuDelegate, zm, $stateParams, $ionicHistory, $state, NVR, $rootScope, $ionicPopup, $translate) {
  $scope.openMenu = function () {
    $ionicSideMenuDelegate.toggleLeft();
  };

  //-------------------------------------------------------------------------
  // Controller Main
  //------------------------------------------------------------------------
  $scope.$on('$ionicView.enter', function () {
    //console.log("**VIEW ** FirstUse Ctrl Entered");
    $ionicSideMenuDelegate.canDragContent(true);
    // right up here lets set certs to true, we will disable it later
    // this is for first starts

    // 
    if (window.cordova) {
      cordova.plugin.http.setSSLCertMode('nocheck', function () {
        NVR.debug('--> First use -> SSL is permissive, will allow any certs for now. You can change it later.');
      }, function () {
        console.log('-->First Use -> Error setting SSL permissive');
      });

      if ($rootScope.platformOS == 'android') {
        NVR.log (">>> Android: enabling inline image view for self signed certs");
        cordova.plugins.certificates.trustUnsecureCerts(true);
      }

    }


  });

  $scope.switchLang = function () {
    $scope.lang = NVR.getLanguages();
    $scope.myopt = {
      lang: ""
    };

    $rootScope.zmPopup = $ionicPopup.show({
      scope: $scope,
      template: '<ion-radio-fix ng-repeat="item in lang" ng-value="item.value" ng-model="myopt.lang"> {{item.text}} </ion-radio-fix>',

      title: $translate.instant('kSelectLanguage'),

      buttons: [{
          text: $translate.instant('kButtonCancel'),
          onTap: function (e) {
            //return "CANCEL";
          }

        },
        {
          text: $translate.instant('kButtonOk'),
          onTap: function (e) {
            NVR.log("Language selected:" + $scope.myopt.lang);
            NVR.setDefaultLanguage($scope.myopt.lang, true);

            //return "OK";

          }
        }
      ]
    });

  };

  $scope.goToLogin = function () {
    $ionicHistory.nextViewOptions({
      disableAnimate: false,
      disableBack: true
    });
    $state.go("app.login", {
      "wizard": false
    });
    return;
  };

  $scope.goToWizard = function () {
    $ionicHistory.nextViewOptions({
      disableAnimate: false,
      disableBack: true
    });
    $state.go("app.wizard");
    return;
  };

}]);