summaryrefslogtreecommitdiffstats
path: root/lbu-controller.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lbu-controller.lua')
-rw-r--r--lbu-controller.lua85
1 files changed, 53 insertions, 32 deletions
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
--- <prefix>/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
-
+--]]