diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm index 4aa26527..dafb43df 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm @@ -31,9 +31,19 @@ ajax '/ajax/content/device/ports' => require_login sub { return unless $set->count; } else { - $f =~ s/\*/%/g if index($f, '*') >= 0; - $f =~ s/\?/_/g if index($f, '?') >= 0; - $f = { '-ilike' => $f }; + # Google-style search. Quoted means exact, otherwise wildcard. + # but still supoort manual wildcarding. + if ($f =~ m/^['"]/ and $f =~ m/['"]$/) { + $f =~ s/^['"]//; + $f =~ s/['"]$//; + } + else { + $f =~ s/\*/%/g; + $f =~ s/\?/_/g; + $f =~ s/^\%*/%/; + $f =~ s/\%*$/%/; + $f = { '-ilike' => $f }; + } if ($set->search({'me.port' => $f})->count) { $set = $set->search({'me.port' => $f}); diff --git a/Netdisco/share/views/ajax/device/addresses.tt b/Netdisco/share/views/ajax/device/addresses.tt index 36231a3c..d4d45cd5 100644 --- a/Netdisco/share/views/ajax/device/addresses.tt +++ b/Netdisco/share/views/ajax/device/addresses.tt @@ -14,7 +14,7 @@ [% row.alias | html_entity %] [% row.dns | html_entity %] [% row.port | html_entity %] + href="[% device_ports %]&q=[% params.q | uri %]&f=%22[% row.port | uri %]%22">[% row.port | html_entity %] [% row.device_port.name | html_entity %] [% row.subnet | html_entity %] diff --git a/Netdisco/share/views/ajax/device/ports.tt b/Netdisco/share/views/ajax/device/ports.tt index c019935c..82eee0d1 100644 --- a/Netdisco/share/views/ajax/device/ports.tt +++ b/Netdisco/share/views/ajax/device/ports.tt @@ -61,7 +61,7 @@ [% END %] + self_options) %]&q=[% params.q | uri %]&f=%22[% row.port | uri %]%22"> [% row.port | html_entity %] [% END %] @@ -211,7 +211,7 @@ [% IF params.c_neighbors AND (row.remote_ip OR row.is_uplink) %] [% IF row.neighbor %] + self_options) %]&q=[% row.neighbor.dns || row.neighbor.ip | uri %]&f=%22[% row.remote_port | uri %]%22"> [% row.neighbor.dns.remove(settings.domain_suffix) || row.neighbor.ip | html_entity %] ([% row.remote_port | html_entity %] [% ' id: '_ row.remote_id IF row.remote_id %] diff --git a/Netdisco/share/views/ajax/report/duplexmismatch.tt b/Netdisco/share/views/ajax/report/duplexmismatch.tt index 1d9ad1c4..5ee66449 100644 --- a/Netdisco/share/views/ajax/report/duplexmismatch.tt +++ b/Netdisco/share/views/ajax/report/duplexmismatch.tt @@ -14,13 +14,13 @@ [% row.left_dns || row.left_ip | html_entity %] + href="[% device_ports %]&q=[% row.left_dns || row.left_ip | uri %]&f=%22[% row.left_port | uri %]%22&c_duplex=on"> [% row.left_port | html_entity %] [% row.left_duplex.ucfirst | html_entity %] [% row.right_dns || row.right_ip | html_entity %] + href="[% device_ports %]&q=[% row.right_dns || row.right_ip | uri %]&f=%22[% row.right_port | uri %]%22&c_duplex=on"> [% row.right_port | html_entity %] [% row.right_duplex.ucfirst | html_entity %] diff --git a/Netdisco/share/views/ajax/report/halfduplex.tt b/Netdisco/share/views/ajax/report/halfduplex.tt index f5594292..5ce01886 100644 --- a/Netdisco/share/views/ajax/report/halfduplex.tt +++ b/Netdisco/share/views/ajax/report/halfduplex.tt @@ -12,7 +12,7 @@ [% row.device.dns || row.device.ip | html_entity %] + href="[% device_ports %]&q=[% row.device.dns || row.device.ip | uri %]&f=%22[% row.port | uri %]%22&c_duplex=on"> [% row.port | html_entity %] [% row.name | html_entity %] [% row.duplex.ucfirst | html_entity %] diff --git a/Netdisco/share/views/ajax/search/node_by_ip.tt b/Netdisco/share/views/ajax/search/node_by_ip.tt index fbe15b58..a230f0ae 100644 --- a/Netdisco/share/views/ajax/search/node_by_ip.tt +++ b/Netdisco/share/views/ajax/search/node_by_ip.tt @@ -40,7 +40,7 @@ [% END %] Switch Port + href="[% device_ports %]&q=[% node.device.dns || node.switch | uri %]&f=%22[% node.port | uri %]%22&c_nodes=on&c_neighbors=on"> [% node.switch | html_entity %] - [% node.port | html_entity %] [% '  ' IF NOT node.active %] [% IF node.device.dns AND node.device_port AND node.device_port.name %] diff --git a/Netdisco/share/views/ajax/search/node_by_mac.tt b/Netdisco/share/views/ajax/search/node_by_mac.tt index 7c6e489e..e54c6186 100644 --- a/Netdisco/share/views/ajax/search/node_by_mac.tt +++ b/Netdisco/share/views/ajax/search/node_by_mac.tt @@ -69,7 +69,7 @@ [% END %] Switch Port + href="[% device_ports %]&q=[% node.device.dns || node.switch | uri %]&f=%22[% node.port | uri %]%22&c_nodes=on&c_neighbors=on"> [% node.switch | html_entity %] - [% node.port | html_entity %] [% '  ' IF NOT node.active %] [% IF node.device.dns AND node.device_port AND node.device_port.name %] @@ -104,7 +104,7 @@ [% END %] Switch Port + href="[% device_ports %]&q=[% port.device.dns || port.ip | uri %]&f=%22[% port.port | uri %]%22&c_mac=on&c_nodes=on&c_neighbors=on"> [% port.ip | html_entity %] - [% port.descr | html_entity %] [% IF port.device.dns AND port.name %] ([% port.device.dns | html_entity %] - [% port.name | html_entity %]) diff --git a/Netdisco/share/views/ajax/search/port.tt b/Netdisco/share/views/ajax/search/port.tt index 7d00832f..b86af1f9 100644 --- a/Netdisco/share/views/ajax/search/port.tt +++ b/Netdisco/share/views/ajax/search/port.tt @@ -11,7 +11,7 @@ [% WHILE (row = results.next) %] [% row.name | html_entity %] - + [% row.ip | html_entity %] [ [% row.port | html_entity %] ] [% ' (' _ row.device.dns _ ')' IF row.device.dns %] diff --git a/Netdisco/share/views/js/device.js b/Netdisco/share/views/js/device.js index 8db23b6b..3f638c45 100644 --- a/Netdisco/share/views/js/device.js +++ b/Netdisco/share/views/js/device.js @@ -68,7 +68,7 @@ var port = $(this).text(); port = $.trim(port); - portfilter.val(port); + portfilter.val('"'+ port +'"'); $('.nd_field-clear-icon').show(); $('#ports_form').trigger('submit');