From ca8952c1a3f5107563020604585ada9f6b088860 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Mon, 22 Sep 2008 20:58:06 +0000 Subject: Rewrite of shorewall to use new libraries, ... Moved statusbasic to status, status to details, expert to listfiles. Changed check to not have a page. Used links for status, edit, startstop. Didn't change config, so it still doesn't work. git-svn-id: svn://svn.alpinelinux.org/acf/shorewall/trunk@1480 ab2d0c66-481e-0410-8bed-d214d4d58bed --- shorewall-controller.lua | 149 ++++++++++------------------------------------- 1 file changed, 32 insertions(+), 117 deletions(-) (limited to 'shorewall-controller.lua') diff --git a/shorewall-controller.lua b/shorewall-controller.lua index 967c4d6..da88e40 100644 --- a/shorewall-controller.lua +++ b/shorewall-controller.lua @@ -1,9 +1,7 @@ module(..., package.seeall) --- This is the object/text used when we want to add a new record - -require("format") - +require("controllerfunctions") +--[[ local newrecordtxt = "[New]" -- ################################################################################ @@ -18,12 +16,40 @@ local function displaycmdsave(self) }) return cmdsave end - +--]] -- ################################################################################ -- PUBLIC FUNCTIONS default_action = "status" +function status(self) + return self.model.getstatus() +end + +function details(self) + return self.model.getstatusdetails() +end + +function startstop(self) + return controllerfunctions.handle_startstop(self, self.model.startstop_service, self.model.getstatus, self.clientdata) +end + +function listfiles(self) + return self.model.getfilelist() +end + +function edit(self) + return controllerfunctions.handle_form(self, function() return self.model.getfiledetails(self.clientdata.filename) end, self.model.updatefiledetails, self.clientdata, "Save", "Edit File", "File Saved") +end + +function check(self) + return self:redirect_to_referrer(self.model.configcheck()) +end + +function logfile(self) + return self.model.getlogfile() +end +--[[ function editrecords(self,types,record,errormessage) local recorddetails = {} local edit = {} @@ -445,17 +471,6 @@ function editrecords(self,types,record,errormessage) } end -function status(self) - 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) -- If we made some changes to a recods... then proceed with the modification @@ -623,104 +638,4 @@ function config(self) configmessage=configmessage, } end - -function check(self) - - local config = self.model:configcheck() - - 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, - startstop = startstop, - debugclientdata = self.clientdata, - } - -end - -function logfile(self) - - local config = self.model:getlogfile() - - 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, - startstop = startstop, - debugclientdata = self.clientdata, - } - -end - -function expert(self) - 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 = 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, }) - cmdsaveresult, cmdsaveerror = self.model:updatefilecontent(filetochange) - self.clientdata.name = self.clientdata.filename - end - - local config = self.model:getfiledetails(cfe({ - name="editfile", - value=self.clientdata.name, - })) - - -- Display save button - config.cmdsave = displaycmdsave() - if (cmdsaveresult) then - config.cmdsave.descr="* Changes has been saved!" - redirect(self,"expert") - end - - return { - option={ script=self.conf.script, - prefix=self.conf.prefix, - controller = self.conf.controller, - action = "edit", - link = self.conf.script .. self.conf.prefix .. self.conf.controller, }, - modifications = modifications, - config = config, - 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 - +--]] -- cgit v1.2.3