implement prefetch for ports list, drop template param for modifying search clause
This commit is contained in:
@@ -98,6 +98,20 @@ ajax '/ajax/content/device/ports' => sub {
|
|||||||
}
|
}
|
||||||
return unless $set->count;
|
return unless $set->count;
|
||||||
|
|
||||||
|
# retrieve related data for additonal table columns, if asked for
|
||||||
|
$set = $set->search_rs({}, {prefetch => {nodes => 'ips'}})
|
||||||
|
if param('c_connected');
|
||||||
|
$set = $set->search_rs({}, {prefetch => {port_vlans_tagged => 'vlan'}})
|
||||||
|
if param('c_vmember');
|
||||||
|
|
||||||
|
# if active or not, control the join to Node table
|
||||||
|
if (param('n_archived')) {
|
||||||
|
$set = $set->search_rs({-or => [{'nodes.active' => 1}, {'nodes.active' => 0}]});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$set = $set->search_rs({'nodes.active' => 1});
|
||||||
|
}
|
||||||
|
|
||||||
# sort, and filter by free ports
|
# sort, and filter by free ports
|
||||||
# the filter could be in the template but here allows a 'no records' msg
|
# the filter could be in the template but here allows a 'no records' msg
|
||||||
my $results = [ sort { &netdisco::sort_port($a->port, $b->port) }
|
my $results = [ sort { &netdisco::sort_port($a->port, $b->port) }
|
||||||
@@ -105,14 +119,10 @@ ajax '/ajax/content/device/ports' => sub {
|
|||||||
or $_->is_free(param('age_num'), param('age_unit')) } $set->all ];
|
or $_->is_free(param('age_num'), param('age_unit')) } $set->all ];
|
||||||
|
|
||||||
return unless scalar @$results;
|
return unless scalar @$results;
|
||||||
my @active = (param('n_archived')
|
|
||||||
? (-or => [{'me.active' => 1}, {'me.active' => 0}])
|
|
||||||
: ('me.active' => 1));
|
|
||||||
|
|
||||||
content_type('text/html');
|
content_type('text/html');
|
||||||
template 'ajax/device/ports.tt', {
|
template 'ajax/device/ports.tt', {
|
||||||
results => $results,
|
results => $results,
|
||||||
archive_filter => {@active},
|
|
||||||
}, { layout => undef };
|
}, { layout => undef };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@
|
|||||||
<br/> ([% row.remote_type %]) / ([% row.remote_id %])</a>
|
<br/> ([% row.remote_type %]) / ([% row.remote_id %])</a>
|
||||||
[% END %]
|
[% END %]
|
||||||
[% END %]
|
[% END %]
|
||||||
[% FOREACH node IN row.nodes(archive_filter) %]
|
[% FOREACH node IN row.nodes %]
|
||||||
[% '<br/>' IF row.remote_ip OR NOT loop.first %]
|
[% '<br/>' IF row.remote_ip OR NOT loop.first %]
|
||||||
[% '<span class="label warning">a</span> ' IF NOT node.active %]
|
[% '<span class="label warning">a</span> ' IF NOT node.active %]
|
||||||
<a href="[% uri_for('/search') %]?tab=node&q=[% node.mac | uri %]">[% node.mac %]</a>
|
<a href="[% uri_for('/search') %]?tab=node&q=[% node.mac | uri %]">[% node.mac %]</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user