summaryrefslogtreecommitdiffstats
path: root/interfaces-read-html.lsp
blob: 8420674054724fcabd11ca96fd94cf129587f839 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<% local view, viewlibrary, page_info, session = ...
htmlviewfunctions = require("htmlviewfunctions")
html = require("acf.html")
%>

<% showoption = function(option)
	if option.errtxt or option.value ~= "" then %>
		<tr><td width='120px' style='font-weight:bold;border:none;'><%= html.html_escape(option.label) %></td>
		<td style='border:none;'<% if option.errtxt then io.write("class='error'") end %>>
		<%= string.gsub(html.html_escape(tostring(option.value)), "\n", "<br/>") %>
		<% if option.errtxt then io.write("<br/>"..html.html_escape(option.errtxt)) end %>
		</td></tr>
	<% end %>
<% end %>

<% htmlviewfunctions.displaycommandresults({"update", "delete", "ifup", "ifdown", "restart"}, session) %>

<% if viewlibrary and viewlibrary.dispatch_component then
	viewlibrary.dispatch_component("status")
end %>

<% local redir = cfe({type="hidden", value=page_info.orig_action}) %>
<% local header_level = htmlviewfunctions.displaysectionstart(view, page_info) %>
<% for i,entry in ipairs(view.value) do
	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
		htmlviewfunctions.displayitem(cfe({type="link", value={name=name, redir=redir}, label="", option="Edit", action="update" }), page_info, -1)
	end
	if viewlibrary.check_permission("delete") then
		htmlviewfunctions.displayitem(cfe({type="form", value={name=name}, label="", option="Delete", action="delete" }), page_info, -1)
	end
	if viewlibrary.check_permission("ifup") then
		htmlviewfunctions.displayitem(cfe({type="form", value={name=name}, label="", option="ifup", action="ifup" }), page_info, -1)
	end
	if viewlibrary.check_permission("ifdown") then
		htmlviewfunctions.displayitem(cfe({type="form", value={name=name}, label="", option="ifdown", action="ifdown" }), page_info, -1)
	end %>
	</td></tr>
	<% end %>

	<%
	showoption(interface.family)
	if interface.method then showoption(interface.method) end
	for name,option in pairs(interface) do
		if name~="name" and name~="family" and name~="method" then
			showoption(option)
		end
	end %>
	</table>
	<% htmlviewfunctions.displayitemend() %>
<% end %>
<% htmlviewfunctions.displaysectionend(header_level) %>

<% if viewlibrary and viewlibrary.dispatch_component then
	viewlibrary.dispatch_component("restart")
end %>