Merge pull request #1275 from dibdot/travelmate
luci-app-travelmate: small bugfixes & optimizations
This commit is contained in:
commit
efb7e5f365
5 changed files with 27 additions and 43 deletions
|
@ -18,7 +18,7 @@ m.hidden = {
|
||||||
device = http.formvalue("device"),
|
device = http.formvalue("device"),
|
||||||
ssid = http.formvalue("ssid"),
|
ssid = http.formvalue("ssid"),
|
||||||
wep = http.formvalue("wep"),
|
wep = http.formvalue("wep"),
|
||||||
wpa_suites = http.formvalue("wpa_suites"),
|
wpa_suites = http.formvalue("wpa_suites"),
|
||||||
wpa_version = http.formvalue("wpa_version")
|
wpa_version = http.formvalue("wpa_version")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,11 +45,11 @@ end
|
||||||
|
|
||||||
function wssid.write(self, section, value)
|
function wssid.write(self, section, value)
|
||||||
newsection = uci:section("wireless", "wifi-iface", nil, {
|
newsection = uci:section("wireless", "wifi-iface", nil, {
|
||||||
mode = "sta",
|
mode = "sta",
|
||||||
network = trmiface,
|
network = trmiface,
|
||||||
device = m.hidden.device,
|
device = m.hidden.device,
|
||||||
ssid = wssid:formvalue(section),
|
ssid = wssid:formvalue(section),
|
||||||
disabled = "1"
|
disabled = "1"
|
||||||
})
|
})
|
||||||
if (tonumber(m.hidden.wep) or 0) == 1 then
|
if (tonumber(m.hidden.wep) or 0) == 1 then
|
||||||
uci:set("wireless", newsection, "encryption", "wep-open")
|
uci:set("wireless", newsection, "encryption", "wep-open")
|
||||||
|
|
|
@ -10,5 +10,4 @@ if cfg ~= nil then
|
||||||
uci:save("wireless")
|
uci:save("wireless")
|
||||||
uci:commit("wireless")
|
uci:commit("wireless")
|
||||||
end
|
end
|
||||||
|
|
||||||
http.redirect(luci.dispatcher.build_url("admin/services/travelmate/stations"))
|
http.redirect(luci.dispatcher.build_url("admin/services/travelmate/stations"))
|
||||||
|
|
|
@ -21,7 +21,6 @@ local s = uci:get_all("wireless", m.hidden.cfg)
|
||||||
if s ~= nil then
|
if s ~= nil then
|
||||||
wssid = m:field(Value, "ssid", translate("SSID"))
|
wssid = m:field(Value, "ssid", translate("SSID"))
|
||||||
wssid.default = s.ssid
|
wssid.default = s.ssid
|
||||||
|
|
||||||
if s.encryption and s.key then
|
if s.encryption and s.key then
|
||||||
wkey = m:field(Value, "key", translatef("Passphrase (%s)", s.encryption))
|
wkey = m:field(Value, "key", translatef("Passphrase (%s)", s.encryption))
|
||||||
wkey.password = true
|
wkey.password = true
|
||||||
|
@ -33,7 +32,7 @@ if s ~= nil then
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
http.redirect(luci.dispatcher.build_url("admin/services/travelmate/stations"))
|
m.on_cancel()
|
||||||
end
|
end
|
||||||
|
|
||||||
function wssid.write(self, section, value)
|
function wssid.write(self, section, value)
|
||||||
|
@ -43,7 +42,7 @@ function wssid.write(self, section, value)
|
||||||
end
|
end
|
||||||
uci:save("wireless")
|
uci:save("wireless")
|
||||||
uci:commit("wireless")
|
uci:commit("wireless")
|
||||||
http.redirect(luci.dispatcher.build_url("admin/services/travelmate/stations"))
|
m.on_cancel()
|
||||||
end
|
end
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
|
|
@ -12,40 +12,26 @@ if cfg ~= nil then
|
||||||
local section = ""
|
local section = ""
|
||||||
local idx = ""
|
local idx = ""
|
||||||
local idx_change = ""
|
local idx_change = ""
|
||||||
if dir == "up" then
|
local changed = ""
|
||||||
uci:foreach("wireless", "wifi-iface", function(s)
|
uci:foreach("wireless", "wifi-iface", function(s)
|
||||||
iface = s.network
|
iface = s.network
|
||||||
if iface == trmiface then
|
if iface == trmiface then
|
||||||
section = s['.name']
|
section = s['.name']
|
||||||
if cfg == section then
|
if cfg == section then
|
||||||
idx = s['.index']
|
idx = s['.index']
|
||||||
else
|
else
|
||||||
idx_change = s['.index']
|
idx_change = s['.index']
|
||||||
end
|
|
||||||
if idx ~= "" and idx_change ~= "" and idx_change < idx then
|
|
||||||
uci:reorder("wireless", cfg, idx_change)
|
|
||||||
idx = ""
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end)
|
if (dir == "up" and idx ~= "" and idx_change ~= "" and idx_change < idx) or
|
||||||
elseif dir == "down" then
|
(dir == "down" and idx ~= "" and idx_change ~= "" and idx_change > idx) then
|
||||||
uci:foreach("wireless", "wifi-iface", function(s)
|
changed = uci:reorder("wireless", cfg, idx_change)
|
||||||
iface = s.network
|
idx = ""
|
||||||
if iface == trmiface then
|
|
||||||
section = s['.name']
|
|
||||||
if cfg == section then
|
|
||||||
idx = s['.index']
|
|
||||||
else
|
|
||||||
idx_change = s['.index']
|
|
||||||
end
|
|
||||||
if idx ~= "" and idx_change ~= "" and idx_change > idx then
|
|
||||||
uci:reorder("wireless", cfg, idx_change)
|
|
||||||
idx = ""
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end)
|
end
|
||||||
|
end)
|
||||||
|
if changed ~= "" then
|
||||||
|
uci:save("wireless")
|
||||||
|
uci:commit("wireless")
|
||||||
end
|
end
|
||||||
uci:save("wireless")
|
|
||||||
uci:commit("wireless")
|
|
||||||
end
|
end
|
||||||
http.redirect(luci.dispatcher.build_url("admin/services/travelmate/stations"))
|
http.redirect(luci.dispatcher.build_url("admin/services/travelmate/stations"))
|
||||||
|
|
|
@ -53,7 +53,7 @@ This is free software, licensed under the Apache License, Version 2.0
|
||||||
<input type="button" class="cbi-button cbi-button-remove" onclick="location.href='<%=url('admin/services/travelmate/wifidelete')%>?cfg=<%=section%>'" title="<%:Delete this Uplink%>" value="<%:Delete%>"/>
|
<input type="button" class="cbi-button cbi-button-remove" onclick="location.href='<%=url('admin/services/travelmate/wifidelete')%>?cfg=<%=section%>'" title="<%:Delete this Uplink%>" value="<%:Delete%>"/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<%
|
<%
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
%>
|
%>
|
||||||
|
|
Loading…
Reference in a new issue