From df9f7a1dd10b1c3b4e17739222b882cdcf2b17f8 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Sun, 5 Jul 2015 20:40:14 -0400 Subject: Add server-side pagination, sorting, and filtering for listdevices action --- provisioning-listdevices-html.lsp | 153 ++++++++++++++++++++++++++------------ 1 file changed, 104 insertions(+), 49 deletions(-) (limited to 'provisioning-listdevices-html.lsp') diff --git a/provisioning-listdevices-html.lsp b/provisioning-listdevices-html.lsp index c511d1e..79c2b32 100644 --- a/provisioning-listdevices-html.lsp +++ b/provisioning-listdevices-html.lsp @@ -12,9 +12,19 @@ html = require("acf.html") +<% -- Determine all of the groups +local columns = {"device_id"} +for i,v in ipairs( view.value.groups.value ) do + columns[#columns+1] = v.name +end +%> + <% htmlviewfunctions.displaycommandresults({"deletedevice", "editdevice", "editdeviceparams", "overridedeviceparams"}, session) %> <% htmlviewfunctions.displaycommandresults({"createdevice"}, session, true) %> -<% -- Determine all of the groups -local tmp = {} -for k,v in ipairs( view.value ) do - for g,c in pairs(v) do - if not tmp[g] then tmp[g] = true end - end -end -local display = {} -for n in pairs(tmp) do - if n ~= "device_id" then - display[#display+1] = n - end -end -table.sort(display) -%> - <% local header_level = htmlviewfunctions.displaysectionstart(view, page_info) %> - + - <% for i,n in ipairs(display) do %> - <% end %> -<% local device_id = cfe({ type="hidden", value="" }) %> -<% local redir = cfe({ type="hidden", value=page_info.orig_action }) %> -<% for k,v in ipairs( view.value ) do %> - - - - <% for i,n in ipairs(display) do %> - - <% end %> - -<% end %>
ActionAction Device ID<%= string.gsub(n, "^.", string.upper) %> + <% for i,g in ipairs(view.value.groups.value) do %> + <%= html.html_escape(g.label) %>
- <% device_id.value = v.device_id %> - <% if viewlibrary.check_permission("editdevice") then %> - <% htmlviewfunctions.displayitem(cfe({type="link", value={device_id=device_id, redir=redir}, label="", option="Edit", action="editdevice"}), page_info, -1) %> - <% end %> - <% if viewlibrary.check_permission("overridedeviceparams") then %> - <% htmlviewfunctions.displayitem(cfe({type="link", value={device_id=device_id, redir=redir}, label="", option="Params", action="overridedeviceparams"}), page_info, -1) %> - <% elseif viewlibrary.check_permission("editdeviceparams") then %> - <% htmlviewfunctions.displayitem(cfe({type="link", value={device_id=device_id, redir=redir}, label="", option="Params", action="editdeviceparams"}), page_info, -1) %> - <% end %> - <% if viewlibrary.check_permission("getdevicevalues") then %> - <% htmlviewfunctions.displayitem(cfe({type="form", value={value=device_id, id=cfe({type="hidden", value="device_id"}), viewtype=cfe({type="hidden", value="templated"})}, label="", option="View", action="getdevicevalues"}), page_info, -1) %> - <% end %> - <% if viewlibrary.check_permission("deletedevice") then %> - <% htmlviewfunctions.displayitem(cfe({type="form", value={device_id=device_id}, label="", option="Delete", action="deletedevice", class="deletedevice"}), page_info, -1) %> - <% end %> - <%= html.html_escape(v.device_id) %><%= html.html_escape(v[n]) %>
+
+
+ Page: + + + + + + +
+
+ <% if view.errtxt then %>

<%= html.html_escape(view.errtxt) %>

<% end %> -<% if #view.value == 0 then %> +<% if #view.value.result.value == 0 then %>

No devices found

<% end %> <% htmlviewfunctions.displaysectionend(header_level) %> -- cgit v1.2.3