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 %] - +
- - - - + + + + - - [% WHILE (row = results.next) %] - - - - - - - [% END %] -
VLAN IDVLAN NameDevice CountPort CountVLAN IDVLAN NameDevice CountPort Count
- [% row.vlan | html_entity %][% row.description %][% row.get_column('dcount') | format_number %][% row.get_column('pcount') | format_number %]
+ diff --git a/Netdisco/share/views/ajax/report/vlaninventory_csv.tt b/Netdisco/share/views/ajax/report/vlaninventory_csv.tt index 1bfc51c3..8373bd44 100644 --- a/Netdisco/share/views/ajax/report/vlaninventory_csv.tt +++ b/Netdisco/share/views/ajax/report/vlaninventory_csv.tt @@ -1,12 +1,12 @@ [% USE CSV -%] [% CSV.dump([ 'VLAN ID' 'VLAN Name' 'Device Count' 'Port Count' ]) %] -[% WHILE (row = results.next) %] +[% FOREACH row IN results %] [% mylist = [] %] [% mylist.push(row.vlan) %] [% mylist.push(row.description) %] - [% mylist.push(row.get_column('dcount')) %] - [% mylist.push(row.get_column('pcount')) %] + [% mylist.push(row.dcount) %] + [% mylist.push(row.pcount) %] [% CSV.dump(mylist) %] [% END %]