From feb964d8ea8ae175c9e2cada6f7dd285f4ea564a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Schr=C3=B6der?= Date: Mon, 25 May 2015 12:49:18 +0200 Subject: [PATCH] User router.radios for getting radio caps --- luciexpress/htdocs/js/app.js | 6 ++--- luciexpress/htdocs/js/rpc.js | 3 +++ .../plugins/core/widgets/luci.expandable.html | 1 + .../plugins/status/pages/status.status.js | 12 +++++----- .../widgets/uci.wireless.device.edit.html | 6 ++--- .../wifi/widgets/uci.wireless.device.edit.js | 22 +++++++++++++++---- luciexpress/share/acl.d/luci2.json | 3 ++- 7 files changed, 37 insertions(+), 16 deletions(-) diff --git a/luciexpress/htdocs/js/app.js b/luciexpress/htdocs/js/app.js index 047f2e7a9..67599bf0d 100644 --- a/luciexpress/htdocs/js/app.js +++ b/luciexpress/htdocs/js/app.js @@ -173,11 +173,11 @@ JUCI.app.config(function ($stateProvider, $locationProvider, $compileProvider, $ } }); }); - $rpc.$authenticate().done(function(){ + if($rpc.$isLoggedIn()){ $juci.redirect(path||"overview"); - }).fail(function(){ + } else { $juci.redirect("login"); - }); + }; }) // TODO: figure out how to avoid forward declarations of things we intend to override. diff --git a/luciexpress/htdocs/js/rpc.js b/luciexpress/htdocs/js/rpc.js index a4169efb0..900aff129 100644 --- a/luciexpress/htdocs/js/rpc.js +++ b/luciexpress/htdocs/js/rpc.js @@ -140,6 +140,9 @@ if(sid) RPC_SESSION_ID = sid; else return RPC_SESSION_ID; }, + $isLoggedIn: function(){ + return RPC_SESSION_ID !== RPC_DEFAULT_SESSION_ID; + }, $authenticate: function(){ var self = this; var deferred = $.Deferred(); diff --git a/luciexpress/htdocs/plugins/core/widgets/luci.expandable.html b/luciexpress/htdocs/plugins/core/widgets/luci.expandable.html index 199edeca6..b8e0939a3 100644 --- a/luciexpress/htdocs/plugins/core/widgets/luci.expandable.html +++ b/luciexpress/htdocs/plugins/core/widgets/luci.expandable.html @@ -2,6 +2,7 @@
+
diff --git a/luciexpress/htdocs/plugins/status/pages/status.status.js b/luciexpress/htdocs/plugins/status/pages/status.status.js index 100bc510c..f371f0768 100644 --- a/luciexpress/htdocs/plugins/status/pages/status.status.js +++ b/luciexpress/htdocs/plugins/status/pages/status.status.js @@ -25,10 +25,12 @@ JUCI.app ] .filter(function(x){ return x.value != "" }) .forEach(function(x, c){ - sections.push({ - "name": x.name, - "interface": _interfaces.find(function(i){ return i.interface == x.value; }) - }); + if(x.interface) { + sections.push({ + "name": x.name, + "interface": _interfaces.find(function(i){ return i.interface == x.value; }) + }); + } }); sections = sections.sort(function(a, b) { return a.interface.up > b.interface.up; }); for(var c = 0; c < sections.length; c++){ @@ -44,7 +46,7 @@ JUCI.app function(next){ $rpc.router.dslstats().done(function(result){ switch(result.dslstats.status){ - case 'Idle': $scope.dsl_status = 'error'; break; + case 'Idle': $scope.dsl_status = 'disabled'; break; case 'Showtime': $scope.dsl_status = 'ok'; break; default: $scope.dsl_status = 'progress'; break; } diff --git a/luciexpress/htdocs/plugins/wifi/widgets/uci.wireless.device.edit.html b/luciexpress/htdocs/plugins/wifi/widgets/uci.wireless.device.edit.html index 29cfc3b9c..a43326144 100644 --- a/luciexpress/htdocs/plugins/wifi/widgets/uci.wireless.device.edit.html +++ b/luciexpress/htdocs/plugins/wifi/widgets/uci.wireless.device.edit.html @@ -1,13 +1,13 @@
- + - + - +
diff --git a/luciexpress/htdocs/plugins/wifi/widgets/uci.wireless.device.edit.js b/luciexpress/htdocs/plugins/wifi/widgets/uci.wireless.device.edit.js index 49deafa67..762226024 100644 --- a/luciexpress/htdocs/plugins/wifi/widgets/uci.wireless.device.edit.js +++ b/luciexpress/htdocs/plugins/wifi/widgets/uci.wireless.device.edit.js @@ -10,9 +10,23 @@ $juci.module("wifi") replace: true, require: "^ngModel" }; -}).controller("WifiDeviceEditController", function($scope){ - $scope.allChannels = [ "auto", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]; - $scope.allModes = ["802.11gn", "802.11bg", "802.11bgn", "802.11n"]; - $scope.allBandwidths = [ "20", "40", "2040", "80" ]; +}).controller("WifiDeviceEditController", function($scope, $rpc, gettext){ + $scope.$watch("device", function(device){ + if(!device) return; + + $rpc.router.radios().done(function(result){ + if(device[".name"] in result){ + var settings = result[device[".name"]]; + $scope.allChannels = [gettext("auto")].concat(settings.channels); + $scope.allModes = settings.hwmodes; + $scope.allBandwidths = settings.bwcaps; + } else { + $scope.allChannels = [ "auto" ]; + $scope.allModes = ["802.11gn", "802.11bg", "802.11bgn", "802.11n"]; + $scope.allBandwidths = [ "20", "40", "80" ]; + } + $scope.$apply(); + }); + }); }); diff --git a/luciexpress/share/acl.d/luci2.json b/luciexpress/share/acl.d/luci2.json index 326f2ef28..72b8890a6 100644 --- a/luciexpress/share/acl.d/luci2.json +++ b/luciexpress/share/acl.d/luci2.json @@ -382,7 +382,8 @@ "luci2.network.bwmon": [ "devices", "statistics" - ] + ], + "router": [ "radios" ] }, "uci": [ "network",