implement addresses pane for device

This commit is contained in:
Oliver Gorwits
2012-01-13 20:59:51 +00:00
parent f1d3bb9fd9
commit 60d8e6de76
4 changed files with 42 additions and 1 deletions

View File

@@ -35,5 +35,7 @@ __PACKAGE__->set_primary_key("ip", "alias");
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:/ugGtBSGyrJ7s6yqJ9bclQ
__PACKAGE__->belongs_to( device => 'Netdisco::DB::Result::Device', 'ip' );
__PACKAGE__->belongs_to( device_port => 'Netdisco::DB::Result::DevicePort',
{ 'foreign.port' => 'self.port', 'foreign.ip' => 'self.ip' } );
1;

View File

@@ -88,6 +88,20 @@ ajax '/ajax/content/device/:thing' => sub {
return "<p>Hello, this is where the ". param('thing') ." content goes.</p>";
};
# device interface addresses
ajax '/ajax/content/device/addresses' => sub {
my $ip = param('ip');
return unless $ip;
my $set = schema('netdisco')->resultset('DeviceIp')->search({ip => $ip}, { order_by => 'alias' });
return unless $set->count;
content_type('text/html');
template 'ajax/device/addresses.tt', {
results => $set,
}, { layout => undef };
};
# device ports with a description (er, name) matching
ajax '/ajax/content/device/ports' => sub {
my $ip = param('ip');

View File

@@ -47,7 +47,7 @@ form .clearfix.success input {
/* icolour for device name and ip in sidebar */
.device_label {
color: #0069D6;
color: #660033;
}
/* nudge content in the sidebar closer to the left */

View File

@@ -0,0 +1,25 @@
<table class="bordered-table condensed-table zebra-striped">
<thead>
<tr>
<th>Address</th>
<th>DNS</th>
<th class="center_cell">Interface</th>
<th>Description</th>
<th>Prefix</th>
</tr>
</thead>
</tbody>
[% WHILE (row = results.next) %]
<tr>
<td>[% row.alias %]</a>
<td>[% row.dns.remove(settings.domain_suffix) %]</a>
<td class="center_cell"><a class="nd_linkcell"
href="/device?tab=ports&ip=[% row.ip %]&q=[% row.port %]">[% row.port %]</a></td>
<td>[% row.device_port.name %]</td>
<td><a class="nd_linkcell"
href="/search?tab=node&q=[% row.subnet %]">[% row.subnet %]</a></td>
</tr>
[% END %]
</tbody>
</table>