acf-openpdu/acf-app/openpdu-status-html.lsp

59 lines
2.3 KiB
Plaintext
Executable File

<% local view, viewlibrary, page_info, session = ... %>
<% htmlviewfunctions = require("htmlviewfunctions") %>
<% html = require("acf.html") %>
<script type="text/javascript">
if (typeof jQuery == 'undefined') {
document.write('<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery-latest.js"><\/script>');
}
</script>
<script type="text/javascript">
if (typeof $.tablesorter == 'undefined') {
document.write('<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery.tablesorter.js"><\/script>');
}
</script>
<script type="text/javascript">
$(document).ready(function() {
$("#list").tablesorter({widgets: ['zebra']});
});
</script>
<% htmlviewfunctions.displaycommandresults({"edit", "startstop", "poweron", "poweroff"}, session) %>
<% local header_level = htmlviewfunctions.displaysectionstart(view, page_info) %>
<table id="list" class="tablesorter"><thead>
<tr>
<th>Outlet #</th>
<th>Status</th>
<th>Description</th>
<% if viewlibrary.check_permission("edit") or viewlibrary.check_permission("power") then %>
<th>Action</th>
<% end %>
</tr>
</thead><tbody>
<%
local redir = cfe({type="hidden", value=page_info.orig_action})
for i,item in ipairs(view.value) do %>
<tr>
<td><%= html.html_escape(item.outlet) %></td>
<td><%= html.html_escape(item.status) %></td>
<td><%= html.html_escape(item.description) %></td>
<% if viewlibrary.check_permission("edit") or viewlibrary.check_permission("power") then %>
<td>
<% local outlet = cfe({type="hidden", value=item.outlet}) %>
<% if viewlibrary.check_permission("edit") then
htmlviewfunctions.displayitem(cfe({type="link", value={outlet=outlet, redir=redir}, label="", option="Edit", action="edit" }), page_info, -1)
end %>
<% if viewlibrary.check_permission("poweron") or viewlibrary.check_permission("poweroff") then
htmlviewfunctions.displayitem(cfe({type="form", value={outlet=outlet, redir=redir}, label="", option="Power ON", action="poweron" }), page_info, -1)
htmlviewfunctions.displayitem(cfe({type="form", value={outlet=outlet, redir=redir}, label="", option="Power OFF", action="poweroff" }), page_info, -1)
end %>
</td>
<% end %>
</tr>
<% end %>
</tbody></table>
<% htmlviewfunctions.displaysectionend(header_level) %>