diff --git a/Netdisco/Changes b/Netdisco/Changes index 035774b7..c4b7b99c 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -19,6 +19,9 @@ * Port MAC query now only returns distinct MAC's * Keep a hint to SNMP community if new style snmp_auth config is in use * [#43] Add doc note about PostgreSQL MD5 authN + * [#49] Allow device port searching with preference for port/name/vlan. + This is to support some devices (HP?) which have plain numbers for port names + and Netdisco defaults to assuming this is a VLAN number (R. Kerr) [BUG FIXES] diff --git a/Netdisco/lib/App/Netdisco/Web/Device.pm b/Netdisco/lib/App/Netdisco/Web/Device.pm index 63574069..8f08c336 100644 --- a/Netdisco/lib/App/Netdisco/Web/Device.pm +++ b/Netdisco/lib/App/Netdisco/Web/Device.pm @@ -146,6 +146,7 @@ hook 'before_template' => sub { my $self_uri = uri_for(request->path, scalar params); $self_uri->query_param_delete('q'); $self_uri->query_param_delete('f'); + $self_uri->query_param_delete('prefer'); $tokens->{self_options} = $self_uri->query_form_hash; }; diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm index ccff9d5b..d41cd194 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm @@ -12,6 +12,9 @@ register_device_tab({ tag => 'ports', label => 'Ports', provides_csv => 1 }); # device ports with a description (er, name) matching get '/ajax/content/device/ports' => require_login sub { my $q = param('q'); + my $prefer = param('prefer'); + $prefer = '' + unless defined $prefer and $prefer =~ m/^(?:port|name|vlan)$/; my $device = schema('netdisco')->resultset('Device') ->search_for_device($q) or send_error('Bad device', 400); @@ -20,7 +23,7 @@ get '/ajax/content/device/ports' => require_login sub { # refine by ports if requested my $f = param('f'); if ($f) { - if ($f =~ m/^\d+$/) { + if (($prefer eq 'vlan') or not $prefer and $f =~ m/^\d+$/) { if (param('invert')) { $set = $set->search({ 'me.vlan' => { '!=' => $f }, @@ -57,7 +60,9 @@ get '/ajax/content/device/ports' => require_login sub { $f = { '!=' => $f }; } - if ($set->search({'me.port' => $f})->count) { + if (($prefer eq 'port') or not $prefer and + $set->search({'me.port' => $f})->count) { + $set = $set->search({'me.port' => $f}); } else { diff --git a/Netdisco/share/public/css/netdisco.css b/Netdisco/share/public/css/netdisco.css index dbb223d7..44b3302d 100644 --- a/Netdisco/share/public/css/netdisco.css +++ b/Netdisco/share/public/css/netdisco.css @@ -526,12 +526,23 @@ td > form.nd_inline-form { } /* sidebar submit button width and spacing */ -.nd_sidebar button { + +/* when the sidebar submit button DOES NOT HAVE a dropdown */ +.nd_sidebar button:not(.nd_sidebar-btn-drop, .nd_sidebar-btn-drop-drop ) { margin-top: 9px; margin-left: -3px; width: 165px; } +/* when the sidebar submit button HAS a dropdown */ +.nd_sidebar-btn-drop { + width: 138px; +} +.nd_sidebar-btn-drop-drop { + height: 28px; + width: 28px; +} + /* little icon inside of search input fields */ .nd_field-clear-icon, .nd_field-copy-icon { position: absolute; diff --git a/Netdisco/share/views/ajax/device/ports.tt b/Netdisco/share/views/ajax/device/ports.tt index 47294d7e..d253d150 100644 --- a/Netdisco/share/views/ajax/device/ports.tt +++ b/Netdisco/share/views/ajax/device/ports.tt @@ -67,7 +67,7 @@