diff --git a/luciexpress/htdocs/index.html b/luciexpress/htdocs/index.html index a81f37468..026e008ad 100644 --- a/luciexpress/htdocs/index.html +++ b/luciexpress/htdocs/index.html @@ -56,6 +56,7 @@ + diff --git a/luciexpress/htdocs/js/app.js b/luciexpress/htdocs/js/app.js index afb0665a1..26fc1eb53 100644 --- a/luciexpress/htdocs/js/app.js +++ b/luciexpress/htdocs/js/app.js @@ -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(); } }); } diff --git a/luciexpress/htdocs/js/timeout.js b/luciexpress/htdocs/js/timeout.js new file mode 100644 index 000000000..9b2d23523 --- /dev/null +++ b/luciexpress/htdocs/js/timeout.js @@ -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); + }); + } + }; +})(); diff --git a/luciexpress/htdocs/plugins/phone/phone.js b/luciexpress/htdocs/plugins/phone/phone.js index b17c666fa..023e1fd33 100644 --- a/luciexpress/htdocs/plugins/phone/phone.js +++ b/luciexpress/htdocs/plugins/phone/phone.js @@ -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 } }); diff --git a/luciexpress/htdocs/plugins/wifi/pages/wifi.general.js b/luciexpress/htdocs/plugins/wifi/pages/wifi.general.js index ceea2b4ae..3854fa843 100644 --- a/luciexpress/htdocs/plugins/wifi/pages/wifi.general.js +++ b/luciexpress/htdocs/plugins/wifi/pages/wifi.general.js @@ -1,4 +1,6 @@ -$juci.module("wifi") +//! Author: Martin K. Schröder + +JUCI.app .controller("WifiGeneralPageCtrl", function($scope, $uci, $tr){ async.series([ function(next){ diff --git a/luciexpress/htdocs/plugins/wifi/pages/wifi.mac_filter.js b/luciexpress/htdocs/plugins/wifi/pages/wifi.mac_filter.js index 670e6dad8..3082043d6 100644 --- a/luciexpress/htdocs/plugins/wifi/pages/wifi.mac_filter.js +++ b/luciexpress/htdocs/plugins/wifi/pages/wifi.mac_filter.js @@ -1,4 +1,6 @@ -$juci.module("wifi") +//! Author: Martin K. Schröder + +JUCI.app .controller("WifiMacFilterPageCtrl", function($scope, $uci, gettext){ window.uci = $uci; $scope.uci = $uci; diff --git a/luciexpress/htdocs/plugins/wifi/pages/wifi.schedule.js b/luciexpress/htdocs/plugins/wifi/pages/wifi.schedule.js index d88847ddd..2cd1fa88c 100644 --- a/luciexpress/htdocs/plugins/wifi/pages/wifi.schedule.js +++ b/luciexpress/htdocs/plugins/wifi/pages/wifi.schedule.js @@ -1,4 +1,6 @@ -$juci.module("wifi") +//! Author: Martin K. Schröder + +JUCI.app .controller("WifiSchedulePageCtrl", function($scope, $uci, gettext){ $scope.statusItems = [ { label: gettext("Enabled"), value: 1 }, diff --git a/luciexpress/htdocs/plugins/wifi/pages/wifi.settings.js b/luciexpress/htdocs/plugins/wifi/pages/wifi.settings.js index f719327c1..20793c7b6 100644 --- a/luciexpress/htdocs/plugins/wifi/pages/wifi.settings.js +++ b/luciexpress/htdocs/plugins/wifi/pages/wifi.settings.js @@ -1,4 +1,6 @@ -$juci.module("wifi") +//! Author: Martin K. Schröder + +JUCI.app .controller("WifiSettingsPageCtrl", function($scope, $uci, gettext){ function load(){ $uci.sync("wireless").done(function(){ diff --git a/luciexpress/htdocs/plugins/wifi/pages/wifi.wps.html b/luciexpress/htdocs/plugins/wifi/pages/wifi.wps.html index 75face43d..ae6de8336 100644 --- a/luciexpress/htdocs/plugins/wifi/pages/wifi.wps.html +++ b/luciexpress/htdocs/plugins/wifi/pages/wifi.wps.html @@ -63,15 +63,13 @@ - +
-

wifi.wpspairmodal.progressinfo.0

-

wifi.wpspairmodal.progressinfo.1

-

wifi.wpspairmodal.progressinfo.2

+

{{text_status}}

diff --git a/luciexpress/htdocs/plugins/wifi/pages/wifi.wps.js b/luciexpress/htdocs/plugins/wifi/pages/wifi.wps.js index d77dec128..b115bf7f4 100644 --- a/luciexpress/htdocs/plugins/wifi/pages/wifi.wps.js +++ b/luciexpress/htdocs/plugins/wifi/pages/wifi.wps.js @@ -1,6 +1,16 @@ -$juci.module("wifi") -.controller("WifiWPSPageCtrl", function($scope, $uci, $rpc){ - console.log("WIFI PAGE CONTROLLER"); +//! Author: Martin K. Schröder + +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(); + } }); diff --git a/luciexpress/htdocs/plugins/wifi/tests/test-wireless.js b/luciexpress/htdocs/plugins/wifi/tests/test-wireless.js index 1eaffc55b..0d8ed6ace 100644 --- a/luciexpress/htdocs/plugins/wifi/tests/test-wireless.js +++ b/luciexpress/htdocs/plugins/wifi/tests/test-wireless.js @@ -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); + }); });