提交 c9bb3a2a authored 作者: Ken Rice's avatar Ken Rice

FS-8102 #resolve #comment Add auto-provision/config support to VC

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.
上级 bdc6c3b8
...@@ -281,6 +281,7 @@ module.exports = function (grunt) { ...@@ -281,6 +281,7 @@ module.exports = function (grunt) {
src: [ src: [
'*.{ico,png,txt}', '*.{ico,png,txt}',
'*.html', '*.html',
'*.json',
'partials/**/*.html', 'partials/**/*.html',
'images/{,*/}*.{webp}', 'images/{,*/}*.{webp}',
'css/fonts/{,*/}*.*', 'css/fonts/{,*/}*.*',
......
{
"login": "1008",
"password": "1234"
}
{
"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"
}
...@@ -2,5 +2,6 @@ ...@@ -2,5 +2,6 @@
"Jonatas Oliveira <jonatas@evolux.net.br>", "Jonatas Oliveira <jonatas@evolux.net.br>",
"Ítalo Rossi <italo@evolux.net.br>", "Ítalo Rossi <italo@evolux.net.br>",
"Stefan Yohansson <stefan@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>"
] ]
...@@ -31,7 +31,18 @@ ...@@ -31,7 +31,18 @@
* fill dialpad via querystring [?autocall=\d+] * fill dialpad via querystring [?autocall=\d+]
*/ */
if ($location.search().autocall) { 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);
} }
/** /**
...@@ -49,10 +60,7 @@ ...@@ -49,10 +60,7 @@
verto.data.call.transfer($rootScope.dialpadNumber); verto.data.call.transfer($rootScope.dialpadNumber);
}; };
/** function call(extension) {
* Call to the number in the $rootScope.dialpadNumber.
*/
$rootScope.call = function(extension) {
storage.data.onHold = false; storage.data.onHold = false;
storage.data.cur_call = 0; storage.data.cur_call = 0;
$rootScope.dialpadNumber = extension; $rootScope.dialpadNumber = extension;
...@@ -79,6 +87,13 @@ ...@@ -79,6 +87,13 @@
CallHistory.add($rootScope.dialpadNumber, 'outbound'); CallHistory.add($rootScope.dialpadNumber, 'outbound');
$location.path('/incall'); $location.path('/incall');
} }
/**
* Call to the number in the $rootScope.dialpadNumber.
*/
$rootScope.call = function(extension) {
return call(extension);
}
} }
]); ]);
......
(function() { (function() {
'use strict'; 'use strict';
angular angular
.module('vertoControllers') .module('vertoControllers')
.controller('LoginController', ['$scope', '$http', '$location', .controller('LoginController', ['$scope', '$http', '$location', 'verto',
'verto', function($scope, $http, $location, verto) {
function($scope, $http, $location, verto) { $scope.checkBrowser();
$scope.checkBrowser();
/*
/** * Load the Configs before logging in
* using stored data (localStorage) for logon * with cache buster
*/ */
verto.data.name = $scope.storage.data.name;
verto.data.email = $scope.storage.data.email; $http.get(window.location.pathname + '/config.json?cachebuster=' + Math.floor((Math.random()*1000000)+1))
if ($scope.storage.data.login != '' && $scope.storage.data.password != '') { .success(function(data) {
verto.data.login = $scope.storage.data.login;
verto.data.password = $scope.storage.data.password; /* save these for later as we're about to possibly over write them */
} var name = verto.data.name;
var email = verto.data.email;
console.debug('Executing LoginController.');
} angular.extend(verto.data, data);
]);
/**
})(); * use stored data (localStorage) for login, allow config.json to take precedence
\ No newline at end of file */
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.');
}
]);
})();
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论