#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
|
=head2 agg_master
|
||||||
|
|
||||||
Returns another row from the C<device_port> table if this port is slave
|
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',
|
'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
|
Returns the entry from the C<device_vlan> table describing this VLAN in
|
||||||
detail, typically in order that the C<name> can be retrieved.
|
detail, typically in order that the C<name> can be retrieved.
|
||||||
|
|
||||||
=cut
|
=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',
|
'foreign.ip' => 'self.ip', 'foreign.vlan' => 'self.vlan',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -108,10 +108,11 @@ get '/ajax/content/device/ports' => require_login sub {
|
|||||||
my $vlans = $set->search({}, {
|
my $vlans = $set->search({}, {
|
||||||
select => [
|
select => [
|
||||||
'port',
|
'port',
|
||||||
{ array_agg => 'port_vlans.vlan', -as => 'vlan_set' },
|
|
||||||
{ count => 'port_vlans.vlan', -as => 'vlan_count' },
|
{ 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',
|
group_by => 'me.port',
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -119,12 +120,21 @@ get '/ajax/content/device/ports' => require_login sub {
|
|||||||
$vlans = { map {(
|
$vlans = { map {(
|
||||||
$_->port => {
|
$_->port => {
|
||||||
# DBIC smart enough to work out this should be an arrayref :)
|
# DBIC smart enough to work out this should be an arrayref :)
|
||||||
vlan_set => $_->get_column('vlan_set'),
|
|
||||||
vlan_count => $_->get_column('vlan_count'),
|
vlan_count => $_->get_column('vlan_count'),
|
||||||
|
vlan_set => $_->get_column('vlan_set'),
|
||||||
|
vlan_name_set => $_->get_column('vlan_name_set'),
|
||||||
},
|
},
|
||||||
)} $vlans->all };
|
)} $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)
|
# get aggregate master status (self join)
|
||||||
$set = $set->search({}, {
|
$set = $set->search({}, {
|
||||||
'join' => 'agg_master',
|
'join' => 'agg_master',
|
||||||
|
|||||||
@@ -126,12 +126,13 @@ sidebar_defaults:
|
|||||||
c_mtu: { label: 'MTU', default: null, idx: 12 }
|
c_mtu: { label: 'MTU', default: null, idx: 12 }
|
||||||
c_pvid: { label: 'Native VLAN', default: checked, idx: 13 }
|
c_pvid: { label: 'Native VLAN', default: checked, idx: 13 }
|
||||||
c_vmember: { label: 'VLAN Membership', default: checked, idx: 14 }
|
c_vmember: { label: 'VLAN Membership', default: checked, idx: 14 }
|
||||||
c_power: { label: 'PoE', default: null, idx: 15 }
|
c_vlan_names: { label: 'use VLAN Names', default: null, idx: 15 }
|
||||||
c_ssid: { label: 'SSID', default: null, idx: 16 }
|
c_power: { label: 'PoE', default: null, idx: 16 }
|
||||||
c_nodes: { label: 'Connected Nodes', default: null, idx: 17 }
|
c_ssid: { label: 'SSID', default: null, idx: 17 }
|
||||||
c_neighbors: { label: 'Connected Devices', default: checked, idx: 18 }
|
c_nodes: { label: 'Connected Nodes', default: null, idx: 18 }
|
||||||
c_stp: { label: 'Spanning Tree', default: null, idx: 19 }
|
c_neighbors: { label: 'Connected Devices', default: checked, idx: 19 }
|
||||||
c_up: { label: 'Status', default: null, idx: 20 }
|
c_stp: { label: 'Spanning Tree', default: null, idx: 20 }
|
||||||
|
c_up: { label: 'Status', default: null, idx: 21 }
|
||||||
mac_format: { default: IEEE }
|
mac_format: { default: IEEE }
|
||||||
n_inventory: { label: 'Remote Inventory', default: checked, idx: 0 }
|
n_inventory: { label: 'Remote Inventory', default: checked, idx: 0 }
|
||||||
n_detailed_inventory: { label: 'Remote Advertisement', default: null, idx: 1 }
|
n_detailed_inventory: { label: 'Remote Advertisement', default: null, idx: 1 }
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
[% FOREACH item IN settings.port_columns %]
|
[% FOREACH item IN settings.port_columns %]
|
||||||
[% NEXT IF item.name == 'c_admin' %]
|
[% NEXT IF item.name == 'c_admin' OR item.name == 'c_vlan_names' %]
|
||||||
[% NEXT IF item.name == 'c_nodes' AND params.c_nodes AND params.c_neighbors %]
|
[% NEXT IF item.name == 'c_nodes' AND params.c_nodes AND params.c_neighbors %]
|
||||||
[% NEXT UNLESS params.${item.name} %]
|
[% NEXT UNLESS params.${item.name} %]
|
||||||
[% SET th_class = '' %]
|
[% SET th_class = '' %]
|
||||||
@@ -204,9 +204,14 @@
|
|||||||
<td>
|
<td>
|
||||||
[% IF row.vlan AND row.vlan > 0 %]
|
[% IF row.vlan AND row.vlan > 0 %]
|
||||||
<a class="nd_linkcell"
|
<a class="nd_linkcell"
|
||||||
|
[% IF params.c_vlan_names %]
|
||||||
|
href="[% uri_for('/search') | none %]?tab=vlan&q=[% row.get_column('native_vlan_name') | uri %]">
|
||||||
|
[% row.get_column('native_vlan_name') | html_entity %]</a>
|
||||||
|
[% ELSE %]
|
||||||
href="[% uri_for('/search') | none %]?tab=vlan&q=[% row.vlan | uri %]">
|
href="[% uri_for('/search') | none %]?tab=vlan&q=[% row.vlan | uri %]">
|
||||||
[% row.vlan | html_entity %]</a>
|
[% row.vlan | html_entity %]</a>
|
||||||
[% END %]
|
[% END %]
|
||||||
|
[% END %]
|
||||||
</td>
|
</td>
|
||||||
[% END %]
|
[% END %]
|
||||||
[% END %]
|
[% END %]
|
||||||
@@ -215,21 +220,20 @@
|
|||||||
<td>
|
<td>
|
||||||
[% IF vlans.$portname.vlan_count <= settings.devport_vlan_limit %]
|
[% IF vlans.$portname.vlan_count <= settings.devport_vlan_limit %]
|
||||||
[% SET vlan_count = vlans.$portname.vlan_count %]
|
[% SET vlan_count = vlans.$portname.vlan_count %]
|
||||||
[% SET output = '' %]
|
[% IF params.c_vlan_names %][% SET vlanlist = vlans.$portname.vlan_name_set.sort %]
|
||||||
[% FOREACH vlan IN vlans.$portname.vlan_set.nsort %]
|
[% ELSE %][% SET vlanlist = vlans.$portname.vlan_set.nsort %][% END %]
|
||||||
[% IF vlan == 0 %][% SET vlan_count = (vlan_count - 1) %][% NEXT %][% END %]
|
[% IF vlan_count > 10 %] [%# TODO make this a settable variable %]
|
||||||
[% SET output = output _
|
<div class="nd_vlan-total">([% vlan_count %])</div><span class="nd_linkcell nd_collapse-vlans">
|
||||||
'<a href="' _ uri_for('/search') _ '?tab=vlan&q=' _ vlan _ '">' _ vlan _ '</a>' %]
|
<div class="nd_arrow-up-down-left icon-chevron-up icon-large"></div>Show VLANs</span>
|
||||||
[% IF NOT loop.last %][% SET output = output _ ', ' %][% END %]
|
<div class="nd_collapsing nd_collapse-pre-hidden">
|
||||||
|
[% END %]
|
||||||
|
[% FOREACH vlan IN vlanlist %]
|
||||||
|
<a href="[% uri_for('/search') %]?tab=vlan&q=[% vlan | uri %]">[% vlan | html_entity %]</a>
|
||||||
|
[% ', ' IF NOT loop.last %]
|
||||||
[% END %]
|
[% END %]
|
||||||
[% IF vlan_count > 10 %] [%# TODO make this a settable variable %]
|
[% IF vlan_count > 10 %] [%# TODO make this a settable variable %]
|
||||||
[% SET output = '<div class="nd_vlan-total">(' _ vlan_count
|
</div>
|
||||||
_ ')</div><span class="nd_linkcell nd_collapse-vlans">
|
|
||||||
<div class="nd_arrow-up-down-left icon-chevron-up icon-large"></div>Show VLANs</span>
|
|
||||||
<div class="nd_collapsing nd_collapse-pre-hidden">' _ output %]
|
|
||||||
[% SET output = output _ '</div>' %]
|
|
||||||
[% END %]
|
[% END %]
|
||||||
[% output | none %]
|
|
||||||
[% ELSE %]
|
[% ELSE %]
|
||||||
<i class="icon-asterisk text-warning"></i> ([% vlans.$portname.vlan_count %] is too many to list)
|
<i class="icon-asterisk text-warning"></i> ([% vlans.$portname.vlan_count %] is too many to list)
|
||||||
[% END %]
|
[% END %]
|
||||||
|
|||||||
Reference in New Issue
Block a user