summaryrefslogtreecommitdiffstats
path: root/interfaces-read-html.lsp
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2008-03-28 11:44:58 +0000
committerMika Havela <mika.havela@gmail.com>2008-03-28 11:44:58 +0000
commit70b28419e50d7947ab1220517e5c3495aca73a93 (patch)
treeda6e5122d68befca005f27b4dff04af7911bf870 /interfaces-read-html.lsp
parentc2af45dbef7d1cd8036bb6f94e03649bd2e9b786 (diff)
downloadacf-alpine-baselayout-70b28419e50d7947ab1220517e5c3495aca73a93.tar.bz2
acf-alpine-baselayout-70b28419e50d7947ab1220517e5c3495aca73a93.tar.xz
Cleaned up 'read' tab so it only allows read (no edit actions).
git-svn-id: svn://svn.alpinelinux.org/acf/alpine-baselayout/trunk@856 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'interfaces-read-html.lsp')
-rw-r--r--interfaces-read-html.lsp116
1 files changed, 74 insertions, 42 deletions
diff --git a/interfaces-read-html.lsp b/interfaces-read-html.lsp
index e3a13e9..8400151 100644
--- a/interfaces-read-html.lsp
+++ b/interfaces-read-html.lsp
@@ -1,45 +1,77 @@
-<? local view = ... ?>
-
-<h1>Interfaces file</h1>
-
-<h2>New interface</h2>
-<dl>
-<dt>Create new interface</dt>
-<dd>[<a href="create?iface=">Create</a>]</dd>
-</dl>
-
-<h2>Existing interface(s)</h2>
-
-<? for i=0,table.maxn(view.iface) do
- local iface=""
- if i > 0 then do
- j = view.iface[i]
- iface = j.name.value ?>
-<h3><?= j.name.value ?></h3>
-<dl>
-<dt>Method</dt>
-<dd><?= j.method.value ?></dd>
-<? if ( j.method.value == "dhcp" ) then ?>
- <dt>Hostname</dt>
- <dd><?= j.address.value ?></dd>
-<? elseif ( j.address.value ~= "" ) then?>
- <dt>Address</dt>
- <dd><?= j.address.value ?>/<?= j.netmask.value ?></dd>
-<? end ?>
-<? if (j.comment.value ~= "") then ?>
- <dt>Comments</dt>
- <dd><?= j.comment.value ?></dd>
-<? end ?>
-
-<? local val = {value="update", type="submit", option="", errtxt=""}?>
-
-<dt>Modify this interface</dt>
-<dd>[<a href="<?= view.actions.link .. "update?iface=" .. j.name.value ?>">update</a>]
-[<a href="<?= view.actions.link .. "delete?iface=" .. j.name.value ?>">delete</a>]</dd>
-</dl>
-<? end ?>
-<? end ?>
-<? end ?>
+<? 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,viewonly)
+ for k,v in pairs(tags) do
+ if (myform[v]) and (myform[v]["value"]) then
+ local val = myform[v]
+ io.write("\t<DT")
+ if (#val.errtxt > 0) then
+ val.class = "error"
+ io.write(" class='error'")
+ end
+ io.write(">" .. val.label .. "</DT>\n")
+ if (viewonly) then
+ io.write("\t\t<DD>" .. val.value .. "\n")
+ else
+ io.write("\t\t<DD>" .. html.form[val.type](val) .. "\n")
+ end
+ if (val.descr) and (#val.descr > 0) then io.write("\t\t<P CLASS='descr'>" .. string.gsub(val.descr, "\n", "<BR>") .. "</P>\n") end
+ if (#val.errtxt > 0) then io.write("\t\t<P CLASS='error'>" .. string.gsub(val.errtxt, "\n", "<BR>") .. "</P>\n") end
+ io.write("\t\t</DD>\n")
+ end
+ end
+end
+?>
+
+<H1>SYSTEM INFO</H1>
+<DL>
+<?
+local myform = form.status
+local tags = { "interfacesfile" }
+displayinfo(myform,tags,"viewonly")
+?>
+</DL>
+
+<H2>Configurations</H2>
+<DL>
+<?
+local myform = form.iface
+io.write("<DT>Configured interfaces</DT><DD>")
+for k,v in pairs(myform) do
+ local myform=v
+ if (myform.name.value ~= "") then
+ io.write("<TABLE STYLE='margin-bottom:10px'>")
+ io.write("<TR><TD COLSPAN=2 STYLE='font-weight:bold;'><IMG SRC='/static/tango/16x16/devices/network-wired.png' width='16' height='16'> " .. (myform.name.value or '') .. "</TD></TR>")
+
+ local tags = {"method", "address", "netmask", "gateway", "provider", "hostname", "pre-up", "up", "down", "post-down", "comment", }
+ for k1,v1 in pairs(tags) do
+ if (myform[v1]['value'] ~= "") then
+ io.write("<TR><TD WIDTH='120px' STYLE='font-weight:bold;padding-left:25px;'>" .. myform[v1]['label'] .. "</TD>")
+ io.write("<TD>" .. string.gsub(myform[v1]['value'], "\n", "<BR>") .. "</TD></TR>")
+ end
+ end
+ io.write("</TABLE>")
+ end
+
+end
+io.write("</DD>")
+?>
+</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>")
+--]]
+?>