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
66
67
68
69
70
71
72
73
74
|
<% local view, viewlibrary, page_info, session = ...
require("viewfunctions")
%>
<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery-latest.js"></script>
<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery.tablesorter.js"></script>
<script type="text/javascript">
<% -- Since we're including a submission of searchdevices, we need to overcome the automatic redirect
if session.searchdevicesresult then
-- Use JavaScript to redirect to the searchdevices page
%>
window.location.assign("<%= html.html_escape(page_info.script..page_info.prefix..page_info.controller) %>/searchdevices");
<%
end
-- Since we're including a submission of createdevicefromrequest, we need to overcome the automatic redirect
if session.createdevicefromrequestresult then
-- Use JavaScript to redirect to the createdevicefromrequest page
%>
window.location.assign("<%= html.html_escape(page_info.script..page_info.prefix..page_info.controller) %>/createdevicefromrequest");
<%
end
%>
$(document).ready(function() {
$("#list").tablesorter({headers: {1:{sorter:'digit'}, 3:{sorter:'ipAddress'}}});
$(".deleterequest").click(function(){ return confirm("Are you sure you want to delete this request?")});
});
</script>
<% displaycommandresults({"deleterequest"}, session) %>
<h1>Requests</h1>
<DL>
<TABLE id="list" class="tablesorter"><THEAD>
<TR style="background:#eee;font-weight:bold;">
<TH>Action</TH>
<TH>Timestamp</TH>
<TH>MAC Address</TH>
<TH>IP Address</TH>
<TH>User Agent</TH>
</TR>
</THEAD><TBODY>
<% for k,v in ipairs( view.value ) do %>
<TR>
<TD>
<% if viewlibrary.check_permission("deleterequest") then %>
<%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/deleterequest?mac="..v.mac, label="Delete ", class="deleterequest"} %>
<% end %>
<% if v.device_id then %>
<% if viewlibrary.check_permission("searchdevices") then %>
<%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/searchdevices?id=device_id&value="..v.device_id.."&redir=searchdevices&Search=Search", label="Search "} %>
<% end %>
<% else %>
<% if viewlibrary.check_permission("createdevicefromrequest") then %>
<%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/createdevicefromrequest?mac="..v.mac.."&Create=Create", label="Create "} %>
<% end %>
<% end %>
</TD>
<TD>
<span style="display:none">
<% local date = {}
date.year, date.month, date.day, date.hour, date.min, date.sec, remainder = string.match(v.date, "(%d+)%-(%d+)%-(%d+) (%d+):(%d+):(%d+)")
local rem = string.match(v.date, "%.%d+$")
io.write((os.time(date) - 1318000000)..(rem or "")) %>
</span>
<%= html.html_escape(v.date) %>
</TD>
<TD><%= html.html_escape(v.mac) %></TD>
<TD><%= html.html_escape(v.ip) %></TD>
<TD><%= html.html_escape(v.agent) %></TD>
</TR>
<% end %>
</TBODY>
</TABLE>
|