]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-8102 #resolve #comment Add auto-provision/config support to VC
authorKen Rice <krice@freeswitch.org>
Tue, 15 Sep 2015 21:45:08 +0000 (16:45 -0500)
committerKen Rice <krice@freeswitch.org>
Mon, 21 Sep 2015 21:01:15 +0000 (16:01 -0500)
Add support for loading config from external json. config.json in the
base path of VC will allow over-ride of arbitrary settings and setting
of arbitrary data in the verto.data data store.

add ability to specify autologin flag in the configs.

add autocall to config.json and make it actually autocall.

additionally refactor the call function so that it will actually call
something.

html5/verto/verto_communicator/Gruntfile.js
html5/verto/verto_communicator/src/config.json [new file with mode: 0644]
html5/verto/verto_communicator/src/config.json.sample [new file with mode: 0644]
html5/verto/verto_communicator/src/contributors.txt
html5/verto/verto_communicator/src/vertoControllers/controllers/DialPadController.js
html5/verto/verto_communicator/src/vertoControllers/controllers/LoginController.js

index cef6d682764aadb1220e9e54975d2b1d53473d31..13ad96523dd006d21b0a444703c560568150d900 100644 (file)
@@ -281,6 +281,7 @@ module.exports = function (grunt) {
            src: [
              '*.{ico,png,txt}',
              '*.html',
+             '*.json',
              'partials/**/*.html',
              'images/{,*/}*.{webp}',
              'css/fonts/{,*/}*.*',
diff --git a/html5/verto/verto_communicator/src/config.json b/html5/verto/verto_communicator/src/config.json
new file mode 100644 (file)
index 0000000..e7b09aa
--- /dev/null
@@ -0,0 +1,4 @@
+{
+      "login": "1008",
+      "password": "1234"
+}
diff --git a/html5/verto/verto_communicator/src/config.json.sample b/html5/verto/verto_communicator/src/config.json.sample
new file mode 100644 (file)
index 0000000..a905c61
--- /dev/null
@@ -0,0 +1,13 @@
+{
+      "extension": "3500",
+      "name": "Ken Rice",
+      "email": "krice@freeswitch.org",
+      "cid": "1008",
+      "textTo": "1000",
+      "login": "1008",
+      "password": "1234",
+      "autologin": "true",
+      "autocall": "3500",
+      "googlelogin": "true",
+      "wsURL": "wss://gamma.tollfreegateway.com/wss2"
+}
index cf34cd6bd0cb7c2c6003998c6db496cf459e9bb9..bc309438b231f528bfd2f02f139da3333e6109bb 100644 (file)
@@ -2,5 +2,6 @@
   "Jonatas Oliveira <jonatas@evolux.net.br>",
   "Ítalo Rossi <italo@evolux.net.br>",
   "Stefan Yohansson <stefan@evolux.net.br>",
-  "João Mesquita <jmesquita@indicium.com.ar>"
+  "João Mesquita <jmesquita@indicium.com.ar>",
+  "Ken Rice <krice@freeswitch.org>"
 ]
index dde658af16496c74b9470d5064fafcf452fb215c..8c7589c93de19c953979d03cf1744c8cff64ddb0 100644 (file)
          * fill dialpad via querystring [?autocall=\d+]
          */
         if ($location.search().autocall) {
-          $rootScope.dialpadNumber = $location.search().autocall;
+            $rootScope.dialpadNumber = $location.search().autocall;
+           delete $location.search().autocall;
+            call($rootScope.dialpadNumber);
+        }
+
+       /**
+        * fill in dialpad via config.json
+        */
+        if ('autocall' in verto.data) {
+          $rootScope.dialpadNumber = verto.data.autocall;
+         delete verto.data.autocall;
+          call($rootScope.dialpadNumber);
         }
 
         /**
           verto.data.call.transfer($rootScope.dialpadNumber);
         };
 
-        /**
-         * Call to the number in the $rootScope.dialpadNumber.
-         */
-        $rootScope.call = function(extension) {
+        function call(extension) {
           storage.data.onHold = false;
           storage.data.cur_call = 0;
           $rootScope.dialpadNumber = extension;
           CallHistory.add($rootScope.dialpadNumber, 'outbound');
           $location.path('/incall');
         }
+
+        /**
+         * Call to the number in the $rootScope.dialpadNumber.
+         */
+        $rootScope.call = function(extension) {
+          return call(extension);
+        }
       }
     ]);
 
index 6ea36372cf1519c38fbac53796591c803627873e..8cb88aa7f13c476ce7396680300239bdf5b19974 100644 (file)
@@ -1,25 +1,54 @@
 (function() {
-  'use strict';
-
-  angular
-    .module('vertoControllers')
-    .controller('LoginController', ['$scope', '$http', '$location',
-      'verto',
-      function($scope, $http, $location, verto) {
-        $scope.checkBrowser();
-
-        /**
-         * using stored data (localStorage) for logon
-         */
-        verto.data.name = $scope.storage.data.name;
-        verto.data.email = $scope.storage.data.email;
-        if ($scope.storage.data.login != '' && $scope.storage.data.password != '') {
-          verto.data.login = $scope.storage.data.login;
-          verto.data.password = $scope.storage.data.password;
-        }
-
-        console.debug('Executing LoginController.');
-      }
-    ]);
-    
-})();
\ No newline at end of file
+       'use strict';
+
+       angular
+       .module('vertoControllers')
+       .controller('LoginController', ['$scope', '$http', '$location', 'verto',
+               function($scope, $http, $location, verto) {
+                               $scope.checkBrowser();
+
+                       /*
+                        * Load the Configs before logging in
+                        * with cache buster
+                        */
+
+                       $http.get(window.location.pathname + '/config.json?cachebuster=' + Math.floor((Math.random()*1000000)+1))
+                               .success(function(data) {
+
+                               /* save these for later as we're about to possibly over write them */
+                               var name = verto.data.name;
+                               var email = verto.data.email;
+
+                               angular.extend(verto.data, data);
+
+                               /**
+                                * use stored data (localStorage) for login, allow config.json to take precedence
+                                */
+
+                               if (name != '' && data.name == '') {
+                                       verto.data.name = name;
+                               }
+                               if (email != '' && data.email == '') {
+                                       verto.data.email = email;
+                               }
+                               if (verto.data.login == '' && verto.data.password == '' && $scope.storage.data.login != '' && $scope.storage.data.password != '') {
+                                       verto.data.login = $scope.storage.data.login;
+                                       verto.data.password = $scope.storage.data.password;
+                               }
+
+                               if (verto.data.autologin == "true" && !verto.data.autologin_done) {
+                                       console.debug("auto login per config.json");
+                                       verto.data.autologin_done = true;
+                                       $scope.login();
+                               }
+                       });
+
+                       verto.data.name = $scope.storage.data.name;
+                       verto.data.email = $scope.storage.data.email;
+
+                       console.debug('Executing LoginController.');
+               }
+       ]);
+
+})();
+