gluon-luci-autoupdater: avoid use of CBI Maps

As convenient as the Map is, the underlying code is very complex and will
be removed.
This commit is contained in:
Matthias Schiffer 2017-01-25 22:37:27 +01:00
parent b5a3b9115b
commit 78d8645e19
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C

View File

@ -12,18 +12,35 @@ You may obtain a copy of the License at
$Id$ $Id$
]]-- ]]--
m = Map("autoupdater", translate("Automatic updates")) local uci = require("simple-uci").cursor()
m.pageaction = false local autoupdater = uci:get_first("autoupdater", "autoupdater")
m.template = "cbi/simpleform"
s = m:section(TypedSection, "autoupdater", nil) local f = SimpleForm("autoupdater", translate("Automatic updates"))
s.addremove = false local s = f:section(SimpleSection, nil, nil)
s.anonymous = true local o
s:option(Flag, "enabled", translate("Enable")) o = s:option(Flag, "enabled", translate("Enable"))
f = s:option(ListValue, "branch", translate("Branch")) o.default = uci:get_bool("autoupdater", autoupdater, "enabled") and o.enabled or o.disabled
o.rmempty = false
uci.cursor():foreach("autoupdater", "branch", function (section) f:value(section[".name"]) end) o = s:option(ListValue, "branch", translate("Branch"))
uci:foreach("autoupdater", "branch",
function (section)
o:value(section[".name"])
end
)
o.default = uci:get("autoupdater", autoupdater, "branch")
return m function f.handle(self, state, data)
if state ~= FORM_VALID then
return
end
uci:set("autoupdater", autoupdater, "enabled", data.enabled)
uci:set("autoupdater", autoupdater, "branch", data.branch)
uci:save("autoupdater")
uci:commit("autoupdater")
end
return f