<% local data, viewlibrary, page_info, session = ... 
htmlviewfunctions = require("htmlviewfunctions")
html = require("acf.html")
%>

<% htmlviewfunctions.displaycommandresults({"enable","config","expert","startstopinterface"}, session) %>

<% viewlibrary.dispatch_component("status") %>

<H2><%= html.html_escape(data.label) %></H2>
<DL><TABLE>
	<TR style="background:#eee;font-weight:bold;">
		<TD style="padding-right:20px;white-space:nowrap;text-align:left;" class="header">Action</TD>
		<TD style="padding-right:20px;white-space:nowrap;text-align:left;" class="header">Interface</TD>
		<TD style="padding-right:20px;white-space:nowrap;text-align:left;" class="header">Status</TD>
		<TD style="white-space:nowrap;text-align:left;" class="header"></TD>
	</TR>		
<% for i,intf in ipairs(data.value) do %>
	<TR>
		<TD style="padding-right:20px;white-space:nowrap;">
		<% if intf.enabled then %>
			<% io.write(html.link{value = "config?DEV="..intf.interface.."&redir="..page_info.orig_action, label="Edit " }) %>
			<% io.write(html.link{value = "expert?filename="..intf.filename.."&redir="..page_info.orig_action, label="Expert " }) %>
			<% io.write(html.link{value = page_info.script .. "/alpine-baselayout/rc/edit?servicename="..intf.init.."&redir=".. page_info.orig_action, label="Autostart " }) %>
		<% else %>
			<% io.write(html.link{value = "enable?submit=true&interface="..intf.interface, label="Enable " }) %>
		<% end %>
		</TD>
		<TD style="padding-right:20px;white-space:nowrap;"><%= html.html_escape(intf.interface) %></TD>
		<TD style="white-space:nowrap;" width="90%"><%= html.html_escape(intf.status) %></TD>
		<% if intf.enabled then %>
			<TD><form action="<%= html.html_escape(page_info.script .. page_info.prefix .. page_info.controller .. "/startstopinterface") %>" method="POST">
			<input type="hidden" name="init" value="<%= intf.init %>">
			<input class="submit" type="submit" name="submit" value="Start">
			<input class="submit" type="submit" name="submit" value="Stop">
			<input class="submit" type="submit" name="submit" value="Restart">
			</form></TD>
		<% end %>
	</TR>
<% end %>
</TABLE></DL>
