[#75] Device module inventory report / search

This commit is contained in:
Eric A. Miller
2014-02-15 22:07:55 -05:00
parent 8cee58c88e
commit ad8bcc3dfc
9 changed files with 419 additions and 2 deletions

View File

@@ -0,0 +1,86 @@
[% USE Number.Format %]
[% IF results.first.ip %]
[% row = results.reset %]
<table class="table table-bordered table-condensed table-striped nd_floatinghead">
<thead>
<tr>
<th>Device</th>
<th>Description</th>
<th>Name</th>
<th>Class</th>
<th>Type</th>
<th>Model</th>
<th>Serial</th>
<th>HW Version</th>
<th>SW Version</th>
<th>FW Version</th>
</tr>
</thead>
</tbody>
[% WHILE (row = results.next) %]
<tr>
<td>
<a class="nd_linkcell"
href="[% uri_for('/device') %]?tab=modules&q=[% row.device.ip | uri %]">
[% row.device.dns || row.device.name || row.device.ip | html_entity %]</a>
</td>
<td>
<a class="nd_linkcell"
href="[% uri_for('/report/moduleinventory') %]?description=[% row.description | uri %]">
[% row.description | html %]</a>
</td>
<td>
<a class="nd_linkcell"
href="[% uri_for('/report/moduleinventory') %]?name=[% row.name | uri %]">
[% row.name | html %]</a>
</td>
<td>
<a class="nd_linkcell"
href="[% uri_for('/report/moduleinventory') %]?class=[% row.class | uri %]">
[% row.class.ucfirst | html %]</a>
</td>
<td>
<a class="nd_linkcell"
href="[% uri_for('/report/moduleinventory') %]?type=[% row.type | uri %]">
[% row.type | html %]</a>
</td>
<td>
<a class="nd_linkcell"
href="[% uri_for('/report/moduleinventory') %]?model=[% row.model | uri %]">
[% row.model | html %]</a>
</td>
<td>
<a class="nd_linkcell"
href="[% uri_for('/report/moduleinventory') %]?serial=[% row.serial | uri %]">
[% row.serial | html %]</a>
</td>
<td>[% row.hw_ver | html_entity %]</td>
<td>[% row.sw_ver | html_entity %]</td>
<td>[% row.fw_ver | html_entity %]</td>
</tr>
[% END %]
</tbody>
</table>
[% ELSE %]
[% row = results.reset %]
<table class="table table-bordered table-condensed table-striped nd_floatinghead">
<thead>
<tr>
<th>Class</th>
<th>Count</th>
</tr>
</thead>
</tbody>
[% WHILE (row = results.next) %]
<tr>
<td>
<a class="nd_linkcell"
href="[% uri_for('/report/moduleinventory') %]?class=[% row.class | uri %]">
[% row.class.ucfirst | html %]</a>
</td>
<td>[% row.count | format_number %]</td>
</tr>
[% END %]
</tbody>
</table>
[% END %]

View File

@@ -0,0 +1,27 @@
[% USE CSV -%]
[% IF results.first.ip %]
[% row = results.reset %]
[% CSV.dump(['Device' 'Description' 'Name' 'Class' 'Type' 'Model' 'Serial' 'HW Version' 'SW Version' 'FW Version']) %]
[% WHILE (row = results.next) %]
[% mylist = [] %]
[% device = row.device.dns || row.device.name || row.device.ip %]
[% FOREACH col IN [ device row.description row.name row.class.ucfirst row.type row.model row.serial row.hw_ver row.sw_ver row.fw_ver ] %]
[% mylist.push(col) %]
[% END %]
[% CSV.dump(mylist) %]
[% END %]
[% ELSE %]
[% row = results.reset %]
[% CSV.dump(['Class' 'Count']) %]
[% WHILE (row = results.next) %]
[% mylist = [] %]
[% FOREACH col IN [ row.class.ucfirst row.count ] %]
[% mylist.push(col) %]
[% END %]
[% CSV.dump(mylist) %]
[% END %]
[% END %]

View File

@@ -2,7 +2,7 @@
// ajax content is loaded
var path = 'report';
// fields in the IP Inventory Report form
// colored input fields in the Report Options sidebar forms
var form_inputs = $(".nd_colored-input");
// this is called by do_search to support local code
@@ -15,7 +15,7 @@
$("[rel=popover]").popover({live: true});
}
// on load, check initial Device Search Options form state,
// on load, check initial Report Options form state,
// and on each change to the form fields
$(document).ready(function() {
var tab = '[% report.tag %]'
@@ -25,6 +25,14 @@
form_inputs.each(function() {device_form_state($(this))});
form_inputs.change(function() {device_form_state($(this))});
// handler for bin icon in search forms
$('.nd_field-clear-icon').click(function() {
var name = $(this).data('btn-for');
var input = $('[name=' + name + ']');
input.val('');
device_form_state(input); // reset input field
});
$('#nd_ipinventory-subnet').on('input', function(event) {
if ($(this).val().indexOf(':') != -1) {
$('#never').attr('disabled', 'disabled');

View File

@@ -0,0 +1,72 @@
<p class="nd_sidebar-title"><em>Module Search Options</em></p>
<div class="clearfix">
<i id="device_clear_btn" data-btn-for="device"
class="nd_field-clear-icon icon-trash icon-large"></i>
<input class="nd_side-input nd_colored-input" placeholder="Device"
type="text" name="device" value="[% params.dns | html_entity %]"
rel="tooltip" data-placement="left" data-offset="5" data-title="Device IP, DNS, Description, Name, Location, Serial, or Contact"/>
</div>
<div class="clearfix">
<i id="description_clear_btn" data-btn-for="description"
class="nd_field-clear-icon icon-trash icon-large"></i>
<input class="nd_side-input nd_colored-input" placeholder="Module Description"
type="text" name="description" value="[% params.description | html_entity %]"
rel="tooltip" data-placement="left" data-offset="5" data-title="Module Description"/>
</div>
<div class="clearfix">
<i id="name_clear_btn" data-btn-for="name"
class="nd_field-clear-icon icon-trash icon-large"></i>
<input class="nd_side-input nd_colored-input" placeholder="Module Name"
type="text" name="name" value="[% params.name | html_entity %]"
rel="tooltip" data-placement="left" data-offset="5" data-title="Module Name"/>
</div>
<div class="clearfix">
<i id="type_clear_btn" data-btn-for="type"
class="nd_field-clear-icon icon-trash icon-large"></i>
<input class="nd_side-input nd_colored-input" placeholder="Module Type"
type="text" name="type" value="[% params.type | html_entity %]"
rel="tooltip" data-placement="left" data-offset="5" data-title="Module Type"/>
</div>
<div class="clearfix">
<i id="model_clear_btn" data-btn-for="model"
class="nd_field-clear-icon icon-trash icon-large"></i>
<input class="nd_side-input nd_colored-input" placeholder="Module Model"
type="text" name="model" value="[% params.model | html_entity %]"
rel="tooltip" data-placement="left" data-offset="5" data-title="Module Model"/>
</div>
<div class="clearfix">
<i id="serial_clear_btn" data-btn-for="serial"
class="nd_field-clear-icon icon-trash icon-large"></i>
<input class="nd_side-input nd_colored-input" placeholder="Module Serial"
type="text" name="serial" value="[% params.serial | html_entity %]"
rel="tooltip" data-placement="left" data-offset="5" data-title="Module Serial"/>
</div>
<div class="clearfix">
<select class="nd_side-select nd_colored-input" size="[% class_list.size > 5 ? 5 : class_list.size %]"
multiple="on" name="class"
rel="tooltip" data-placement="left" data-offset="5" data-title="Module Class"/>
[% FOREACH opt IN class_list %]
<option[% ' selected="selected"' IF class_lkp.exists(opt) %]>[% opt | html_entity %]</option>
[% END %]
</select>
</div>
<div class="clearfix">
<em class="muted">Limit:</em><br/>
<select id="nd_mac-format" class="nd_side-select" name="limit">
[% FOREACH size IN [ '128', '256', '1024', '2048', '4096', '8192' ] %]
<option[% ' selected="selected"' IF params.limit == size %]>[% size %]</option>
[% END %]
</select>
</div>
<div class="clearfix input-prepend">
<label class="add-on">
<input type="checkbox" id="matchall"
name="matchall"[% ' checked="checked"' IF params.matchall %]/>
</label>
<label class="nd_checkboxlabel" for="matchall">
<span class="nd_searchcheckbox uneditable-input">Match All Options</span>
</label>
</div>
<button id="[% tab.tag %]_submit" type="submit" class="btn btn-info">
<i class="icon-search icon-large pull-left nd_navbar-icon"></i> Search Modules</button>