implement connected devices list for ports
This commit is contained in:
@@ -64,6 +64,38 @@ __PACKAGE__->set_primary_key("port", "ip");
|
||||
# Created by DBIx::Class::Schema::Loader v0.07015 @ 2012-01-07 14:20:02
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:lcbweb0loNwHoWUuxTN/hA
|
||||
|
||||
__PACKAGE__->has_many( nodes => 'Netdisco::DB::Result::Node',
|
||||
{
|
||||
'foreign.switch' => 'self.ip',
|
||||
'foreign.port' => 'self.port',
|
||||
},
|
||||
{
|
||||
prefetch => 'ips',
|
||||
order_by => 'me.mac',
|
||||
'+select' => [
|
||||
\"replace(age(me.time_last, me.time_recent)::text, 'mon', 'month')",
|
||||
],
|
||||
'+as' => [
|
||||
'me.time_last',
|
||||
],
|
||||
},
|
||||
);
|
||||
|
||||
sub get_nodes {
|
||||
my ($row, $archive) = @_;
|
||||
return $row->nodes({ ($archive ? () : ('me.active' => 1, 'ips.active' => 1)) });
|
||||
}
|
||||
|
||||
__PACKAGE__->belongs_to( neighbor_alias => 'Netdisco::DB::Result::DeviceIp',
|
||||
{
|
||||
'foreign.alias' => 'self.remote_ip',
|
||||
},
|
||||
{
|
||||
join_type => 'left',
|
||||
},
|
||||
);
|
||||
# FIXME make this more efficient by specifying the full join to DBIC
|
||||
sub neighbor { return eval { (shift)->neighbor_alias->device } }
|
||||
__PACKAGE__->belongs_to( device => 'Netdisco::DB::Result::Device', 'ip',
|
||||
{
|
||||
'+select' => [
|
||||
|
||||
@@ -82,7 +82,36 @@
|
||||
</td>
|
||||
[% END %]
|
||||
[% IF params.c_connected %]
|
||||
<td>[% row.connected | html_entity %]</td>
|
||||
<td>
|
||||
[% IF row.remote_ip %]
|
||||
[% IF row.neighbor %]
|
||||
<a href="/device?tab=ports&ip=[% row.neighbor.ip | uri %]&q=[% row.remote_port | uri %]">
|
||||
[% row.neighbor.dns.remove(settings.domain_suffix) || row.neighbor.ip %]
|
||||
([% row.remote_port | html_entity %])</a>
|
||||
[% ELSE %]
|
||||
<span class="label important">n</span>
|
||||
<a href="/search?tab=node&q=[% row.remote_ip | uri %]">[% row.remote_ip %] ([% row.remote_port %])
|
||||
<br/> ([% row.remote_type %]) / ([% row.remote_id %]</a>
|
||||
[% END %]
|
||||
[% END %]
|
||||
[% FOREACH node IN row.get_nodes(params.n_archived) %]
|
||||
[% '<br/>' IF row.remote_ip OR NOT loop.first %]
|
||||
[% '<span class="label warning">a</span> ' IF NOT node.active %]
|
||||
<a href="/search?tab=node&q=[% node.mac | uri %]">[% node.mac %]</a>
|
||||
[% ' (' _ node.time_last _ ')' IF params.n_age %]
|
||||
[% IF params.n_ip %]
|
||||
[% FOREACH ip IN node.ips %]
|
||||
<br/> [% '<span class="label warning">a</span> ' IF NOT node.active %]
|
||||
[% SET dns = ip.dns %]
|
||||
[% IF dns %]
|
||||
<a href="/search?tab=node&q=[% ip.ip | uri %]">[% ip.dns %] ([% ip.ip %])</a>
|
||||
[% ELSE %]
|
||||
<a href="/search?tab=node&q=[% ip.ip | uri %]">[% ip.ip %]</a>
|
||||
[% END %]
|
||||
[% END %]
|
||||
[% END %]
|
||||
[% END %]
|
||||
</td>
|
||||
[% END %]
|
||||
[% IF params.c_stp %]
|
||||
<td class="center_cell">[% row.stp | html_entity %]</td>
|
||||
|
||||
Reference in New Issue
Block a user