Individual column selections for connected nodes and devices

This commit is contained in:
Oliver Gorwits
2012-11-25 17:16:14 +00:00
parent 532f000c97
commit 68ca015697
3 changed files with 16 additions and 8 deletions

View File

@@ -7,6 +7,7 @@
* Show device name on device details views (closes #30)
* Migrated to Font Awesome for a wider range of icon fonts
* Simple network map showing *some* links between devices
* Individual column selections for connected nodes and devices
[ENHANCEMENTS]

View File

@@ -22,7 +22,8 @@ hook 'before' => sub {
{ name => 'c_mtu', label => 'MTU', default => '' },
{ name => 'c_vlan', label => 'Native VLAN', default => 'on' },
{ name => 'c_vmember', label => 'VLAN Membership', default => 'on' },
{ name => 'c_connected', label => 'Connected Devices', default => '' },
{ name => 'c_nodes', label => 'Connected Nodes', default => '' },
{ name => 'c_neighbors', label => 'Connected Devices', default => 'on' },
{ name => 'c_stp', label => 'Spanning Tree', default => '' },
{ name => 'c_up', label => 'Status', default => '' },
]);
@@ -206,12 +207,15 @@ ajax '/ajax/content/device/ports' => sub {
# what kind of nodes are we interested in?
my $nodes_name = (param('n_archived') ? 'nodes' : 'active_nodes');
$nodes_name .= '_with_age' if param('c_connected') and param('n_age');
$nodes_name .= '_with_age' if param('c_nodes') and param('n_age');
# retrieve active/all connected nodes, and device, if asked for
$set = $set->search_rs({}, {
prefetch => [{$nodes_name => 'ips'}, {neighbor_alias => 'device'}],
}) if param('c_connected');
# retrieve active/all connected nodes, if asked for
$set = $set->search_rs({}, { prefetch => [{$nodes_name => 'ips'}] })
if param('c_nodes');
# retrieve neighbor devices, if asked for
$set = $set->search_rs({}, { prefetch => [{neighbor_alias => 'device'}] })
if param('c_neighbors');
# sort ports (empty set would be a 'no records' msg)
my $results = [ sort { &Netdisco::Util::sort_port($a->port, $b->port) } $set->all ];

View File

@@ -4,6 +4,7 @@
<th></th>
[% FOREACH item IN vars.port_columns %]
[% NEXT IF item.name == 'c_admin' %]
[% NEXT IF item.name == 'c_nodes' AND params.c_nodes AND params.c_neighbors %]
[% NEXT UNLESS params.${item.name} %]
<th[% ' class="center_cell"' IF NOT loop.first %]>[% item.label %]</th>
[% END %]
@@ -134,9 +135,9 @@
</td>
[% END %]
[% IF params.c_connected %]
[% IF params.c_nodes OR params.c_neighbors %]
<td>
[% IF row.remote_ip %]
[% IF params.c_neighbors AND row.remote_ip %]
[% IF row.neighbor %]
<a href="[% uri_for('/device',
vars.self_options) %]&q=[% row.neighbor.ip | uri %]&f=[% row.remote_port | uri %]">
@@ -149,6 +150,7 @@
id: [% (row.remote_type _ ' / ') IF row.remote_type %][% row.remote_id %])</a>
[% END %]
[% END %]
[% IF params.c_nodes %]
[% FOREACH node IN row.$nodes %]
[% '<br/>' IF row.remote_ip OR NOT loop.first %]
[% '<span class="label label-warning">A</span> &nbsp;' IF NOT node.active %]
@@ -166,6 +168,7 @@
[% END %]
[% END %]
[% END %]
[% END %]
</td>
[% END %]