#1010 Search port descriptions

This commit is contained in:
Oliver Gorwits
2023-04-03 22:02:43 +01:00
parent 5baad7311d
commit e268b9d522
3 changed files with 20 additions and 2 deletions

View File

@@ -17,7 +17,7 @@ register_search_tab({
api_endpoint => 1, api_endpoint => 1,
api_parameters => [ api_parameters => [
q => { q => {
description => 'Port name or VLAN or MAC address', description => 'Port name, VLAN, or MAC address',
required => 1, required => 1,
}, },
partial => { partial => {
@@ -30,6 +30,11 @@ register_search_tab({
type => 'boolean', type => 'boolean',
default => 'false', default => 'false',
}, },
descr => {
description => 'Search in the Port Description field',
type => 'boolean',
default => 'false',
},
ethernet => { ethernet => {
description => 'Only Ethernet type interfaces in results', description => 'Only Ethernet type interfaces in results',
type => 'boolean', type => 'boolean',
@@ -76,6 +81,9 @@ get '/ajax/content/search/port' => require_login sub {
-and => [ -and => [
-or => [ -or => [
{ "me.name" => ( param('partial') ? $likeclause : $q ) }, { "me.name" => ( param('partial') ? $likeclause : $q ) },
( param('descr') ? (
{ "me.descr" => ( param('partial') ? $likeclause : $q ) },
) : () ),
( ((!defined $mac) or $mac->errstr) ( ((!defined $mac) or $mac->errstr)
? \[ 'me.mac::text ILIKE ?', $likeval ] ? \[ 'me.mac::text ILIKE ?', $likeval ]
: { 'me.mac' => $mac->as_ieee } : { 'me.mac' => $mac->as_ieee }

View File

@@ -108,6 +108,7 @@ sidebar_defaults:
search_port: search_port:
partial: { default: checked } partial: { default: checked }
uplink: { default: null } uplink: { default: null }
descr: { default: null }
ethernet: { default: checked } ethernet: { default: checked }
search_device: search_device:
matchall: { default: checked } matchall: { default: checked }

View File

@@ -16,7 +16,16 @@
name="uplink"[% ' checked="checked"' IF vars.sidebar_defaults.search_port.uplink %]/> name="uplink"[% ' checked="checked"' IF vars.sidebar_defaults.search_port.uplink %]/>
</label> </label>
<label class="nd_checkboxlabel" for="port_uplink"> <label class="nd_checkboxlabel" for="port_uplink">
<span class="nd_searchcheckbox uneditable-input">Uplinks</span> <span class="nd_searchcheckbox uneditable-input">Include Uplinks</span>
</label>
</div>
<div class="clearfix input-prepend">
<label class="add-on">
<input type="checkbox" id="port_descr"
name="descr"[% ' checked="checked"' IF vars.sidebar_defaults.search_port.descr %]/>
</label>
<label class="nd_checkboxlabel" for="port_descr">
<span class="nd_searchcheckbox uneditable-input">Search Description</span>
</label> </label>
</div> </div>
<div class="clearfix input-prepend"> <div class="clearfix input-prepend">