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

@@ -7,6 +7,8 @@ package App::Netdisco::DB::Result::Node;
use strict;
use warnings;
use Net::MAC;
use base 'DBIx::Class::Core';
__PACKAGE__->table("node");
__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') }
=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;

View File

@@ -7,6 +7,8 @@ package App::Netdisco::DB::Result::NodeIp;
use strict;
use warnings;
use Net::MAC;
use base 'DBIx::Class::Core';
__PACKAGE__->table("node_ip");
__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') }
=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;

View File

@@ -51,6 +51,7 @@ hook 'before' => sub {
if (not param('tab') or param('tab') ne 'ports') {
params->{'age_num'} = 3;
params->{'age_unit'} = 'months';
params->{'mac_format'} = 'IEEE';
}
};
@@ -62,8 +63,13 @@ hook 'before_template' => sub {
tab => 'ports',
age_num => 3,
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') }) {
next unless $col->{default} eq 'on';
$tokens->{device_ports}->query_param($col->{name}, 'checked');