diff options
author | Ted Trask <ttrask01@yahoo.com> | 2014-03-08 23:49:47 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2014-03-08 23:49:47 +0000 |
commit | 4c0e9b17d5bbcfb7e7a704c6a57af2cfe327c308 (patch) | |
tree | e7cc751f7ec4e48c12d2d3aa2c7beb062f9b66cd | |
parent | cecb1d586d237c74cd9ef6d05e305726a3072ad0 (diff) | |
download | acf-alpine-baselayout-4c0e9b17d5bbcfb7e7a704c6a57af2cfe327c308.tar.bz2 acf-alpine-baselayout-4c0e9b17d5bbcfb7e7a704c6a57af2cfe327c308.tar.xz |
Modified HTML views to use new htmlviewfunctions functions and replace links with forms created by displayitem
Use htmlviewfunctions.displayheader .incrementheader .displayitemstart/middle/end
-rw-r--r-- | cron-listjobs-html.lsp | 30 | ||||
-rw-r--r-- | health-networkstats-html.lsp | 14 | ||||
-rw-r--r-- | interfaces-read-html.lsp | 36 | ||||
-rw-r--r-- | interfaces-update-html.lsp | 4 | ||||
-rw-r--r-- | logfiles-status-html.lsp | 15 | ||||
-rw-r--r-- | logfiles-tail-html.lsp | 7 | ||||
-rw-r--r-- | rc-status-html.lsp | 12 |
7 files changed, 56 insertions, 62 deletions
diff --git a/cron-listjobs-html.lsp b/cron-listjobs-html.lsp index b9759d3..bc7564e 100644 --- a/cron-listjobs-html.lsp +++ b/cron-listjobs-html.lsp @@ -31,26 +31,14 @@ viewlibrary.dispatch_component("status") end %> -<% -- set up the form for the move action -local formstart = '<form action="'..html.html_escape(page_info.script .. page_info.prefix .. page_info.controller .. "/movejob")..'" method="POST">' -formstart = formstart .. '<input type="hidden" name="name" value="' -local formend = '">\n<select name="period" style="width:150px">' -for i,tabl in ipairs(view.value) do - if i == 1 then - formend = formend .. '<option selected value="'..tabl.period..'">'..tabl.period..'</option>' - else - formend = formend .. '<option value="'..tabl.period..'">'..tabl.period..'</option>' - end -end -formend = formend .. '</select>\n<input class="submit" type="submit" name="submit" value="Move"></form>' -local function createmoveform(name) - io.write(formstart, name, formend) -end -%> - <% local header_level = htmlviewfunctions.displayheader(view, page_info) header_level = htmlviewfunctions.incrementheader(header_level) +local redir = cfe({type="hidden", value=page_info.orig_action}) +local period = cfe({type="select", option={}}) +for i,tabl in ipairs(view.value) do + period.option[#period.option+1] = tabl.period +end %> <% for i,tabl in ipairs(view.value) do %> <% htmlviewfunctions.displayheader(cfe({label=tabl.period}), page_info, header_level) %> @@ -65,13 +53,15 @@ header_level = htmlviewfunctions.incrementheader(header_level) </tr> </thead><tbody> <% for i,job in ipairs(tabl.jobs) do %> + <% local name = cfe({type="hidden", value=job}) %> <tr> <td><%= html.html_escape(string.gsub(job, "^.*/", "")) %></td> <td> - <%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/editjob?name="..job.."&redir="..page_info.orig_action, label="Edit "} %> - <%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/deletejob?name="..job.."&submit=true", label="Delete "} %> + <% htmlviewfunctions.displayitem(cfe({type="link", value={name=name, redir=redir}, label="", option="Edit", action="editjob" }), -1, page_info) %> + <% htmlviewfunctions.displayitem(cfe({type="form", value={name=name}, label="", option="Delete", action="deletejob" }), -1, page_info) %> </td><td> - <% createmoveform(job, tabl.period) %> + <% period.value = tabl.period %> + <% htmlviewfunctions.displayitem(cfe({type="form", value={name=name, period=period}, label="", option="Move", action="movejob" }), -1, page_info) %> </td> </tr> <% end %> diff --git a/health-networkstats-html.lsp b/health-networkstats-html.lsp index e6a5d3a..d04163a 100644 --- a/health-networkstats-html.lsp +++ b/health-networkstats-html.lsp @@ -146,8 +146,9 @@ <p>Network traffic in bytes/second</p> <div id="chart" style="width:680px; height:300px;"></div> -<div class='item'><p class='left'>Display Options</p> -<div class='right'> +<% htmlviewfunctions.displayitemstart() %> +Display Options +<% htmlviewfunctions.displayitemmiddle() %> <table class="tablesorter"><thead> <tr><th>Interface</th><th>IP Address</th><th colspan="2">RX</th><th colspan="2">TX</th></tr> </thead><tbody> @@ -159,13 +160,14 @@ <td><div style="width:14px;height:10px;border:1px solid #ccc;padding:1px"><div style="width:14px;height:10px;background-color:<%= rgb[i][2] %>;overflow:hidden"></div></div></td></tr> <% end %> </tbody></table> -</div></div><!-- end .item --> +<% htmlviewfunctions.displayitemend() %> -<div class='item'><p class='left'>Start / Stop</p> -<div class='right'> +<% htmlviewfunctions.displayitemstart() %> +Start / Stop +<% htmlviewfunctions.displayitemmiddle() %> <input class="submit" type="button" id="Start" value="Start"> <input class="submit" type="button" id="Stop" value="Stop"> -</div></div><!-- end .item --> +<% htmlviewfunctions.displayitemend() %> <% --[[ -- display table of colors %> <table style="width:auto;"> diff --git a/interfaces-read-html.lsp b/interfaces-read-html.lsp index ae84b44..a9150e6 100644 --- a/interfaces-read-html.lsp +++ b/interfaces-read-html.lsp @@ -19,27 +19,31 @@ html = require("acf.html") viewlibrary.dispatch_component("status") end %> +<% local redir = cfe({type="hidden", value=page_info.orig_action}) %> <% htmlviewfunctions.displayheader(view, page_info) %> <% for i,entry in ipairs(view.value) do - local interface = entry.value %> - <div class='item'><div class='left'><IMG SRC='<%= html.html_escape(page_info.wwwprefix..page_info.staticdir) %>/tango/16x16/devices/network-wired.png' width='16' height='16'> <%= html.html_escape(interface.name.value) %></div> - <div class='right'> + local interface = entry.value + htmlviewfunctions.displayitemstart() + %> + <img src='<%= html.html_escape(page_info.wwwprefix..page_info.staticdir) %>/tango/16x16/devices/network-wired.png' width='16' height='16'> <%= html.html_escape(interface.name.value) %> + <% htmlviewfunctions.displayitemmiddle() %> <table style='margin-bottom:10px'> <% if viewlibrary.check_permission("update") or viewlibrary.check_permission("delete") or viewlibrary.check_permission("ifup") or viewlibrary.check_permission("ifdown") then %> + <% local name = cfe({type="hidden", value=interface.name.value}) %> <tr><td colspan=2 style='border:none;'> - <% if viewlibrary.check_permission("update") then %> - <a href='update?name=<%= html.html_escape(interface.name.value) %>&redir=read'>Edit </a> - <% end - if viewlibrary.check_permission("delete") then %> - <a href='delete?name=<%= html.html_escape(interface.name.value) %>&submit=true&redir=read'>Delete </a> - <% end - if viewlibrary.check_permission("ifup") then %> - <a href='ifup?name=<%= html.html_escape(interface.name.value) %>&submit=true&redir=read'>ifup </a> - <% end - if viewlibrary.check_permission("ifdown") then %> - <a href='ifdown?name=<%= html.html_escape(interface.name.value) %>&submit=true&redir=read'>ifdown </a> - <% end %> + <% if viewlibrary.check_permission("update") then + htmlviewfunctions.displayitem(cfe({type="link", value={name=name, redir=redir}, label="", option="Edit", action="update" }), -1, page_info) + end + if viewlibrary.check_permission("delete") then + htmlviewfunctions.displayitem(cfe({type="form", value={name=name}, label="", option="Delete", action="delete" }), -1, page_info) + end + if viewlibrary.check_permission("ifup") then + htmlviewfunctions.displayitem(cfe({type="form", value={name=name}, label="", option="ifup", action="ifup" }), -1, page_info) + end + if viewlibrary.check_permission("ifdown") then + htmlviewfunctions.displayitem(cfe({type="form", value={name=name}, label="", option="ifdown", action="ifdown" }), -1, page_info) + end %> </td></tr> <% end %> @@ -52,7 +56,7 @@ end %> end end %> </table> - </div></div><!-- end .item --> + <% htmlviewfunctions.displayitemend() %> <% end %> <% if viewlibrary and viewlibrary.dispatch_component then diff --git a/interfaces-update-html.lsp b/interfaces-update-html.lsp index 7033fda..8d65d99 100644 --- a/interfaces-update-html.lsp +++ b/interfaces-update-html.lsp @@ -79,7 +79,5 @@ end <% if page_info.action == "update" then form.label = form.label.." - "..form.value.name.value end -local header_level = htmlviewfunctions.displayheader(form, page_info) -header_level = htmlviewfunctions.incrementheader(header_level) - htmlviewfunctions.displayform(form, nil, nil, page_info, htmlviewfunctions.incrementheader(header_level)) +htmlviewfunctions.displayitem(form, nil, page_info) %> diff --git a/logfiles-status-html.lsp b/logfiles-status-html.lsp index 454d309..6d56009 100644 --- a/logfiles-status-html.lsp +++ b/logfiles-status-html.lsp @@ -55,19 +55,22 @@ end </tr> </thead><tbody> +<% local viewtype = cfe({type="hidden", value="stream"}) %> <% for i,file in ipairs(view.value) do %> + <% local filename = cfe({type="hidden", value=file.value.filename.value}) %> <tr> <% if viewlibrary.check_permission("delete") then %> <td> <% if file.value.inuse.value then %> in use - <% else %> - <%= html.link{value = "delete?filename="..file.value.filename.value.."&submit=true", label="Delete" } %> - <% end %></td> + <% else + htmlviewfunctions.displayitem(cfe({type="form", value={filename=filename}, label="", option="Delete", action="delete" }), -1, page_info) + end %> + </td> <% end %> - <td><%= html.link{value = "view?filename="..file.value.filename.value, label="View" } %></td> - <td><%= html.link{value = "tail?filename="..file.value.filename.value, label="Tail" } %></td> - <td><%= html.link{value = "download?viewtype=stream&filename="..file.value.filename.value, label="Download" } %></td> + <td><% htmlviewfunctions.displayitem(cfe({type="link", value={filename=filename}, label="", option="View", action="view" }), -1, page_info) %></td> + <td><% htmlviewfunctions.displayitem(cfe({type="link", value={filename=filename}, label="", option="Tail", action="tail" }), -1, page_info) %></td> + <td><% htmlviewfunctions.displayitem(cfe({type="link", value={filename=filename, viewtype=viewtype}, label="", option="Download", action="download" }), -1, page_info) %></td> <td><span style="display:none"><%= convertsize(file.value.filesize.value) %>b</span><%= html.html_escape(file.value.filesize.value) %></td> <td><%= html.html_escape(file.value.mtime.value) %></td> <td><%= html.html_escape(file.value.filename.value) %></td> diff --git a/logfiles-tail-html.lsp b/logfiles-tail-html.lsp index 8666d27..b14a02e 100644 --- a/logfiles-tail-html.lsp +++ b/logfiles-tail-html.lsp @@ -73,8 +73,9 @@ end <textarea id="filecontent"> </textarea> <p class="error" id="errtxt"></p> -<div class='item'><p class='left'>Start / Stop tailing file</p> -<div class='right'> +<% htmlviewfunctions.displayitemstart() %> +Start / Stop tailing file +<% htmlviewfunctions.displayitemmiddle() %> <input type="button" id="Start" value="Start" onClick='$("#errtxt").empty(); Update(); $("#Start").attr("disabled","disabled");$("#Stop").removeAttr("disabled");'> <input type="button" id="Stop" value="Stop" onClick='window.clearTimeout(ID); $("#Stop").attr("disabled","disabled");$("#Start").removeAttr("disabled");'> -</div></div><!-- end .item --> +<% htmlviewfunctions.displayitemend() %> diff --git a/rc-status-html.lsp b/rc-status-html.lsp index 001f790..c787234 100644 --- a/rc-status-html.lsp +++ b/rc-status-html.lsp @@ -35,20 +35,16 @@ </tr> </thead><tbody> <% +local redir = cfe({type="hidden", value=page_info.orig_action}) for i,item in ipairs(view.value) do %> <tr> <td> + <% local servicename = cfe({type="hidden", value=item.servicename}) %> <% if viewlibrary.check_permission("edit") then - local editlink = cfe({type="link", value={}, label="", option="Edit", action="edit" }) - editlink.value.servicename = cfe({type="hidden", value=item.servicename}) - editlink.value.redir = cfe({type="hidden", value=page_info.orig_action}) - htmlviewfunctions.displayitem(editlink, -1, page_info) + htmlviewfunctions.displayitem(cfe({type="link", value={servicename=servicename, redir=redir}, label="", option="Edit", action="edit" }), -1, page_info) end %> <% if viewlibrary.check_permission("startstop") and item.actions then - local startstopform = cfe({type="form", value={}, label="", option={}, action="startstop" }) - startstopform.value.servicename = cfe({type="hidden", value=item.servicename}) - startstopform.value.redir = cfe({type="hidden", value=page_info.orig_action}) - + local startstopform = cfe({type="form", value={servicename=servicename}, label="", option={}, action="startstop" }) for i,a in ipairs(item.actions) do startstopform.option[#startstopform.option+1] = a:gsub("^%l", string.upper) end |