diff options
author | Mika Havela <mika.havela@gmail.com> | 2008-05-15 15:12:42 +0000 |
---|---|---|
committer | Mika Havela <mika.havela@gmail.com> | 2008-05-15 15:12:42 +0000 |
commit | a3965b138f8c37b32cc28889250d55e20124983f (patch) | |
tree | 158a140cab494c92f9a03f3fa953b45465a3ce14 /shorewall-controller.lua | |
parent | 2019d21baffd94e03608d28eba103150fb1ba1cd (diff) | |
download | acf-shorewall-a3965b138f8c37b32cc28889250d55e20124983f.tar.bz2 acf-shorewall-a3965b138f8c37b32cc28889250d55e20124983f.tar.xz |
Saving work for today.
Applying the component functionallity to acf-shorewall.
Cleaning up and rebuilding the view-files.
git-svn-id: svn://svn.alpinelinux.org/acf/shorewall/trunk@1121 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'shorewall-controller.lua')
-rw-r--r-- | shorewall-controller.lua | 99 |
1 files changed, 29 insertions, 70 deletions
diff --git a/shorewall-controller.lua b/shorewall-controller.lua index bfa680b..967c4d6 100644 --- a/shorewall-controller.lua +++ b/shorewall-controller.lua @@ -9,35 +9,6 @@ local newrecordtxt = "[New]" -- ################################################################################ -- LOCAL FUNCTIONS -local function displaycmdmanagement(pidofstatus) - -- Add a management buttons - local management = {} ---[[ - management.start = cfe({ name="cmdmanagement", - label="Program control-panel", - value="Start", - type="submit", - }) - management.stop = cfe({ name="cmdmanagement", - label="Program control-panel", - value="Stop", - type="submit", - }) ---]] - management.restart = cfe({ name="cmdmanagement", - label="Program control-panel", - value="Restart", - type="submit", - }) - -- next CFE can be used to present the result of the previous action - management.actionresult = cfe({ name="actionresult", - label="Previous action result", - }) - - return management -end - - local function displaycmdsave(self) -- Add a cmd button to the view local cmdsave = cfe({ name="cmdsave", @@ -475,7 +446,14 @@ function editrecords(self,types,record,errormessage) end function status(self) - return { status=self.model.getstatus() } + return { status=self.model.getstatusdetails() } +end +function statusbasic(self) + return { + status=self.model.getstatus(), + version=self.model.getversion(), + autostart=self.model.getautostart(), + } end function config(self) @@ -521,7 +499,6 @@ function config(self) end local config=self.model:getconfig() - local status=self.model.getstatus() -- Add a [New] record to the options table.insert(config.params.option, newrecordtxt) @@ -635,7 +612,6 @@ function config(self) end return { - status=status, config=config, option={ script=self.conf.script, prefix=self.conf.prefix, @@ -649,41 +625,16 @@ function config(self) end function check(self) - -- Start/Stop/Restart process - local cmdmanagement, actionresult - if ( self.clientdata.cmdmanagement) then - cmdmanagement = cfe({ - name="cmdmanagement", - label="Previous action result", - action=cfe({ - name="cmdmanagement", - value=string.lower(self.clientdata.cmdmanagement), -- This row contains start/stop/restart (one of these commands) - }), - }) - actionresult, cmdmanagement = self.model:startstop_service( cmdmanagement.action ) - end - local status = self.model.getstatus() local config = self.model:configcheck() - -- Management buttons (Hide/show buttons - local pidofstatus - if (string.lower(status.status.value) == "enabled" ) then pidofstatus = true end - management = displaycmdmanagement(pidofstatus) - if (actionresult) then - management.actionresult.descr=cmdmanagement.descr - management.actionresult.errtxt=cmdmanagement.errtxt - end - return { option={ script=self.conf.script, prefix=self.conf.prefix, controller = self.conf.controller, action = "expert", link = self.conf.script .. self.conf.prefix .. self.conf.controller, }, - management = management, config = config, - status = status, startstop = startstop, debugclientdata = self.clientdata, } @@ -692,7 +643,6 @@ end function logfile(self) - local status = self.model.getstatus() local config = self.model:getlogfile() return { @@ -702,7 +652,6 @@ function logfile(self) action = "expert", link = self.conf.script .. self.conf.prefix .. self.conf.controller, }, config = config, - status = status, startstop = startstop, debugclientdata = self.clientdata, } @@ -710,34 +659,28 @@ function logfile(self) end function expert(self) - - local status = self.model.getstatus() - local config = self.model:getfilelist() - return { option={ script=self.conf.script, prefix=self.conf.prefix, controller = self.conf.controller, action = "expert", link = self.conf.script .. self.conf.prefix .. self.conf.controller, }, - config = config, - status = status, + config = self.model:getfilelist(), startstop = startstop, debugclientdata = self.clientdata, } - end function edit(self) -- Save changes + local cmdsaveresult, cmdsaveerror if ( self.clientdata.cmdsave) then local filetochange = cfe ({ name=self.clientdata.filename, value=self.clientdata.filecontent, }) - modifications = self.model:updatefilecontent(filetochange) + cmdsaveresult, cmdsaveerror = self.model:updatefilecontent(filetochange) self.clientdata.name = self.clientdata.filename end - local status = self.model.getstatus() local config = self.model:getfiledetails(cfe({ name="editfile", value=self.clientdata.name, @@ -745,8 +688,9 @@ function edit(self) -- Display save button config.cmdsave = displaycmdsave() - if (self.clientdata.cmdsave) then + if (cmdsaveresult) then config.cmdsave.descr="* Changes has been saved!" + redirect(self,"expert") end return { @@ -757,11 +701,26 @@ function edit(self) link = self.conf.script .. self.conf.prefix .. self.conf.controller, }, modifications = modifications, config = config, - status = status, startstop = startstop, debugclientdata = self.clientdata, } 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} }) +end |