diff options
8 files changed, 82 insertions, 61 deletions
diff --git a/modules/luci-base/luasrc/model/network.lua b/modules/luci-base/luasrc/model/network.lua index 78df72da24..cce559aab1 100644 --- a/modules/luci-base/luasrc/model/network.lua +++ b/modules/luci-base/luasrc/model/network.lua @@ -1348,7 +1348,9 @@ function interface.ip6addrs(self) end function interface.type(self) - if self.wif or _wifi_iface(self.ifname) then + if self.ifname and self.ifname:byte(1) == 64 then + return "alias" + elseif self.wif or _wifi_iface(self.ifname) then return "wifi" elseif _bridge[self.ifname] then return "bridge" @@ -1385,7 +1387,9 @@ end function interface.get_type_i18n(self) local x = self:type() - if x == "wifi" then + if x == "alias" then + return lng.translate("Alias Interface") + elseif x == "wifi" then return lng.translate("Wireless Adapter") elseif x == "bridge" then return lng.translate("Bridge") @@ -1438,7 +1442,11 @@ function interface.bridge_stp(self) end function interface.is_up(self) - return self:_ubus("up") or false + local up = self:_ubus("up") + if up == nil then + up = (self:type() == "alias") + end + return up or false end function interface.is_bridge(self) diff --git a/modules/luci-base/luasrc/view/cbi/network_ifacelist.htm b/modules/luci-base/luasrc/view/cbi/network_ifacelist.htm index abfa33e1ed..a97e9ef6d0 100644 --- a/modules/luci-base/luasrc/view/cbi/network_ifacelist.htm +++ b/modules/luci-base/luasrc/view/cbi/network_ifacelist.htm @@ -26,9 +26,14 @@ else local n = self.network and net:get_network(self.network) if n then - local i - for _, i in ipairs(n:get_interfaces() or { n:get_interface() }) do - checked[i:name()] = true + local a = n:is_alias() + if a then + checked['@' .. a] = true + else + local i + for _, i in ipairs(n:get_interfaces() or { n:get_interface() }) do + checked[i:name()] = true + end end end end @@ -50,7 +55,8 @@ --></script> <ul> <% for _, iface in ipairs(ifaces) do - if (not self.nobridges or not iface:is_bridge()) and + if (not self.noaliases or iface:type() ~= "alias") and + (not self.nobridges or not iface:is_bridge()) and (not self.noinactive or iface:is_up()) and iface:name() ~= self.exclude then %> diff --git a/modules/luci-mod-admin-full/luasrc/controller/admin/network.lua b/modules/luci-mod-admin-full/luasrc/controller/admin/network.lua index 4680687883..31b9416253 100644 --- a/modules/luci-mod-admin-full/luasrc/controller/admin/network.lua +++ b/modules/luci-mod-admin-full/luasrc/controller/admin/network.lua @@ -211,6 +211,7 @@ function iface_status(ifaces) errors = net:errors(), name = device:shortname(), type = device:type(), + typename = device:get_type_i18n(), ifname = device:name(), macaddr = device:mac(), is_up = net:is_up() and device:is_up(), @@ -228,6 +229,7 @@ function iface_status(ifaces) data.subdevices[#data.subdevices+1] = { name = device:shortname(), type = device:type(), + typename = device:get_type_i18n(), ifname = device:name(), macaddr = device:mac(), is_up = device:is_up(), diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/ifaces.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/ifaces.lua index 5c630bb5ce..06bce01fc4 100644 --- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/ifaces.lua +++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/ifaces.lua @@ -285,6 +285,7 @@ if not net:is_floating() then ifname_single.template = "cbi/network_ifacelist" ifname_single.widget = "radio" ifname_single.nobridges = true + ifname_single.noaliases = false ifname_single.rmempty = false ifname_single.network = arg[1] ifname_single:depends("type", "") @@ -295,12 +296,18 @@ if not net:is_floating() then end function ifname_single.write(self, s, val) - local i + local _, i local new_ifs = { } local old_ifs = { } - for _, i in ipairs(net:get_interfaces() or { net:get_interface() }) do - old_ifs[#old_ifs+1] = i:name() + local alias = net:is_alias() + + if alias then + old_ifs[1] = '@' .. alias + else + for _, i in ipairs(net:get_interfaces() or { net:get_interface() }) do + old_ifs[#old_ifs+1] = i:name() + end end for i in ut.imatch(val) do @@ -335,6 +342,7 @@ if not net:is_virtual() then ifname_multi = s:taboption("physical", Value, "ifname_multi", translate("Interface")) ifname_multi.template = "cbi/network_ifacelist" ifname_multi.nobridges = true + ifname_multi.noaliases = true ifname_multi.rmempty = false ifname_multi.network = arg[1] ifname_multi.widget = "checkbox" diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi_overview.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi_overview.lua index dda31fb1ed..dcd03cb0fe 100644 --- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi_overview.lua +++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi_overview.lua @@ -78,18 +78,9 @@ local tpl_radio = tpl.Template(nil, [[ </div> <div class="td middle cbi-section-actions"> <div> - <input type="button" class="cbi-button cbi-button-neutral" title="<%:Restart radio interface%>" value="<%:Restart%>" onclick="wifi_restart(event)" data-radio="<%=dev:name()%>" /> - - <form action="<%=url('admin/network/wireless_join')%>" method="post" class="inline"> - <input type="hidden" name="device" value="<%=dev:name()%>" /> - <input type="hidden" name="token" value="<%=token%>" /> - <input type="submit" class="cbi-button cbi-button-action important" title="<%:Find and join network%>" value="<%:Scan%>" /> - </form> - <form action="<%=url('admin/network/wireless_add')%>" method="post" class="inline"> - <input type="hidden" name="device" value="<%=dev:name()%>" /> - <input type="hidden" name="token" value="<%=token%>" /> - <input type="submit" class="cbi-button cbi-button-add" title="<%:Provide new network%>" value="<%:Add%>" /> - </form> + <input type="button" class="cbi-button cbi-button-neutral" title="<%:Restart radio interface%>" value="<%:Restart%>" data-radio="<%=dev:name()%>" onclick="wifi_restart(event)" /> + <input type="submit" class="cbi-button cbi-button-action important" title="<%:Find and join network%>" value="<%:Scan%>" data-radio="<%=dev:name()%>" onclick="wifi_action(event, 'join')" /> + <input type="submit" class="cbi-button cbi-button-add" title="<%:Provide new network%>" value="<%:Add%>" data-radio="<%=dev:name()%>" onclick="wifi_action(event, 'add')" /> </div> </div> </div> diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_network/iface_overview_status.htm b/modules/luci-mod-admin-full/luasrc/view/admin_network/iface_overview_status.htm index f56b3e0ade..2c89d10430 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_network/iface_overview_status.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_network/iface_overview_status.htm @@ -30,21 +30,33 @@ networks.push(n.getAttribute('data-network')); }); + function render_iface(ifc) { + return E('span', { class: 'cbi-tooltip-container' }, [ + E('img', { 'class' : 'middle', 'src': '<%=resource%>/icons/%s%s.png'.format( + ifc.is_alias ? 'alias' : ifc.type, + ifc.is_up ? '' : '_disabled') }), + E('span', { 'class': 'cbi-tooltip ifacebadge large' }, [ + E('img', { 'src': '<%=resource%>/icons/%s%s.png'.format( + ifc.type, ifc.is_up ? '' : '_disabled') }), + E('span', { 'class': 'left' }, [ + E('strong', '<%:Type%>: '), ifc.typename, E('br'), + E('strong', '<%:Device%>: '), ifc.ifname, E('br'), + E('strong', '<%:Connected%>: '), ifc.is_up ? '<%:yes%>' : '<%:no%>', E('br'), + ifc.macaddr ? E('strong', '<%:MAC%>: ') : '', + ifc.macaddr ? ifc.macaddr : '', + ifc.macaddr ? E('br') : '', + E('strong', '<%:RX%>: '), '%.2mB (%d <%:Pkts.%>)'.format(ifc.rx_bytes, ifc.rx_packets), E('br'), + E('strong', '<%:TX%>: '), '%.2mB (%d <%:Pkts.%>)'.format(ifc.tx_bytes, ifc.tx_packets) + ]) + ]) + ]); + } + XHR.poll(5, '<%=url('admin/network/iface_status')%>/' + networks.join(','), null, function(x, ifcs) { if (ifcs) { - var primary_devices = { }; - - for (var idx = 0; idx < ifcs.length; idx++) - { - var ifc = ifcs[idx]; - - if (!ifc.is_alias && !ifc.is_dynamic) - primary_devices[ifc.name] = ifc; - } - for (var idx = 0; idx < ifcs.length; idx++) { var ifc = ifcs[idx]; @@ -53,37 +65,25 @@ var s = document.getElementById(ifc.id + '-ifc-devices'); if (s) { - var stat = String.format( - '<img src="<%=resource%>/icons/%s%s.png" style="width:16px; height:16px; vertical-align:middle" />', - (ifc.is_dynamic || ifc.is_alias) ? 'alias' : ifc.type, - ifc.is_up ? '' : '_disabled' - ); + while (s.firstChild) + s.removeChild(s.firstChild); + + s.appendChild(render_iface(ifc)); if (ifc.subdevices && ifc.subdevices.length) { - stat += ' <strong>('; + var sifs = [ ' (' ]; for (var j = 0; j < ifc.subdevices.length; j++) - { - var sif = ifc.subdevices[j]; - - stat += String.format( - '<img src="<%=resource%>/icons/%s%s.png" style="width:16px; height:16px; vertical-align:middle" title="%h" />', - sif.type, - sif.is_up ? '' : '_disabled', - sif.name - ); - } + sifs.push(render_iface(ifc.subdevices[j])); - stat += ')</strong>'; - } + sifs.push(')'); - stat += String.format( - '<br /><small>%h</small>', - ifc.name - ); + s.appendChild(E('span', {}, sifs)); + } - s.innerHTML = stat; + s.appendChild(E('br')); + s.appendChild(E('small', {}, ifc.is_alias ? '<%:Alias of "%s"%>'.format(ifc.is_alias) : ifc.name)); } var d = document.getElementById(ifc.id + '-ifc-description'); @@ -106,7 +106,8 @@ html += String.format('<strong><%:Uptime%>:</strong> %t<br />', ifc.uptime); } - if (!primary_devices[ifc.name] || primary_devices[ifc.name] === ifc) + + if (!ifc.is_dynamic && !ifc.is_alias) { if (ifc.macaddr) html += String.format('<strong><%:MAC-Address%>:</strong> %s<br />', ifc.macaddr); diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview_status.htm b/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview_status.htm index 9730bc2c92..cc6db1721f 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview_status.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview_status.htm @@ -26,6 +26,14 @@ { token: '<%=token%>' }, XHR.run); } + function wifi_action(ev, action) { + var i = ev.target, + e = i.getAttribute('data-radio'); + + i.parentNode.appendChild(E('input', { type: 'hidden', name: 'device', value: e })); + i.form.action = '<%=url('admin/network/wireless_')%>' + action; + } + var networks = [ ]; document.querySelectorAll('[data-network]').forEach(function(n) { diff --git a/themes/luci-theme-bootstrap/htdocs/luci-static/bootstrap/cascade.css b/themes/luci-theme-bootstrap/htdocs/luci-static/bootstrap/cascade.css index 38f3ca54e2..4ca9e84f41 100644 --- a/themes/luci-theme-bootstrap/htdocs/luci-static/bootstrap/cascade.css +++ b/themes/luci-theme-bootstrap/htdocs/luci-static/bootstrap/cascade.css @@ -567,7 +567,7 @@ textarea { color: #bfbfbf; } -input, textarea { +.btn, .cbi-button, input, textarea { transition: border linear 0.2s, box-shadow linear 0.2s; box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1); } @@ -577,6 +577,7 @@ input:focus, textarea:focus { outline: 0; border-color: rgba(82, 168, 236, 0.8) !important; box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6); + text-decoration: none; } input[type=file]:focus, input[type=checkbox]:focus, select:focus { @@ -1591,10 +1592,6 @@ button.btn::-moz-focus-inner, input[type=submit].btn::-moz-focus-inner { line-height: 28px; } -.alert-message .btn { - box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25); -} - .label { padding: 1px 3px 2px; font-size: 9.75px; |