Hey, I have the following code:
function generate_page(m)
local state_str
state = send_message("query")
if state == "0" or state == "1" then
if state == "0" then
state_str = "Connected"
else
state_str = "Disconnected"
end
s = m:section(TypedSection, "amld_conf", "Daemon Status: " .. state_str)
local updown = s:option( Button, "_updown", translate("Start / Stop") )
if state == "0" then
updown._state = true
else
updown._state = false
end
function updown.cbid(self, section)
self.option = self._state and "stop" or "start"
return AbstractValue.cbid(self, section)
end
function updown.cfgvalue(self,section)
self.title = self._state and "stop" or "start"
self.inputstyle = self._state and "reset" or "reload"
end
function updown.write(self,section,value)
if self.option == "stop" then
reply = send_message("stop")
if reply == "0" then
--Error sending signal
s = m:section(TypedSection, "amld_conf", "Daemon Status: " .. "Error stopping daemon!")
elseif reply == "1" then
--Success sending signal
s = m:section(TypedSection, "amld_conf", "Daemon Status: " .. "Stopped daemon successfully!")
elseif reply == "2" then
--amld isnt running!
s = m:section(TypedSection, "amld_conf", "Daemon Status: " .. "Error: amld not running!")
end
else
args = build_run_time_args()
reply = send_message(args)
if reply == "0" then
--Program ended successfully
s = m:section(TypedSection, "amld_conf", "Daemon Status: " .. "Daemon started successfully!")
else
s = m:section(TypedSection, "amld_conf", "Daemon Status: " .. "Error starting daemon, error: " .. reply)
end
end
end
end
Which looks like this:
And after I click:
Does anybody know how to update a section instead of creating a new one?
Thanks!