summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-travelmate/luasrc/model/cbi/travelmate
diff options
context:
space:
mode:
authorDirk Brenken <dev@brenken.org>2017-08-03 17:04:58 +0200
committerDirk Brenken <dev@brenken.org>2017-08-03 17:04:58 +0200
commitb110746b982c68e6e27c693a37862827d65bec9f (patch)
treedb3f3dedc2d391c3d870cc96c12efee28bec7368 /applications/luci-app-travelmate/luasrc/model/cbi/travelmate
parent3909cf79dcee55c90dc3dd50af619fbb63290b65 (diff)
luci-app-travelmate: small bugfixes & optimizations
* various small bugfixes and optimizations Signed-off-by: Dirk Brenken <dev@brenken.org>
Diffstat (limited to 'applications/luci-app-travelmate/luasrc/model/cbi/travelmate')
-rw-r--r--applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_add.lua12
-rw-r--r--applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_delete.lua1
-rw-r--r--applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_edit.lua5
-rw-r--r--applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_order.lua50
4 files changed, 26 insertions, 42 deletions
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 979307e001..3f3f2348a7 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
@@ -18,7 +18,7 @@ m.hidden = {
device = http.formvalue("device"),
ssid = http.formvalue("ssid"),
wep = http.formvalue("wep"),
- wpa_suites = http.formvalue("wpa_suites"),
+ wpa_suites = http.formvalue("wpa_suites"),
wpa_version = http.formvalue("wpa_version")
}
@@ -45,11 +45,11 @@ end
function wssid.write(self, section, value)
newsection = uci:section("wireless", "wifi-iface", nil, {
- mode = "sta",
- network = trmiface,
- device = m.hidden.device,
- ssid = wssid:formvalue(section),
- disabled = "1"
+ mode = "sta",
+ network = trmiface,
+ device = m.hidden.device,
+ ssid = wssid:formvalue(section),
+ disabled = "1"
})
if (tonumber(m.hidden.wep) or 0) == 1 then
uci:set("wireless", newsection, "encryption", "wep-open")
diff --git a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_delete.lua b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_delete.lua
index 97ec1ca3ca..0c3cc1865b 100644
--- a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_delete.lua
+++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_delete.lua
@@ -10,5 +10,4 @@ if cfg ~= nil then
uci:save("wireless")
uci:commit("wireless")
end
-
http.redirect(luci.dispatcher.build_url("admin/services/travelmate/stations"))
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 0bae98460f..b0a77e4865 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
@@ -21,7 +21,6 @@ local s = uci:get_all("wireless", m.hidden.cfg)
if s ~= nil then
wssid = m:field(Value, "ssid", translate("SSID"))
wssid.default = s.ssid
-
if s.encryption and s.key then
wkey = m:field(Value, "key", translatef("Passphrase (%s)", s.encryption))
wkey.password = true
@@ -33,7 +32,7 @@ if s ~= nil then
end
end
else
- http.redirect(luci.dispatcher.build_url("admin/services/travelmate/stations"))
+ m.on_cancel()
end
function wssid.write(self, section, value)
@@ -43,7 +42,7 @@ function wssid.write(self, section, value)
end
uci:save("wireless")
uci:commit("wireless")
- http.redirect(luci.dispatcher.build_url("admin/services/travelmate/stations"))
+ m.on_cancel()
end
return m
diff --git a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_order.lua b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_order.lua
index d53e1f55e5..5b6141e52d 100644
--- a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_order.lua
+++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_order.lua
@@ -12,40 +12,26 @@ if cfg ~= nil then
local section = ""
local idx = ""
local idx_change = ""
- if dir == "up" then
- uci:foreach("wireless", "wifi-iface", function(s)
- iface = s.network
- 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
+ local changed = ""
+ uci:foreach("wireless", "wifi-iface", function(s)
+ iface = s.network
+ if iface == trmiface then
+ section = s['.name']
+ if cfg == section then
+ idx = s['.index']
+ else
+ idx_change = s['.index']
end
- end)
- elseif dir == "down" then
- uci:foreach("wireless", "wifi-iface", function(s)
- iface = s.network
- 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
+ if (dir == "up" and idx ~= "" and idx_change ~= "" and idx_change < idx) or
+ (dir == "down" and idx ~= "" and idx_change ~= "" and idx_change > idx) then
+ changed = uci:reorder("wireless", cfg, idx_change)
+ idx = ""
end
- end)
+ end
+ end)
+ if changed ~= "" then
+ uci:save("wireless")
+ uci:commit("wireless")
end
- uci:save("wireless")
- uci:commit("wireless")
end
http.redirect(luci.dispatcher.build_url("admin/services/travelmate/stations"))