From 94d2fdb5e7dc424efa0409d2617d3241e4daaa35 Mon Sep 17 00:00:00 2001 From: Zach LeBar Date: Fri, 30 Mar 2012 20:54:16 +0000 Subject: Fixing acf-chrony to work with changes made to acf-core. Removing the use of controllerfunctions.lua and using the new 'handle_form()' found in acf_www-controller.lua. Also using 'handle_form()' in place of 'redirect_to_referrer()'. --- chrony-controller.lua | 12 +++++------- chrony-keyfile-html.lsp | 7 +++++-- chrony-model.lua | 34 +++++++++++++++++++++++----------- 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/chrony-controller.lua b/chrony-controller.lua index 5f135da..16962bb 100644 --- a/chrony-controller.lua +++ b/chrony-controller.lua @@ -1,7 +1,5 @@ module(..., package.seeall) -require("controllerfunctions") - default_action = "status" function status(self) @@ -13,21 +11,21 @@ function details(self) end function startstop(self) - return controllerfunctions.handle_startstop(self, self.model.startstop_service, self.clientdata) + return self.handle_form(self, self.model.get_startstop, self.model.startstop_service, self.clientdata) end function config(self) - return controllerfunctions.handle_form(self, self.model.get_config, self.model.update_config, self.clientdata, "Save", "Edit Config", "Configuration Set") + return self.handle_form(self, self.model.get_config, self.model.update_config, self.clientdata, "Save", "Edit Config", "Configuration Set") end function keyfile(self) - return controllerfunctions.handle_form(self, self.model.get_keyfiledetails, self.model.update_keyfiledetails, self.clientdata, "Save", "Edit Key File", "Key File Saved") + return self.handle_form(self, self.model.get_keyfiledetails, self.model.update_keyfiledetails, self.clientdata, "Save", "Edit Key File", "Key File Saved") end function enablekeyfile(self) - return self:redirect_to_referrer(self.model.enable_keyfile()) + return self.handle_form(self, self.model.get_enable_keyfile, self.model.enable_keyfile, self.clientdata, "Enable", "Enabled Key File", "Enabled key file") end function expert(self) - return controllerfunctions.handle_form(self, self.model.get_filedetails, self.model.update_filedetails, self.clientdata, "Save", "Edit Config File", "Configuration Set") + return self.handle_form(self, self.model.get_filedetails, self.model.update_filedetails, self.clientdata, "Save", "Edit Config File", "Configuration Set") end diff --git a/chrony-keyfile-html.lsp b/chrony-keyfile-html.lsp index 50420b6..b90ee14 100644 --- a/chrony-keyfile-html.lsp +++ b/chrony-keyfile-html.lsp @@ -7,9 +7,12 @@
<% displayitem(form.value.status) - if form.value.status.errtxt then %> + if form.value.status.errtxt then + +%>
"> -
+ + <% end %>
diff --git a/chrony-model.lua b/chrony-model.lua index 84b9aaa..3f3f9ed 100644 --- a/chrony-model.lua +++ b/chrony-model.lua @@ -2,9 +2,10 @@ module(..., package.seeall) -- Load libraries require("modelfunctions") -require("format") -require("fs") -require("validator") +format = require("acf.format") +fs = require("acf.fs") +validator = require("acf.validator") +processinfo = require("acf.processinfo") -- Set variables local configfile = "/etc/chrony/chrony.conf" @@ -66,7 +67,15 @@ end -- ################################################################################ -- PUBLIC FUNCTIONS -function startstop_service(action) +function get_startstop(clientdata) + return modelfunctions.get_startstop(processname) +end + +function startstop_service(startstop, action) + return modelfunctions.startstop_service(startstop, action) +end + +function old_startstop_service(action) local result = modelfunctions.startstop_service(processname, action) table.insert(result.value.actions.value, "Online") table.insert(result.value.actions.value, "Offline") @@ -211,22 +220,25 @@ function update_keyfiledetails(filedetails) return get_keyfilestatus(modelfunctions.setfiledetails(filedetails, {keyfile})) end -function enable_keyfile() - local result = cfe({ value="Enabled key file", label="Enable Key file result" }) +function get_enable_keyfile() + local result = {} + return cfe({ type="group", value=result, label="Enable Key File" }) +end + +function enable_keyfile(enablerequest) local config = get_config() config.value.keyfile.value = keyfile config = update_config(config) if config.errtxt then - result.value = "" - result.errtxt = {config.errtxt} + enablerequest.errtxt = {config.errtxt} for name,val in pairs(config.value) do if val.errtxt then - table.insert(result.errtxt, name.." - "..val.errtxt) + table.insert(enablerequest.errtxt, name.." - "..val.errtxt) end end - result.errtxt = table.concat(result.errtxt, "\n") + enablerequest.errtxt = table.concat(enablerequest.errtxt, "\n") end - return result + return enablerequest end function get_filedetails() -- cgit v1.2.3