User router.radios for getting radio caps

This commit is contained in:
Martin Schröder 2015-05-25 12:49:18 +02:00 committed by Martin Schröder
parent 02bb73836c
commit feb964d8ea
7 changed files with 37 additions and 16 deletions

View file

@ -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.

View file

@ -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();

View file

@ -2,6 +2,7 @@
<div class="panel-heading">
<div class="btn-group pull-right">
<span ng-show="status == 'ok'" class="btn pull-right"><i style="color: green;" class="fa fa-check-circle fa-2x"></i></span>
<span ng-show="status == 'disabled'" class="btn pull-right"><i style="color: gray;" class="fa fa-times-circle fa-2x"></i></span>
<span ng-show="status == 'progress'" class="btn pull-right"><i style="color: orange;" class="fa fa-spinner fa-2x fa-spin"></i></span>
<span ng-show="status == 'error'" class="btn pull-right"><i style="color: red;" class="fa fa-exclamation-circle fa-2x"></i></span>
</div>

View file

@ -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;
}

View file

@ -1,13 +1,13 @@
<div>
<luci-config-lines>
<luci-config-line title="{{'Wifi Mode'|translate}}">
<luci-select ng-model="device.hwmode.value" ng-items="device.hwmode.schema.allow"/>
<luci-select ng-model="device.hwmode.value" ng-items="allModes"/>
</luci-config-line>
<luci-config-line title="{{'Bandwidth'|translate}}">
<luci-select ng-model="device.bandwidth.value" ng-items="device.bandwidth.schema.allow"/>
<luci-select ng-model="device.bandwidth.value" ng-items="allBandwidths"/>
</luci-config-line>
<luci-config-line title="{{'Channel'|translate}}">
<luci-select ng-model="device.channel.value" ng-items="device.channel.schema.allow"/>
<luci-select ng-model="device.channel.value" ng-items="allChannels"/>
</luci-config-line>
</luci-config-lines>
</div>

View file

@ -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();
});
});
});

View file

@ -382,7 +382,8 @@
"luci2.network.bwmon": [
"devices",
"statistics"
]
],
"router": [ "radios" ]
},
"uci": [
"network",