summaryrefslogtreecommitdiffstats
path: root/interfaces-read-html.lsp
blob: a0cb44a088fdeda6aa554a3066e110c00316a5f6 (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
<% 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 %>

<h1>Configured Interfaces</h1>
<% 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'>
	<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 %>
	<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 %>
	</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>
	</div></div><!-- end .item -->
<% end %>

<h1>Restart Networking</h1>
<p class="error">WARNING!!! Restarting networking may cause the ACF web interface to stop functioning. Try refreshing this page after restarting. If that fails, you may have to use terminal access to recover.</p>
<div class='item'><p class='left'>Restart Networking</p>
<div class='right'>
<form action="<%= html.html_escape(page_info.script .. page_info.prefix .. page_info.controller .. "/restart?redir=read") %>"><input class="submit" type="submit" name="submit" value="Restart"></form>
</div></div><!-- end .item -->