luci-app-travelmate: sync with 0.9.2
[project/luci.git] / applications / luci-app-travelmate / luasrc / model / cbi / travelmate / wifi_edit.lua
index 0bae984..c60ff22 100644 (file)
@@ -6,6 +6,7 @@ local uci = require("luci.model.uci").cursor()
 local http = require("luci.http")
 
 m = SimpleForm("edit", translate("Edit Wireless Uplink Configuration"))
+m.submit = translate("Save")
 m.cancel = translate("Back to overview")
 m.reset = false
 
@@ -21,11 +22,15 @@ local s = uci:get_all("wireless", m.hidden.cfg)
 if s ~= nil then
        wssid = m:field(Value, "ssid", translate("SSID"))
        wssid.default = s.ssid
-       
+       wssid.datatype = "rangelength(1,32)"
        if s.encryption and s.key then
                wkey = m:field(Value, "key", translatef("Passphrase (%s)", s.encryption))
+       elseif s.encryption and s.password then
+               wkey = m:field(Value, "password", translatef("Passphrase (%s)", s.encryption))
+       end
+       if s.encryption and (s.key or s.password) then
                wkey.password = true
-               wkey.default = s.key
+               wkey.default = s.key or s.password
                if s.encryption == "wep" then
                        wkey.datatype = "wepkey"
                else
@@ -33,17 +38,19 @@ 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)
        uci:set("wireless", m.hidden.cfg, "ssid", wssid:formvalue(section))
        if s.encryption and s.key then
                uci:set("wireless", m.hidden.cfg, "key", wkey:formvalue(section))
+       elseif s.encryption and s.password then
+               uci:set("wireless", m.hidden.cfg, "password", wkey:formvalue(section))
        end
        uci:save("wireless")
        uci:commit("wireless")
-       http.redirect(luci.dispatcher.build_url("admin/services/travelmate/stations"))
+       m.on_cancel()
 end
 
 return m