#667 Network Map: Filter by VLAN doesnt work as expected

This commit is contained in:
Oliver Gorwits
2019-12-22 00:16:04 +00:00
parent 4268fff785
commit d133eb97c2
2 changed files with 14 additions and 2 deletions

View File

@@ -141,6 +141,18 @@ __PACKAGE__->has_many(
'ip', { join_type => 'RIGHT' }
);
=head2 port_vlans_filter
A JOIN condition which can be used to filter a set of Devices to those known
carrying a given VLAN on its ports. Uses an INNER JOIN to achieve this.
=cut
__PACKAGE__->has_many(
port_vlans_filter => 'App::Netdisco::DB::Result::DevicePortVlan',
'ip', { join_type => 'INNER' }
);
# helper which assumes we've just RIGHT JOINed to Vlans table
sub vlan { return (shift)->vlans->first }

View File

@@ -211,8 +211,8 @@ ajax '/ajax/data/device/netmap' => require_login sub {
# filter by vlan for all or neighbors only
if ($vlan) {
$devices = $devices->search(
{ 'vlans.vlan' => $vlan },
{ join => 'vlans' }
{ 'port_vlans_filter.vlan' => $vlan },
{ join => 'port_vlans_filter' }
);
}