summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2008-04-07 13:56:10 +0000
committerMika Havela <mika.havela@gmail.com>2008-04-07 13:56:10 +0000
commitbfac3536373cdd298169019d80a0af7078ce37b9 (patch)
treedfed4d58668f781f51aa45bf119d4d0aab1e462a
parentc36119a8b48fc3a04a0189bdf76f61de7fab21aa (diff)
downloadacf-quagga-bfac3536373cdd298169019d80a0af7078ce37b9.tar.bz2
acf-quagga-bfac3536373cdd298169019d80a0af7078ce37b9.tar.xz
Added expert and logfile functionallity.
git-svn-id: svn://svn.alpinelinux.org/acf/quagga/trunk@951 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--Makefile4
-rw-r--r--quagga-controller.lua2
-rw-r--r--quagga-expert-html.lsp113
-rw-r--r--quagga-logfile-html.lsp78
-rw-r--r--quagga-model.lua1
-rw-r--r--quagga.menu4
6 files changed, 198 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index da669d4..05737da 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,13 @@
APP_NAME=quagga
PACKAGE=acf-$(APP_NAME)
-VERSION=0.1.2
+VERSION=0.2.0
APP_DIST=\
quagga-controller.lua \
quagga-model.lua \
quagga-status-html.lsp \
+ quagga-logfile-html.lsp \
+ quagga-expert-html.lsp \
quagga.menu \
diff --git a/quagga-controller.lua b/quagga-controller.lua
index ac216e7..8550fb5 100644
--- a/quagga-controller.lua
+++ b/quagga-controller.lua
@@ -98,7 +98,7 @@ expert = function (self)
end
-- Display management buttons
management = displaycmdmanagement(disablestart,disablestop,disablerestart)
-
+
return ( {
status = status,
file = file,
diff --git a/quagga-expert-html.lsp b/quagga-expert-html.lsp
new file mode 100644
index 0000000..cf70091
--- /dev/null
+++ b/quagga-expert-html.lsp
@@ -0,0 +1,113 @@
+<? local form = ... ?>
+<?
+--[[ 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>")
+--]]
+?>
+<?
+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
+?>
+
+<H1>SYSTEM INFO</H1>
+<DL>
+<?
+local myform = form.status
+local tags = { "status", "version", "autostart", }
+displayinfo(myform,tags,"viewonly")
+?>
+</DL>
+
+
+<form name="myform" action="" method="POST">
+<h1>CONFIGURATION</h1>
+<H2>Expert config</H2>
+<h3>File details</h3>
+<DL>
+<?
+local myform = form.file
+local tags = { "filename", "filesize", "mtime", "sumerrors", }
+displayinfo(myform,tags,"viewonly")
+?>
+</DL>
+
+<H3>FILE CONTENT</H3>
+<?
+local myform = form.file
+io.write(html.form[myform.filecontent.type](myform.filecontent))
+?>
+
+<H2>SAVE AND APPLY ABOVE SETTINGS</H2>
+<DL>
+<?
+local tags = { "cmdsave", }
+displayinfo(myform,tags)
+?>
+</DL>
+
+</form>
+
+<? -- MANAGEMENT BUTTONS
+local cmdform = form.management
+local cmdresult = form.cmdmanagement
+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>')
+
+ 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 ?>
+
+<?
+--[[ 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>")
+--]]
+?>
+
diff --git a/quagga-logfile-html.lsp b/quagga-logfile-html.lsp
new file mode 100644
index 0000000..6f8f8f7
--- /dev/null
+++ b/quagga-logfile-html.lsp
@@ -0,0 +1,78 @@
+<? local form = ... ?>
+
+<?
+--[[ 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>")
+--]]
+?>
+<?
+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
+?>
+
+<H1>SYSTEM INFO</H1>
+<DL>
+<?
+local myform = form.status
+local tags = { "status", "version", "autostart", }
+displayinfo(myform,tags,"viewonly")
+?>
+</DL>
+
+
+<? local myform = form.logfile ?>
+<form name="myform" action="" method="POST">
+<h1>LOGFILE</h1>
+<h2>Details</h2>
+<DL>
+<?
+local tags = { "filename", "filesize", "mtime", "sumerrors", }
+displayinfo(myform,tags,"viewonly")
+?>
+</DL>
+
+<H3>FILE CONTENT</H3>
+<?
+io.write(html.form[myform.filecontent.type](myform.filecontent))
+?>
+
+</form>
+
+<?
+--[[ 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>")
+--]]
+?>
diff --git a/quagga-model.lua b/quagga-model.lua
index 8153fa2..279a1a2 100644
--- a/quagga-model.lua
+++ b/quagga-model.lua
@@ -4,6 +4,7 @@ require("fs")
require("procps")
require("getopts")
require("format")
+require("posix")
require("daemoncontrol")
require("validator")
diff --git a/quagga.menu b/quagga.menu
index 57c49a0..d0d6b24 100644
--- a/quagga.menu
+++ b/quagga.menu
@@ -1,5 +1,5 @@
#CAT GROUP/DESC TAB ACTION
Networking 46BGP Status status
-#Networking 46BGP Expert expert
-#Networking 46BGP Logfile logfile
+Networking 46BGP Expert expert
+Networking 46BGP Logfile logfile