Partial Match option when searching on device port name

This commit is contained in:
Oliver Gorwits
2013-03-02 15:24:48 +00:00
parent a94b5a913d
commit 26c5014479
4 changed files with 28 additions and 3 deletions

View File

@@ -1,11 +1,16 @@
2.005000_003 - 2013-02-24
[NEW FEATURES]
* Partial Match option when searching on device port name
[ENHANCEMENTS]
* random() and LIMIT the number of daemon jobs requested from Netdisco queue
* Remove Daemon's job queue DBIC schema from user config
* Add log messages to the Daemon
* Use Path::Class for path and file name construction consistently
* Avoid use of DNS when looking up devices in DB by IP
2.005000_002 - 2013-02-10

View File

@@ -50,7 +50,7 @@ ajax '/ajax/content/search/node' => sub {
}
else {
if (param('partial')) {
$node = "\%$node\%";
$node = "\%$node\%" if $node !~ m/%/;
}
elsif (setting('domain_suffix')) {
$node .= setting('domain_suffix')

View File

@@ -15,10 +15,17 @@ ajax '/ajax/content/search/port' => sub {
my $set;
if ($q =~ m/^\d+$/) {
$set = schema('netdisco')->resultset('DevicePort')->search({vlan => $q});
$set = schema('netdisco')->resultset('DevicePort')
->search({vlan => $q});
}
else {
$set = schema('netdisco')->resultset('DevicePort')->search({name => $q});
my $query = $q;
if (param('partial')) {
$q = "\%$q\%" if $q !~ m/%/;
$query = { -ilike => $q };
}
$set = schema('netdisco')->resultset('DevicePort')
->search({name => $query});
}
return unless $set->count;

View File

@@ -0,0 +1,13 @@
<p class="nd_sidebar_title"><em>Port Search Options</em></p>
<input name="q" value="[% params.q %]" type="hidden"/>
<div class="clearfix input-prepend">
<label class="add-on">
<input type="checkbox" id="partial"
name="partial"[% ' checked="checked"' IF params.partial %]/>
</label>
<label class="nd_checkboxlabel" for="partial">
<span class="nd_searchcheckbox uneditable-input">Partial Name</span>
</label>
</div>
<button id="[% tab.id %]_submit" type="submit" class="btn btn-info">Search Again</button>