diff options
author | Dirk Brenken <dev@brenken.org> | 2017-07-19 22:36:47 +0200 |
---|---|---|
committer | Dirk Brenken <dev@brenken.org> | 2017-07-20 07:44:15 +0200 |
commit | e900b892e871fcd0939df883e9586febe665c252 (patch) | |
tree | 50109c8e420961c8a019b6fc6702a63dd9b1e251 /applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_edit.lua | |
parent | 76b3af64c038905ddcc1c511b99c65e3c4879bbc (diff) |
luci-app-travelmate: sync with travelmate 0.9.0
* add a wireless station manager to edit and delete existing
interfaces or scan for new uplinks
Signed-off-by: Dirk Brenken <dev@brenken.org>
Diffstat (limited to 'applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_edit.lua')
-rw-r--r-- | applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_edit.lua | 49 |
1 files changed, 49 insertions, 0 deletions
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 new file mode 100644 index 000000000..0bae98460 --- /dev/null +++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_edit.lua @@ -0,0 +1,49 @@ +-- Copyright 2017 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") + +m = SimpleForm("edit", translate("Edit Wireless Uplink Configuration")) +m.cancel = translate("Back to overview") +m.reset = false + +function m.on_cancel() + http.redirect(luci.dispatcher.build_url("admin/services/travelmate/stations")) +end + +m.hidden = { + cfg = http.formvalue("cfg") +} + +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 + wkey.default = s.key + if s.encryption == "wep" then + wkey.datatype = "wepkey" + else + wkey.datatype = "wpakey" + end + end +else + http.redirect(luci.dispatcher.build_url("admin/services/travelmate/stations")) +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)) + end + uci:save("wireless") + uci:commit("wireless") + http.redirect(luci.dispatcher.build_url("admin/services/travelmate/stations")) +end + +return m |