Be more strict about Node Search matching ports/wifi within date range
This commit is contained in:
@@ -8,6 +8,8 @@
|
|||||||
[ENHANCEMENTS]
|
[ENHANCEMENTS]
|
||||||
|
|
||||||
* Show page and total records number on DataTables tables
|
* Show page and total records number on DataTables tables
|
||||||
|
* Be more strict about Node Search matching ports/wifi within date range
|
||||||
|
* Allow filtering out of Device Ports on Node (MAC) search
|
||||||
|
|
||||||
[BUG FIXES]
|
[BUG FIXES]
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ ajax '/ajax/content/search/node' => require_login sub {
|
|||||||
my $mac = NetAddr::MAC->new(mac => $node);
|
my $mac = NetAddr::MAC->new(mac => $node);
|
||||||
my @active = (param('archived') ? () : (-bool => 'active'));
|
my @active = (param('archived') ? () : (-bool => 'active'));
|
||||||
|
|
||||||
my @times = ();
|
my (@times, @wifitimes, @porttimes);
|
||||||
if ($start and $end) {
|
if ($start and $end) {
|
||||||
$start = $start . ' 00:00:00';
|
$start = $start . ' 00:00:00';
|
||||||
$end = $end . ' 23:59:59';
|
$end = $end . ' 23:59:59';
|
||||||
@@ -34,12 +34,28 @@ ajax '/ajax/content/search/node' => require_login sub {
|
|||||||
time_first => [ { '<', $start }, undef ],
|
time_first => [ { '<', $start }, undef ],
|
||||||
time_last => { '>', $end },
|
time_last => { '>', $end },
|
||||||
]);
|
]);
|
||||||
|
@wifitimes = (-or => [
|
||||||
|
time_last => { '<', $start },
|
||||||
|
time_last => { '>', $end },
|
||||||
|
]);
|
||||||
|
@porttimes = (-or => [
|
||||||
|
creation => { '<', $start },
|
||||||
|
creation => { '>', $end },
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@times = (-and => [
|
@times = (-and => [
|
||||||
time_first => { '>=', $start },
|
time_first => { '>=', $start },
|
||||||
time_last => { '<=', $end },
|
time_last => { '<=', $end },
|
||||||
]);
|
]);
|
||||||
|
@wifitimes = (-and => [
|
||||||
|
time_last => { '>=', $start },
|
||||||
|
time_last => { '<=', $end },
|
||||||
|
]);
|
||||||
|
@porttimes = (-and => [
|
||||||
|
creation => { '>=', $start },
|
||||||
|
creation => { '<=', $end },
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,11 +101,8 @@ ajax '/ajax/content/search/node' => require_login sub {
|
|||||||
join => 'oui'
|
join => 'oui'
|
||||||
});
|
});
|
||||||
|
|
||||||
my $ports = schema('netdisco')->resultset('DevicePort')
|
|
||||||
->search({ -and => [@where_mac] });
|
|
||||||
|
|
||||||
my $wireless = schema('netdisco')->resultset('NodeWireless')->search(
|
my $wireless = schema('netdisco')->resultset('NodeWireless')->search(
|
||||||
{ -and => [@where_mac] },
|
{ -and => [@where_mac, @wifitimes] },
|
||||||
{ order_by => { '-desc' => 'time_last' },
|
{ order_by => { '-desc' => 'time_last' },
|
||||||
'+columns' => [
|
'+columns' => [
|
||||||
'oui.company',
|
'oui.company',
|
||||||
@@ -101,8 +114,10 @@ ajax '/ajax/content/search/node' => require_login sub {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($sightings->has_rows or $ips->has_rows
|
my $rs_dp = schema('netdisco')->resultset('DevicePort');
|
||||||
or $ports->has_rows or $netbios->has_rows) {
|
if ($sightings->has_rows or $ips->has_rows or $netbios->has_rows) {
|
||||||
|
my $ports = param('deviceports')
|
||||||
|
? $rs_dp->search({ -and => [@where_mac] }) : undef;
|
||||||
|
|
||||||
return template 'ajax/search/node_by_mac.tt', {
|
return template 'ajax/search/node_by_mac.tt', {
|
||||||
ips => $ips,
|
ips => $ips,
|
||||||
@@ -112,7 +127,20 @@ ajax '/ajax/content/search/node' => require_login sub {
|
|||||||
netbios => $netbios,
|
netbios => $netbios,
|
||||||
}, { layout => undef };
|
}, { layout => undef };
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
my $ports = param('deviceports')
|
||||||
|
? $rs_dp->search({ -and => [@where_mac, @porttimes] }) : undef;
|
||||||
|
|
||||||
|
if (defined $ports and $ports->has_rows) {
|
||||||
|
return template 'ajax/search/node_by_mac.tt', {
|
||||||
|
ips => $ips,
|
||||||
|
sightings => $sightings,
|
||||||
|
ports => $ports,
|
||||||
|
wireless => $wireless,
|
||||||
|
netbios => $netbios,
|
||||||
|
}, { layout => undef };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
my $set = schema('netdisco')->resultset('NodeNbt')
|
my $set = schema('netdisco')->resultset('NodeNbt')
|
||||||
->search_by_name({nbname => $likeval, @active, @times});
|
->search_by_name({nbname => $likeval, @active, @times});
|
||||||
@@ -133,7 +161,7 @@ ajax '/ajax/content/search/node' => require_login sub {
|
|||||||
# if the user selects Vendor search opt, then
|
# if the user selects Vendor search opt, then
|
||||||
# we'll try the OUI company name as a fallback
|
# we'll try the OUI company name as a fallback
|
||||||
|
|
||||||
if (not $set->has_rows and param('show_vendor')) {
|
if (param('show_vendor') and not $set->has_rows) {
|
||||||
$set = schema('netdisco')->resultset('NodeIp')
|
$set = schema('netdisco')->resultset('NodeIp')
|
||||||
->with_times
|
->with_times
|
||||||
->search(
|
->search(
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ use NetAddr::MAC ();
|
|||||||
hook 'before' => sub {
|
hook 'before' => sub {
|
||||||
# view settings for node options
|
# view settings for node options
|
||||||
var('node_options' => [
|
var('node_options' => [
|
||||||
{ name => 'stamps', label => 'Time Stamps', default => 'on' },
|
{ name => 'stamps', label => 'Time Stamps', default => 'on' },
|
||||||
|
{ name => 'deviceports', label => 'Device Ports', default => 'on' },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
# view settings for device options
|
# view settings for device options
|
||||||
|
|||||||
@@ -10,6 +10,15 @@
|
|||||||
<span class="nd_searchcheckbox uneditable-input">Time Stamps</span>
|
<span class="nd_searchcheckbox uneditable-input">Time Stamps</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="clearfix input-prepend">
|
||||||
|
<label class="add-on">
|
||||||
|
<input type="checkbox" id="deviceports"
|
||||||
|
name="deviceports"[% ' checked="checked"' IF params.deviceports %]/>
|
||||||
|
</label>
|
||||||
|
<label class="nd_checkboxlabel" for="deviceports">
|
||||||
|
<span class="nd_searchcheckbox uneditable-input">Device Ports</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<div class="clearfix input-prepend">
|
<div class="clearfix input-prepend">
|
||||||
<label class="add-on">
|
<label class="add-on">
|
||||||
<input type="checkbox" id="show_vendor"
|
<input type="checkbox" id="show_vendor"
|
||||||
|
|||||||
Reference in New Issue
Block a user