From: Dirk Brenken Date: Sat, 28 Jul 2018 17:02:35 +0000 (+0200) Subject: luci-app-travelmate: sync with travelmate 1.2.1 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=11cd64e08e3b69371ed61459f5118c7a48a7f846;p=oweals%2Fluci.git luci-app-travelmate: sync with travelmate 1.2.1 * Runtime Information, Logview and Station Overview are now dynamically updated via XHR poll * New runtime information for "Faulty Stations" (Travelmate backend will no longer rename faulty uplinks) * Add a new "Restart" button to reset "Faulty Stations" information and trigger a Travelmate restart * In Stations overview the currently used uplink is emphasized in blue, faulty uplinks in red * Numerous cleanups (e.g. space=>tab indentation) and other small fixes Signed-off-by: Dirk Brenken --- diff --git a/applications/luci-app-travelmate/luasrc/controller/travelmate.lua b/applications/luci-app-travelmate/luasrc/controller/travelmate.lua index 493a387c3..00969ffe7 100644 --- a/applications/luci-app-travelmate/luasrc/controller/travelmate.lua +++ b/applications/luci-app-travelmate/luasrc/controller/travelmate.lua @@ -3,9 +3,12 @@ module("luci.controller.travelmate", package.seeall) -local util = require("luci.util") -local i18n = require("luci.i18n") -local templ = require("luci.template") +local sys = require("luci.sys") +local util = require("luci.util") +local http = require("luci.http") +local i18n = require("luci.i18n") +local json = require("luci.jsonc") +local uci = require("luci.model.uci").cursor() function index() if not nixio.fs.access("/etc/config/travelmate") then @@ -14,13 +17,16 @@ function index() entry({"admin", "services", "travelmate"}, firstchild(), _("Travelmate"), 40).dependent = false entry({"admin", "services", "travelmate", "tab_from_cbi"}, cbi("travelmate/overview_tab", {hideresetbtn=true, hidesavebtn=true}), _("Overview"), 10).leaf = true entry({"admin", "services", "travelmate", "stations"}, template("travelmate/stations"), _("Wireless Stations"), 20).leaf = true - entry({"admin", "services", "travelmate", "logfile"}, call("logread"), _("View Logfile"), 30).leaf = true + entry({"admin", "services", "travelmate", "log"}, template("travelmate/logread"), _("View Logfile"), 30).leaf = true entry({"admin", "services", "travelmate", "advanced"}, firstchild(), _("Advanced"), 100) entry({"admin", "services", "travelmate", "advanced", "configuration"}, form("travelmate/configuration_tab"), _("Edit Travelmate Configuration"), 110).leaf = true entry({"admin", "services", "travelmate", "advanced", "cfg_wireless"}, form("travelmate/cfg_wireless_tab"), _("Edit Wireless Configuration"), 120).leaf = true entry({"admin", "services", "travelmate", "advanced", "cfg_network"}, form("travelmate/cfg_network_tab"), _("Edit Network Configuration"), 130).leaf = true entry({"admin", "services", "travelmate", "advanced", "cfg_firewall"}, form("travelmate/cfg_firewall_tab"), _("Edit Firewall Configuration"), 140).leaf = true + entry({"admin", "services", "travelmate", "logread"}, call("logread"), nil).leaf = true + entry({"admin", "services", "travelmate", "status"}, call("status_update"), nil).leaf = true + entry({"admin", "services", "travelmate", "action"}, call("trm_action"), nil).leaf = true entry({"admin", "services", "travelmate", "apqr"}, template("travelmate/ap_qr")).leaf = true entry({"admin", "services", "travelmate", "wifiscan"}, template("travelmate/wifi_scan")).leaf = true entry({"admin", "services", "travelmate", "wifiadd"}, form("travelmate/wifi_add", {hideresetbtn=true, hidesavebtn=true})).leaf = true @@ -29,13 +35,38 @@ function index() entry({"admin", "services", "travelmate", "wifiorder"}, form("travelmate/wifi_order", {hideresetbtn=true, hidesavebtn=true})).leaf = true end +function trm_action(name) + if name == "do_restart" then + luci.sys.call("/etc/init.d/travelmate restart >/dev/null 2>&1") + end + luci.http.prepare_content("text/plain") + luci.http.write("0") +end + +function status_update() + local rt_file + local content + + rt_file = uci:get("travelmate", "global", "trm_rtfile") or "/tmp/trm_runtime.json" + + if nixio.fs.access(rt_file) then + content = json.parse(nixio.fs.readfile(rt_file) or "") + http.prepare_content("application/json") + http.write_json(content) + end +end + function logread() - local logfile = "" + local content if nixio.fs.access("/var/log/messages") then - logfile = util.trim(util.exec("grep -F 'travelmate-' /var/log/messages")) - elseif nixio.fs.access("/sbin/logread") then - logfile = util.trim(util.exec("logread -e 'travelmate-'")) + content = util.trim(util.exec("grep -F 'travelmate-' /var/log/messages")) + else + content = util.trim(util.exec("logread -e 'travelmate-'")) + end + + if content == "" then + content = "No travelmate related logs yet!" end - templ.render("travelmate/logread", {title = i18n.translate("Travelmate Logfile"), content = logfile}) + http.write(content) end diff --git a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_firewall_tab.lua b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_firewall_tab.lua index e5a048fa8..fea190e9b 100644 --- a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_firewall_tab.lua +++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_firewall_tab.lua @@ -1,11 +1,11 @@ --- Copyright 2017 Dirk Brenken (dev@brenken.org) +-- Copyright 2017-2018 Dirk Brenken (dev@brenken.org) -- This is free software, licensed under the Apache License, Version 2.0 -local fs = require("nixio.fs") -local util = require("luci.util") -local trminput = "/etc/config/firewall" +local fs = require("nixio.fs") +local util = require("luci.util") +local input = "/etc/config/firewall" -if not nixio.fs.access(trminput) then +if not fs.access(input) then m = SimpleForm("error", nil, translate("Input file not found, please check your configuration.")) return m end @@ -23,11 +23,15 @@ f.rows = 20 f.rmempty = true function f.cfgvalue() - return nixio.fs.readfile(trminput) or "" + return fs.readfile(input) or "" end function f.write(self, section, data) - return nixio.fs.writefile(trminput, "\n" .. util.trim(data:gsub("\r\n", "\n")) .. "\n") + return fs.writefile(input, "\n" .. util.trim(data:gsub("\r\n", "\n")) .. "\n") +end + +function f.remove(self, section, value) + return fs.writefile(input, "") end function s.handle(self, state, data) diff --git a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_network_tab.lua b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_network_tab.lua index 0096d6a8c..6f0ade772 100644 --- a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_network_tab.lua +++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_network_tab.lua @@ -1,11 +1,11 @@ --- Copyright 2017 Dirk Brenken (dev@brenken.org) +-- Copyright 2017-2018 Dirk Brenken (dev@brenken.org) -- This is free software, licensed under the Apache License, Version 2.0 -local fs = require("nixio.fs") -local util = require("luci.util") -local trminput = "/etc/config/network" +local fs = require("nixio.fs") +local util = require("luci.util") +local input = "/etc/config/network" -if not nixio.fs.access(trminput) then +if not fs.access(input) then m = SimpleForm("error", nil, translate("Input file not found, please check your configuration.")) return m end @@ -23,11 +23,15 @@ f.rows = 20 f.rmempty = true function f.cfgvalue() - return nixio.fs.readfile(trminput) or "" + return fs.readfile(input) or "" end function f.write(self, section, data) - return nixio.fs.writefile(trminput, "\n" .. util.trim(data:gsub("\r\n", "\n")) .. "\n") + return fs.writefile(input, "\n" .. util.trim(data:gsub("\r\n", "\n")) .. "\n") +end + +function f.remove(self, section, value) + return fs.writefile(input, "") end function s.handle(self, state, data) diff --git a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_wireless_tab.lua b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_wireless_tab.lua index 7ef9920a0..ab59dfb37 100644 --- a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_wireless_tab.lua +++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_wireless_tab.lua @@ -1,11 +1,11 @@ --- Copyright 2017 Dirk Brenken (dev@brenken.org) +-- Copyright 2017-2018 Dirk Brenken (dev@brenken.org) -- This is free software, licensed under the Apache License, Version 2.0 -local fs = require("nixio.fs") -local util = require("luci.util") -local trminput = "/etc/config/wireless" +local fs = require("nixio.fs") +local util = require("luci.util") +local input = "/etc/config/wireless" -if not nixio.fs.access(trminput) then +if not fs.access(input) then m = SimpleForm("error", nil, translate("Input file not found, please check your configuration.")) return m end @@ -23,11 +23,15 @@ f.rows = 20 f.rmempty = true function f.cfgvalue() - return nixio.fs.readfile(trminput) or "" + return fs.readfile(input) or "" end function f.write(self, section, data) - return nixio.fs.writefile(trminput, "\n" .. util.trim(data:gsub("\r\n", "\n")) .. "\n") + return fs.writefile(input, "\n" .. util.trim(data:gsub("\r\n", "\n")) .. "\n") +end + +function f.remove(self, section, value) + return fs.writefile(input, "") end function s.handle(self, state, data) diff --git a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/configuration_tab.lua b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/configuration_tab.lua index 8a20ab9cc..7bb32c1ec 100644 --- a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/configuration_tab.lua +++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/configuration_tab.lua @@ -1,11 +1,11 @@ --- Copyright 2017 Dirk Brenken (dev@brenken.org) +-- Copyright 2017-2018 Dirk Brenken (dev@brenken.org) -- This is free software, licensed under the Apache License, Version 2.0 -local fs = require("nixio.fs") -local util = require("luci.util") -local trminput = "/etc/config/travelmate" +local fs = require("nixio.fs") +local util = require("luci.util") +local input = "/etc/config/travelmate" -if not nixio.fs.access(trminput) then +if not fs.access(input) then m = SimpleForm("error", nil, translate("Input file not found, please check your configuration.")) m.reset = false m.submit = false @@ -25,11 +25,15 @@ f.rows = 20 f.rmempty = true function f.cfgvalue() - return nixio.fs.readfile(trminput) or "" + return fs.readfile(input) or "" end function f.write(self, section, data) - return nixio.fs.writefile(trminput, "\n" .. util.trim(data:gsub("\r\n", "\n")) .. "\n") + return fs.writefile(input, "\n" .. util.trim(data:gsub("\r\n", "\n")) .. "\n") +end + +function f.remove(self, section, value) + return fs.writefile(input, "") end function s.handle(self, state, data) diff --git a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/overview_tab.lua b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/overview_tab.lua index a1dcbc638..ab39dab6b 100644 --- a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/overview_tab.lua +++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/overview_tab.lua @@ -3,15 +3,12 @@ local fs = require("nixio.fs") local uci = require("luci.model.uci").cursor() -local json = require("luci.jsonc") local util = require("luci.util") local nw = require("luci.model.network").init() local fw = require("luci.model.firewall").init() local dump = util.ubus("network.interface", "dump", {}) local trmiface = uci:get("travelmate", "global", "trm_iface") or "trm_wwan" -local trminput = uci:get("travelmate", "global", "trm_rtfile") or "/tmp/trm_runtime.json" local uplink = uci:get("network", trmiface) or "" -local parse = json.parse(fs.readfile(trminput) or "") m = Map("travelmate", translate("Travelmate"), translate("Configuration of the travelmate package to to enable travel router functionality. ") @@ -20,11 +17,9 @@ m = Map("travelmate", translate("Travelmate"), .. "see online documentation", "https://github.com/openwrt/packages/blob/master/net/travelmate/files/README.md")) m:chain("network") m:chain("firewall") -m.apply_on_parse = true function m.on_apply(self) luci.sys.call("env -i /etc/init.d/travelmate restart >/dev/null 2>&1") - luci.http.redirect(luci.dispatcher.build_url("admin", "services", "travelmate")) end -- Interface Wizard @@ -33,7 +28,7 @@ if uplink == "" then ds = m:section(NamedSection, "global", "travelmate", translate("Interface Wizard")) o = ds:option(Value, "trm_iface", translate("Create Uplink interface"), translate("Create a new wireless wan uplink interface, configure it to use dhcp and ") - .. translate("add it to the wan zone of the firewall.
") + .. translate("add it to the wan zone of the firewall. ") .. translate("This step has only to be done once.")) o.datatype = "and(uciname,rangelength(3,15))" o.default = trmiface @@ -96,55 +91,8 @@ end -- Runtime information -ds = m:section(NamedSection, "global", "travelmate", translate("Runtime Information")) - -dv1 = ds:option(DummyValue, "status", translate("Travelmate Status (Quality)")) -dv1.template = "travelmate/runtime" -if parse ~= nil then - dv1.value = parse.data.travelmate_status or translate("n/a") -else - dv1.value = translate("n/a") -end - -dv2 = ds:option(DummyValue, "travelmate_version", translate("Travelmate Version")) -dv2.template = "travelmate/runtime" -if parse ~= nil then - dv2.value = parse.data.travelmate_version or translate("n/a") -else - dv2.value = translate("n/a") -end - -dv3 = ds:option(DummyValue, "station_id", translate("Station ID (SSID/BSSID)")) -dv3.template = "travelmate/runtime" -if parse ~= nil then - dv3.value = parse.data.station_id or translate("n/a") -else - dv3.value = translate("n/a") -end - -dv4 = ds:option(DummyValue, "station_interface", translate("Station Interface")) -dv4.template = "travelmate/runtime" -if parse ~= nil then - dv4.value = parse.data.station_interface or translate("n/a") -else - dv4.value = translate("n/a") -end - -dv5 = ds:option(DummyValue, "station_radio", translate("Station Radio")) -dv5.template = "travelmate/runtime" -if parse ~= nil then - dv5.value = parse.data.station_radio or translate("n/a") -else - dv5.value = translate("n/a") -end - -dv6 = ds:option(DummyValue, "last_rundate", translate("Last rundate")) -dv6.template = "travelmate/runtime" -if parse ~= nil then - dv6.value = parse.data.last_rundate or translate("n/a") -else - dv6.value = translate("n/a") -end +ds = s:option(DummyValue, "_dummy") +ds.template = "travelmate/runtime" -- Extra options diff --git a/applications/luci-app-travelmate/luasrc/view/travelmate/ap_qr.htm b/applications/luci-app-travelmate/luasrc/view/travelmate/ap_qr.htm index a92dbe146..3f01a81e3 100644 --- a/applications/luci-app-travelmate/luasrc/view/travelmate/ap_qr.htm +++ b/applications/luci-app-travelmate/luasrc/view/travelmate/ap_qr.htm @@ -6,60 +6,61 @@ This is free software, licensed under the Apache License, Version 2.0 <%+header%>
-
- <%=translate("Here you'll find the QR codes from all of your configured Access Points. It allows you to connect your Android or iOS devices to your router's WiFi using the QR code shown below.")%> -
-<%- - local write = io.write - local uci = require("luci.model.uci").cursor() +
+ <%=translate("Here you'll find the QR codes from all of your configured Access Points. It allows you to connect your Android or iOS devices to your router's WiFi using the QR code shown below.")%> +
+ <%- local uci = require("luci.model.uci").cursor() - uci:foreach("wireless", "wifi-iface", function(s) - local device = s.device or "" - local mode = s.mode or "" - local ssid = s.ssid or "" - local enc = s.encryption or "" - local key = s.key or "" - local hidden = s.hidden or "false" - local disabled = s.disabled or "" - local wep_slots = {s.key1 or "", s.key2 or "", s.key3 or "", s.key4 or ""} + uci:foreach("wireless", "wifi-iface", function(s) + local device = s.device or "" + local mode = s.mode or "" + local ssid = s.ssid or "" + local enc = s.encryption or "" + local key = s.key or "" + local hidden = s.hidden or "false" + local disabled = s.disabled or "" + local wep_slots = {s.key1 or "", s.key2 or "", s.key3 or "", s.key4 or ""} - if device and mode == "ap" and disabled ~= "1" then - if string.match(enc, '^psk') then - enc = "WPA" - elseif string.match(enc, '^wep') then - enc = "WEP" - if tonumber(key) then - key = wep_slots[tonumber(key)] - end - elseif enc == "none" then - enc = "nopass" - key = "nokey" - else - enc = "" - end - if hidden == "1" then - hidden = "true" - end - if ssid and enc and key then - local e_ssid = string.gsub(ssid,"[\"\\';:, ]",[[\\\%1]]) - local e_key = string.gsub(key,"[\"\\';:, ]",[[\\\%1]]) - local qrcode = "" - qrcode = luci.sys.exec("/usr/bin/qrencode --inline --8bit --type=SVG --output=- 'WIFI:S:\"'" .. e_ssid .. "'\";T:'" .. enc .. "';P:\"'" .. e_key .. "'\";H:'" .. hidden .. "';'") --%> -
- AP on <%=device%> with SSID "<%=ssid%>" -

<%=qrcode%>

-
-<%- - end - end - end) -%> + if device and mode == "ap" and disabled ~= "1" then + if string.match(enc, '^psk') then + enc = "WPA" + elseif string.match(enc, '^wep') then + enc = "WEP" + if tonumber(key) then + key = wep_slots[tonumber(key)] + end + elseif enc == "none" then + enc = "nopass" + key = "nokey" + else + enc = "" + end + + if hidden == "1" then + hidden = "true" + end + + if ssid and enc and key then + local e_ssid = string.gsub(ssid,"[\"\\';:, ]",[[\\\%1]]) + local e_key = string.gsub(key,"[\"\\';:, ]",[[\\\%1]]) + local qrcode = "" + + qrcode = luci.sys.exec("/usr/bin/qrencode --inline --8bit --type=SVG --output=- 'WIFI:S:\"'" .. e_ssid .. "'\";T:'" .. enc .. "';P:\"'" .. e_key .. "'\";H:'" .. hidden .. "';'") + -%> +
+

AP on <%=device%> with SSID "<%=ssid%>"

+

<%=qrcode%>

+
+ <%- + end + end + end) + -%>
-
- -
+
+ +
<%+footer%> diff --git a/applications/luci-app-travelmate/luasrc/view/travelmate/logread.htm b/applications/luci-app-travelmate/luasrc/view/travelmate/logread.htm index c40bdeeb5..4457296f5 100644 --- a/applications/luci-app-travelmate/luasrc/view/travelmate/logread.htm +++ b/applications/luci-app-travelmate/luasrc/view/travelmate/logread.htm @@ -5,16 +5,47 @@ This is free software, licensed under the Apache License, Version 2.0 <%+header%> + + + +
-
<%:This form shows the syslog output, pre-filtered for travelmate related messages only.%>
- +
<%:The syslog output, pre-filtered for travelmate related messages only.%>
+
- - <%+footer%> diff --git a/applications/luci-app-travelmate/luasrc/view/travelmate/runtime.htm b/applications/luci-app-travelmate/luasrc/view/travelmate/runtime.htm index 7e93efab9..aba4a3201 100644 --- a/applications/luci-app-travelmate/luasrc/view/travelmate/runtime.htm +++ b/applications/luci-app-travelmate/luasrc/view/travelmate/runtime.htm @@ -3,8 +3,143 @@ Copyright 2017-2018 Dirk Brenken (dev@brenken.org) This is free software, licensed under the Apache License, Version 2.0 -%> -<%+cbi/valueheader%> + - + + +

<%:Runtime Information%>

+
+ +
+ - +
+
+
+ +
+ - +
+
+
+ +
+ - +
+
+
+ +
+ - +
+
+
+ +
+ - +
+
+
+ +
+ - +
+
+
+
+ +
+ + +
+
diff --git a/applications/luci-app-travelmate/luasrc/view/travelmate/stations.htm b/applications/luci-app-travelmate/luasrc/view/travelmate/stations.htm index 74542a9ca..98e2e64bc 100644 --- a/applications/luci-app-travelmate/luasrc/view/travelmate/stations.htm +++ b/applications/luci-app-travelmate/luasrc/view/travelmate/stations.htm @@ -4,75 +4,151 @@ This is free software, licensed under the Apache License, Version 2.0 -%> <%- - local write = io.write - local uci = require("luci.model.uci").cursor() - local trmiface = uci:get("travelmate", "global", "trm_iface") or "trm_wwan" + local uci = require("luci.model.uci").cursor() + local trmiface = uci:get("travelmate", "global", "trm_iface") or "trm_wwan" -%> <%+header%> +
-
- <%=translatef("Provides an overview of all configured uplinks for the travelmate interface (%s). You can edit, delete or re-order existing uplinks or scan for a new one. The currently used uplink is emphasized in blue.", trmiface)%> -
+
+ <%=translatef("Provides an overview of all configured uplinks for the travelmate interface (%s). You can edit, delete or re-order existing uplinks or scan for a new one. The currently used uplink is emphasized in blue, faulty stations in red.", trmiface)%> +
-
-
-
-
<%:Device%>
-
<%:SSID%>
-
<%:BSSID%>
-
<%:Encryption%>
-
 
-
-<% - uci:foreach("wireless", "wifi-iface", function(s) - local iface = s.network or "" - if iface == trmiface then - local section = s['.name'] or "" - local device = s.device or "-" - local ssid = s.ssid or "-" - local bssid = s.bssid or "-" - local encryption = s.encryption or "-" - local disabled = s.disabled or "" - local style = "text-align:left;color:#000000" - if disabled == "0" then - style = "text-align:left;color:#0069d6;font-weight:bold" - end -%> -
-
<%=device%>
-
<%=ssid%>
-
<%=bssid%>
-
<%=encryption%>
-
- - - - -
-
-<% - end - end) -%> -
-
-
-<% - uci:foreach("wireless", "wifi-device", function(s) - local device = s[".name"] -%> -
- - - -
-<% - end) -%> -
+
+
+
+
<%:Device%>
+
<%:SSID%>
+
<%:BSSID%>
+
<%:Encryption%>
+
<%:Action%>
+
+ <%- uci:foreach("wireless", "wifi-iface", function(s) + local iface = s.network or "" + if iface == trmiface then + local section = s['.name'] or "" + local device = s.device or "-" + local ssid = s.ssid or "-" + local bssid = s.bssid or "-" + local encr = s.encryption or "-" + -%> +
+
<%=device%>
+
<%=ssid%>
+
<%=bssid%>
+
<%=encr%>
+
+
+ + + + +
+
+
+ <%- end; end) -%> +
+
+
+ <%- uci:foreach("wireless", "wifi-device", function(s) + local device = s[".name"] + local hwmode = s.hwmode or "-" -%> +
+ + + +
+ <%- end) -%> +
<%+footer%> diff --git a/applications/luci-app-travelmate/luasrc/view/travelmate/stations_backup.htm b/applications/luci-app-travelmate/luasrc/view/travelmate/stations_backup.htm new file mode 100644 index 000000000..ecfc6cd5a --- /dev/null +++ b/applications/luci-app-travelmate/luasrc/view/travelmate/stations_backup.htm @@ -0,0 +1,70 @@ +<%# +Copyright 2017-2018 Dirk Brenken (dev@brenken.org) +This is free software, licensed under the Apache License, Version 2.0 +-%> + +<%- + local uci = require("luci.model.uci").cursor() + local trmiface = uci:get("travelmate", "global", "trm_iface") or "trm_wwan" +-%> + +<%+header%> + +
+
+ <%=translatef("Provides an overview of all configured uplinks for the travelmate interface (%s). You can edit, delete or re-order existing uplinks or scan for a new one. The currently used uplink is emphasized in blue.", trmiface)%> +
+ +
+
+
+
<%:Device%>
+
<%:SSID%>
+
<%:BSSID%>
+
<%:Encryption%>
+
<%:Action%>
+
+ <%- uci:foreach("wireless", "wifi-iface", function(s) + local iface = s.network or "" + if iface == trmiface then + local section = s['.name'] or "" + local device = s.device or "-" + local ssid = s.ssid or "-" + local bssid = s.bssid or "-" + local encr = s.encryption or "-" + local disabled = s.disabled or "" + local style = "text-align:left;color:#000000" + if disabled == "0" then + style = "text-align:left;color:#0069d6;font-weight:bold" + end -%> +
+
<%=device%>
+
<%=ssid%>
+
<%=bssid%>
+
<%=encr%>
+
+
+ + + + +
+
+
+ <%- end; end) -%> +
+
+
+ <%- uci:foreach("wireless", "wifi-device", function(s) + local device = s[".name"] + local hwmode = s.hwmode or "-" -%> +
+ + + +
+ <%- end) -%> +
+
+ +<%+footer%> diff --git a/applications/luci-app-travelmate/luasrc/view/travelmate/wifi_scan.htm b/applications/luci-app-travelmate/luasrc/view/travelmate/wifi_scan.htm index 8a417d69c..ab3fe77fb 100644 --- a/applications/luci-app-travelmate/luasrc/view/travelmate/wifi_scan.htm +++ b/applications/luci-app-travelmate/luasrc/view/travelmate/wifi_scan.htm @@ -1,97 +1,99 @@ <%# -Copyright 2017 Dirk Brenken (dev@brenken.org) +Copyright 2017-2018 Dirk Brenken (dev@brenken.org) This is free software, licensed under the Apache License, Version 2.0 -%> <%- - local sys = require("luci.sys") - local utl = require("luci.util") - local dev = luci.http.formvalue("device") - local iw = luci.sys.wifi.getiwinfo(dev) - local wpa_label = {translate("WPA"), translate("WPA2"), translate("WPA/WPA2")} + local sys = require("luci.sys") + local utl = require("luci.util") + local dev = luci.http.formvalue("device") + local iw = luci.sys.wifi.getiwinfo(dev) + local label = {translate("WPA"), translate("WPA2"), translate("WPA/WPA2")} - if not iw then - luci.http.redirect(luci.dispatcher.build_url("admin/services/travelmate/stations")) - end + if not iw then + luci.http.redirect(luci.dispatcher.build_url("admin/services/travelmate/stations")) + end - function format_wifi_encryption(info) - if info.wep == true then - return translate("WEP") - elseif info.wpa > 0 then - return "%s (%s/%s)" %{wpa_label[info.wpa], table.concat(info.auth_suites), table.concat(info.group_ciphers)} - elseif info.enabled then - return translate("Unknown") - else - return translate("Open") - end - end + function format_wifi_encryption(info) + if info.wep == true then + return translate("WEP") + elseif info.wpa > 0 then + return "%s (%s/%s)" %{label[info.wpa], table.concat(info.auth_suites), table.concat(info.group_ciphers)} + elseif info.enabled then + return translate("Unknown") + else + return translate("Open") + end + 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 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 -%> <%+header%> -
-

<%:Wireless Scan%>

-
-
-
-
<%:Uplink SSID%>
-
<%:Uplink BSSID%>
-
<%:Encryption%>
-
<%:Signal strength%>
-
- <% for i, net in ipairs(iw.scanlist or { }) do %> -
-
- <%=net.ssid and utl.pcdata(net.ssid) or "%s" % translate("hidden")%> -
-
- <%=net.bssid and utl.pcdata(net.bssid)%> -
-
- <%=format_wifi_encryption(net.encryption)%> -
-
- <%=percent_wifi_signal(net)%> % -
-
-
- - - - - - <% if net.encryption.wpa then %> - - <% for _, v in ipairs(net.encryption.auth_suites) do %><% end %> - <% end %> - -
-
-
- <% end %> -
-
-
-
- -
-
- - - -
-
+

<%:Wireless Scan%>

+
+
+
+
<%:Uplink SSID%>
+
<%:Uplink BSSID%>
+
<%:Encryption%>
+
<%:Signal strength%>
+
<%:Action%>
+
+ <%- for i, net in ipairs(iw.scanlist or { }) do -%> +
+
+ <%=net.ssid and utl.pcdata(net.ssid) or "%s" % translate("hidden")%> +
+
+ <%=net.bssid and utl.pcdata(net.bssid)%> +
+
+ <%=format_wifi_encryption(net.encryption)%> +
+
+ <%=percent_wifi_signal(net)%> % +
+
+
+ + + + + + <%- if net.encryption.wpa then -%> + + <%- for _, v in ipairs(net.encryption.auth_suites) do -%> + + <%- end -%> + <%- end -%> + +
+
+
+ <%- end -%> +
+
+
+
+ +
+
+ + + +
+
<%+footer%>