Skip to content
Snippets Groups Projects
Unverified Commit 78d8645e authored by Matthias Schiffer's avatar Matthias Schiffer
Browse files

gluon-luci-autoupdater: avoid use of CBI Maps

As convenient as the Map is, the underlying code is very complex and will
be removed.
parent b5a3b911
No related branches found
No related tags found
No related merge requests found
......@@ -12,18 +12,35 @@ You may obtain a copy of the License at
$Id$
]]--
m = Map("autoupdater", translate("Automatic updates"))
m.pageaction = false
m.template = "cbi/simpleform"
s = m:section(TypedSection, "autoupdater", nil)
s.addremove = false
s.anonymous = true
s:option(Flag, "enabled", translate("Enable"))
f = s:option(ListValue, "branch", translate("Branch"))
uci.cursor():foreach("autoupdater", "branch", function (section) f:value(section[".name"]) end)
return m
local uci = require("simple-uci").cursor()
local autoupdater = uci:get_first("autoupdater", "autoupdater")
local f = SimpleForm("autoupdater", translate("Automatic updates"))
local s = f:section(SimpleSection, nil, nil)
local o
o = s:option(Flag, "enabled", translate("Enable"))
o.default = uci:get_bool("autoupdater", autoupdater, "enabled") and o.enabled or o.disabled
o.rmempty = false
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")
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment