diff --git a/Changes b/Changes index 1319b6a9..f7158a18 100644 --- a/Changes +++ b/Changes @@ -12,6 +12,10 @@ * Scheduler config does not need to be uncommented * More efficient polling of the job queue + [BUG FIXES] + + * Specific search from titlebar uses default sidebar settings + 2.036011 - 2017-10-09 [BUG FIXES] diff --git a/lib/App/Netdisco/Web/Plugin/Search/Port.pm b/lib/App/Netdisco/Web/Plugin/Search/Port.pm index 37ab2f75..9bc43f22 100644 --- a/lib/App/Netdisco/Web/Plugin/Search/Port.pm +++ b/lib/App/Netdisco/Web/Plugin/Search/Port.pm @@ -18,33 +18,48 @@ get '/ajax/content/search/port' => require_login sub { if ( $q =~ m/^\d+$/ ) { $rs = schema('netdisco')->resultset('DevicePort') - ->columns( [qw/ ip port name descr /] )->search( - { "port_vlans.vlan" => $q }, - { '+columns' => [qw/ device.dns device.name port_vlans.vlan /], + ->columns( [qw/ ip port name up up_admin speed /] )->search({ + "port_vlans.vlan" => $q, + ( param('uplink') ? () : (-or => [ + {-not_bool => "me.is_uplink"}, + {"me.is_uplink" => undef}, + ]) ), + ( param('ethernet') ? ("me.type" => 'ethernetCsmacd') : () ), + },{ '+columns' => [qw/ device.dns device.name port_vlans.vlan /], join => [qw/ port_vlans device /] } - ); + )->with_times; } else { my ( $likeval, $likeclause ) = sql_match($q); $rs = schema('netdisco')->resultset('DevicePort') - ->columns( [qw/ ip port name descr /] )->search( - { -or => [ - { "me.name" => ( param('partial') ? $likeclause : $q ) }, - ( length $q == 17 - ? { "me.mac" => $q } - : \[ 'me.mac::text ILIKE ?', $likeval ] - ), + ->columns( [qw/ ip port name up up_admin speed /] ) + ->search({ + -and => [ + -or => [ + { "me.name" => ( param('partial') ? $likeclause : $q ) }, + ( length $q == 17 + ? { "me.mac" => $q } + : \[ 'me.mac::text ILIKE ?', $likeval ] + ), + ( param('uplink') ? ( { "me.remote_id" => $likeclause }, { "me.remote_type" => $likeclause }, - ] + ) : () ), + ], + ( param('uplink') ? () : (-or => [ + {-not_bool => "me.is_uplink"}, + {"me.is_uplink" => undef}, + ]) ), + ( param('ethernet') ? ("me.type" => 'ethernetCsmacd') : () ), + ] }, { '+columns' => [qw/ device.dns device.name port_vlans.vlan /], join => [qw/ port_vlans device /] } - ); + )->with_times; } my @results = $rs->hri->all; diff --git a/lib/App/Netdisco/Web/Search.pm b/lib/App/Netdisco/Web/Search.pm index a2adb106..4ee39116 100644 --- a/lib/App/Netdisco/Web/Search.pm +++ b/lib/App/Netdisco/Web/Search.pm @@ -15,24 +15,24 @@ hook 'before' => sub { { name => 'deviceports', label => 'Device Ports', default => 'on' }, ]); + # view settings for port options + var('port_options' => [ + { name => 'ethernet', label => 'Ethernet Only', default => 'on' }, + ]); + # view settings for device options var('device_options' => [ { name => 'matchall', label => 'Match All Options', default => 'on' }, ]); - return unless (request->path eq uri_for('/search')->path - or index(request->path, uri_for('/ajax/content/search')->path) == 0); + return unless param('firstsearch') and + (request->path eq uri_for('/search')->path + or index(request->path, uri_for('/ajax/content/search')->path) == 0); - foreach my $col (@{ var('node_options') }) { - next unless $col->{default} eq 'on'; - params->{$col->{name}} = 'checked' - if not param('tab') or param('tab') ne 'node'; - } - - foreach my $col (@{ var('device_options') }) { - next unless $col->{default} eq 'on'; - params->{$col->{name}} = 'checked' - if not param('tab') or param('tab') ne 'device'; + foreach my $col (@{ var('node_options') }, + @{ var('port_options') }, + @{ var('device_options') }) { + params->{$col->{name}} = 'checked' if $col->{default} eq 'on'; } }; diff --git a/share/views/ajax/search/port.tt b/share/views/ajax/search/port.tt index 4380c920..25c1a1cc 100644 --- a/share/views/ajax/search/port.tt +++ b/share/views/ajax/search/port.tt @@ -1,10 +1,12 @@
| Status | Name | Port | -Description | Vlan | +Speed | +Last Change |
|---|