[#69] Add search by layers to device search
This commit is contained in:
@@ -2,7 +2,11 @@
|
|||||||
|
|
||||||
[NEW FEATURES]
|
[NEW FEATURES]
|
||||||
|
|
||||||
* [#86] Use Vendor abbrevs to enhance node display in device port view
|
* [#86] Use Vendor abbrevs to enhance node display in device port view
|
||||||
|
|
||||||
|
[ENHANCEMENTS]
|
||||||
|
|
||||||
|
* [#69] Add search by layers to device search
|
||||||
|
|
||||||
|
|
||||||
2.022000 - 2014-01-26
|
2.022000 - 2014-01-26
|
||||||
|
|||||||
@@ -204,6 +204,23 @@ sub search_by_field {
|
|||||||
|| NetAddr::IP::Lite->new('255.255.255.255') );
|
|| NetAddr::IP::Lite->new('255.255.255.255') );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# For Search on Layers
|
||||||
|
my @layer_search = ( '_', '_', '_', '_', '_', '_', '_' );
|
||||||
|
# @layer_search is computer indexed, left->right
|
||||||
|
my $layers = $p->{layers};
|
||||||
|
if ( defined $layers && ref $layers ) {
|
||||||
|
foreach my $layer (@$layers) {
|
||||||
|
next unless defined $layer and length($layer);
|
||||||
|
next if ( $layer < 1 || $layer > 7 );
|
||||||
|
$layer_search[ $layer - 1 ] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif ( defined $layers ) {
|
||||||
|
$layer_search[ $layers - 1 ] = 1;
|
||||||
|
}
|
||||||
|
# the database field is in order 87654321
|
||||||
|
my $layer_string = join( '', reverse @layer_search );
|
||||||
|
|
||||||
return $rs
|
return $rs
|
||||||
->search_rs({}, $attrs)
|
->search_rs({}, $attrs)
|
||||||
->search({
|
->search({
|
||||||
@@ -214,6 +231,8 @@ sub search_by_field {
|
|||||||
{ '-ilike' => "\%$p->{location}\%" }) : ()),
|
{ '-ilike' => "\%$p->{location}\%" }) : ()),
|
||||||
($p->{description} ? ('me.description' =>
|
($p->{description} ? ('me.description' =>
|
||||||
{ '-ilike' => "\%$p->{description}\%" }) : ()),
|
{ '-ilike' => "\%$p->{description}\%" }) : ()),
|
||||||
|
($p->{layers} ? ('me.layers' =>
|
||||||
|
{ '-ilike' => "\%$layer_string" }) : ()),
|
||||||
|
|
||||||
($p->{model} ? ('me.model' =>
|
($p->{model} ? ('me.model' =>
|
||||||
{ '-in' => $p->{model} }) : ()),
|
{ '-in' => $p->{model} }) : ()),
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ my $headers = ['Device','Contact','Location','System Name','Model','OS Version',
|
|||||||
# device with various properties or a default match-all
|
# device with various properties or a default match-all
|
||||||
get '/ajax/content/search/device' => require_login sub {
|
get '/ajax/content/search/device' => require_login sub {
|
||||||
my $has_opt = List::MoreUtils::any {param($_)}
|
my $has_opt = List::MoreUtils::any {param($_)}
|
||||||
qw/name location dns ip description model os_ver vendor/;
|
qw/name location dns ip description model os_ver vendor layers/;
|
||||||
my $set;
|
my $set;
|
||||||
|
|
||||||
if ($has_opt) {
|
if ($has_opt) {
|
||||||
|
|||||||
@@ -68,6 +68,15 @@
|
|||||||
[% END %]
|
[% END %]
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="clearfix">
|
||||||
|
<select class="nd_side-select" size="3"
|
||||||
|
multiple="on" name="layers"
|
||||||
|
rel="tooltip" data-placement="left" data-offset="5" data-title="Layer"/>
|
||||||
|
[% FOREACH opt IN [ 1 .. 7 ] %]
|
||||||
|
<option[% ' selected="selected"' IF layers_lkp.exists(opt) %]>[% opt | html_entity %]</option>
|
||||||
|
[% END %]
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<div class="clearfix input-prepend">
|
<div class="clearfix input-prepend">
|
||||||
<label class="add-on">
|
<label class="add-on">
|
||||||
<input type="checkbox" id="matchall"
|
<input type="checkbox" id="matchall"
|
||||||
|
|||||||
Reference in New Issue
Block a user