Navbar query for device with single hit redirects to Device details page
This commit is contained in:
4
Changes
4
Changes
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
[ENHANCEMENTS]
|
[ENHANCEMENTS]
|
||||||
|
|
||||||
* Move DBIC virtual tables into Virtual:: namespace.
|
* Move DBIC virtual tables into Virtual:: namespace (closes #19)
|
||||||
|
* Maintain node search options when changing navbar query (closes #27)
|
||||||
|
* Navbar query for device with single hit redirects to Device details page
|
||||||
|
|
||||||
0.6 2012-08-28
|
0.6 2012-08-28
|
||||||
|
|
||||||
|
|||||||
@@ -210,7 +210,13 @@ get '/search' => sub {
|
|||||||
my $s = schema('netdisco');
|
my $s = schema('netdisco');
|
||||||
if ($q =~ m{^[a-f0-9.:/]+$}i) {
|
if ($q =~ m{^[a-f0-9.:/]+$}i) {
|
||||||
my $ip = NetAddr::IP::Lite->new($q);
|
my $ip = NetAddr::IP::Lite->new($q);
|
||||||
if ($ip and $s->resultset('Device')->search_by_field({ip => $q})->count) {
|
my $nd = $s->resultset('Device')->search_by_field({ip => $q});
|
||||||
|
if ($ip and $nd->count) {
|
||||||
|
if ($nd->count == 1) {
|
||||||
|
# redirect to device details for the one device
|
||||||
|
redirect uri_for('/device',
|
||||||
|
{tab => 'details', q => $q, f => ''});
|
||||||
|
}
|
||||||
params->{'tab'} = 'device';
|
params->{'tab'} = 'device';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -220,8 +226,13 @@ get '/search' => sub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ($s->resultset('Device')
|
my $nd = $s->resultset('Device')->search({dns => { '-ilike' => "\%$q\%" }});
|
||||||
->search({dns => { '-ilike' => "\%$q\%" }})->count) {
|
if ($nd->count) {
|
||||||
|
if ($nd->count == 1) {
|
||||||
|
# redirect to device details for the one device
|
||||||
|
redirect uri_for('/device',
|
||||||
|
{tab => 'details', q => $nd->first->ip, f => ''});
|
||||||
|
}
|
||||||
params->{'tab'} = 'device';
|
params->{'tab'} = 'device';
|
||||||
}
|
}
|
||||||
elsif ($s->resultset('DevicePort')
|
elsif ($s->resultset('DevicePort')
|
||||||
|
|||||||
Reference in New Issue
Block a user