diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/Report/ModuleInventory.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/ModuleInventory.pm index 4d07ef43..ec449496 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin/Report/ModuleInventory.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/ModuleInventory.pm @@ -67,6 +67,7 @@ get '/ajax/content/report/moduleinventory' => require_login sub { my $rs = schema('netdisco')->resultset('DeviceModule'); $rs = $rs->search({-bool => 'fru'}) if param('fruonly'); + my @results; if ($has_opt) { @@ -77,25 +78,32 @@ get '/ajax/content/report/moduleinventory' => require_login sub { params->{'ips'} = \@ips; } - $rs = $rs->search_by_field( scalar params )->prefetch('device') - ->limit( param('limit') )->hri; - - } + @results = $rs->search_by_field( scalar params )->columns( + [ qw/ ip description name class type serial hw_ver fw_ver sw_ver model / + ] + )->search( + {}, + { '+columns' => [qw/ device.dns device.name /], + join => 'device', + collapse => 1, + })->limit( param('limit') )->hri->all; + } else { - $rs = $rs->search( + @results = $rs->search( {}, { select => [ 'class', { count => 'class' } ], as => [qw/ class count /], group_by => [qw/ class /] } - )->order_by( { -desc => 'count' } )->hri; + )->order_by( { -desc => 'count' } )->hri->all; } - return unless $rs->has_rows; + return unless scalar @results; if ( request->is_ajax ) { + my $results = to_json (\@results); template 'ajax/report/moduleinventory.tt', - { results => $rs, opt => $has_opt }, + { results => $results, opt => $has_opt }, { layout => undef }; } else { diff --git a/Netdisco/share/views/ajax/report/moduleinventory.tt b/Netdisco/share/views/ajax/report/moduleinventory.tt index 7f898270..1aeb6289 100644 --- a/Netdisco/share/views/ajax/report/moduleinventory.tt +++ b/Netdisco/share/views/ajax/report/moduleinventory.tt @@ -1,6 +1,5 @@ -[% USE Number.Format %] [% IF opt %] - +
@@ -14,71 +13,117 @@ - - - [% WHILE (row = results.next) %] - - - - - - - - - - - - - [% END %] - +
DeviceSW Version FW Version
- - [% row.device.dns || row.device.name || row.device.ip | html_entity %] - - - [% row.description | html_entity %] - - - [% row.name | html_entity %] - - - [% row.class.ucfirst | html_entity %] - - - [% row.type | html_entity %] - - - [% row.model | html_entity %] - - - [% row.serial | html_entity %] - [% row.hw_ver | html_entity %][% row.sw_ver | html_entity %][% row.fw_ver | html_entity %]
[% ELSE %] - +
- - [% WHILE (row = results.next) %] - - - - - [% END %] -
Class Count
- - [% row.class.ucfirst | html_entity %] - [% row.count | format_number %]
[% END %] + + \ No newline at end of file