X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;f=applications%2Fluci-app-travelmate%2Fluasrc%2Fmodel%2Fcbi%2Ftravelmate%2Fwifi_order.lua;h=6eb4c720632d24e118d85399777cc161024a0878;hb=f03bee5a91b09b81b4de9536d5dacdc670c7fb26;hp=d53e1f55e59c82d380f5be9d5011289f2675e6d5;hpb=7387bf619f7ad42b1047ee799649c1e1a96fadd4;p=project%2Fluci.git 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 d53e1f55e..6eb4c7206 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 @@ -8,44 +8,29 @@ local uci = require("luci.model.uci").cursor() local trmiface = uci:get("travelmate", "global", "trm_iface") or "trm_wwan" if cfg ~= nil then - local iface = "" 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) + local iface = s.network or "" + 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"))