diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/Report/VlanInventory.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/VlanInventory.pm index ff14bd1c..91492277 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin/Report/VlanInventory.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/VlanInventory.pm @@ -15,7 +15,7 @@ register_report( ); get '/ajax/content/report/vlaninventory' => require_login sub { - my $set = schema('netdisco')->resultset('DeviceVlan')->search( + my @results = schema('netdisco')->resultset('DeviceVlan')->search( { 'me.description' => { '!=', 'NULL' } }, { join => { 'ports' => 'vlan' }, select => [ @@ -27,16 +27,18 @@ get '/ajax/content/report/vlaninventory' => require_login sub { as => [qw/ vlan description dcount pcount /], group_by => [qw/ me.vlan me.description /], } - ); - return unless $set->has_rows; + )->hri->all; + + return unless scalar @results; if ( request->is_ajax ) { - template 'ajax/report/vlaninventory.tt', { results => $set, }, + my $json = to_json (\@results); + template 'ajax/report/vlaninventory.tt', { results => $json }, { layout => undef }; } else { header( 'Content-Type' => 'text/comma-separated-values' ); - template 'ajax/report/vlaninventory_csv.tt', { results => $set, }, + template 'ajax/report/vlaninventory_csv.tt', { results => \@results }, { layout => undef }; } }; diff --git a/Netdisco/share/views/ajax/report/vlaninventory.tt b/Netdisco/share/views/ajax/report/vlaninventory.tt index 84b95ed2..ca072f1e 100644 --- a/Netdisco/share/views/ajax/report/vlaninventory.tt +++ b/Netdisco/share/views/ajax/report/vlaninventory.tt @@ -1,24 +1,44 @@ -[% USE Number.Format %] -
| VLAN ID | -VLAN Name | -Device Count | -Port Count | +VLAN ID | +VLAN Name | +Device Count | +Port Count |
|---|---|---|---|---|---|---|---|
| - [% row.vlan | html_entity %] | -[% row.description %] | -[% row.get_column('dcount') | format_number %] | -[% row.get_column('pcount') | format_number %] | -