Add FRU filter option to Module Inventory Report

This commit is contained in:
Oliver Gorwits
2014-04-09 21:22:56 +01:00
parent 88ad3552c1
commit 10a6e33561
4 changed files with 37 additions and 16 deletions

View File

@@ -16,16 +16,6 @@ register_report(
);
hook 'before' => sub {
# view settings
var('module_options' => [
{ name => 'matchall',
label => 'Match All Options',
default => 'on'
},
]
);
return
unless (
request->path eq uri_for('/report/moduleinventory')->path
@@ -33,13 +23,20 @@ hook 'before' => sub {
uri_for('/ajax/content/report/moduleinventory')->path ) == 0
);
# view settings
var('module_options' => [
{ name => 'fruonly',
label => 'FRU Only',
default => 'on'
},
{ name => 'matchall',
label => 'Match All Options',
default => 'on'
},
]
);
params->{'limit'} ||= 1024;
foreach my $col ( @{ var('module_options') } ) {
next unless $col->{default} eq 'on';
params->{ $col->{name} } = 'checked';
}
};
hook 'before_template' => sub {
@@ -69,6 +66,7 @@ get '/ajax/content/report/moduleinventory' => require_login sub {
qw/device description name type model serial class/;
my $rs = schema('netdisco')->resultset('DeviceModule');
$rs = $rs->search({-bool => 'fru'}) if param('fruonly');
if ($has_opt) {

View File

@@ -17,6 +17,14 @@ get '/report/*' => require_login sub {
elsif ( $tag eq 'moduleinventory' ) {
$class_list = [ schema('netdisco')->resultset('DeviceModule')
->get_distinct_col('class') ];
# this is a bit fragile... three params currently
if (3 == scalar keys params()) {
foreach my $col ( @{ var('module_options') } ) {
next unless $col->{default} eq 'on';
params->{ $col->{name} } = 'checked';
}
}
}
elsif ( $tag eq 'portssid' ) {
$ssid_list = [ schema('netdisco')->resultset('DevicePortSsid')