Allow device port searching with preference for port/name/vlan
This commit is contained in:
@@ -67,7 +67,7 @@
|
||||
<td nowrap>
|
||||
[% END %]
|
||||
<a class="nd_linkcell nd_this-port-only" href="[% uri_for('/device',
|
||||
self_options) %]&q=[% params.q | uri %]&f=[% row.port | uri %]">
|
||||
self_options) %]&q=[% params.q | uri %]&f=[% row.port | uri %]&prefer=port">
|
||||
[% row.port | html_entity %]
|
||||
</a></td>
|
||||
[% END %]
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
$(document).ready(function() {
|
||||
var tab = '[% tab.tag %]'
|
||||
var target = '#' + tab + '_pane';
|
||||
var portfilter = $('#ports_form').find("input[name=f]");
|
||||
|
||||
// sidebar form fields should change colour and have trash/copy icon
|
||||
form_inputs.each(function() {device_form_state($(this))});
|
||||
@@ -45,14 +46,25 @@
|
||||
.toggleClass('icon-chevron-up icon-chevron-down');
|
||||
});
|
||||
|
||||
// if the user edits the filter box, revert to automagical search
|
||||
$('#ports_form').on('input', "input[name=f]", function() {
|
||||
$('#nd_ports-form-prefer-field').attr('value', '');
|
||||
});
|
||||
|
||||
// handler for trashcan icon in port filter box
|
||||
var portfilter = $('#ports_form').find("input[name=f]");
|
||||
$('.nd_field-clear-icon').click(function() {
|
||||
portfilter.val('');
|
||||
$('#ports_form').trigger('submit');
|
||||
device_form_state(portfilter); // will hide copy icons
|
||||
});
|
||||
|
||||
// allow port filter to have a preference for port/name/vlan
|
||||
$('#ports_form').on('click', '.nd_device-port-submit-prefer', function() {
|
||||
event.preventDefault();
|
||||
$('#nd_ports-form-prefer-field').attr('value', $(this).data('prefer'));
|
||||
$(this).parents('form').submit();
|
||||
});
|
||||
|
||||
// clickable device port names can simply resubmit AJAX rather than
|
||||
// fetch the whole page again.
|
||||
$('#ports_pane').on('click', '.nd_this-port-only', function(event) {
|
||||
@@ -61,8 +73,11 @@
|
||||
var port = $(this).text();
|
||||
port = $.trim(port);
|
||||
portfilter.val(port);
|
||||
|
||||
$('.nd_field-clear-icon').show();
|
||||
|
||||
// make sure we're preferring a port filter
|
||||
$('#nd_ports-form-prefer-field').attr('value', 'port');
|
||||
|
||||
$('#ports_form').trigger('submit');
|
||||
device_form_state(portfilter); // will hide copy icons
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
<input name="q" value="[% params.q | html_entity %]" type="hidden"/>
|
||||
<input id="nd_ports-form-prefer-field" name="prefer" value="[% params.prefer | html_entity %]" type="hidden"/>
|
||||
<div class="clearfix">
|
||||
<i class="nd_field-clear-icon icon-trash icon-large"
|
||||
rel="tooltip" data-placement="bottom" data-offset="3" data-title="Show all Ports"
|
||||
@@ -133,5 +134,17 @@
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<button id="[% tab.tag %]_submit" type="submit" class="btn btn-info">
|
||||
<i class="icon-search icon-large pull-left nd_navbar-icon"></i> Update View</button>
|
||||
<div class="btn-group">
|
||||
<button id="[% tab.tag %]_submit" type="submit" class="btn btn-info nd_sidebar-btn-drop">
|
||||
<i class="icon-search icon-large pull-left nd_navbar-icon"></i> Update View</button>
|
||||
<button class="btn btn-info dropdown-toggle nd_sidebar-btn-drop-drop" data-toggle="dropdown">
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="nd_device-port-submit-prefer" href="" data-prefer="">Default Search</a></li>
|
||||
<li><a class="nd_device-port-submit-prefer" href="" data-prefer="port">Filter by Port</a></li>
|
||||
<li><a class="nd_device-port-submit-prefer" href="" data-prefer="name">Filter by Name</a></li>
|
||||
<li><a class="nd_device-port-submit-prefer" href="" data-prefer="vlan">Filter by VLAN</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user