summaryrefslogtreecommitdiffstats
path: root/syslog-controller.lua
diff options
context:
space:
mode:
Diffstat (limited to 'syslog-controller.lua')
-rw-r--r--syslog-controller.lua64
1 files changed, 7 insertions, 57 deletions
diff --git a/syslog-controller.lua b/syslog-controller.lua
index 12a7929..5bd65c4 100644
--- a/syslog-controller.lua
+++ b/syslog-controller.lua
@@ -1,75 +1,25 @@
module(..., package.seeall)
+require("controllerfunctions")
-default_action = "status"
+default_action = "loginfo"
-function status(self)
+function loginfo(self)
return self.model.getlogging()
end
function config(self)
- local config = self.model.getconfig()
- if self.clientdata.Save then
- for name,value in pairs(config.value) do
- if value.type == "boolean" then
- value.value = (self.clientdata[name] ~= nil)
- elseif clientdata[name] then
- value.value = clientdata[name]
- end
- end
- config = self.model.updateconfig(config)
- if not config.errtxt then
- config.descr = "Saved config"
- end
- end
-
- config.type = "form"
- config.label = "Edit config"
- config.option = "Save"
-
- return config
+ return controllerfunctions.handle_form(self, self.model.getconfig, self.model.updateconfig, self.clientdata, "Save", "Edit config", "Configuration Set")
end
function expert(self)
- -- Save changes
- local config = self.model.get_filedetails()
- if self.clientdata.Save then
- local modifications = self.clientdata.filecontent or ""
- local result = self.model.update_filecontent(modifications)
- if not result.value then
- config.value.filecontent.value = modifications
- config.value.filecontent.errtxt = result.errtxt
- config.errtxt = "Failed to save config!"
- else
- config = self.model.get_filedetails()
- config.descr = "Saved File"
- end
- end
-
- config.type = "form"
- config.label = "Edit config"
- config.option = "Save"
-
- return config
+ return controllerfunctions.handle_form(self, self.model.get_filedetails, self.model.update_filedetails, self.clientdata, "Save", "Edit config", "Configuration Set")
end
function startstop(self)
- local result
- if self.clientdata.action then
- result = self.model:startstop_service(self.clientdata.action)
- self.sessiondata.syslogstartstopresult = result
- self.redirect_to_referrer(self)
- end
-
- local status = self.model.getstatus()
- if self.sessiondata.syslogstartstopresult then
- result = self.sessiondata.syslogstartstopresult
- self.sessiondata.syslogstartstopresult = nil
- end
-
- return cfe({ type="group", value={status=status, result=result} })
+ return controllerfunctions.handle_startstop(self, self.model.startstop_service, self.model.getstatus, self.clientdata)
end
-function basicstatus(self)
+function status(self)
status = self.model.getstatus()
version = self.model.getversion()
return cfe({ type="group", value={status=status, version=version} })