summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-mod-admin-full/luasrc
diff options
context:
space:
mode:
Diffstat (limited to 'modules/luci-mod-admin-full/luasrc')
-rw-r--r--modules/luci-mod-admin-full/luasrc/controller/admin/network.lua179
-rw-r--r--modules/luci-mod-admin-full/luasrc/controller/admin/status.lua4
-rw-r--r--modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/dhcp.lua3
-rw-r--r--modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/iface_add.lua4
-rw-r--r--modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/ifaces.lua14
-rw-r--r--modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/network.lua137
-rw-r--r--modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi.lua22
-rw-r--r--modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi_overview.lua223
-rw-r--r--modules/luci-mod-admin-full/luasrc/view/admin_network/diagnostics.htm2
-rw-r--r--modules/luci-mod-admin-full/luasrc/view/admin_network/iface_overview.htm250
-rw-r--r--modules/luci-mod-admin-full/luasrc/view/admin_network/iface_overview_status.htm183
-rw-r--r--modules/luci-mod-admin-full/luasrc/view/admin_network/iface_status.htm2
-rw-r--r--modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_join.htm301
-rw-r--r--modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview.htm353
-rw-r--r--modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview_status.htm127
-rw-r--r--modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_status.htm8
-rw-r--r--modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm6
17 files changed, 991 insertions, 827 deletions
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 e04a964dd7..c45605a983 100644
--- a/modules/luci-mod-admin-full/luasrc/controller/admin/network.lua
+++ b/modules/luci-mod-admin-full/luasrc/controller/admin/network.lua
@@ -1,5 +1,5 @@
-- Copyright 2008 Steven Barth <steven@midlink.org>
--- Copyright 2011-2015 Jo-Philipp Wich <jow@openwrt.org>
+-- Copyright 2011-2018 Jo-Philipp Wich <jo@mein.io>
-- Licensed to the public under the Apache License 2.0.
module("luci.controller.admin.network", package.seeall)
@@ -45,26 +45,26 @@ function index()
if has_wifi then
page = entry({"admin", "network", "wireless_assoclist"}, call("wifi_assoclist"), nil)
page.leaf = true
-
+
page = entry({"admin", "network", "wireless_join"}, post("wifi_join"), nil)
page.leaf = true
page = entry({"admin", "network", "wireless_add"}, post("wifi_add"), nil)
page.leaf = true
- page = entry({"admin", "network", "wireless_delete"}, post("wifi_delete"), nil)
- page.leaf = true
-
page = entry({"admin", "network", "wireless_status"}, call("wifi_status"), nil)
page.leaf = true
page = entry({"admin", "network", "wireless_reconnect"}, post("wifi_reconnect"), nil)
page.leaf = true
- page = entry({"admin", "network", "wireless_shutdown"}, post("wifi_shutdown"), nil)
+ page = entry({"admin", "network", "wireless_scan_trigger"}, post("wifi_scan_trigger"), nil)
+ page.leaf = true
+
+ page = entry({"admin", "network", "wireless_scan_results"}, call("wifi_scan_results"), nil)
page.leaf = true
- page = entry({"admin", "network", "wireless"}, arcombine(template("admin_network/wifi_overview"), cbi("admin_network/wifi")), _("Wireless"), 15)
+ page = entry({"admin", "network", "wireless"}, arcombine(cbi("admin_network/wifi_overview"), cbi("admin_network/wifi")), _("Wireless"), 15)
page.leaf = true
page.subindex = true
@@ -88,18 +88,12 @@ function index()
page = entry({"admin", "network", "iface_add"}, form("admin_network/iface_add"), nil)
page.leaf = true
- page = entry({"admin", "network", "iface_delete"}, post("iface_delete"), nil)
- page.leaf = true
-
page = entry({"admin", "network", "iface_status"}, call("iface_status"), nil)
page.leaf = true
page = entry({"admin", "network", "iface_reconnect"}, post("iface_reconnect"), nil)
page.leaf = true
- page = entry({"admin", "network", "iface_shutdown"}, post("iface_shutdown"), nil)
- page.leaf = true
-
page = entry({"admin", "network", "network"}, arcombine(cbi("admin_network/network"), cbi("admin_network/ifaces")), _("Interfaces"), 10)
page.leaf = true
page.subindex = true
@@ -201,29 +195,6 @@ function wifi_add()
end
end
-function wifi_delete(network)
- local ntm = require "luci.model.network".init()
- local wnet = ntm:get_wifinet(network)
- if wnet then
- local dev = wnet:get_device()
- local nets = wnet:get_networks()
- if dev then
- ntm:del_wifinet(network)
- ntm:commit("wireless")
- local _, net
- for _, net in ipairs(nets) do
- if net:is_empty() then
- ntm:del_network(net:name())
- ntm:commit("network")
- end
- end
- luci.sys.call("env -i /bin/ubus call network reload >/dev/null 2>/dev/null")
- end
- end
-
- luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless"))
-end
-
function iface_status(ifaces)
local netm = require "luci.model.network".init()
local rv = { }
@@ -235,6 +206,7 @@ function iface_status(ifaces)
if device then
local data = {
id = iface,
+ desc = net:get_i18n(),
proto = net:proto(),
uptime = net:uptime(),
gwaddr = net:gwaddr(),
@@ -242,11 +214,15 @@ function iface_status(ifaces)
ip6addrs = net:ip6addrs(),
dnsaddrs = net:dnsaddrs(),
ip6prefix = net:ip6prefix(),
+ errors = net:errors(),
name = device:shortname(),
type = device:type(),
+ typename = device:get_type_i18n(),
ifname = device:name(),
macaddr = device:mac(),
- is_up = device:is_up(),
+ is_up = net:is_up() and device:is_up(),
+ is_alias = net:is_alias(),
+ is_dynamic = net:is_dynamic(),
rx_bytes = device:rx_bytes(),
tx_bytes = device:tx_bytes(),
rx_packets = device:rx_packets(),
@@ -259,6 +235,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(),
@@ -301,34 +278,6 @@ function iface_reconnect(iface)
luci.http.status(404, "No such interface")
end
-function iface_shutdown(iface)
- local netmd = require "luci.model.network".init()
- local net = netmd:get_network(iface)
- if net then
- luci.sys.call("env -i /sbin/ifdown %s >/dev/null 2>/dev/null"
- % luci.util.shellquote(iface))
- luci.http.status(200, "Shutdown")
- return
- end
-
- luci.http.status(404, "No such interface")
-end
-
-function iface_delete(iface)
- local netmd = require "luci.model.network".init()
- local net = netmd:del_network(iface)
- if net then
- luci.sys.call("env -i /sbin/ifdown %s >/dev/null 2>/dev/null"
- % luci.util.shellquote(iface))
- luci.http.redirect(luci.dispatcher.build_url("admin/network/network"))
- netmd:commit("network")
- netmd:commit("wireless")
- return
- end
-
- luci.http.status(404, "No such interface")
-end
-
function wifi_status(devs)
local s = require "luci.tools.status"
local rv = { }
@@ -349,37 +298,93 @@ function wifi_status(devs)
luci.http.status(404, "No such device")
end
-local function wifi_reconnect_shutdown(shutdown, wnet)
- local netmd = require "luci.model.network".init()
- local net = netmd:get_wifinet(wnet)
- local dev = net:get_device()
- if dev and net then
- dev:set("disabled", nil)
- net:set("disabled", shutdown and 1 or nil)
- netmd:commit("wireless")
-
- luci.sys.call("env -i /bin/ubus call network reload >/dev/null 2>/dev/null")
- luci.http.status(200, shutdown and "Shutdown" or "Reconnected")
+function wifi_reconnect(radio)
+ local rc = luci.sys.call("env -i /sbin/wifi up %s" % luci.util.shellquote(radio))
- return
+ if rc == 0 then
+ luci.http.status(200, "Reconnected")
+ else
+ luci.http.status(500, "Error")
end
+end
+
+function wifi_assoclist()
+ local s = require "luci.tools.status"
- luci.http.status(404, "No such radio")
+ luci.http.prepare_content("application/json")
+ luci.http.write_json(s.wifi_assoclist())
end
-function wifi_reconnect(wnet)
- wifi_reconnect_shutdown(false, wnet)
+
+local function _wifi_get_scan_results(cache_key)
+ local results = luci.util.ubus("session", "get", {
+ ubus_rpc_session = luci.model.uci:get_session_id(),
+ keys = { cache_key }
+ })
+
+ if type(results) == "table" and
+ type(results.values) == "table" and
+ type(results.values[cache_key]) == "table"
+ then
+ return results.values[cache_key]
+ end
+
+ return { }
end
-function wifi_shutdown(wnet)
- wifi_reconnect_shutdown(true, wnet)
+function wifi_scan_trigger(radio, update)
+ local iw = radio and luci.sys.wifi.getiwinfo(radio)
+
+ if not iw then
+ luci.http.status(404, "No such radio device")
+ return
+ end
+
+ luci.http.status(200, "Scan scheduled")
+
+ if nixio.fork() == 0 then
+ io.stderr:close()
+ io.stdout:close()
+
+ local _, bss
+ local data, bssids = { }, { }
+ local cache_key = "scan_%s" % radio
+
+ luci.util.ubus("session", "set", {
+ ubus_rpc_session = luci.model.uci:get_session_id(),
+ values = { [cache_key] = nil }
+ })
+
+ for _, bss in ipairs(iw.scanlist or { }) do
+ data[_] = bss
+ bssids[bss.bssid] = bss
+ end
+
+ if update then
+ for _, bss in ipairs(_wifi_get_scan_results(cache_key)) do
+ if not bssids[bss.bssid] then
+ bss.stale = true
+ data[#data + 1] = bss
+ end
+ end
+ end
+
+ luci.util.ubus("session", "set", {
+ ubus_rpc_session = luci.model.uci:get_session_id(),
+ values = { [cache_key] = data }
+ })
+ end
end
-function wifi_assoclist()
- local s = require "luci.tools.status"
-
- luci.http.prepare_content("application/json")
- luci.http.write_json(s.wifi_assoclist())
+function wifi_scan_results(radio)
+ local results = radio and _wifi_get_scan_results("scan_%s" % radio)
+
+ if results and #results > 0 then
+ luci.http.prepare_content("application/json")
+ luci.http.write_json(results)
+ else
+ luci.http.status(404, "No wireless scan results")
+ end
end
function lease_status()
diff --git a/modules/luci-mod-admin-full/luasrc/controller/admin/status.lua b/modules/luci-mod-admin-full/luasrc/controller/admin/status.lua
index 4471fd597a..ff95f3d915 100644
--- a/modules/luci-mod-admin-full/luasrc/controller/admin/status.lua
+++ b/modules/luci-mod-admin-full/luasrc/controller/admin/status.lua
@@ -122,12 +122,12 @@ function action_connections()
luci.http.prepare_content("application/json")
- luci.http.write("{ connections: ")
+ luci.http.write('{ "connections": ')
luci.http.write_json(sys.net.conntrack())
local bwc = io.popen("luci-bwc -c 2>/dev/null")
if bwc then
- luci.http.write(", statistics: [")
+ luci.http.write(', "statistics": [')
while true do
local ln = bwc:read("*l")
diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/dhcp.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/dhcp.lua
index 855ed31f10..ae8a95f9ce 100644
--- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/dhcp.lua
+++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/dhcp.lua
@@ -122,6 +122,9 @@ s:taboption("advanced", Flag, "strictorder",
translate("<abbr title=\"Domain Name System\">DNS</abbr> servers will be queried in the " ..
"order of the resolvfile")).optional = true
+s:taboption("advanced", Flag, "allservers",
+ translate("All Servers"),
+ translate("Query all available upstream <abbr title=\"Domain Name System\">DNS</abbr> servers")).optional = true
bn = s:taboption("advanced", DynamicList, "bogusnxdomain", translate("Bogus NX Domain Override"),
translate("List of hosts that supply bogus NX domain results"))
diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/iface_add.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/iface_add.lua
index e48e3b4bdf..ca66e9f365 100644
--- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/iface_add.lua
+++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/iface_add.lua
@@ -10,6 +10,10 @@ m = SimpleForm("network", translate("Create Interface"))
m.redirect = luci.dispatcher.build_url("admin/network/network")
m.reset = false
+function m.on_cancel()
+ luci.http.redirect(luci.dispatcher.build_url("admin/network/network"))
+end
+
newnet = m:field(Value, "_netname", translate("Name of the new interface"),
translate("The allowed characters are: <code>A-Z</code>, <code>a-z</code>, " ..
"<code>0-9</code> and <code>_</code>"
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/network.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/network.lua
index 2bfe974af1..799386d29c 100644
--- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/network.lua
+++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/network.lua
@@ -3,11 +3,146 @@
-- Licensed to the public under the Apache License 2.0.
local fs = require "nixio.fs"
+local tpl = require "luci.template"
+local ntm = require "luci.model.network".init()
+local fwm = require "luci.model.firewall".init()
local json = require "luci.jsonc"
m = Map("network", translate("Interfaces"))
+m:chain("wireless")
+m:chain("firewall")
+m:chain("dhcp")
m.pageaction = false
-m:section(SimpleSection).template = "admin_network/iface_overview"
+
+
+local tpl_networks = tpl.Template(nil, [[
+ <div class="cbi-section-node">
+ <div class="table">
+ <%
+ for i, net in ipairs(netlist) do
+ local z = net[3]
+ local c = z and z:get_color() or "#EEEEEE"
+ local t = z and translate("Part of zone %q" % z:name()) or translate("No zone assigned")
+ local disabled = (net[4]:get("auto") == "0")
+ local dynamic = net[4]:is_dynamic()
+ %>
+ <div class="tr cbi-rowstyle-<%=i % 2 + 1%>">
+ <div class="td col-3 center middle">
+ <div class="ifacebox">
+ <div class="ifacebox-head" style="background-color:<%=c%>" title="<%=pcdata(t)%>">
+ <strong><%=net[1]:upper()%></strong>
+ </div>
+ <div class="ifacebox-body" id="<%=net[1]%>-ifc-devices" data-network="<%=net[1]%>">
+ <img src="<%=resource%>/icons/ethernet_disabled.png" style="width:16px; height:16px" /><br />
+ <small>?</small>
+ </div>
+ </div>
+ </div>
+ <div class="td col-5 left middle" id="<%=net[1]%>-ifc-description">
+ <em><%:Collecting data...%></em>
+ </div>
+ <div class="td cbi-section-actions">
+ <div>
+ <input type="button" class="cbi-button cbi-button-neutral" onclick="iface_reconnect('<%=net[1]%>')" title="<%:Reconnect this interface%>" value="<%:Restart%>"<%=ifattr(disabled or dynamic, "disabled", "disabled")%> />
+
+ <% if disabled then %>
+ <input type="hidden" name="cbid.network.<%=net[1]%>.__disable__" value="1" />
+ <input type="submit" name="cbi.apply" class="cbi-button cbi-button-neutral" onclick="this.previousElementSibling.value='0'" title="<%:Reconnect this interface%>" value="<%:Connect%>"<%=ifattr(dynamic, "disabled", "disabled")%> />
+ <% else %>
+ <input type="hidden" name="cbid.network.<%=net[1]%>.__disable__" value="0" />
+ <input type="submit" name="cbi.apply" class="cbi-button cbi-button-neutral" onclick="this.previousElementSibling.value='1'" title="<%:Shutdown this interface%>" value="<%:Stop%>"<%=ifattr(dynamic, "disabled", "disabled")%> />
+ <% end %>
+
+ <input type="button" class="cbi-button cbi-button-action important" onclick="location.href='<%=url("admin/network/network", net[1])%>'" title="<%:Edit this interface%>" value="<%:Edit%>" id="<%=net[1]%>-ifc-edit"<%=ifattr(dynamic, "disabled", "disabled")%> />
+
+ <input type="hidden" name="cbid.network.<%=net[1]%>.__delete__" value="" />
+ <input type="submit" name="cbi.apply" class="cbi-button cbi-button-negative" onclick="iface_delete(event)" value="<%:Delete%>"<%=ifattr(dynamic, "disabled", "disabled")%> />
+ </div>
+ </div>
+ </div>
+ <% end %>
+ </div>
+ </div>
+ <div class="cbi-section-create">
+ <input type="button" class="cbi-button cbi-button-add" value="<%:Add new interface...%>" onclick="location.href='<%=url("admin/network/iface_add")%>'" />
+ </div>
+]])
+
+local _, net
+local ifaces, netlist = { }, { }
+
+for _, net in ipairs(ntm:get_networks()) do
+ if net:name() ~= "loopback" then
+ local zn = net:zonename()
+ local z = zn and fwm:get_zone(zn) or fwm:get_zone_by_network(net:name())
+
+ local w = 1
+ if net:is_alias() then
+ w = 2
+ elseif net:is_dynamic() then
+ w = 3
+ end
+
+ ifaces[#ifaces+1] = net:name()
+ netlist[#netlist+1] = {
+ net:name(), z and z:name() or "-", z, net, w
+ }
+ end
+end
+
+table.sort(netlist,
+ function(a, b)
+ if a[2] ~= b[2] then
+ return a[2] < b[2]
+ elseif a[5] ~= b[5] then
+ return a[5] < b[5]
+ else
+ return a[1] < b[1]
+ end
+ end)
+
+s = m:section(TypedSection, "interface", translate("Interface Overview"))
+
+function s.sections(self)
+ local _, net, sl = nil, nil, { }
+
+ for _, net in ipairs(netlist) do
+ sl[#sl+1] = net[1]
+ end
+
+ return sl
+end
+
+function s.render(self)
+ tpl_networks:render({
+ netlist = netlist
+ })
+end
+
+o = s:option(Value, "__disable__")
+
+function o.cfgvalue(self, sid)
+ return (m:get(sid, "auto") == "0") and "1" or "0"
+end
+
+function o.write(self, sid, value)
+ if value ~= "1" then
+ m:set(sid, "auto", "")
+ else
+ m:set(sid, "auto", "0")
+ end
+end
+
+o.remove = o.write
+
+o = s:option(Value, "__delete__")
+
+function o.write(self, sid, value)
+ ntm:del_network(sid)
+end
+
+
+m:section(SimpleSection).template = "admin_network/iface_overview_status"
if fs.access("/etc/init.d/dsl_control") then
local ok, boarddata = pcall(json.parse, fs.readfile("/etc/board.json"))
diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi.lua
index d51a72aba1..743efaa1e8 100644
--- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi.lua
+++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi.lua
@@ -16,7 +16,7 @@ local acct_port, acct_secret, acct_server, anonymous_identity, ant1, ant2,
mp, nasid, network, password, pmk_r1_push, privkey, privkey2, privkeypwd,
privkeypwd2, r0_key_lifetime, r0kh, r1_key_holder, r1kh,
reassociation_deadline, retry_timeout, ssid, st, tp, wepkey, wepslot,
- wmm, wpakey, wps
+ wmm, wpakey, wps, disassoc_low_ack, short_preamble, beacon_int, dtim_period
arg[1] = arg[1] or ""
@@ -250,6 +250,14 @@ if hwtype == "mac80211" then
s:taboption("advanced", Value, "frag", translate("Fragmentation Threshold"))
s:taboption("advanced", Value, "rts", translate("RTS/CTS Threshold"))
+
+ s:taboption("advanced", Flag, "noscan", translate("Force 40MHz mode"),
+ translate("Always use 40MHz channels even if the secondary channel overlaps. Using this option does not comply with IEEE 802.11n-2009!")).optional = true
+
+ beacon_int = s:taboption("advanced", Value, "beacon_int", translate("Beacon Interval"))
+ beacon_int.optional = true
+ beacon_int.placeholder = 100
+ beacon_int.datatype = "range(15,65535)"
end
@@ -491,6 +499,18 @@ if hwtype == "mac80211" then
ifname = s:taboption("advanced", Value, "ifname", translate("Interface name"), translate("Override default interface name"))
ifname.optional = true
+
+ short_preamble = s:taboption("advanced", Flag, "short_preamble", translate("Short Preamble"))
+ short_preamble.default = short_preamble.enabled
+
+ dtim_period = s:taboption("advanced", Value, "dtim_period", translate("DTIM Interval"), translate("Delivery Traffic Indication Message Interval"))
+ dtim_period.optional = true
+ dtim_period.placeholder = 2
+ dtim_period.datatype = "range(1,255)"
+
+ disassoc_low_ack = s:taboption("advanced", Flag, "disassoc_low_ack", translate("Disassociate On Low Acknowledgement"),
+ translate("Allow AP mode to disconnect STAs based on low ACK condition"))
+ disassoc_low_ack.default = disassoc_low_ack.enabled
end
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
new file mode 100644
index 0000000000..ad20f09187
--- /dev/null
+++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi_overview.lua
@@ -0,0 +1,223 @@
+-- Copyright 2018 Jo-Philipp Wich <jo@mein.io>
+-- Licensed to the public under the Apache License 2.0.
+
+local fs = require "nixio.fs"
+local utl = require "luci.util"
+local tpl = require "luci.template"
+local ntm = require "luci.model.network"
+
+local has_iwinfo = pcall(require, "iwinfo")
+
+function guess_wifi_hw(dev)
+ local bands = ""
+ local ifname = dev:name()
+ local name, idx = ifname:match("^([a-z]+)(%d+)")
+ idx = tonumber(idx)
+
+ if has_iwinfo then
+ local bl = dev.iwinfo.hwmodelist
+ if bl and next(bl) then
+ if bl.a then bands = bands .. "a" end
+ if bl.b then bands = bands .. "b" end
+ if bl.g then bands = bands .. "g" end
+ if bl.n then bands = bands .. "n" end
+ if bl.ac then bands = bands .. "ac" end
+ end
+
+ local hw = dev.iwinfo.hardware_name
+ if hw then
+ return "%s 802.11%s" %{ hw, bands }
+ end
+ end
+
+ -- wl.o
+ if name == "wl" then
+ local name = translatef("Broadcom 802.11%s Wireless Controller", bands)
+ local nm = 0
+
+ local fd = nixio.open("/proc/bus/pci/devices", "r")
+ if fd then
+ local ln
+ for ln in fd:linesource() do
+ if ln:match("wl$") then
+ if nm == idx then
+ local version = ln:match("^%S+%s+%S%S%S%S([0-9a-f]+)")
+ name = translatef(
+ "Broadcom BCM%04x 802.11 Wireless Controller",
+ tonumber(version, 16)
+ )
+
+ break
+ else
+ nm = nm + 1
+ end
+ end
+ end
+ fd:close()
+ end
+
+ return name
+
+ -- dunno yet
+ else
+ return translatef("Generic 802.11%s Wireless Controller", bands)
+ end
+end
+
+local tpl_radio = tpl.Template(nil, [[
+ <div class="cbi-section-node">
+ <div class="table">
+ <!-- physical device -->
+ <div class="tr cbi-rowstyle-2">
+ <div class="td col-2 center middle">
+ <span class="ifacebadge"><img src="<%=resource%>/icons/wifi_disabled.png" id="<%=dev:name()%>-iw-upstate" /> <%=dev:name()%></span>
+ </div>
+ <div class="td col-7 left middle">
+ <big><strong><%=hw%></strong></big><br />
+ <span id="<%=dev:name()%>-iw-devinfo"></span>
+ </div>
+ <div class="td middle cbi-section-actions">
+ <div>
+ <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="button" class="cbi-button cbi-button-action important" title="<%:Find and join network%>" value="<%:Scan%>" onclick="cbi_submit(this, 'device', '<%=dev:name()%>', '<%=url('admin/network/wireless_join')%>')" />
+ <input type="button" class="cbi-button cbi-button-add" title="<%:Provide new network%>" value="<%:Add%>" onclick="cbi_submit(this, 'device', '<%=dev:name()%>', '<%=url('admin/network/wireless_add')%>')" />
+ </div>
+ </div>
+ </div>
+ <!-- /physical device -->
+
+ <!-- network list -->
+ <% if #wnets > 0 then %>
+ <% for i, net in ipairs(wnets) do local disabled = (dev:get("disabled") == "1" or net:get("disabled") == "1") %>
+ <div class="tr cbi-rowstyle-<%=1 + ((i-1) % 2)%>">
+ <div class="td col-2 center middle" id="<%=net:id()%>-iw-signal">
+ <span class="ifacebadge" title="<%:Not associated%>"><img src="<%=resource%>/icons/signal-<%= disabled and "none" or "0" %>.png" /> 0%</span>
+ </div>
+ <div class="td col-7 left middle" id="<%=net:id()%>-iw-status" data-network="<%=net:id()%>" data-disabled="<%= disabled and "true" or "false" %>">
+ <em><%= disabled and translate("Wireless is disabled") or translate("Collecting data...") %></em>
+ </div>
+ <div class="td middle cbi-section-actions">
+ <div>
+ <% if disabled then %>
+ <input name="cbid.wireless.<%=net:name()%>.__disable__" type="hidden" value="1" />
+ <input name="cbi.apply" type="submit" class="cbi-button cbi-button-neutral" title="<%:Enable this network%>" value="<%:Enable%>" onclick="this.previousElementSibling.value='0'" />
+ <% else %>
+ <input name="cbid.wireless.<%=net:name()%>.__disable__" type="hidden" value="0" />
+ <input name="cbi.apply" type="submit" class="cbi-button cbi-button-neutral" title="<%:Disable this network%>" value="<%:Disable%>" onclick="this.previousElementSibling.value='1'" />
+ <% end %>
+
+ <input type="button" class="cbi-button cbi-button-action important" onclick="location.href='<%=net:adminlink()%>'" title="<%:Edit this network%>" value="<%:Edit%>" />
+
+ <input name="cbid.wireless.<%=net:name()%>.__delete__" type="hidden" value="" />
+ <input name="cbi.apply" type="submit" class="cbi-button cbi-button-negative" title="<%:Delete this network%>" value="<%:Remove%>" onclick="wifi_delete(event)" />
+ </div>
+ </div>
+ </div>
+ <% end %>
+ <% else %>
+ <div class="tr placeholder">
+ <div class="td">
+ <em><%:No network configured on this device%></em>
+ </div>
+ </div>
+ <% end %>
+ <!-- /network list -->
+ </div>
+ </div>
+]])
+
+
+m = Map("wireless", translate("Wireless Overview"))
+m:chain("network")
+m.pageaction = false
+
+if not has_iwinfo then
+ s = m:section(NamedSection, "__warning__")
+
+ function s.render(self)
+ tpl.render_string([[
+ <div class="alert-message warning">
+ <h4><%:Package libiwinfo required!%></h4>
+ <p><%_The <em>libiwinfo-lua</em> package is not installed. You must install this component for working wireless configuration!%></p>
+ </div>
+ ]])
+ end
+end
+
+local _, dev, net
+for _, dev in ipairs(ntm:get_wifidevs()) do
+ s = m:section(TypedSection)
+ s.wnets = dev:get_wifinets()
+
+ function s.render(self, sid)
+ tpl_radio:render({
+ hw = guess_wifi_hw(dev),
+ dev = dev,
+ wnets = self.wnets
+ })
+ end
+
+ function s.cfgsections(self)
+ local _, net, sl = nil, nil, { }
+ for _, net in ipairs(self.wnets) do
+ sl[#sl+1] = net:name()
+ self.wnets[net:name()] = net
+ end
+ return sl
+ end
+
+ o = s:option(Value, "__disable__")
+
+ function o.cfgvalue(self, sid)
+ local wnet = self.section.wnets[sid]
+ local wdev = wnet:get_device()
+
+ return ((wnet and wnet:get("disabled") == "1") or
+ (wdev and wdev:get("disabled") == "1")) and "1" or "0"
+ end
+
+ function o.write(self, sid, value)
+ local wnet = self.section.wnets[sid]
+ local wdev = wnet:get_device()
+
+ if value ~= "1" then
+ wnet:set("disabled", nil)
+ wdev:set("disabled", nil)
+ else
+ wnet:set("disabled", "1")
+ end
+ end
+
+ o.remove = o.write
+
+
+ o = s:option(Value, "__delete__")
+
+ function o.write(self, sid, value)
+ local wnet = self.section.wnets[sid]
+ local nets = wnet:get_networks()
+
+ ntm:del_wifinet(wnet:id())
+
+ local _, net
+ for _, net in ipairs(nets) do
+ if net:is_empty() then
+ ntm:del_network(net:name())
+ end
+ end
+ end
+end
+
+s = m:section(NamedSection, "__script__")
+s.template = "admin_network/wifi_overview_status"
+
+s = m:section(NamedSection, "__assoclist__")
+
+function s.render(self, sid)
+ tpl.render_string([[
+ <h2><%:Associated Stations%></h2>
+ <%+admin_network/wifi_assoclist%>
+ ]])
+end
+
+return m
diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_network/diagnostics.htm b/modules/luci-mod-admin-full/luasrc/view/admin_network/diagnostics.htm
index d9217894fd..b409c8b039 100644
--- a/modules/luci-mod-admin-full/luasrc/view/admin_network/diagnostics.htm
+++ b/modules/luci-mod-admin-full/luasrc/view/admin_network/diagnostics.htm
@@ -8,7 +8,7 @@
<%
local fs = require "nixio.fs"
local has_ping6 = fs.access("/bin/ping6") or fs.access("/usr/bin/ping6")
-local has_traceroute6 = fs.access("/usr/bin/traceroute6")
+local has_traceroute6 = fs.access("/bin/traceroute6") or fs.access("/usr/bin/traceroute6")
local dns_host = luci.config.diag and luci.config.diag.dns or "dev.openwrt.org"
local ping_host = luci.config.diag and luci.config.diag.ping or "dev.openwrt.org"
diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_network/iface_overview.htm b/modules/luci-mod-admin-full/luasrc/view/admin_network/iface_overview.htm
deleted file mode 100644
index 00ef8944c6..0000000000
--- a/modules/luci-mod-admin-full/luasrc/view/admin_network/iface_overview.htm
+++ /dev/null
@@ -1,250 +0,0 @@
-<%#
- Copyright 2010 Jo-Philipp Wich <jow@openwrt.org>
- Licensed to the public under the Apache License 2.0.
--%>
-
-<%-
- local ntm = require "luci.model.network".init()
- local fwm = require "luci.model.firewall".init()
-
- local net
- local ifaces = { }
- local netlist = { }
- for _, net in ipairs(ntm:get_networks()) do
- if net:name() ~= "loopback" then
- local z = fwm:get_zone_by_network(net:name())
- ifaces[#ifaces+1] = net:name()
- netlist[#netlist+1] = {
- net:name(), z and z:name() or "-", z
- }
- end
- end
-
- table.sort(netlist,
- function(a, b)
- if a[2] ~= b[2] then
- return a[2] < b[2]
- else
- return a[1] < b[1]
- end
- end)
--%>
-
-<script type="text/javascript">//<![CDATA[
- function iface_shutdown(id, reconnect) {
- if (!reconnect && !confirm(<%=luci.http.write_json(translate('Really shutdown interface "%s"? You might lose access to this device if you are connected via this interface.'))%>.format(id)))
- return;
-
- var d = document.getElementById(id + '-ifc-description');
- if (d)
- d.innerHTML = reconnect
- ? '<em><%:Interface is reconnecting...%></em>'
- : '<em><%:Interface is shutting down...%></em>';
-
- var s = document.getElementById('ifc-rc-status');
- if (s)
- {
- s.parentNode.style.display = 'block';
- s.innerHTML = '<%:Waiting for changes to be applied...%>';
- }
-
- (new XHR()).post('<%=url('admin/network')%>/iface_' + (reconnect ? 'reconnect' : 'shutdown') + '/' + id, { token: '<%=token%>' },
- function(x)
- {
- if (s)
- {
- s.innerHTML = reconnect
- ? '<%:Interface reconnected%>'
- : '<%:Interface shut down%>';
-
- window.setTimeout(function() {
- s.parentNode.style.display = 'none';
- }, 1000);
- }
- }
- );
- }
-
- function iface_delete(id) {
- if (!confirm(<%=luci.http.write_json(translate('Really delete this interface? The deletion cannot be undone! You might lose access to this device if you are connected via this interface'))%>))
- return;
-
- (new XHR()).post('<%=url('admin/network/iface_delete')%>/' + id, { token: '<%=token%>' },
- function(x) {
- location.href = '<%=url('admin/network/network')%>';
- }
- );
- }
-
- var iwxhr = new XHR();
- var wifidevs = <%=luci.http.write_json(netdevs)%>;
- var arptable = <%=luci.http.write_json(arpcache)%>;
-
- XHR.poll(5, '<%=url('admin/network/iface_status', table.concat(ifaces, ","))%>', null,
- function(x, ifcs)
- {
- if (ifcs)
- {
- for (var idx = 0; idx < ifcs.length; idx++)
- {
- var ifc = ifcs[idx];
- var html = '';
-
- 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.type,
- ifc.is_up ? '' : '_disabled'
- );
-
- if (ifc.subdevices && ifc.subdevices.length)
- {
- stat += ' <strong>(';
-
- 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
- );
- }
-
- stat += ')</strong>';
- }
-
- stat += String.format(
- '<br /><small>%h</small>',
- ifc.name
- );
-
- s.innerHTML = stat;
- }
-
- var d = document.getElementById(ifc.id + '-ifc-description');
- if (d && ifc.proto && ifc.ifname)
- {
- if (ifc.is_up)
- {
- html += String.format('<strong><%:Uptime%>:</strong> %t<br />', ifc.uptime);
- }
-
- if (ifc.macaddr)
- {
- html += String.format('<strong><%:MAC-Address%>:</strong> %s<br />', ifc.macaddr);
- }
-
- html += String.format(
- '<strong><%:RX%>:</strong> %.2mB (%d <%:Pkts.%>)<br />' +
- '<strong><%:TX%>:</strong> %.2mB (%d <%:Pkts.%>)<br />',
- ifc.rx_bytes, ifc.rx_packets,
- ifc.tx_bytes, ifc.tx_packets
- );
-
- if (ifc.ipaddrs && ifc.ipaddrs.length)
- {
- for (var i = 0; i < ifc.ipaddrs.length; i++)
- html += String.format(
- '<strong><%:IPv4%>:</strong> %s<br />',
- ifc.ipaddrs[i]
- );
- }
-
- if (ifc.ip6addrs && ifc.ip6addrs.length)
- {
- for (var i = 0; i < ifc.ip6addrs.length; i++)
- html += String.format(
- '<strong><%:IPv6%>:</strong> %s<br />',
- ifc.ip6addrs[i]
- );
- }
-
- if (ifc.ip6prefix)
- {
- html += String.format('<strong><%:IPv6-PD%>:</strong> %s<br />', ifc.ip6prefix);
- }
-
- d.innerHTML = html;
- }
- else if (d && !ifc.proto)
- {
- var e = document.getElementById(ifc.id + '-ifc-edit');
- if (e)
- e.disabled = true;
-
- d.innerHTML = String.format(
- '<em><%:Unsupported protocol type.%></em><br />' +
- '<a href="%h"><%:Install protocol extensions...%></a>',
- '<%=url("admin/system/packages")%>?query=luci-proto&display=available'
- );
- }
- else if (d && !ifc.ifname)
- {
- d.innerHTML = String.format(
- '<em><%:Network without interfaces.%></em><br />' +
- '<a href="<%=url("admin/network/network/%s")%>?tab.network.%s=physical"><%:Assign interfaces...%></a>',
- ifc.name, ifc.name
- );
- }
- else if (d)
- {
- d.innerHTML = '<em><%:Interface not present or not connected yet.%></em>';
- }
- }
- }
- }
- );
-//]]></script>
-
-<fieldset class="cbi-section" style="display:none">
- <legend><%:Reconnecting interface%></legend>
- <img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" />
- <span id="ifc-rc-status"><%:Waiting for changes to be applied...%></span>
-</fieldset>
-
-<div class="cbi-map">
- <div class="cbi-section">
- <legend><%:Interface Overview%></legend>
-
- <div class="cbi-section-node">
- <div class="table">
- <%
- for i, net in ipairs(netlist) do
- local z = net[3]
- local c = z and z:get_color() or "#EEEEEE"
- local t = z and translate("Part of zone %q" % z:name()) or translate("No zone assigned")
- %>
- <div class="tr cbi-rowstyle-<%=i % 2 + 1%>">
- <div class="td col-3 center middle">
- <div class="ifacebox">
- <div class="ifacebox-head" style="background-color:<%=c%>" title="<%=pcdata(t)%>">
- <strong><%=net[1]:upper()%></strong>
- </div>
- <div class="ifacebox-body" id="<%=net[1]%>-ifc-devices">
- <img src="<%=resource%>/icons/ethernet_disabled.png" style="width:16px; height:16px" /><br />
- <small>?</small>
- </div>
- </div>
- </div>
- <div class="td col-5 left" id="<%=net[1]%>-ifc-description">
- <em><%:Collecting data...%></em>
- </div>
- <div class="td cbi-section-actions">
- <input type="button" class="cbi-button cbi-button-neutral" onclick="iface_shutdown('<%=net[1]%>', true)" title="<%:Reconnect this interface%>" value="<%:Connect%>" />
- <input type="button" class="cbi-button cbi-button-neutral" onclick="iface_shutdown('<%=net[1]%>', false)" title="<%:Shutdown this interface%>" value="<%:Stop%>" />
- <input type="button" class="cbi-button cbi-button-action important" onclick="location.href='<%=url("admin/network/network", net[1])%>'" title="<%:Edit this interface%>" value="<%:Edit%>" id="<%=net[1]%>-ifc-edit" />
- <input type="button" class="cbi-button cbi-button-negative" onclick="iface_delete('<%=net[1]%>')" value="<%:Delete%>" />
- </div>
- </div>
- <% end %>
- </div>
- </div>
-
- <input type="button" class="cbi-button cbi-button-add" value="<%:Add new interface...%>" onclick="location.href='<%=url("admin/network/iface_add")%>'" />
- </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
new file mode 100644
index 0000000000..7427154a04
--- /dev/null
+++ b/modules/luci-mod-admin-full/luasrc/view/admin_network/iface_overview_status.htm
@@ -0,0 +1,183 @@
+<%#
+ Copyright 2010-2018 Jo-Philipp Wich <jo@mein.io>
+ Licensed to the public under the Apache License 2.0.
+-%>
+
+<script type="text/javascript">//<![CDATA[
+ function iface_reconnect(id) {
+ XHR.halt();
+
+ var d = document.getElementById(id + '-ifc-description');
+ if (d) d.innerHTML = '<em><%:Interface is reconnecting...%></em>';
+
+ (new XHR()).post('<%=url('admin/network/iface_reconnect')%>/' + id,
+ { token: '<%=token%>' }, XHR.run);
+ }
+
+ function iface_delete(ev) {
+ if (!confirm(<%=luci.http.write_json(translate('Really delete this interface? The deletion cannot be undone! You might lose access to this device if you are connected via this interface'))%>)) {
+ ev.preventDefault();
+ return false;
+ }
+
+ ev.target.previousElementSibling.value = '1';
+ return true;
+ }
+
+ var networks = [];
+
+ document.querySelectorAll('[data-network]').forEach(function(n) {
+ 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)
+ {
+ for (var idx = 0; idx < ifcs.length; idx++)
+ {
+ var ifc = ifcs[idx];
+ var html = '';
+
+ var s = document.getElementById(ifc.id + '-ifc-devices');
+ if (s)
+ {
+ while (s.firstChild)
+ s.removeChild(s.firstChild);
+
+ s.appendChild(render_iface(ifc));
+
+ if (ifc.subdevices && ifc.subdevices.length)
+ {
+ var sifs = [ ' (' ];
+
+ for (var j = 0; j < ifc.subdevices.length; j++)
+ sifs.push(render_iface(ifc.subdevices[j]));
+
+ sifs.push(')');
+
+ s.appendChild(E('span', {}, sifs));
+ }
+
+ 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');
+ if (d && ifc.proto && ifc.ifname)
+ {
+ var desc = null;
+
+ if (ifc.is_dynamic)
+ desc = '<%:Virtual dynamic interface%>';
+ else if (ifc.is_alias)
+ desc = '<%:Alias Interface%>';
+
+ if (ifc.desc)
+ desc = desc ? '%s (%s)'.format(desc, ifc.desc) : ifc.desc;
+
+ html += String.format('<strong><%:Protocol%>:</strong> %h<br />', desc || '?');
+
+ if (ifc.is_up)
+ {
+ html += String.format('<strong><%:Uptime%>:</strong> %t<br />', ifc.uptime);
+ }
+
+
+ if (!ifc.is_dynamic && !ifc.is_alias)
+ {
+ if (ifc.macaddr)
+ html += String.format('<strong><%:MAC%>:</strong> %s<br />', ifc.macaddr);
+
+ html += String.format(
+ '<strong><%:RX%>:</strong> %.2mB (%d <%:Pkts.%>)<br />' +
+ '<strong><%:TX%>:</strong> %.2mB (%d <%:Pkts.%>)<br />',
+ ifc.rx_bytes, ifc.rx_packets,
+ ifc.tx_bytes, ifc.tx_packets
+ );
+ }
+
+ if (ifc.ipaddrs && ifc.ipaddrs.length)
+ {
+ for (var i = 0; i < ifc.ipaddrs.length; i++)
+ html += String.format(
+ '<strong><%:IPv4%>:</strong> %s<br />',
+ ifc.ipaddrs[i]
+ );
+ }
+
+ if (ifc.ip6addrs && ifc.ip6addrs.length)
+ {
+ for (var i = 0; i < ifc.ip6addrs.length; i++)
+ html += String.format(
+ '<strong><%:IPv6%>:</strong> %s<br />',
+ ifc.ip6addrs[i]
+ );
+ }
+
+ if (ifc.ip6prefix)
+ html += String.format('<strong><%:IPv6-PD%>:</strong> %s<br />', ifc.ip6prefix);
+
+ if (ifc.errors)
+ {
+ for (var i = 0; i < ifc.errors.length; i++)
+ html += String.format(
+ '<em class="error"><strong><%:Error%>:</strong> %h</em><br />',
+ ifc.errors[i]
+ );
+ }
+
+ d.innerHTML = html;
+ }
+ else if (d && !ifc.proto)
+ {
+ var e = document.getElementById(ifc.id + '-ifc-edit');
+ if (e)
+ e.disabled = true;
+
+ d.innerHTML = String.format(
+ '<em><%:Unsupported protocol type.%></em><br />' +
+ '<a href="%h"><%:Install protocol extensions...%></a>',
+ '<%=url("admin/system/packages")%>?query=luci-proto&display=available'
+ );
+ }
+ else if (d && !ifc.ifname)
+ {
+ d.innerHTML = String.format(
+ '<em><%:Network without interfaces.%></em><br />' +
+ '<a href="<%=url("admin/network/network/%s")%>?tab.network.%s=physical"><%:Assign interfaces...%></a>',
+ ifc.name, ifc.name
+ );
+ }
+ else if (d)
+ {
+ d.innerHTML = '<em><%:Interface not present or not connected yet.%></em>';
+ }
+ }
+ }
+ }
+ );
+//]]></script>
diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_network/iface_status.htm b/modules/luci-mod-admin-full/luasrc/view/admin_network/iface_status.htm
index 9c5173dae2..34be35dd20 100644
--- a/modules/luci-mod-admin-full/luasrc/view/admin_network/iface_status.htm
+++ b/modules/luci-mod-admin-full/luasrc/view/admin_network/iface_status.htm
@@ -17,7 +17,7 @@
html += String.format('<strong><%:Uptime%>:</strong> %t<br />', ifc.uptime);
if (ifc.macaddr)
- html += String.format('<strong><%:MAC-Address%>:</strong> %s<br />', ifc.macaddr);
+ html += String.format('<strong><%:MAC%>:</strong> %s<br />', ifc.macaddr);
html += String.format(
'<strong><%:RX%></strong>: %.2mB (%d <%:Pkts.%>)<br />' +
diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_join.htm b/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_join.htm
index 9b93942c88..987123642f 100644
--- a/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_join.htm
+++ b/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_join.htm
@@ -8,56 +8,6 @@
local sys = require "luci.sys"
local utl = require "luci.util"
- function guess_wifi_signal(info)
- local scale = (100 / (info.quality_max or 100) * (info.quality or 0))
- local icon
-
- if not info.bssid or info.bssid == "00:00:00:00:00:00" then
- icon = resource .. "/icons/signal-none.png"
- elseif scale < 15 then
- icon = resource .. "/icons/signal-0.png"
- elseif scale < 35 then
- icon = resource .. "/icons/signal-0-25.png"
- elseif scale < 55 then
- icon = resource .. "/icons/signal-25-50.png"
- elseif scale < 75 then
- icon = resource .. "/icons/signal-50-75.png"
- else
- icon = resource .. "/icons/signal-75-100.png"
- end
-
- return icon
- end
-
- function percent_wifi_signal(info)
- local qc = info.quality or 0
- local qm = info.quality_max or 0
-
- if info.bssid and qc > 0 and qm > 0 then
- return math.floor((100 / qm) * qc)
- else
- return 0
- end
- end
-
- function format_wifi_encryption(info)
- if info.wep == true then
- return "WEP"
- elseif info.wpa > 0 then
- return translatef("<abbr title='Pairwise: %s / Group: %s'>%s - %s</abbr>",
- table.concat(info.pair_ciphers, ", "),
- table.concat(info.group_ciphers, ", "),
- (info.wpa == 3) and translate("mixed WPA/WPA2")
- or (info.wpa == 2 and "WPA2" or "WPA"),
- table.concat(info.auth_suites, ", ")
- )
- elseif info.enabled then
- return "<em>%s</em>" % translate("unknown")
- else
- return "<em>%s</em>" % translate("open")
- end
- end
-
local dev = luci.http.formvalue("device")
local iw = luci.sys.wifi.getiwinfo(dev)
@@ -65,91 +15,198 @@
luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless"))
return
end
-
-
- function scanlist(times)
- local i, k, v
- local l = { }
- local s = { }
-
- for i = 1, times do
- for k, v in ipairs(iw.scanlist or { }) do
- if not s[v.bssid] then
- l[#l+1] = v
- s[v.bssid] = true
- end
- end
- end
-
- return l
- end
-%>
<%+header%>
+<script type="text/javascript">//<![CDATA[
+ var xhr = new XHR(),
+ poll = null;
+
+ function format_signal(bss) {
+ var qval = bss.quality || 0,
+ qmax = bss.quality_max || 100,
+ scale = 100 / qmax * qval,
+ range = 'none';
+
+ if (!bss.bssid || bss.bssid == '00:00:00:00:00:00')
+ range = 'none';
+ else if (scale < 15)
+ range = '0';
+ else if (scale < 35)
+ range = '0-25';
+ else if (scale < 55)
+ range = '25-50';
+ else if (scale < 75)
+ range = '50-75';
+ else
+ range = '75-100';
+
+ return E('span', {
+ class: 'ifacebadge',
+ title: '<%:Signal%>: %d<%:dB%> / <%:Quality%>: %d/%d'.format(bss.signal, qval, qmax)
+ }, [
+ E('img', { src: '<%=resource%>/icons/signal-%s.png'.format(range) }),
+ ' %d%%'.format(scale)
+ ]);
+ }
+
+ function format_encryption(bss) {
+ var enc = bss.encryption || { }
+
+ if (enc.wep === true)
+ return 'WEP';
+ else if (enc.wpa > 0)
+ return E('abbr', {
+ title: 'Pairwise: %h / Group: %h'.format(
+ enc.pair_ciphers.join(', '),
+ enc.group_ciphers.join(', '))
+ },
+ '%h - %h'.format(
+ (enc.wpa === 3) ? '<%:mixed WPA/WPA2%>' : (enc.wpa === 2 ? 'WPA2' : 'WPA'),
+ enc.auth_suites.join(', ')));
+ else if (enc.enabled)
+ return '<em><%:unknown%></em>';
+ else
+ return '<em><%:open%></em>';
+ }
+
+ function format_actions(bss) {
+ var enc = bss.encryption || { },
+ input = [
+ E('input', { type: 'submit', class: 'cbi-button cbi-button-action important', value: '<%:Join Network%>' }),
+ E('input', { type: 'hidden', name: 'token', value: '<%=token%>' }),
+ E('input', { type: 'hidden', name: 'device', value: '<%=dev%>' }),
+ E('input', { type: 'hidden', name: 'join', value: bss.ssid }),
+ E('input', { type: 'hidden', name: 'mode', value: bss.mode }),
+ E('input', { type: 'hidden', name: 'bssid', value: bss.bssid }),
+ E('input', { type: 'hidden', name: 'channel', value: bss.channel }),
+ E('input', { type: 'hidden', name: 'clbridge', value: <%=iw.type == "wl" and 1 or 0%> }),
+ E('input', { type: 'hidden', name: 'wep', value: enc.wep ? 1 : 0 })
+ ];
+
+ if (enc.wpa) {
+ input.push(E('input', { type: 'hidden', name: 'wpa_version', value: enc.wpa }));
+
+ enc.auth_suites.forEach(function(s) {
+ input.push(E('input', { type: 'hidden', name: 'wpa_suites', value: s }));
+ });
+
+ enc.group_ciphers.forEach(function(s) {
+ input.push(E('input', { type: 'hidden', name: 'wpa_group', value: s }));
+ });
+
+ enc.pair_ciphers.forEach(function(s) {
+ input.push(E('input', { type: 'hidden', name: 'wpa_pairwise', value: s }));
+ });
+ }
+
+ return E('form', {
+ class: 'inline',
+ method: 'post',
+ action: '<%=url("admin/network/wireless_join")%>'
+ }, input);
+ }
+
+ function fade(bss, content) {
+ if (bss.stale)
+ return E('span', { style: 'opacity:0.5' }, content);
+ else
+ return content;
+ }
+
+ function flush() {
+ XHR.stop(poll);
+ XHR.halt();
+
+ scan();
+ }
+
+ function scan() {
+ var tbl = document.getElementById('scan_results');
+
+ cbi_update_table(tbl, [], '<em><img src="<%=resource%>/icons/loading.gif" class="middle" /> <%:Starting wireless scan...%></em>');
+
+ xhr.post('<%=url("admin/network/wireless_scan_trigger", dev)%>', { token: '<%=token%>' },
+ function(s) {
+ if (s.status !== 200) {
+ cbi_update_table(tbl, [], '<em><%:Scan request failed%></em>');
+ return;
+ }
+
+ var count = 0;
+
+ poll = XHR.poll(3, '<%=url("admin/network/wireless_scan_results", dev)%>', null,
+ function(s, results) {
+ if (Array.isArray(results)) {
+ var bss = [];
+
+ results.sort(function(a, b) {
+ var diff = (b.quality - a.quality) || (a.channel - b.channel);
+
+ if (diff)
+ return diff;
+
+ if (a.ssid < b.ssid)
+ return -1;
+ else if (a.ssid > b.ssid)
+ return 1;
+
+ if (a.bssid < b.bssid)
+ return -1;
+ else if (a.bssid > b.bssid)
+ return 1;
+ }).forEach(function(res) {
+ bss.push([
+ fade(res, format_signal(res)),
+ fade(res, res.ssid ? '%h'.format(res.ssid) : E('em', {}, '<%:hidden%>')),
+ fade(res, res.channel),
+ fade(res, res.mode),
+ fade(res, res.bssid),
+ fade(res, format_encryption(res)),
+ format_actions(res)
+ ]);
+ });
+
+ cbi_update_table(tbl, bss, '<em><img src="<%=resource%>/icons/loading.gif" class="middle" /> <%:No scan results available yet...%>');
+ }
+
+ if (count++ >= 3) {
+ count = 0;
+ xhr.post('<%=url("admin/network/wireless_scan_trigger", dev, "1")%>',
+ { token: '<%=token%>' }, function() { });
+ }
+ });
+
+ XHR.run();
+ });
+ }
+
+ document.addEventListener('DOMContentLoaded', scan);
+
+//]]></script>
+
<h2 name="content"><%:Join Network: Wireless Scan%></h2>
<div class="cbi-map">
<div class="cbi-section">
- <div class="table">
+ <div class="table" id="scan_results">
<div class="tr table-titles">
- <div class="th col-1 center"><%:Signal%></div>
- <div class="th col-5 left"><%:SSID%></div>
- <div class="th col-2 center"><%:Channel%></div>
- <div class="th col-2 left"><%:Mode%></div>
- <div class="th col-3 left"><%:BSSID%></div>
- <div class="th col-2 left"><%:Encryption%></div>
+ <div class="th col-1 middle center"><%:Signal%></div>
+ <div class="th col-5 middle left"><%:SSID%></div>
+ <div class="th col-2 middle center"><%:Channel%></div>
+ <div class="th col-2 middle left"><%:Mode%></div>
+ <div class="th col-3 middle left"><%:BSSID%></div>
+ <div class="th col-2 middle left"><%:Encryption%></div>
<div class="th cbi-section-actions">&#160;</div>
</div>
- <!-- scan list -->
- <% for i, net in ipairs(scanlist(3)) do net.encryption = net.encryption or { } %>
- <div class="tr cbi-rowstyle-<%=1 + ((i-1) % 2)%>">
- <div class="td col-1 center">
- <abbr title="<%:Signal%>: <%=net.signal%> <%:dB%> / <%:Quality%>: <%=net.quality%>/<%=net.quality_max%>">
- <img src="<%=guess_wifi_signal(net)%>" /><br />
- <small><%=percent_wifi_signal(net)%>%</small>
- </abbr>
- </div>
- <div class="td col-5 left" data-title="<%:SSID%>">
- <strong><%=net.ssid and utl.pcdata(net.ssid) or "<em>%s</em>" % translate("hidden")%></strong>
- </div>
- <div class="td col-2 center" data-title="<%:Channel%>">
- <%=net.channel%>
- </div>
- <div class="td col-2 left" data-title="<%:Mode%>">
- <%=net.mode%>
- </div>
- <div class="td col-3 left" data-title="<%:BSSID%>">
- <%=net.bssid%>
- </div>
- <div class="td col-2 left" data-title="<%:Encryption%>">
- <%=format_wifi_encryption(net.encryption)%>
- </div>
- <div class="td cbi-section-actions">
- <form action="<%=url('admin/network/wireless_join')%>" method="post">
- <input type="hidden" name="token" value="<%=token%>" />
- <input type="hidden" name="device" value="<%=utl.pcdata(dev)%>" />
- <input type="hidden" name="join" value="<%=utl.pcdata(net.ssid)%>" />
- <input type="hidden" name="mode" value="<%=net.mode%>" />
- <input type="hidden" name="bssid" value="<%=net.bssid%>" />
- <input type="hidden" name="channel" value="<%=net.channel%>" />
- <input type="hidden" name="wep" value="<%=net.encryption.wep and 1 or 0%>" />
- <% if net.encryption.wpa then %>
- <input type="hidden" name="wpa_version" value="<%=net.encryption.wpa%>" />
- <% for _, v in ipairs(net.encryption.auth_suites) do %><input type="hidden" name="wpa_suites" value="<%=v%>" />
- <% end; for _, v in ipairs(net.encryption.group_ciphers) do %><input type="hidden" name="wpa_group" value="<%=v%>" />
- <% end; for _, v in ipairs(net.encryption.pair_ciphers) do %><input type="hidden" name="wpa_pairwise" value="<%=v%>" />
- <% end; end %>
-
- <input type="hidden" name="clbridge" value="<%=iw.type == "wl" and 1 or 0%>" />
-
- <input class="cbi-button cbi-button-action important" type="submit" value="<%:Join Network%>" />
- </form>
+ <div class="tr placeholder">
+ <div class="td">
+ <img src="<%=resource%>/icons/loading.gif" class="middle" />
+ <em><%:Collecting data...%></em>
</div>
</div>
- <% end %>
- <!-- /scan list -->
</div>
</div>
</div>
@@ -160,7 +217,7 @@
<form class="inline" action="<%=url('admin/network/wireless_join')%>" method="post">
<input type="hidden" name="token" value="<%=token%>" />
<input type="hidden" name="device" value="<%=utl.pcdata(dev)%>" />
- <input class="cbi-button cbi-button-action" type="submit" value="<%:Repeat scan%>" />
+ <input type="button" class="cbi-button cbi-button-action" value="<%:Repeat scan%>" onclick="flush()" />
</form>
</div>
diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview.htm b/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview.htm
deleted file mode 100644
index f3809ea941..0000000000
--- a/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview.htm
+++ /dev/null
@@ -1,353 +0,0 @@
-<%#
- Copyright 2008-2009 Steven Barth <steven@midlink.org>
- Copyright 2008-2015 Jo-Philipp Wich <jow@openwrt.org>
- Licensed to the public under the Apache License 2.0.
--%>
-
-<%-
-
- local ip = require "luci.ip"
- local fs = require "nixio.fs"
- local utl = require "luci.util"
- local uci = require "luci.model.uci".cursor()
- local ntm = require "luci.model.network"
-
- local has_iwinfo = pcall(require, "iwinfo")
-
- ntm.init(uci)
-
- function guess_wifi_hw(dev)
- local bands = ""
- local ifname = dev:name()
- local name, idx = ifname:match("^([a-z]+)(%d+)")
- idx = tonumber(idx)
-
- if has_iwinfo then
- local bl = dev.iwinfo.hwmodelist
- if bl and next(bl) then
- if bl.a then bands = bands .. "a" end
- if bl.b then bands = bands .. "b" end
- if bl.g then bands = bands .. "g" end
- if bl.n then bands = bands .. "n" end
- if bl.ac then bands = bands .. "ac" end
- end
-
- local hw = dev.iwinfo.hardware_name
- if hw then
- return "%s 802.11%s" %{ hw, bands }
- end
- end
-
- -- wl.o
- if name == "wl" then
- local name = translatef("Broadcom 802.11%s Wireless Controller", bands)
- local nm = 0
-
- local fd = nixio.open("/proc/bus/pci/devices", "r")
- if fd then
- local ln
- for ln in fd:linesource() do
- if ln:match("wl$") then
- if nm == idx then
- local version = ln:match("^%S+%s+%S%S%S%S([0-9a-f]+)")
- name = translatef(
- "Broadcom BCM%04x 802.11 Wireless Controller",
- tonumber(version, 16)
- )
-
- break
- else
- nm = nm + 1
- end
- end
- end
- fd:close()
- end
-
- return name
-
- -- ralink
- elseif name == "ra" then
- return translatef("RaLink 802.11%s Wireless Controller", bands)
-
- -- hermes
- elseif name == "eth" then
- return translate("Hermes 802.11b Wireless Controller")
-
- -- hostap
- elseif name == "wlan" and fs.stat("/proc/net/hostap/" .. ifname, "type") == "dir" then
- return translate("Prism2/2.5/3 802.11b Wireless Controller")
-
- -- dunno yet
- else
- return translatef("Generic 802.11%s Wireless Controller", bands)
- end
- end
-
- local devices = ntm:get_wifidevs()
- local netlist = { }
- local netdevs = { }
-
- local dev
- for _, dev in ipairs(devices) do
- local net
- for _, net in ipairs(dev:get_wifinets()) do
- netlist[#netlist+1] = net:id()
- netdevs[net:id()] = dev:name()
- end
- end
--%>
-
-<%+header%>
-
-<% if not has_iwinfo then %>
- <div class="alert-message warning">
- <h4><%:Package libiwinfo required!%></h4>
- <p><%_The <em>libiwinfo-lua</em> package is not installed. You must install this component for working wireless configuration!%></p>
- </div>
-<% end %>
-
-<script type="text/javascript">//<![CDATA[
- var wifidevs = <%=luci.http.write_json(netdevs)%>;
-
- var is_reconnecting = false;
-
- function wifi_shutdown(id, toggle) {
- var reconnect = (toggle.getAttribute('active') == 'false');
-
- if (!reconnect && !confirm(<%=luci.http.write_json(translate('Really shut down network? You might lose access to this device if you are connected via this interface'))%>))
- return;
-
- is_reconnecting = true;
-
- var s = document.getElementById('iw-rc-status');
- if (s)
- {
- s.parentNode.style.display = 'block';
- s.innerHTML = '<%:Waiting for changes to be applied...%>';
- }
-
- for (var net in wifidevs)
- {
- var st = document.getElementById(net + '-iw-status');
- if (st)
- st.innerHTML = '<em><%:Wireless is restarting...%></em>';
- }
-
- (new XHR()).post('<%=url('admin/network')%>/wireless_' + (reconnect ? 'reconnect' : 'shutdown') + '/' + id, { token: '<%=token%>' },
- function(x)
- {
- if (s)
- {
- s.innerHTML = reconnect
- ? '<%:Wireless restarted%>'
- : '<%:Wireless shut down%>';
-
- window.setTimeout(function() {
- s.parentNode.style.display = 'none';
- is_reconnecting = false;
- }, 1000);
- }
- }
- );
- }
-
- function wifi_delete(id) {
- if (!confirm(<%=luci.http.write_json(translate('Really delete this wireless network? The deletion cannot be undone! You might lose access to this device if you are connected via this network.'))%>))
- return;
-
- (new XHR()).post('<%=url('admin/network/wireless_delete')%>/' + id, { token: '<%=token%>' },
- function(x) {
- location.href = '<%=url('admin/network/wireless')%>';
- }
- );
- }
-
- var hosts = <%=luci.http.write_json(luci.sys.net.host_hints())%>;
-
- XHR.poll(5, '<%=url('admin/network/wireless_status', table.concat(netlist, ","))%>', null,
- function(x, st)
- {
- if (st)
- {
- var rowstyle = 1;
- var radiostate = { };
-
- st.forEach(function(s) {
- var r = radiostate[wifidevs[s.id]] || (radiostate[wifidevs[s.id]] = {});
-
- s.is_assoc = (s.bssid && s.bssid != '00:00:00:00:00:00' && s.channel && s.mode != 'Unknown' && !s.disabled);
-
- r.up = r.up || s.is_assoc;
- r.channel = r.channel || s.channel;
- r.bitrate = r.bitrate || s.bitrate;
- r.frequency = r.frequency || s.frequency;
- });
-
- for( var i = 0; i < st.length; i++ )
- {
- var iw = st[i];
- var p = iw.quality;
- var q = iw.is_assoc ? p : -1;
-
- var icon;
- if (q < 0)
- icon = "<%=resource%>/icons/signal-none.png";
- else if (q == 0)
- icon = "<%=resource%>/icons/signal-0.png";
- else if (q < 25)
- icon = "<%=resource%>/icons/signal-0-25.png";
- else if (q < 50)
- icon = "<%=resource%>/icons/signal-25-50.png";
- else if (q < 75)
- icon = "<%=resource%>/icons/signal-50-75.png";
- else
- icon = "<%=resource%>/icons/signal-75-100.png";
-
- var sig = document.getElementById(iw.id + '-iw-signal');
- if (sig)
- sig.innerHTML = String.format(
- '<span class="ifacebadge" title="<%:Signal%>: %d <%:dBm%> / <%:Noise%>: %d <%:dBm%>"><img src="%s" /> %d%%</span>',
- iw.signal, iw.noise, icon, p
- );
-
- var toggle = document.getElementById(iw.id + '-iw-toggle');
- if (toggle)
- {
- if (!iw.disabled)
- {
- toggle.className = 'cbi-button cbi-button-neutral';
- toggle.value = '<%:Disable%>';
- toggle.title = '<%:Shutdown this network%>';
- }
- else
- {
- toggle.className = 'cbi-button cbi-button-neutral';
- toggle.value = '<%:Enable%>';
- toggle.title = '<%:Activate this network%>';
- }
-
- toggle.setAttribute('active', !iw.disabled);
- }
-
- var info = document.getElementById(iw.id + '-iw-status');
- if (info)
- {
- if (iw.is_assoc)
- info.innerHTML = String.format(
- '<strong><%:SSID%>:</strong> %h | ' +
- '<strong><%:Mode%>:</strong> %s<br />' +
- '<strong><%:BSSID%>:</strong> %s | ' +
- '<strong><%:Encryption%>:</strong> %s',
- iw.ssid, iw.mode, iw.bssid,
- iw.encryption ? iw.encryption : '<%:None%>'
- );
- else
- info.innerHTML = String.format(
- '<strong><%:SSID%>:</strong> %h | ' +
- '<strong><%:Mode%>:</strong> %s<br />' +
- '<em>%s</em>',
- iw.ssid || '?', iw.mode,
- is_reconnecting
- ? '<em><%:Wireless is restarting...%></em>'
- : '<em><%:Wireless is disabled or not associated%></em>'
- );
- }
- }
-
- for (var dev in radiostate)
- {
- var img = document.getElementById(dev + '-iw-upstate');
- if (img)
- img.src = '<%=resource%>/icons/wifi' + (radiostate[dev].up ? '' : '_disabled') + '.png';
-
- var stat = document.getElementById(dev + '-iw-devinfo');
- if (stat)
- stat.innerHTML = String.format(
- '<strong><%:Channel%>:</strong> %s (%s <%:GHz%>) | ' +
- '<strong><%:Bitrate%>:</strong> %s <%:Mbit/s%>',
- radiostate[dev].channel ? radiostate[dev].channel : '?',
- radiostate[dev].frequency ? radiostate[dev].frequency : '?',
- radiostate[dev].bitrate ? radiostate[dev].bitrate : '?'
- );
- }
- }
- }
- );
-//]]></script>
-
-<h2 name="content"><%:Wireless Overview%></h2>
-
-<div class="cbi-section" style="display:none">
- <legend><%:Reconnecting interface%></legend>
- <img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" />
- <span id="iw-rc-status"><%:Waiting for changes to be applied...%></span>
-</div>
-
-<div id="cbi-wireless-overview" class="cbi-map">
-
- <% for _, dev in ipairs(devices) do local nets = dev:get_wifinets() %>
- <!-- device <%=dev:name()%> -->
- <div class="cbi-section-node">
- <div class="table">
- <!-- physical device -->
- <div class="tr">
- <div class="td col-2 center">
- <span class="ifacebadge"><img src="<%=resource%>/icons/wifi_disabled.png" id="<%=dev:name()%>-iw-upstate" /> <%=dev:name()%></span>
- </div>
- <div class="td col-7 left">
- <big><strong><%=guess_wifi_hw(dev)%></strong></big><br />
- <span id="<%=dev:name()%>-iw-devinfo"></span>
- </div>
- <div class="td cbi-section-actions">
- <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" 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>
- </div>
- </div>
- <!-- /physical device -->
-
- <!-- network list -->
- <% if #nets > 0 then %>
- <% for i, net in ipairs(nets) do %>
- <div class="tr cbi-rowstyle-<%=1 + ((i-1) % 2)%>">
- <div class="td col-2 center" id="<%=net:id()%>-iw-signal">
- <span class="ifacebadge" title="<%:Not associated%>"><img src="<%=resource%>/icons/signal-none.png" /> 0%</span>
- </div>
- <div class="td col-7 left" id="<%=net:id()%>-iw-status">
- <em><%:Collecting data...%></em>
- </div>
- <div class="td cbi-section-actions">
- <input id="<%=net:id()%>-iw-toggle" type="button" class="cbi-button cbi-button-neutral" onclick="wifi_shutdown('<%=net:id()%>', this)" title="<%:Enable this network%>" value="<%:Enable%>" />
- <input type="button" class="cbi-button cbi-button-action important" onclick="location.href='<%=net:adminlink()%>'" title="<%:Edit this network%>" value="<%:Edit%>" />
- <input type="button" class="cbi-button cbi-button-negative" onclick="wifi_delete('<%=net:id()%>')" title="<%:Delete this network%>" value="<%:Remove%>" />
- </div>
- </div>
- <% end %>
- <% else %>
- <div class="tr cbi-rowstyle-2">
- <div class="td left">
- <em><%:No network configured on this device%></em>
- </div>
- </div>
- <% end %>
- <!-- /network list -->
- </div>
- </div>
- <!-- /device <%=dev:name()%> -->
- <% end %>
-
-
- <h2><%:Associated Stations%></h2>
-
- <%+admin_network/wifi_assoclist%>
-</div>
-
-<%+footer%>
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
new file mode 100644
index 0000000000..9730bc2c92
--- /dev/null
+++ b/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview_status.htm
@@ -0,0 +1,127 @@
+<%#
+ Copyright 2008-2009 Steven Barth <steven@midlink.org>
+ Copyright 2008-2018 Jo-Philipp Wich <jo@mein.io>
+ Licensed to the public under the Apache License 2.0.
+-%>
+
+<script type="text/javascript">//<![CDATA[
+ function wifi_delete(ev) {
+ if (!confirm(<%=luci.http.write_json(translate('Really delete this wireless network? The deletion cannot be undone! You might lose access to this device if you are connected via this network.'))%>)) {
+ ev.preventDefault();
+ return false;
+ }
+
+ ev.target.previousElementSibling.value = '1';
+ return true;
+ }
+
+ function wifi_restart(ev) {
+ XHR.halt();
+
+ findParent(ev.target, '.table').querySelectorAll('[data-disabled="false"]').forEach(function(s) {
+ s.innerHTML = '<em><%:Wireless is restarting...%></em>';
+ });
+
+ (new XHR()).post('<%=url('admin/network/wireless_reconnect')%>/' + ev.target.getAttribute('data-radio'),
+ { token: '<%=token%>' }, XHR.run);
+ }
+
+ var networks = [ ];
+
+ document.querySelectorAll('[data-network]').forEach(function(n) {
+ networks.push(n.getAttribute('data-network'));
+ });
+
+ XHR.poll(5, '<%=url('admin/network/wireless_status')%>/' + networks.join(','), null,
+ function(x, st)
+ {
+ if (st)
+ {
+ var rowstyle = 1;
+ var radiostate = { };
+
+ st.forEach(function(s) {
+ var r = radiostate[s.device.device] || (radiostate[s.device.device] = {});
+
+ s.is_assoc = (s.bssid && s.bssid != '00:00:00:00:00:00' && s.channel && s.mode != 'Unknown' && !s.disabled);
+
+ r.up = r.up || s.is_assoc;
+ r.channel = r.channel || s.channel;
+ r.bitrate = r.bitrate || s.bitrate;
+ r.frequency = r.frequency || s.frequency;
+ });
+
+ for( var i = 0; i < st.length; i++ )
+ {
+ var iw = st[i],
+ sig = document.getElementById(iw.id + '-iw-signal'),
+ info = document.getElementById(iw.id + '-iw-status'),
+ disabled = (info && info.getAttribute('data-disabled') === 'true');
+
+ var p = iw.quality;
+ var q = disabled ? -1 : p;
+
+ var icon;
+ if (q < 0)
+ icon = "<%=resource%>/icons/signal-none.png";
+ else if (q == 0)
+ icon = "<%=resource%>/icons/signal-0.png";
+ else if (q < 25)
+ icon = "<%=resource%>/icons/signal-0-25.png";
+ else if (q < 50)
+ icon = "<%=resource%>/icons/signal-25-50.png";
+ else if (q < 75)
+ icon = "<%=resource%>/icons/signal-50-75.png";
+ else
+ icon = "<%=resource%>/icons/signal-75-100.png";
+
+
+ if (sig)
+ sig.innerHTML = String.format(
+ '<span class="ifacebadge" title="<%:Signal%>: %d <%:dBm%> / <%:Noise%>: %d <%:dBm%>"><img src="%s" /> %d%%</span>',
+ iw.signal, iw.noise, icon, p
+ );
+
+ if (info)
+ {
+ if (iw.is_assoc)
+ info.innerHTML = String.format(
+ '<strong><%:SSID%>:</strong> %h | ' +
+ '<strong><%:Mode%>:</strong> %s<br />' +
+ '<strong><%:BSSID%>:</strong> %s | ' +
+ '<strong><%:Encryption%>:</strong> %s',
+ iw.ssid, iw.mode, iw.bssid,
+ iw.encryption ? iw.encryption : '<%:None%>'
+ );
+ else
+ info.innerHTML = String.format(
+ '<strong><%:SSID%>:</strong> %h | ' +
+ '<strong><%:Mode%>:</strong> %s<br />' +
+ '<em>%s</em>',
+ iw.ssid || '?', iw.mode,
+ disabled ? '<em><%:Wireless is disabled%></em>'
+ : '<em><%:Wireless is not associated%></em>'
+ );
+ }
+ }
+
+ for (var dev in radiostate)
+ {
+ var img = document.getElementById(dev + '-iw-upstate');
+ if (img)
+ img.src = '<%=resource%>/icons/wifi' + (radiostate[dev].up ? '' : '_disabled') + '.png';
+
+ var stat = document.getElementById(dev + '-iw-devinfo');
+ if (stat)
+ stat.innerHTML = String.format(
+ '<strong><%:Channel%>:</strong> %s (%s <%:GHz%>) | ' +
+ '<strong><%:Bitrate%>:</strong> %s <%:Mbit/s%>',
+ radiostate[dev].channel ? radiostate[dev].channel : '?',
+ radiostate[dev].frequency ? radiostate[dev].frequency : '?',
+ radiostate[dev].bitrate ? radiostate[dev].bitrate : '?'
+ );
+ }
+ }
+ }
+ );
+//]]></script>
diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_status.htm b/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_status.htm
index ad20ea38fe..bfad3d0804 100644
--- a/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_status.htm
+++ b/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_status.htm
@@ -8,7 +8,7 @@
{
var is_assoc = (iw.bssid && iw.bssid != '00:00:00:00:00:00' && iw.channel && !iw.disabled);
var p = iw.quality;
- var q = is_assoc ? p : -1;
+ var q = iw.disabled ? -1 : p;
var icon;
if (q < 0)
@@ -55,8 +55,10 @@
info.innerHTML = String.format(
'<strong><%:SSID%>:</strong> %h | ' +
'<strong><%:Mode%>:</strong> %s<br />' +
- '<em><%:Wireless is disabled or not associated%></em>',
- iw.ssid || '?', iw.mode
+ '<em>%s</em>',
+ iw.ssid || '?', iw.mode,
+ iw.disabled ? '<em><%:Wireless is disabled%></em>'
+ : '<em><%:Wireless is not associated%></em>'
);
}
}
diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm b/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm
index 03155dbb62..db8535086f 100644
--- a/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm
+++ b/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm
@@ -299,9 +299,9 @@
var is_assoc = (net.bssid != '00:00:00:00:00:00' && net.channel && !net.disabled);
var icon;
- if (!is_assoc)
+ if (net.disabled)
icon = "<%=resource%>/icons/signal-none.png";
- else if (net.quality == 0)
+ else if (net.quality <= 0)
icon = "<%=resource%>/icons/signal-0.png";
else if (net.quality < 25)
icon = "<%=resource%>/icons/signal-0-25.png";
@@ -320,7 +320,7 @@
'<%:BSSID%>', is_assoc ? (net.bssid || '-') : null,
'<%:Encryption%>', is_assoc ? net.encryption : null,
'<%:Associations%>', is_assoc ? (net.num_assoc || '-') : null,
- null, is_assoc ? null : E('em', '<%:Wireless is disabled or not associated%>')));
+ null, is_assoc ? null : E('em', net.disabled ? '<%:Wireless is disabled%>' : '<%:Wireless is not associated%>')));
}
ws.appendChild(renderBox(