diff options
Diffstat (limited to 'applications/luci-app-travelmate/luasrc')
5 files changed, 70 insertions, 18 deletions
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 429d4357d6..cc38bd97e1 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 @@ -71,19 +71,24 @@ o4 = s:option(Flag, "trm_proactive", translate("ProActive Uplink Switch"), o4.default = o4.enabled o4.rmempty = false -o5 = s:option(ListValue, "trm_iface", translate("Uplink / Trigger interface"), +o5 = s:option(Flag, "trm_autoadd", translate("Add Open Uplinks"), + translate("Automatically add open uplinks like hotel captive portals to your wireless config.")) +o5.default = o5.disabled +o5.rmempty = false + +o6 = s:option(ListValue, "trm_iface", translate("Uplink / Trigger interface"), translate("Name of the used uplink interface.")) if dump then local i, v for i, v in ipairs(dump.interface) do if v.interface ~= "loopback" and v.interface ~= "lan" then local device = v.l3_device or v.device or "-" - o5:value(v.interface, v.interface.. " (" ..device.. ")") + o6:value(v.interface, v.interface.. " (" ..device.. ")") end end end -o5.default = trmiface -o5.rmempty = false +o6.default = trmiface +o6.rmempty = false -- Runtime information diff --git a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_add.lua b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_add.lua index 83011e9dd5..e8580daac7 100644 --- a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_add.lua +++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_add.lua @@ -1,9 +1,11 @@ --- Copyright 2017-2018 Dirk Brenken (dev@brenken.org) +-- Copyright 2017-2019 Dirk Brenken (dev@brenken.org) -- This is free software, licensed under the Apache License, Version 2.0 local fs = require("nixio.fs") local uci = require("luci.model.uci").cursor() local http = require("luci.http") +local util = require("luci.util") +local scripts = util.split(util.trim(util.exec("ls /etc/travelmate/*.login 2>/dev/null")), "\n", nil, true) or {} local trmiface = uci:get("travelmate", "global", "trm_iface") or "trm_wwan" local encr_psk = {"psk", "psk2", "psk-mixed"} local encr_wpa = {"wpa", "wpa2", "wpa-mixed"} @@ -135,6 +137,17 @@ elseif (tonumber(m.hidden.wpa_version) or 0) > 0 then end end +local login_section = (m.hidden.ssid or "") .. (m.hidden.bssid or "") +login_section = login_section:gsub("[^%w_]", "_") +local cmd = uci:get("travelmate", login_section, "command") +cmd_list = m:field(ListValue, "cmdlist", translate("Auto Login Script"), + translate("External script reference which will be called for automated captive portal logins.")) +cmd_list:value("none") +for _, z in ipairs(scripts) do + cmd_list:value(z) +end +cmd_list.default = cmd or "none" + function wssid.write(self, section, value) newsection = uci:section("wireless", "wifi-iface", nil, { mode = "sta", @@ -174,6 +187,16 @@ function wssid.write(self, section, value) else uci:set("wireless", newsection, "encryption", "none") end + local login_section = (wssid:formvalue(section) or "") .. (bssid:formvalue(section) or "") + login_section = login_section:gsub("[^%w_]", "_") + if not uci:get("travelmate", login_section) and cmd_list:formvalue(section) ~= "none" then + uci:set("travelmate", login_section, "login") + end + if uci:get("travelmate", login_section) then + uci:set("travelmate", login_section, "command", cmd_list:formvalue(section)) + uci:save("travelmate") + uci:commit("travelmate") + end uci:save("wireless") uci:commit("wireless") luci.sys.call("env -i /bin/ubus call network reload >/dev/null 2>&1") diff --git a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_edit.lua b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_edit.lua index dae358ae03..cd2fa69ae4 100644 --- a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_edit.lua +++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_edit.lua @@ -1,9 +1,11 @@ -- Copyright 2017-2019 Dirk Brenken (dev@brenken.org) -- This is free software, licensed under the Apache License, Version 2.0 -local fs = require("nixio.fs") -local uci = require("luci.model.uci").cursor() -local http = require("luci.http") +local fs = require("nixio.fs") +local uci = require("luci.model.uci").cursor() +local http = require("luci.http") +local util = require("luci.util") +local scripts = util.split(util.trim(util.exec("ls /etc/travelmate/*.login 2>/dev/null")), "\n", nil, true) or {} m = SimpleForm("edit", translate("Edit Wireless Uplink Configuration")) m.submit = translate("Save") @@ -19,6 +21,7 @@ m.hidden = { } local s = uci:get_all("wireless", m.hidden.cfg) + if s ~= nil then wssid = m:field(Value, "ssid", translate("SSID")) wssid.datatype = "rangelength(1,32)" @@ -126,6 +129,17 @@ if s ~= nil then wkey.password = true wkey.default = s.key or s.password end + + local login_section = (s.ssid or "") .. (s.bssid or "") + login_section = login_section:gsub("[^%w_]", "_") + local cmd = uci:get("travelmate", login_section, "command") + cmd_list = m:field(ListValue, "cmdlist", translate("Auto Login Script"), + translate("External script reference which will be called for automated captive portal logins.")) + cmd_list:value("none") + for _, z in ipairs(scripts) do + cmd_list:value(z) + end + cmd_list.default = cmd or "none" else m.on_cancel() end @@ -160,6 +174,16 @@ function wssid.write(self, section, value) uci:set("wireless", m.hidden.cfg, "priv_key_pwd", privkeypwd:formvalue(section) or "") end end + local login_section = (wssid:formvalue(section) or "") .. (bssid:formvalue(section) or "") + login_section = login_section:gsub("[^%w_]", "_") + if not uci:get("travelmate", login_section) and cmd_list:formvalue(section) ~= "none" then + uci:set("travelmate", login_section, "login") + end + if uci:get("travelmate", login_section) then + uci:set("travelmate", login_section, "command", cmd_list:formvalue(section)) + uci:save("travelmate") + uci:commit("travelmate") + end uci:save("wireless") uci:commit("wireless") luci.sys.call("env -i /bin/ubus call network reload >/dev/null 2>&1") diff --git a/applications/luci-app-travelmate/luasrc/view/travelmate/stations.htm b/applications/luci-app-travelmate/luasrc/view/travelmate/stations.htm index 0e78803d06..5c28966339 100644 --- a/applications/luci-app-travelmate/luasrc/view/travelmate/stations.htm +++ b/applications/luci-app-travelmate/luasrc/view/travelmate/stations.htm @@ -34,7 +34,7 @@ This is free software, licensed under the Apache License, Version 2.0 if (view) { view.setAttribute("name", "station_nok"); - view.setAttribute("style", "color: #a22; font-weight: bold"); + view.setAttribute("style", "text-align: left !important; color: #a22; font-weight: bold"); } } } @@ -59,7 +59,7 @@ This is free software, licensed under the Apache License, Version 2.0 view = document.getElementById(search); if (view) { - view.setAttribute("style", "color: #37c; font-weight: bold"); + view.setAttribute("style", "text-align: left !important; color: #37c; font-weight: bold"); } } } @@ -122,10 +122,10 @@ This is free software, licensed under the Apache License, Version 2.0 local encr = s.encryption or "-" -%> <div class="tr cbi-section-table-row cbi-rowstyle-1" name="station_ok" id="1_<%=device%>/<%=ssid%>/<%=bssid%>"> - <div class="td left" name="station_ok" id="2_<%=device%>/<%=ssid%>/<%=bssid%>"><%=device%></div> - <div class="td left" name="station_ok" id="3_<%=device%>/<%=ssid%>/<%=bssid%>"><%=ssid%></div> - <div class="td left" name="station_ok" id="4_<%=device%>/<%=ssid%>/<%=bssid%>"><%=bssid%></div> - <div class="td left" name="station_ok" id="5_<%=device%>/<%=ssid%>/<%=bssid%>"><%=encr%></div> + <div class="td left" style="text-align: left !important" name="station_ok" id="2_<%=device%>/<%=ssid%>/<%=bssid%>"><%=device%></div> + <div class="td left" style="text-align: left !important" name="station_ok" id="3_<%=device%>/<%=ssid%>/<%=bssid%>"><%=ssid%></div> + <div class="td left" style="text-align: left !important" name="station_ok" id="4_<%=device%>/<%=ssid%>/<%=bssid%>"><%=bssid%></div> + <div class="td left" style="text-align: left !important" name="station_ok" id="5_<%=device%>/<%=ssid%>/<%=bssid%>"><%=encr%></div> <div class="td middle cbi-section-actions"> <div> <input class="cbi-button cbi-button-up" type="button" value="<%:Up%>" onclick="location.href='<%=luci.dispatcher.build_url('admin/services/travelmate/wifiorder')%>?cfg=<%=section%>&dir=up'" alt="<%:Move up%>" title="<%:Move up%>" /> 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 67568f179e..86846a5710 100644 --- a/applications/luci-app-travelmate/luasrc/view/travelmate/wifi_scan.htm +++ b/applications/luci-app-travelmate/luasrc/view/travelmate/wifi_scan.htm @@ -52,16 +52,16 @@ This is free software, licensed under the Apache License, Version 2.0 </div> <%- for i, net in ipairs(iw.scanlist or { }) do -%> <div class="tr cbi-section-table-row cbi-rowstyle-1"> - <div class="td left"> + <div class="td left" style="text-align: left !important"> <%=net.ssid and utl.pcdata(net.ssid) or "<em>%s</em>" % translate("hidden")%> </div> - <div class="td left"> + <div class="td left" style="text-align: left !important"> <%=net.bssid and utl.pcdata(net.bssid)%> </div> - <div class="td left"> + <div class="td left" style="text-align: left !important"> <%=format_wifi_encryption(net.encryption)%> </div> - <div class="td left"> + <div class="td left" style="text-align: left !important"> <%=percent_wifi_signal(net)%> % </div> <div class="td cbi-section-actions"> |