select MAC Address display format on Node and Device Port search

This commit is contained in:
Oliver Gorwits
2013-04-24 22:18:04 +01:00
parent 558184d8ac
commit 8dca426e92
10 changed files with 65 additions and 5 deletions

View File

@@ -5,6 +5,7 @@
* Finally we have a discover/refresh daemon job :) * Finally we have a discover/refresh daemon job :)
* Also... a Scheduler which removes need for crontab installation * Also... a Scheduler which removes need for crontab installation
* The netdisco-do script can run a one-off discover for a device * The netdisco-do script can run a one-off discover for a device
* Can select MAC Address display format on Node and Device Port search
[ENHANCEMENTS] [ENHANCEMENTS]

View File

@@ -7,6 +7,8 @@ package App::Netdisco::DB::Result::Node;
use strict; use strict;
use warnings; use warnings;
use Net::MAC;
use base 'DBIx::Class::Core'; use base 'DBIx::Class::Core';
__PACKAGE__->table("node"); __PACKAGE__->table("node");
__PACKAGE__->add_columns( __PACKAGE__->add_columns(
@@ -134,4 +136,12 @@ between the date stamp and time stamp. That is:
sub time_last_stamp { return (shift)->get_column('time_last_stamp') } sub time_last_stamp { return (shift)->get_column('time_last_stamp') }
=head2 net_mac
Returns the C<mac> column instantiated into a L<Net::MAC> object.
=cut
sub net_mac { return Net::MAC->new(mac => (shift)->mac) }
1; 1;

View File

@@ -7,6 +7,8 @@ package App::Netdisco::DB::Result::NodeIp;
use strict; use strict;
use warnings; use warnings;
use Net::MAC;
use base 'DBIx::Class::Core'; use base 'DBIx::Class::Core';
__PACKAGE__->table("node_ip"); __PACKAGE__->table("node_ip");
__PACKAGE__->add_columns( __PACKAGE__->add_columns(
@@ -206,4 +208,12 @@ between the date stamp and time stamp. That is:
sub time_last_stamp { return (shift)->get_column('time_last_stamp') } sub time_last_stamp { return (shift)->get_column('time_last_stamp') }
=head2 net_mac
Returns the C<mac> column instantiated into a L<Net::MAC> object.
=cut
sub net_mac { return Net::MAC->new(mac => (shift)->mac) }
1; 1;

View File

@@ -51,6 +51,7 @@ hook 'before' => sub {
if (not param('tab') or param('tab') ne 'ports') { if (not param('tab') or param('tab') ne 'ports') {
params->{'age_num'} = 3; params->{'age_num'} = 3;
params->{'age_unit'} = 'months'; params->{'age_unit'} = 'months';
params->{'mac_format'} = 'IEEE';
} }
}; };
@@ -62,8 +63,13 @@ hook 'before_template' => sub {
tab => 'ports', tab => 'ports',
age_num => 3, age_num => 3,
age_unit => 'months', age_unit => 'months',
mac_format => 'IEEE',
}); });
# for Net::MAC method
$tokens->{mac_format_call} = 'as_'. params->{'mac_format'}
if params->{'mac_format'};
foreach my $col (@{ var('port_columns') }) { foreach my $col (@{ var('port_columns') }) {
next unless $col->{default} eq 'on'; next unless $col->{default} eq 'on';
$tokens->{device_ports}->query_param($col->{name}, 'checked'); $tokens->{device_ports}->query_param($col->{name}, 'checked');

View File

@@ -252,6 +252,19 @@ td {
width: 95px; width: 95px;
} }
/* set the MAC format drop-down width */
#nd_mac_format {
margin-top: 4px;
width: 154px;
}
/* set the MAC format drop-down width */
#nd_node_mac_format {
margin-left: -2px;
margin-top: 4px;
width: 165px;
}
/* sidebar submit button width and spacing from Node Props */ /* sidebar submit button width and spacing from Node Props */
.sidebar button { .sidebar button {
margin-top: 9px; margin-top: 9px;

View File

@@ -196,7 +196,8 @@
[% FOREACH node IN row.$nodes %] [% 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 label-warning">A</span> &nbsp;' IF NOT node.active %] [% '<span class="label label-warning">A</span> &nbsp;' IF NOT node.active %]
<a href="[% search_node %]&q=[% node.mac | uri %]">[% node.mac | html_entity %]</a> <a href="[% search_node %]&q=[% node.net_mac.$mac_format_call | uri %]">
[% node.net_mac.$mac_format_call | html_entity %]</a>
[% ' (' _ node.time_last_age _ ')' IF params.n_age %] [% ' (' _ node.time_last_age _ ')' IF params.n_age %]
[% IF params.n_ip %] [% IF params.n_ip %]
[% FOREACH ip IN node.ips %] [% FOREACH ip IN node.ips %]

View File

@@ -17,7 +17,8 @@
[% WHILE (row = macs.next) %] [% WHILE (row = macs.next) %]
<tr> <tr>
<td><a class="nd_linkcell" <td><a class="nd_linkcell"
href="[% search_node %]&q=[% row.mac | uri %]">[% row.mac | html_entity %]</a></td> href="[% search_node %]&q=[% row.net_mac.$mac_format_call | uri %]">
[% row.net_mac.$mac_format_call | html_entity %]</a></td>
[% IF params.vendor %] [% IF params.vendor %]
<td>[% row.oui.company | html_entity %]</td> <td>[% row.oui.company | html_entity %]</td>
[% END %] [% END %]

View File

@@ -20,7 +20,8 @@
<td> <td>
[% IF first_row %] [% IF first_row %]
<a class="nd_linkcell" <a class="nd_linkcell"
href="[% search_node %]&q=[% row.mac | uri %]">[% row.mac | html_entity %]</a> href="[% search_node %]&q=[% row.net_mac.$mac_format_call | uri %]">
[% row.net_mac.$mac_format_call | html_entity %]</a>
[% ELSE %] [% ELSE %]
&nbsp; &nbsp;
[% END %] [% END %]
@@ -51,7 +52,8 @@
<td> <td>
[% IF first_row %] [% IF first_row %]
<a class="nd_linkcell" <a class="nd_linkcell"
href="[% search_node %]&q=[% node.mac | uri %]">[% node.mac | html_entity %]</a> href="[% search_node %]&q=[% node.net_mac.$mac_format_call | uri %]">
[% node.net_mac.$mac_format_call | html_entity %]</a>
[% ELSE %] [% ELSE %]
&nbsp; &nbsp;
[% END %] [% END %]

View File

@@ -76,7 +76,7 @@
<div id="nd_portprops" class="collapse"> <div id="nd_portprops" class="collapse">
<ul class="inputs-list unstyled"> <ul class="inputs-list unstyled">
<li> <li>
Mark as Free if Down for:<br/> <em>Mark as Free if Down for:</em><br/>
<select id="nd_days_select" name="age_num"> <select id="nd_days_select" name="age_num">
[% FOREACH count IN [1..32] %] [% FOREACH count IN [1..32] %]
<option[% ' selected="selected"' IF params.age_num == count %]>[% count %]</option> <option[% ' selected="selected"' IF params.age_num == count %]>[% count %]</option>
@@ -105,6 +105,14 @@
</label></span> </label></span>
<div id="nd_nodeprops" class="collapse"> <div id="nd_nodeprops" class="collapse">
<ul class="inputs-list unstyled"> <ul class="inputs-list unstyled">
<li>
<em>MAC address format:</em><br/>
<select id="nd_mac_format" name="mac_format">
[% FOREACH format IN [ 'IEEE', 'Cisco', 'Microsoft', 'Sun' ] %]
<option[% ' selected="selected"' IF params.mac_format == format %]>[% format %]</option>
[% END %]
</select>
</li>
[% FOREACH item IN vars.connected_properties %] [% FOREACH item IN vars.connected_properties %]
<li> <li>
<label class="checkbox"> <label class="checkbox">

View File

@@ -38,4 +38,12 @@
<span class="nd_searchcheckbox uneditable-input">Partial Name</span> <span class="nd_searchcheckbox uneditable-input">Partial Name</span>
</label> </label>
</div> </div>
<div class="clearfix">
<em>MAC address format:</em><br/>
<select id="nd_node_mac_format" name="mac_format">
[% FOREACH format IN [ 'IEEE', 'Cisco', 'Microsoft', 'Sun' ] %]
<option[% ' selected="selected"' IF params.mac_format == format %]>[% format %]</option>
[% END %]
</select>
</div>
<button id="[% tab.id %]_submit" type="submit" class="btn btn-info">Search Again</button> <button id="[% tab.id %]_submit" type="submit" class="btn btn-info">Search Again</button>