summaryrefslogtreecommitdiffstats
path: root/provisioning-listdevices-html.lsp
blob: 40da260476d54ae692ebc945113e461b2895b945 (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
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">
        $(document).ready(function() {
                $("#list").tablesorter({headers: {0:{sorter: false}}});
        });
</script>

<% displaycommandresults({"deletedevice", "editdevice", "editdeviceparams", "overridedeviceparams"}, session) %>
<% displaycommandresults({"createdevice"}, session, true) %>

<h1>Devices</h1>
<DL>
<TABLE id="list" class="tablesorter"><THEAD>
	<TR style="background:#eee;font-weight:bold;">
		<TH>Action</TH>
		<TH>Name</TH>
		<TH>Label</TH>
	<% if page_info.action == "searchdevices" then %>
	<% if view.value[1] and view.value[1].group and view.value[1].group ~= "" then %>
		<TH>Group</TH>
	<% end %>
		<TH>Param</TH>
		<TH>Value</TH>
	<% end %>
	</TR>		
</THEAD><TBODY>
<% for k,v in ipairs( view.value ) do %>
	<TR>
		<TD>
		<% if viewlibrary.check_permission("deletedevice") then %>
			<%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/deletedevice?device_id="..v.device_id, label="Delete "} %>
		<% end %>
		<% if viewlibrary.check_permission("editdevice") then %>
			<%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/editdevice?device_id="..v.device_id.."&redir="..page_info.orig_action, label="Edit "} %>
		<% end %>
		<% if viewlibrary.check_permission("overridedeviceparams") then %>
			<%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/overridedeviceparams?device_id="..v.device_id.."&redir="..page_info.orig_action, label="Params "} %>
		<% elseif viewlibrary.check_permission("editdeviceparams") then %>
			<%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/editdeviceparams?device_id="..v.device_id.."&redir="..page_info.orig_action, label="Params "} %>
		<% end %>
		<% if viewlibrary.check_permission("getdevicevalues") then %>
			<%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/getdevicevalues?name="..v.name.."&viewtype=templated", label="View "} %>
		<% end %>
		</TD>
                <TD><%= html.html_escape(v.name) %></TD>
                <TD><%= html.html_escape(v.label) %></TD>
	<% if page_info.action == "searchdevices" then %>
	<% if v.group and v.group ~= "" then %>
		<TD><%= html.html_escape(v.group) %></TD>
	<% end %>
		<TD><%= html.html_escape(v.param) %></TD>
		<TD><%= html.html_escape(v.value) %></TD>
	<% end %>
	</TR>
<% end %>
</TBODY>
</TABLE>

<% if view.errtxt then %>
<p class="error"><%= html.html_escape(view.errtxt) %></p>
<% end %>
<% if #view.value == 0 then %>
<p>No devices found</p>
<% end %>
</DL>

<% if page_info.action == "listdevices" and viewlibrary and viewlibrary.dispatch_component and viewlibrary.check_permission("createdevice") then
        viewlibrary.dispatch_component("createdevice")
end %>