Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
'require baseclass';
'require validation';
'require tools.widgets as widgets';
'require rpc';

function validateAddr(section_id, value) {
if (value == '')
Expand Down Expand Up @@ -363,6 +364,25 @@ var cbiTagValue = form.Value.extend({
remove: function() {}
});

var callDeviceStatus = rpc.declare({
object: 'network.device',
method: 'status',
params: [ 'name' ]
});

function extractSupportedSpeeds(status) {
var sup = (status && (status['link-supported'] || status['link_supported'])) || [];
var uniq = Object.create(null);

L.toArray(sup).forEach(function (v) {
var m = String(v).match(/^(\d+)/);
if (m) uniq[m[1]] = true;
});

return Object.keys(uniq).sort(function (a, b) { return (+a) - (+b); });
}


return baseclass.extend({

protocols: [ // name, proto number, description
Expand Down Expand Up @@ -1141,6 +1161,35 @@ return baseclass.extend({
o.placeholder = dev ? dev._devstate('qlen') : '';
o.datatype = 'uinteger';

o = this.replaceOption(s, 'devgeneral', form.Value, 'speed', _('Speed'));

o.editable = true;
o.placeholder = '0';
o.datatype = 'uinteger';
o.rmempty = true;
o.default=''


o.value('', '');
o.load = function (section_id) {

var ifn = this.section.formvalue(section_id, 'ifname_single')
|| this.section.formvalue(section_id, 'name_simple')
|| uci.get('network', section_id, 'name')
|| (dev ? dev.getName() : '');

ifn = String(ifn || '').replace(/\.\d+$/, '');

if (!ifn) ifn = 'eth1';

var self = this;
return callDeviceStatus(ifn).then(function (st) {
extractSupportedSpeeds(st).forEach(function (sp) {
self.value(sp, sp + ' Mbit/s');
});
});
};

/* PSE / PoE options */
if (hasPSE) {
o = this.replaceOption(s, 'devpse', form.ListValue, 'pse', _('PoE (C33)'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"iwinfo": [ "assoclist", "countrylist", "freqlist", "txpowerlist" ],
"luci": [ "getSwconfigFeatures", "getSwconfigPortState" ]
},
"uci": [ "dhcp", "firewall", "network", "wireless", "system" ]
},
"uci": [ "dhcp", "firewall", "network", "wireless", "system" ],
"network.device": [ "status" ] },
"write": {
"cgi-io": [ "exec" ],
"file": {
Expand Down