Added timeout and fixed wps

This commit is contained in:
Martin Schröder 2015-05-21 13:37:05 +02:00 committed by Martin Schröder
parent ee37236655
commit bb7d68a676
11 changed files with 85 additions and 26 deletions

View file

@ -56,6 +56,7 @@
<script src="js/session.js"></script>
<script src="js/tr.js"></script>
<script src="js/theme.js"></script>
<script src="js/timeout.js"></script>
<!-- ###---### -->
</body>
</html>

View file

@ -145,6 +145,9 @@ JUCI.app.config(function ($stateProvider, $locationProvider, $compileProvider, $
$rootScope.errors.splice(0, $rootScope.errors.length);
$uci.$revert();
document.title = $tr(k.replace(/\//g, ".")+".title")+" - "+$tr(gettext("application.name"));
},
onExit: function($interval){
JUCI.interval.$clearAll();
}
});
}

View file

@ -0,0 +1,33 @@
(function(){
var _timeouts = {};
JUCI.interval = {
once: function(t, fn){
var i = setTimeout(function _onTimeout(){
fn(function next(ret, err){
clearTimeout(i);
delete _timeouts[name];
});
}, t);
_timeouts[name] = i;
},
repeat: function(name, t, fn){
var i = setTimeout(function _onTimeout(){
fn(function next(ret, err){
if(ret){
clearTimeout(i);
delete _timeouts[name];
} else {
// restart the timeout if it did not exit
setTimeout(_onTimeout, t);
}
});
}, t);
_timeouts[name] = i;
},
$clearAll: function(){
Object.keys(_timeouts).map(function(t){
clearTimeout(t);
});
}
};
})();

View file

@ -99,7 +99,7 @@ UCI.voice_client.$registerSectionType("call_filter_rule_incoming", {
"extension": { dvalue: "", type: String }
});
UCI.voice_client.$registerSectionType("dialplan": {
UCI.voice_client.$registerSectionType("dialplan", {
"custom_outgoing_enabled": { dvalue: false, type: Boolean },
"custom_incoming_enabled": { dvalue: false, type: Boolean },
"custom_hangup_enabled": { dvalue: false, type: Boolean },
@ -108,7 +108,7 @@ UCI.voice_client.$registerSectionType("dialplan": {
"test_echo_extension": { dvalue: "#123458", type: String},
"record_message_extension": { dvalue: "#999999", type: String}
});
UCI.voice_client.$registerSectionType("sip_advanced": {
UCI.voice_client.$registerSectionType("sip_advanced", {
"rtpstart": { dvalue: 10000, type: Number },
"rtpend": { dvalue: 20000, type: Number },
"dtmfmode": { dvalue: "rfc2833", type: String},
@ -128,7 +128,7 @@ UCI.voice_client.$registerSectionType("sip_advanced": {
"dnsmgr_refresh_interval": { dvalue: 300, type: Number },
"srvlookup": { dvalue: "yes", type: String}
});
UCI.voice_client.$registerSectionType("brcm_advanced": {
UCI.voice_client.$registerSectionType("brcm_advanced", {
"country": { dvalue: "SWE", type: String},
"jbenable": { dvalue: "yes", type: String},
"jbforce": { dvalue: "no", type: String},
@ -138,19 +138,19 @@ UCI.voice_client.$registerSectionType("brcm_advanced": {
"dialoutmsec": { dvalue: 4000, type: Number },
"cw_enable": { dvalue: "yes", type: String}
});
UCI.voice_client.$registerSectionType("features": {
UCI.voice_client.$registerSectionType("features", {
"cbbs_enabled": { dvalue: true, type: Boolean },
"callforward_enabled": { dvalue: true, type: Boolean },
"redial_enabled": { dvalue: true, type: Boolean },
"callreturn_enabled": { dvalue: true, type: Boolean },
"advanced_register_settings": { dvalue: true, type: Boolean },
});
UCI.voice_client.$registerSectionType("log": {
UCI.voice_client.$registerSectionType("log", {
"console": { dvalue: "notice,warning,error", type: String },
"messages": { dvalue: "error", type: String },
"syslog_facility": { dvalue: "local0", type: String }
});
UCI.voice_client.$registerSectionType("speed_dial": {
UCI.voice_client.$registerSectionType("speed_dial", {
"tone": { dvalue: 1, type: Number },
"number": { dvalue: "", type: String }
});

View file

@ -1,4 +1,6 @@
$juci.module("wifi")
//! Author: Martin K. Schröder <mkschreder.uk@gmail.com>
JUCI.app
.controller("WifiGeneralPageCtrl", function($scope, $uci, $tr){
async.series([
function(next){

View file

@ -1,4 +1,6 @@
$juci.module("wifi")
//! Author: Martin K. Schröder <mkschreder.uk@gmail.com>
JUCI.app
.controller("WifiMacFilterPageCtrl", function($scope, $uci, gettext){
window.uci = $uci;
$scope.uci = $uci;

View file

@ -1,4 +1,6 @@
$juci.module("wifi")
//! Author: Martin K. Schröder <mkschreder.uk@gmail.com>
JUCI.app
.controller("WifiSchedulePageCtrl", function($scope, $uci, gettext){
$scope.statusItems = [
{ label: gettext("Enabled"), value: 1 },

View file

@ -1,4 +1,6 @@
$juci.module("wifi")
//! Author: Martin K. Schröder <mkschreder.uk@gmail.com>
JUCI.app
.controller("WifiSettingsPageCtrl", function($scope, $uci, gettext){
function load(){
$uci.sync("wireless").done(function(){

View file

@ -63,15 +63,13 @@
</luci-config-lines>
</luci-config-section>
</luci-config>
<modal title="{{'Attempting to Pair'|translate}}" ng-show="progress != 0 && progress != 2">
<modal title="{{'Attempting to Pair'|translate}}" ng-show="progress != 0 && progress != 2" dismiss-label="Cancel" on-dismiss="onCancelWPS()">
<div style="text-align: center;">
<div ng-show="progress != 0" >
<i class="fa fa-spinner fa-spin fa-3x"/>
<!--<p>{{timeRemaining}} <span translate>seconds remaining</span></p>-->
</div>
<p ng-show="progress == 0" translate>wifi.wpspairmodal.progressinfo.0</p>
<p ng-show="progress == 1" translate>wifi.wpspairmodal.progressinfo.1</p>
<p ng-show="progress == 2" translate>wifi.wpspairmodal.progressinfo.2</p>
<p translate>{{text_status}}</p>
</div>
</modal>
</div>

View file

@ -1,6 +1,16 @@
$juci.module("wifi")
.controller("WifiWPSPageCtrl", function($scope, $uci, $rpc){
console.log("WIFI PAGE CONTROLLER");
//! Author: Martin K. Schröder <mkschreder.uk@gmail.com>
JUCI.app
.controller("WifiWPSPageCtrl", function($scope, $uci, $rpc, $interval, gettext){
var wps_status_strings = {
0: gettext("wps.status.init"),
1: gettext("wps.status.processing"),
2: gettext("wps.status.success"),
3: gettext("wps.status.fail"),
4: gettext("wps.status.timeout"),
7: gettext("wps.status.msgdone")
};
$scope.data = {
userPIN: ""
}
@ -22,15 +32,14 @@ $juci.module("wifi")
console.log("failed to sync config: "+err);
});
function retry(){
setTimeout(function(){
$uci.sync("broadcom").done(function(){
$scope.progress = $uci.broadcom.nvram.wps_proc_status.value;
$scope.$apply();
retry();
});
}, 1000);
} retry();
JUCI.interval.repeat("wifi.wps.retry", 1000, function(next){
$rpc.wps.status().done(function(result){
$scope.progress = result.code;
$scope.text_status = wps_status_strings[result.code]||gettext("wps.status.unknown");
$scope.$apply();
next();
});
});
$rpc.wps.showpin().done(function(data){
$scope.generatedPIN = data.pin;
@ -53,4 +62,8 @@ $juci.module("wifi")
});
});
}
$scope.onCancelWPS = function(){
$rpc.wps.stop();
}
});

View file

@ -56,4 +56,7 @@ describe("Wireless", function(){
it("should have wps.pbc rpc call", function(){
expect($rpc.wps.pbc).to.be.a(Function);
});
it("should have wps.status rpc call", function(){
expect($rpc.wps.status).to.be.a(Function);
});
});