module(..., package.seeall) local list_redir = function (self) self.conf.action = "status" self.conf.type = "redir" error (self.conf) end mvc = {} mvc.on_load = function(self, parent) if (self.worker[self.conf.action] == nil ) or ( self.conf.action == "init" ) then self.worker[self.conf.action] = list_redir(self) end end function status(self) return { status=self.model.getstatus() } end function config(self) if ( self.clientdata.cmddaemon) then startstop = self.model:startstop_service( self.clientdata.cmddaemon ) end local status = self.model.getstatus() local config, errors = self.model.getconfig() local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller return { status = status, startstop = startstop, config = config, errors = errors, url = url, } end function expert(self) local modifications = self.clientdata.modifications or "" if ( self.clientdata.cmdsave) then modifications = self.model:update_filecontent(modifications) end if ( self.clientdata.cmddaemon) then startstop = self.model:startstop_service( self.clientdata.cmddaemon ) end local status = self.model.getstatus() local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller return { file = self.model:get_filedetails(), status = status, startstop = startstop, clientdata = self.clientdata, url = url, } end