#882 option to display vlan names instead of numbers in device ports table
This commit is contained in:
@@ -203,6 +203,26 @@ __PACKAGE__->might_have(
|
||||
}
|
||||
);
|
||||
|
||||
=head2 native_vlan
|
||||
|
||||
Returns the row from the C<device_vlan> table corresponding to the native
|
||||
vlan of this port.
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->belongs_to(
|
||||
native_vlan => 'App::Netdisco::DB::Result::DeviceVlan',
|
||||
sub {
|
||||
my $args = shift;
|
||||
return {
|
||||
"$args->{foreign_alias}.ip" =>
|
||||
{ '-ident' => "$args->{self_alias}.ip" },
|
||||
"$args->{self_alias}.vlan" =>
|
||||
{ '=' => \"cast($args->{foreign_alias}.vlan as text)" }
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
=head2 agg_master
|
||||
|
||||
Returns another row from the C<device_port> table if this port is slave
|
||||
|
||||
@@ -60,14 +60,14 @@ __PACKAGE__->belongs_to( port => 'App::Netdisco::DB::Result::DevicePort', {
|
||||
'foreign.ip' => 'self.ip', 'foreign.port' => 'self.port',
|
||||
});
|
||||
|
||||
=head2 vlan
|
||||
=head2 vlan_entry
|
||||
|
||||
Returns the entry from the C<device_vlan> table describing this VLAN in
|
||||
detail, typically in order that the C<name> can be retrieved.
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->belongs_to( vlan => 'App::Netdisco::DB::Result::DeviceVlan', {
|
||||
__PACKAGE__->belongs_to( vlan_entry => 'App::Netdisco::DB::Result::DeviceVlan', {
|
||||
'foreign.ip' => 'self.ip', 'foreign.vlan' => 'self.vlan',
|
||||
});
|
||||
|
||||
|
||||
@@ -108,10 +108,11 @@ get '/ajax/content/device/ports' => require_login sub {
|
||||
my $vlans = $set->search({}, {
|
||||
select => [
|
||||
'port',
|
||||
{ array_agg => 'port_vlans.vlan', -as => 'vlan_set' },
|
||||
{ count => 'port_vlans.vlan', -as => 'vlan_count' },
|
||||
{ array_agg => 'port_vlans.vlan', -as => 'vlan_set' },
|
||||
{ array_agg => 'vlan_entry.description', -as => 'vlan_name_set' },
|
||||
],
|
||||
join => 'port_vlans',
|
||||
join => {'port_vlans' => 'vlan_entry'},
|
||||
group_by => 'me.port',
|
||||
});
|
||||
|
||||
@@ -119,12 +120,21 @@ get '/ajax/content/device/ports' => require_login sub {
|
||||
$vlans = { map {(
|
||||
$_->port => {
|
||||
# DBIC smart enough to work out this should be an arrayref :)
|
||||
vlan_set => $_->get_column('vlan_set'),
|
||||
vlan_count => $_->get_column('vlan_count'),
|
||||
vlan_set => $_->get_column('vlan_set'),
|
||||
vlan_name_set => $_->get_column('vlan_name_set'),
|
||||
},
|
||||
)} $vlans->all };
|
||||
}
|
||||
|
||||
if (param('c_vlan_names')) {
|
||||
$set = $set->search({}, {
|
||||
'join' => 'native_vlan',
|
||||
'+select' => [qw/native_vlan.description/],
|
||||
'+as' => [qw/native_vlan_name/],
|
||||
});
|
||||
}
|
||||
|
||||
# get aggregate master status (self join)
|
||||
$set = $set->search({}, {
|
||||
'join' => 'agg_master',
|
||||
|
||||
Reference in New Issue
Block a user