diff --git a/luciexpress/htdocs/js/uci.js b/luciexpress/htdocs/js/uci.js index 028ae1f78..2edd0f119 100644 --- a/luciexpress/htdocs/js/uci.js +++ b/luciexpress/htdocs/js/uci.js @@ -485,7 +485,6 @@ UCIConfig.prototype.$deleteSection = function(section){ var self = this; var deferred = $.Deferred(); - console.log("Deleting section "+self[".name"]+"."+section[".name"]); //self[".need_commit"] = true; $rpc.uci.delete({ @@ -493,6 +492,7 @@ "section": section[".name"] }).done(function(){ _unlinkSection(self, section); + console.log("Deleted section "+self[".name"]+"."+section[".name"]); self[".need_commit"] = true; deferred.resolve(); }).fail(function(){ diff --git a/luciexpress/htdocs/plugins/phone/pages/phone.numbers.html b/luciexpress/htdocs/plugins/phone/pages/phone.numbers.html index e5e0922d5..1d8473a99 100644 --- a/luciexpress/htdocs/plugins/phone/pages/phone.numbers.html +++ b/luciexpress/htdocs/plugins/phone/pages/phone.numbers.html @@ -1,5 +1,9 @@
- This page is not done yet. Waiting for voice API. + + {{ 'Phone Numbers' | translate }} + {{ 'phone.speed_dialing.info' | translate }} + +
diff --git a/luciexpress/htdocs/plugins/phone/pages/phone.speed_dialing.html b/luciexpress/htdocs/plugins/phone/pages/phone.speed_dialing.html index aed111fac..b2675fefe 100644 --- a/luciexpress/htdocs/plugins/phone/pages/phone.speed_dialing.html +++ b/luciexpress/htdocs/plugins/phone/pages/phone.speed_dialing.html @@ -1,5 +1,27 @@
- This page is not done yet. Waiting for voice API. + + {{ 'Speed Dialing' | translate }} + {{ 'phone.speed_dialing.info' | translate }} + + + + + +
+
+
#{{dial.tone}}
+
+ +
+
+
+ + + + + +
+
diff --git a/luciexpress/htdocs/plugins/phone/pages/phone.speed_dialing.js b/luciexpress/htdocs/plugins/phone/pages/phone.speed_dialing.js index 2a470054f..eacc59f93 100644 --- a/luciexpress/htdocs/plugins/phone/pages/phone.speed_dialing.js +++ b/luciexpress/htdocs/plugins/phone/pages/phone.speed_dialing.js @@ -20,7 +20,69 @@ * 02110-1301 USA */ -$juci.module("phone") -.controller("PhoneSpeedDialingCtrl", function($scope){ +JUCI.app +.controller("PhoneSpeedDialingCtrl", function($scope, $uci){ + $scope.speed_dials = []; + $scope.speed_dialing = true; + $scope.$watch("speed_dials", function(){ + var dials = {}; + $scope.speed_dials.map(function(x){ if(x.number != "") dials[x.tone] = x; }); + async.eachSeries(Object.keys(dials), function(k, next){ + if(!dials[k].exists){ + $uci.voice_client.create({".type": "speed_dial"}).done(function(section){ + section.tone.value = dials[k].tone; + section.number.value = dials[k].number; + dials[k].exists = true; + }).always(function(){ + next(); + }); + } else { + next(); + } + }, function(){ + Object.keys($scope.speed_dials).map(function(k){ + var dial = $scope.speed_dials[k]; + var section = $uci.voice_client["@speed_dial"].find(function(x){ return x.tone.value == dial.tone; }); + if(section){ + section.tone.value = dial.tone; + section.number.value = dial.number; + } + }); + }); + }, true); + + function resync(){ + $uci.sync("voice_client").done(function(){ + var dials = {}; + $uci.voice_client["@speed_dial"].map(function(x){ + dials[x.tone.value] = { + tone: x.tone.value, + number: x.number.value, + exists: true + }; + }); + for(var c = 0; c < 10; c++){ + if(!(dials[c])) dials[c] = { + tone: c, + number: "" + } + } + $scope.speed_dials = Object.keys(dials).map(function(x){ return dials[x]; }); + $scope.$apply(); + }); + } resync(); + + $scope.onClearAll = function(){ + var dials = $uci.voice_client["@speed_dial"].map(function(x){ return x; }); + async.eachSeries(dials, function(dial, next){ + dial.$delete().always(function(){ next(); }); + }, function(){ + console.log("Save!"); + $uci.save().done(function(){ + console.log("resync"); + resync(); + }); + }); + } }); diff --git a/luciexpress/share/acl.d/luci2.json b/luciexpress/share/acl.d/luci2.json index 2785ba5d5..94fa6b739 100644 --- a/luciexpress/share/acl.d/luci2.json +++ b/luciexpress/share/acl.d/luci2.json @@ -130,7 +130,8 @@ "setpin", "pbc", "showpin", - "stapin" + "stapin", + "status" ], "router": [ "networks" @@ -161,7 +162,8 @@ "setpin", "pbc", "showpin", - "stapin" + "stapin", + "status" ] }, "uci": [