From 4c0e9b17d5bbcfb7e7a704c6a57af2cfe327c308 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Sat, 8 Mar 2014 23:49:47 +0000 Subject: Modified HTML views to use new htmlviewfunctions functions and replace links with forms created by displayitem Use htmlviewfunctions.displayheader .incrementheader .displayitemstart/middle/end --- cron-listjobs-html.lsp | 30 ++++++++++-------------------- health-networkstats-html.lsp | 14 ++++++++------ interfaces-read-html.lsp | 36 ++++++++++++++++++++---------------- interfaces-update-html.lsp | 4 +--- logfiles-status-html.lsp | 15 +++++++++------ logfiles-tail-html.lsp | 7 ++++--- 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 = '
' -formstart = formstart .. '\n\n
' -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) <% for i,job in ipairs(tabl.jobs) do %> + <% local name = cfe({type="hidden", value=job}) %> <%= html.html_escape(string.gsub(job, "^.*/", "")) %> - <%= 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) %> - <% 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) %> <% 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 @@

Network traffic in bytes/second

-

Display Options

-
+<% htmlviewfunctions.displayitemstart() %> +Display Options +<% htmlviewfunctions.displayitemmiddle() %> @@ -159,13 +160,14 @@ <% end %>
InterfaceIP AddressRXTX
-
+<% htmlviewfunctions.displayitemend() %> -

Start / Stop

-
+<% htmlviewfunctions.displayitemstart() %> +Start / Stop +<% htmlviewfunctions.displayitemmiddle() %> -
+<% htmlviewfunctions.displayitemend() %> <% --[[ -- display table of colors %> 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 %> -
<%= html.html_escape(interface.name.value) %>
-
+ local interface = entry.value + htmlviewfunctions.displayitemstart() + %> + <%= html.html_escape(interface.name.value) %> + <% htmlviewfunctions.displayitemmiddle() %>
<% 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}) %> <% end %> @@ -52,7 +56,7 @@ end %> end end %>
- <% if viewlibrary.check_permission("update") then %> - Edit - <% end - if viewlibrary.check_permission("delete") then %> - Delete - <% end - if viewlibrary.check_permission("ifup") then %> - ifup - <% end - if viewlibrary.check_permission("ifdown") then %> - ifdown - <% 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 %>
- + <% 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 +<% 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}) %> <% if viewlibrary.check_permission("delete") then %> <% if file.value.inuse.value then %> in use - <% else %> - <%= html.link{value = "delete?filename="..file.value.filename.value.."&submit=true", label="Delete" } %> - <% end %> + <% else + htmlviewfunctions.displayitem(cfe({type="form", value={filename=filename}, label="", option="Delete", action="delete" }), -1, page_info) + end %> + <% end %> - <%= html.link{value = "view?filename="..file.value.filename.value, label="View" } %> - <%= html.link{value = "tail?filename="..file.value.filename.value, label="Tail" } %> - <%= html.link{value = "download?viewtype=stream&filename="..file.value.filename.value, label="Download" } %> + <% htmlviewfunctions.displayitem(cfe({type="link", value={filename=filename}, label="", option="View", action="view" }), -1, page_info) %> + <% htmlviewfunctions.displayitem(cfe({type="link", value={filename=filename}, label="", option="Tail", action="tail" }), -1, page_info) %> + <% htmlviewfunctions.displayitem(cfe({type="link", value={filename=filename, viewtype=viewtype}, label="", option="Download", action="download" }), -1, page_info) %> <%= convertsize(file.value.filesize.value) %>b<%= html.html_escape(file.value.filesize.value) %> <%= html.html_escape(file.value.mtime.value) %> <%= html.html_escape(file.value.filename.value) %> 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

-

Start / Stop tailing file

-
+<% htmlviewfunctions.displayitemstart() %> +Start / Stop tailing file +<% htmlviewfunctions.displayitemmiddle() %> -
+<% 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 @@ <% +local redir = cfe({type="hidden", value=page_info.orig_action}) for i,item in ipairs(view.value) do %> + <% 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 -- cgit v1.2.3