admin-full: Better fix for the last change (timeserver setup), add button to add the missing section
This commit is contained in:
parent
a196198fb9
commit
525da459d7
1 changed files with 53 additions and 37 deletions
|
@ -154,13 +154,16 @@ end
|
||||||
--
|
--
|
||||||
|
|
||||||
if has_ntpd then
|
if has_ntpd then
|
||||||
s = m:section(TypedSection, "timeserver", translate("Time Synchronization"))
|
|
||||||
s.anonymous = true
|
|
||||||
s.addremove = false
|
|
||||||
|
|
||||||
function m.on_parse()
|
-- timeserver setup was requested, create section and reload page
|
||||||
|
if m:formvalue("cbid.system._timeserver._enable") then
|
||||||
|
m.uci:section("system", "timeserver", "ntp")
|
||||||
|
m.uci:save("system")
|
||||||
|
luci.http.redirect(luci.dispatcher.build_url("admin/system", arg[1]))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local has_section = false
|
local has_section = false
|
||||||
|
|
||||||
m.uci:foreach("system", "timeserver",
|
m.uci:foreach("system", "timeserver",
|
||||||
function(s)
|
function(s)
|
||||||
has_section = true
|
has_section = true
|
||||||
|
@ -168,9 +171,21 @@ if has_ntpd then
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if not has_section then
|
if not has_section then
|
||||||
m.uci:section("system", "timeserver", "ntp")
|
|
||||||
end
|
s = m:section(TypedSection, "timeserver", translate("Time Synchronization"))
|
||||||
end
|
s.anonymous = true
|
||||||
|
s.cfgsections = function() return { "_timeserver" } end
|
||||||
|
|
||||||
|
x = s:option(Button, "_enable")
|
||||||
|
x.title = translate("Time Synchronization is not configured yet.")
|
||||||
|
x.inputtitle = translate("Setup Time Synchronization")
|
||||||
|
x.inputstyle = "apply"
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
s = m:section(TypedSection, "timeserver", translate("Time Synchronization"))
|
||||||
|
s.anonymous = true
|
||||||
|
s.addremove = false
|
||||||
|
|
||||||
o = s:option(Flag, "enable", translate("Enable builtin NTP server"))
|
o = s:option(Flag, "enable", translate("Enable builtin NTP server"))
|
||||||
o.rmempty = false
|
o.rmempty = false
|
||||||
|
@ -197,7 +212,8 @@ if has_ntpd then
|
||||||
|
|
||||||
-- retain server list even if disabled
|
-- retain server list even if disabled
|
||||||
function o.remove() end
|
function o.remove() end
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
|
Loading…
Reference in a new issue