Skip to content

Commit

Permalink
#1205 include device remote_dns in search (port search)
Browse files Browse the repository at this point in the history
  • Loading branch information
ollyg committed May 2, 2024
1 parent b55e3c1 commit 02e9120
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
9 changes: 6 additions & 3 deletions lib/App/Netdisco/Web/Plugin/Search/Port.pm
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ get '/ajax/content/search/port' => require_login sub {
or ($mac->as_ieee !~ m/^$RE{net}{MAC}$/i)));

$rs = schema(vars->{'tenant'})->resultset('DevicePort')
->columns( [qw/ ip port name up up_admin speed /] )
->columns( [qw/ ip port name up up_admin speed properties.remote_dns /] )
->search({
-and => [
-or => [
Expand All @@ -88,12 +88,14 @@ get '/ajax/content/search/port' => require_login sub {
? \[ 'me.mac::text ILIKE ?', $likeval ]
: { 'me.mac' => $mac->as_ieee }
),
{ "properties.remote_dns" => $likeclause },
( param('uplink') ? (
{ "me.remote_id" => $likeclause },
{ "me.remote_type" => $likeclause },
) : () ),
],
( param('uplink') ? () : (-or => [
{ "properties.remote_dns" => $likeclause },
{-not_bool => "properties.remote_is_discoverable"},
{-or => [
{-not_bool => "me.is_uplink"},
Expand All @@ -103,8 +105,9 @@ get '/ajax/content/search/port' => require_login sub {
( param('ethernet') ? ("me.type" => 'ethernetCsmacd') : () ),
]
},
{ '+columns' => [qw/ device.dns device.name port_vlans.vlan /],
join => [qw/ properties port_vlans device /]
{ '+columns' => [qw/ device.dns device.name /, {vlan_agg => q{array_to_string(array_agg(port_vlans.vlan), ', ')}} ],
join => [qw/ properties port_vlans device /],
group_by => [qw/me.ip me.port me.name me.up me.up_admin me.speed device.dns device.name device.last_discover device.uptime properties.remote_dns/],
}
)->with_times;
}
Expand Down
4 changes: 3 additions & 1 deletion lib/App/Netdisco/Web/Search.pm
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ get '/search' => require_login sub {
params->{'tab'} = 'device';
}
elsif ($s->resultset('DevicePort')
->with_properties
->search({
-or => [
{name => $likeclause},
{ name => $likeclause },
{ 'properties.remote_dns' => $likeclause },
(((!defined $mac) or $mac->errstr)
? \['mac::text ILIKE ?', $likeval]
: {mac => $mac->as_ieee}),
Expand Down
11 changes: 9 additions & 2 deletions share/views/ajax/search/port.tt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
<th>Status</th>
<th>Name</th>
<th>Port</th>
<th>VLAN</th>
<th>VLANs</th>
<th>Speed</th>
<th>Connected Device</th>
<th>Last Change</th>
</tr>
</thead>
Expand All @@ -25,6 +26,7 @@ $(document).ready(function() {
"columns": [{
"data": 'up',
"className": "nd_center-cell nd_devport-icon",
"width": "unset",
"render": function(data, type, row, meta) {
if (row.up_admin != "up") {
return'<i class="icon-remove"></i>';
Expand Down Expand Up @@ -54,7 +56,7 @@ $(document).ready(function() {
+ ' [' + he.encode(row.port) + ']</a>' + ddns;
}
}, {
"data": 'port_vlans.vlan',
"data": 'vlan_agg',
"render": function(data, type, row, meta) {
return data || '';
}
Expand All @@ -63,6 +65,11 @@ $(document).ready(function() {
"render": function(data, type, row, meta) {
return data || '';
}
}, {
"data": 'properties.remote_dns',
"render": function(data, type, row, meta) {
return data || '';
}
}, {
"data": 'lastchange_stamp',
"render": function(data, type, row, meta) {
Expand Down

0 comments on commit 02e9120

Please sign in to comment.