}
-var Hosts, Network, Protocol, Device, WifiDevice, WifiNetwork;
+var Hosts, Network, Protocol, Device, WifiDevice, WifiNetwork, WifiVlan;
/**
* @class network
*/
getAssocList: function() {
var tasks = [];
- var ifnames = [ this.getIfname() ].concat(this.getVlanIfnames());
+ var station;
- for (var i = 0; i < ifnames.length; i++)
- tasks.push(callIwinfoAssoclist(ifnames[i]));
+ for (let vlan of this.getVlans())
+ tasks.push(callIwinfoAssoclist(vlan.getIfname()).then(
+ function(stations) {
+ for (station of stations)
+ station.vlan = vlan;
+
+ return stations;
+ })
+ );
+
+ tasks.push(callIwinfoAssoclist(this.getIfname()));
return Promise.all(tasks).then(function(values) {
return Array.prototype.concat.apply([], values);
});
},
+ /**
+ * Fetch the vlans for this network.
+ *
+ * @returns {Array<LuCI.network.WifiVlan>}
+ * Returns an array of vlans for this network.
+ */
+ getVlans: function() {
+ var vlans = [];
+ var vlans_ubus = this.ubus('net', 'vlans');
+
+ if (vlans_ubus)
+ for (let vlan of vlans_ubus)
+ vlans.push(new WifiVlan(vlan));
+
+ return vlans;
+ },
+
/**
* Query the current operating frequency of the wireless network.
*
}
});
+/**
+ * @class
+ * @memberof LuCI.network
+ * @hideconstructor
+ * @classdesc
+ *
+ * A `Network.WifiVlan` class instance represents a vlan on a WifiNetwork.
+ */
+WifiVlan = baseclass.extend(/** @lends LuCI.network.WifiVlan.prototype */ {
+ __init__: function(vlan) {
+ this.ifname = vlan.ifname;
+ if (L.isObject(vlan.config)) {
+ this.vid = vlan.config.vid;
+ this.name = vlan.config.name;
+
+ if (Array.isArray(vlan.config.network) && vlan.config.network.length)
+ this.network = vlan.config.network[0];
+ }
+ },
+
+ /**
+ * Get the name of the wifi vlan.
+ *
+ * @returns {string}
+ * Returns the name.
+ */
+ getName: function() {
+ return this.name;
+ },
+
+ /**
+ * Get the vlan id of the wifi vlan.
+ *
+ * @returns {number}
+ * Returns the vlan id.
+ */
+ getVlanId: function() {
+ return this.vid;
+ },
+
+ /**
+ * Get the network of the wifi vlan.
+ *
+ * @returns {string}
+ * Returns the network.
+ */
+ getNetwork: function() {
+ return this.network;
+ },
+
+ /**
+ * Get the Linux network device name of the wifi vlan.
+ *
+ * @returns {string}
+ * Returns the current network device name for this wifi vlan.
+ */
+ getIfname: function() {
+ return this.ifname;
+ },
+
+ /**
+ * Get a long description string for the wifi vlan.
+ *
+ * @returns {string}
+ * Returns a string containing the vlan id and the vlan name,
+ * if it is different than the vlan id
+ */
+ getI18n: function() {
+ var name = this.name && this.name != this.vid ? ' (' + this.name + ')' : '';
+ return 'vlan %d%s'.format(this.vid, name);
+ },
+});
+
return Network;
])
];
+ var zones = data[4];
+ if (bss.vlan) {
+ var desc = bss.vlan.getI18n();
+ var vlan_network = bss.vlan.getNetwork();
+ var vlan_zone;
+
+ if (vlan_network && zones)
+ for (let zone of zones)
+ if (zone.getNetworks().includes(vlan_network))
+ vlan_zone = zone;
+
+ row[0].insertBefore(
+ E('div', {
+ 'class' : 'zonebadge',
+ 'title' : desc,
+ 'style' : firewall.getZoneColorStyle(vlan_zone)
+ }, [ desc ]), row[0].firstChild);
+ }
+
if (bss.network.isClientDisconnectSupported()) {
if (table.firstElementChild.childNodes.length < 6)
table.firstElementChild.appendChild(E('th', { 'class': 'th cbi-section-actions'}));
return Promise.all([
uci.changes(),
uci.load('wireless'),
- uci.load('system')
+ uci.load('system'),
+ firewall.getZones(),
]);
},
params: [ 'config', 'section', 'name' ]
}),
- render: function() {
+ render: function(data) {
if (this.checkAnonymousSections())
return this.renderMigration();
else
- return this.renderOverview();
+ return this.renderOverview(data[3]);
},
handleMigration: function(ev) {
]);
},
- renderOverview: function() {
+ renderOverview: function(zones) {
var m, s, o;
m = new form.Map('wireless');
return hosts_radios_wifis;
});
}, network))
+ .then(L.bind(function(zones, data) {
+ data.push(zones);
+ return data;
+ }, network, zones))
.then(L.bind(this.poll_status, this, nodes));
}, this), 5);
'require uci';
'require fs';
'require rpc';
+'require firewall';
return baseclass.extend({
title: _('Wireless'),
network.getHostHints(),
this.callSessionAccess('access-group', 'luci-mod-status-index-wifi', 'read'),
this.callSessionAccess('access-group', 'luci-mod-status-index-wifi', 'write'),
+ firewall.getZones(),
L.hasSystemFeature('wifi') ? L.resolveDefault(uci.load('wireless')) : L.resolveDefault(),
]).then(L.bind(function(data) {
var tasks = [],
networks = data[1],
hosthints = data[2],
hasReadPermission = data[3],
- hasWritePermission = data[4];
+ hasWritePermission = data[4],
+ zones = data[5];
var table = E('div', { 'class': 'network-status-table' });
])
];
+ if (bss.vlan) {
+ var desc = bss.vlan.getI18n();
+ var vlan_network = bss.vlan.getNetwork();
+ var vlan_zone;
+
+ if (vlan_network)
+ for (let zone of zones)
+ if (zone.getNetworks().includes(vlan_network))
+ vlan_zone = zone;
+
+ row[0].insertBefore(
+ E('div', {
+ 'class' : 'zonebadge',
+ 'title' : desc,
+ 'style' : firewall.getZoneColorStyle(vlan_zone)
+ }, [ desc ]), row[0].firstChild);
+ }
+
if (networks[i].isClientDisconnectSupported() && hasWritePermission) {
if (assoclist.firstElementChild.childNodes.length < 6)
assoclist.firstElementChild.appendChild(E('th', { 'class': 'th cbi-section-actions' }));