#72 Search on Vendor / OUI

This commit is contained in:
Eric A. Miller
2014-02-16 23:09:33 -05:00
parent 6b13100b82
commit b49216c9cb
7 changed files with 265 additions and 1 deletions

View File

@@ -0,0 +1,59 @@
[% USE Number.Format %]
[% IF opt %]
<table class="table table-bordered table-condensed table-striped nd_floatinghead">
<thead>
<tr>
<th>MAC</th>
<th>Vendor</th>
<th>Device (Port)</th>
</tr>
</thead>
</tbody>
[% WHILE (row = results.next) %]
<tr>
<td>
<a class="nd_linkcell"
href="[% search_node %]&q=[% row.mac | uri %]">
[% row.mac.upper | html_entity %][% '&nbsp;&nbsp;<i class="icon-book"></i> ' IF NOT row.active %]</a>
</td>
<td>
<a class="nd_linkcell"
[% IF row.oui.abbrev %]
href="[% uri_for('/report/nodevendor') %]?vendor=[% row.oui.abbrev | uri %]">
[% row.oui.abbrev | html_entity %] ( [% row.oui.company | html_entity %] )</a>
[% ELSE %]
href="[% uri_for('/report/nodevendor') %]?vendor=blank">
(Unknown Vendor)</a>
[% END %]
</td>
<td>
<a class="nd_linkcell"
href="[% device_ports %]&q=[% row.switch | uri %]&f=[% row.port | uri %]&c_nodes=on&n_ssid=on">
[% row.device.dns || row.device.name || row.switch | html_entity %] ( [% row.port | html_entity %] )</a>
</td>
</tr>
[% END %]
</tbody>
</table>
[% ELSE %]
<table class="table table-bordered table-condensed table-striped nd_floatinghead">
<thead>
<tr>
<th class="nd_center-cell">Vendor</th>
<th class="nd_center-cell">Count</th>
</tr>
</thead>
</tbody>
[% WHILE (row = results.next) %]
<tr>
<td>
<a class="nd_linkcell"
href="[% uri_for('/report/nodevendor') %]?vendor=[% row.vendor || 'blank' | uri %]">
[% row.vendor || '(Unknown Vendor)' | html_entity %]</a>
</td>
<td class="nd_center-cell">[% row.count | format_number %]</td>
</tr>
[% END %]
</tbody>
</table>
[% END %]

View File

@@ -0,0 +1,26 @@
[% USE CSV -%]
[% IF opt %]
[% CSV.dump(['MAC' 'Vendor' 'Company' 'Device' 'Port']) %]
[% WHILE (row = results.next) %]
[% mylist = [] %]
[% device = row.device.dns || row.device.name || row.switch %]
[% FOREACH col IN [ row.mac.upper row.oui.abbrev row.oui.company device row.port ] %]
[% mylist.push(col) %]
[% END %]
[% CSV.dump(mylist) %]
[% END %]
[% ELSE %]
[% CSV.dump(['Vendor' 'Count']) %]
[% WHILE (row = results.next) %]
[% mylist = [] %]
[% vendor = row.vendor || '(Unknown Vendor)' %]
[% FOREACH col IN [ vendor row.count ] %]
[% mylist.push(col) %]
[% END %]
[% CSV.dump(mylist) %]
[% END %]
[% END %]

View File

@@ -0,0 +1,60 @@
<p class="nd_sidebar-title"><em>Node Vendor Search</em></p>
<fieldset>
<legend class="nd_sidebar-legend">
<label><em><strong>Vendor</strong></em></label>
</legend>
<div class="clearfix">
<select class="nd_side-select nd_colored-input" size="[% vendor_list.size > 8 ? 8 : vendor_list.size %]"
multiple="on" name="vendor"
rel="tooltip" data-placement="left" data-offset="5" data-title="Vendor"/>
[% FOREACH opt IN vendor_list %]
[% UNLESS opt == '' %]
<option[% ' selected="selected"' IF vendor_lkp.exists(opt) %]>[% opt | html_entity %]</option>
[% ELSE %]
<option value="blank"[% ' selected="selected"' IF vendor_lkp.exists('blank') %]>[% '(Unknown Vendor)' | html_entity %]</option>
[% END %]
[% END %]
</select>
</div>
</fieldset>
<fieldset>
<legend class="nd_sidebar-legend">
<label><em><strong>Options</strong></em></label>
</legend>
<div class="clearfix">
<ul class="unstyled">
<li>
<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>
</li>
<li>
<em class="muted">Order By:</em><br/>
<select id="nd_mac-format" class="nd_side-select" name="order">
[% FOREACH item IN [ 'Device', 'MAC', 'Vendor' ] %]
<option[% ' selected="selected"' IF params.order == item %]>[% item %]</option>
[% END %]
</select>
</li>
</ul>
<div class="clearfix input-prepend"
rel="tooltip" data-placement="left" data-offset="5" data-title="Include Archived Data">
<label class="add-on">
<input type="checkbox" id="archived"
name="archived"[% ' checked="checked"' IF params.archived %]/>
</label>
<label class="nd_checkboxlabel" for="archived">
<span class="nd_searchcheckbox uneditable-input">Archived Data</span>
</label>
</div>
</div>
</fieldset>
<button id="[% report.tag %]_submit" type="submit" class="btn btn-info">
<i class="icon-search icon-large pull-left nd_navbar-icon"></i> Search Vendors</button>