From 8e9359a77cb89ac67db14b21dc3f44e26f32285d Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Mon, 6 Jul 2015 11:50:49 -0400 Subject: Fix searchdevices html view by adding in old listdevices code Since we're searching, filtering is not valid and pagination isn't as important as for list page Also, changed searchbymac to be case insensitive --- provisioning-searchbymac-html.lsp | 2 +- provisioning-searchdevices-html.lsp | 75 +++++++++++++++++++++++++++++++++++-- 2 files changed, 72 insertions(+), 5 deletions(-) diff --git a/provisioning-searchbymac-html.lsp b/provisioning-searchbymac-html.lsp index eba96f8..45a771d 100644 --- a/provisioning-searchbymac-html.lsp +++ b/provisioning-searchbymac-html.lsp @@ -25,7 +25,7 @@ html = require("acf.html") <% local id = cfe({type="hidden", value="device.mac"}) -local comparison = cfe({type="hidden", value="~"}) +local comparison = cfe({type="hidden", value="~*"}) local value = cfe({label="MAC Address"}) local form = cfe({type="form", label="Search by MAC Address", value={id=id, comparison=comparison, value=value}, action="searchdevices", option="Search"}) diff --git a/provisioning-searchdevices-html.lsp b/provisioning-searchdevices-html.lsp index d2f086d..332a817 100644 --- a/provisioning-searchdevices-html.lsp +++ b/provisioning-searchdevices-html.lsp @@ -9,6 +9,12 @@ html = require("acf.html") } + + @@ -38,12 +46,71 @@ if form.value.values then form.value.values = nil -- And here we display the list of devices in the result elseif form.value.result then + -- Determine all of the columns + local tmp = {} + for k,v in ipairs( form.value.result.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) - print("There are "..#form.value.result.value.." devices in the result") --- local func = haserl.loadfile(page_info.viewfile:gsub(page_info.action, "listdevices")) --- func(form, viewlibrary, page_info, session) -end + local header_level = htmlviewfunctions.displaysectionstart(form.value.result, page_info) %> + + + + + <% for i,n in ipairs(display) do %> + + + <% local device_id = cfe({ type="hidden", value="" }) %> + <% local redir = cfe({ type="hidden", value=page_info.orig_action }) %> + <% for k,v in ipairs( form.value.result.value ) do %> + + + + <% for i,n in ipairs(display) do %> + + <% end %> + + <% end %> + +
ActionDevice ID<%= html.html_escape(string.gsub(n, "^.", string.upper)) %> + <% end %> +
+ <% 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]) %>
+ + <% if form.value.result.errtxt then %> +

<%= html.html_escape(form.value.result.errtxt) %>

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

No devices found

+ <% end %> + <% htmlviewfunctions.displaysectionend(header_level) %> + +<% end %> <% form.value.result = nil -- cgit v1.2.3