summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2008-04-08 11:49:10 +0000
committerMika Havela <mika.havela@gmail.com>2008-04-08 11:49:10 +0000
commit448421b511b9630dadb0ebca5de29731d3c56ebf (patch)
tree6d45d3a06cd0f6967b1a81f7600d85b5dc50c625
parent5901c2a6bf7c6f17a32bc957772dda9ec456ed55 (diff)
downloadacf-quagga-448421b511b9630dadb0ebca5de29731d3c56ebf.tar.bz2
acf-quagga-448421b511b9630dadb0ebca5de29731d3c56ebf.tar.xz
Cleaning up the code even more.
Moving view-function from the view-files into a library instead. git-svn-id: svn://svn.alpinelinux.org/acf/quagga/trunk@953 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--quagga-controller.lua40
-rw-r--r--quagga-expert-html.lsp63
-rw-r--r--quagga-logfile-html.lsp35
-rw-r--r--quagga-status-html.lsp42
4 files changed, 44 insertions, 136 deletions
diff --git a/quagga-controller.lua b/quagga-controller.lua
index cb63668..fdaf6ad 100644
--- a/quagga-controller.lua
+++ b/quagga-controller.lua
@@ -15,13 +15,14 @@ local function list_redir(self)
error (self.conf)
end
-local function displaycmdmanagement(disablestart,disablestop,disablerestart)
+local function displaycmdmanagement(pidofstatus)
-- Add a management buttons
local management = {}
management.start = cfe({ name="cmdmanagement",
label="Program control-panel",
value="Start",
type="submit",
+ descr="When starting or restarting BGP, the web-page will freeze for some reason!",
})
management.stop = cfe({ name="cmdmanagement",
label="Program control-panel",
@@ -33,11 +34,20 @@ local function displaycmdmanagement(disablestart,disablestop,disablerestart)
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",
+ descr="", --Content of this variable is displayed as <PRE> ... </PRE> in BLACK text
+ errtxt="", --Content of this variable is displayed as <PRE> ... </PRE> in RED text
+ })
-- Disable management buttons based on if the process is running or not
- if (disablestart) then management.start.disabled = "yes" end
- if (disablestop) then management.stop.disabled = "yes" end
- if (disablerestart) then management.restart.disabled = "yes" end
+ if (pidofstatus) then
+ management.start.disabled = "yes"
+ else
+ management.stop.disabled = "yes"
+ management.restart.disabled = "yes"
+ end
return management
end
@@ -63,7 +73,7 @@ function expert(self)
local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller
-- Start/Stop/Restart process
- local cmdmanagement
+ local cmdmanagement, actionresult
if ( self.clientdata.cmdmanagement) then
cmdmanagement = cfe({
name="cmdmanagement",
@@ -73,7 +83,7 @@ function expert(self)
value=string.lower(self.clientdata.cmdmanagement), -- This row contains start/stop/restart (one of these commands)
}),
})
- local actionresult, cmdmanagement = self.model:startstop_service( cmdmanagement.action )
+ actionresult, cmdmanagement = self.model:startstop_service( cmdmanagement.action )
end
local status=self.model.getstatus()
@@ -90,24 +100,20 @@ function expert(self)
file.cmdsave.descr="* Changes has been saved!"
end
-
- -- Management buttons
- local disablestart,disablestop,disablerestart
- -- Disable management buttons based on if the process is running or not
- if (string.lower(status.status.value) == "enabled" ) then
- disablestart = "yes"
- else
- disablestop = "yes"
+ -- 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
- -- Display management buttons
- management = displaycmdmanagement(disablestart,disablestop,disablerestart)
return ( {
status = status,
file = file,
modifications = modifications,
management = management,
- cmdmanagement = cmdmanagement,
url = url, } )
end
diff --git a/quagga-expert-html.lsp b/quagga-expert-html.lsp
index 19bda27..3f1fedc 100644
--- a/quagga-expert-html.lsp
+++ b/quagga-expert-html.lsp
@@ -1,36 +1,6 @@
<? local form = ... ?>
<?
-function displayinfo(myform,tags,viewtype)
- for k,v in pairs(tags) do
- if (myform[v]) and (myform[v]["value"]) then
- local val = myform[v]
- io.write("\n\t<DT")
- if (#val.errtxt > 0) then
- val.class = "error"
- io.write(" class='error'")
- end
- io.write(">" .. val.label .. "</DT>")
- io.write("\n\t\t<DD>")
- if (viewtype == "viewonly") then
- io.write(val.value)
- elseif (val.type == "radio") and (type(val.option) == "table") and (#val.option > 0) then
- io.write("<span style='display:inline' class='" .. ( val.class or "") .. "'>")
- for k1,v1 in pairs(val.option) do
- io.write(tostring(v1.label) .. ":")
- io.write("<input style='margin-right:20px;margin-left:5px;' type='radio' class='" .. ( val.class or "") .. "' name='" .. val.name .. "'")
- if (tostring(val.value) == tostring(v1.value)) then io.write(" checked='yes'") end
- io.write(" value='" .. v1.value .. "'>")
- end
- io.write("</input></span>")
- else
- io.write(html.form[val.type](val))
- end
- if (val.descr) and (#val.descr > 0) then io.write("\n\t\t<P CLASS='descr'>" .. string.gsub(val.descr, "\n", "<BR>") .. "</P>") end
- if (#val.errtxt > 0) then io.write("\n\t\t<P CLASS='error'>" .. string.gsub(val.errtxt, "\n", "<BR>") .. "</P>") end
- io.write("\n\t\t</DD>\n")
- end
- end
-end
+require("viewfunctions")
?>
<H1>SYSTEM INFO</H1>
@@ -69,30 +39,15 @@ displayinfo(myform,tags)
?>
</DL>
-</form>
-<? -- MANAGEMENT BUTTONS
-local cmdform = form.management
-local cmdresult = form.cmdmanagement
+<H1>MANAGEMENT</H1>
+<DL>
+<?
+local myform = form.management
local tags = { "start", "stop", "restart" }
-if (cmdform) and (cmdform[tags[1]]) then
-
- io.write('<form name="management" action="" method="POST">')
- io.write('<H1>MANAGEMENT</H1>')
- io.write('<dl>')
- io.write('<dt>' .. cmdform[tags[1]]["label"] .. '</dt>')
- io.write('<dd>')
- for k,v in pairs(tags) do
- if (cmdform[v]) then
- io.write(html.form[cmdform[v].type](cmdform[v]))
- end
- end
- io.write('</dd>')
+displaymanagement(myform,tags)
+?>
+</DL>
- if (cmdresult) and (cmdresult.action) and (#cmdresult.action.descr > 0) then
- io.write('<dt>' .. cmdresult.label .. '</dt>')
- io.write('<dd><pre>' .. cmdresult.action.descr .. '</pre></dd>')
- end
- io.write('</dl></form>')
-end ?>
+</form>
diff --git a/quagga-logfile-html.lsp b/quagga-logfile-html.lsp
index 2d2b1b7..aa0b6e5 100644
--- a/quagga-logfile-html.lsp
+++ b/quagga-logfile-html.lsp
@@ -1,36 +1,6 @@
<? local form = ... ?>
<?
-function displayinfo(myform,tags,viewtype)
- for k,v in pairs(tags) do
- if (myform[v]) and (myform[v]["value"]) then
- local val = myform[v]
- io.write("\n\t<DT")
- if (#val.errtxt > 0) then
- val.class = "error"
- io.write(" class='error'")
- end
- io.write(">" .. val.label .. "</DT>")
- io.write("\n\t\t<DD>")
- if (viewtype == "viewonly") then
- io.write(val.value)
- elseif (val.type == "radio") and (type(val.option) == "table") and (#val.option > 0) then
- io.write("<span style='display:inline' class='" .. ( val.class or "") .. "'>")
- for k1,v1 in pairs(val.option) do
- io.write(tostring(v1.label) .. ":")
- io.write("<input style='margin-right:20px;margin-left:5px;' type='radio' class='" .. ( val.class or "") .. "' name='" .. val.name .. "'")
- if (tostring(val.value) == tostring(v1.value)) then io.write(" checked='yes'") end
- io.write(" value='" .. v1.value .. "'>")
- end
- io.write("</input></span>")
- else
- io.write(html.form[val.type](val))
- end
- if (val.descr) and (#val.descr > 0) then io.write("\n\t\t<P CLASS='descr'>" .. string.gsub(val.descr, "\n", "<BR>") .. "</P>") end
- if (#val.errtxt > 0) then io.write("\n\t\t<P CLASS='error'>" .. string.gsub(val.errtxt, "\n", "<BR>") .. "</P>") end
- io.write("\n\t\t</DD>\n")
- end
- end
-end
+require("viewfunctions")
?>
<H1>SYSTEM INFO</H1>
@@ -42,13 +12,12 @@ displayinfo(myform,tags,"viewonly")
?>
</DL>
-
-<? local myform = form.logfile ?>
<form name="myform" action="" method="POST">
<h1>LOGFILE</h1>
<h2>Details</h2>
<DL>
<?
+local myform = form.logfile
local tags = { "filename", "filesize", "mtime", "sumerrors", }
displayinfo(myform,tags,"viewonly")
?>
diff --git a/quagga-status-html.lsp b/quagga-status-html.lsp
index fb6172d..6b68a52 100644
--- a/quagga-status-html.lsp
+++ b/quagga-status-html.lsp
@@ -1,39 +1,8 @@
<? local form = ... ?>
<?
-function displayinfo(myform,tags,viewtype)
- for k,v in pairs(tags) do
- if (myform[v]) and (myform[v]["value"]) then
- local val = myform[v]
- io.write("\n\t<DT")
- if (#val.errtxt > 0) then
- val.class = "error"
- io.write(" class='error'")
- end
- io.write(">" .. val.label .. "</DT>")
- io.write("\n\t\t<DD>")
- if (viewtype == "viewonly") then
- io.write(val.value)
- elseif (val.type == "radio") and (type(val.option) == "table") and (#val.option > 0) then
- io.write("<span style='display:inline' class='" .. ( val.class or "") .. "'>")
- for k1,v1 in pairs(val.option) do
- io.write(tostring(v1.label) .. ":")
- io.write("<input style='margin-right:20px;margin-left:5px;' type='radio' class='" .. ( val.class or "") .. "' name='" .. val.name .. "'")
- if (tostring(val.value) == tostring(v1.value)) then io.write(" checked='yes'") end
- io.write(" value='" .. v1.value .. "'>")
- end
- io.write("</input></span>")
- else
- io.write(html.form[val.type](val))
- end
- if (val.descr) and (#val.descr > 0) then io.write("\n\t\t<P CLASS='descr'>" .. string.gsub(val.descr, "\n", "<BR>") .. "</P>") end
- if (#val.errtxt > 0) then io.write("\n\t\t<P CLASS='error'>" .. string.gsub(val.errtxt, "\n", "<BR>") .. "</P>") end
- io.write("\n\t\t</DD>\n")
- end
- end
-end
+require("viewfunctions")
?>
-
<H1>SYSTEM INFO</H1>
<DL>
<?
@@ -61,3 +30,12 @@ end
?>
</DL>
+
+<?
+--[[ DEBUG INFORMATION
+io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
+io.write(html.cfe_unpack(form))
+io.write("</span>")
+--]]
+?>
+