From 773a0952af828389e84c4cc94f1bff15e4f7f09b Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Wed, 16 Jan 2008 17:01:00 +0000 Subject: Moving around things in LBU to get a grip on how it could look and work git-svn-id: svn://svn.alpinelinux.org/acf/lbu/trunk@592 ab2d0c66-481e-0410-8bed-d214d4d58bed --- lbu-controller.lua | 85 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 32 deletions(-) (limited to 'lbu-controller.lua') diff --git a/lbu-controller.lua b/lbu-controller.lua index 51a0538..079bf4c 100644 --- a/lbu-controller.lua +++ b/lbu-controller.lua @@ -1,7 +1,7 @@ module(..., package.seeall) local list_redir = function(self) - self.conf.action = "read" + self.conf.action = "status" self.conf.type = "redir" error(self.conf) end @@ -16,9 +16,52 @@ mvc.on_load = function(self, parent) end end --- Public methods --- /hostname/get +status = function (self) + local cmd = self.clientdata.cmd + local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller + return ( {status = self.model:getstatus(), + lbustatus = self.model:list(), + url = url, } ) +end + +config = function (self) + local cmd = self.clientdata.cmd + local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller + return ( {status = self.model:getstatus(), url = url } ) +end + +-- ################################################################################ +-- OLD FUNCTIONS + +--[[ +function commit(self) + local ret = { + script=ENV["SCRIPT_NAME"], + prefix=self.conf.prefix, + controller = self.conf.controller, + action="commit", + data={}, + title="LBU", + text={}, + } + if self.clientdata.commit then + local result, report = self.model:commit() + local label = result and "Report" or "Error" + ret.text[#ret.text + 1] = { label=label, content=report } + else + for i,v in ipairs(self.model:list(nil)) do + ret.data[#ret.data + 1] = { + status = v.status, + name = v.name, + } + end + end + ret.note=getNotes(self) + return ret +end +--]] +--[[ local function getNotes(self) ret = {} for k,v in pairs(cfgfile.model:list(nil)) do @@ -31,8 +74,9 @@ local function getNotes(self) end return ret end - -read = function(self) +--]] +--[[ +xxxstatus = function(self) return { list=cfgfile.model:list(function(x) return x.app == "lbu" end), script=ENV["SCRIPT_NAME"], @@ -43,6 +87,9 @@ read = function(self) } end +--]] + +--[[ update = function(self) local id = tonumber(self.clientdata.id) or -1 local result @@ -70,30 +117,4 @@ update = function(self) extra = ""}, value = data} end - -function commit(self) - local ret = { - script=ENV["SCRIPT_NAME"], - prefix=self.conf.prefix, - controller = self.conf.controller, - action="commit", - data={}, - title="LBU", - text={}, - } - if self.clientdata.commit then - local result, report = self.model:commit() - local label = result and "Report" or "Error" - ret.text[#ret.text + 1] = { label=label, content=report } - else - for i,v in ipairs(self.model:list(nil)) do - ret.data[#ret.data + 1] = { - status = v.status, - name = v.name, - } - end - end - ret.note=getNotes(self) - return ret -end - +--]] -- cgit v1.2.3