diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/Report/DeviceByLocation.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/DeviceByLocation.pm index 24d01b99..86cdeb8c 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin/Report/DeviceByLocation.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/DeviceByLocation.pm @@ -15,21 +15,24 @@ register_report( ); get '/ajax/content/report/devicebylocation' => require_login sub { - my $set + my @results = schema('netdisco')->resultset('Device') - ->search( {}, - { order_by => [qw/ location name ip vendor model /], } ); - return unless $set->count; + ->columns( [qw/ ip dns name location vendor model /] ) + ->order_by( [qw/ location name ip vendor model /] )->hri->all; + + return unless scalar @results; if ( request->is_ajax ) { - template 'ajax/report/devicebylocation.tt', { results => $set, }, + my $results = to_json( \@results ); + template 'ajax/report/devicebylocation.tt', { results => $results }, { layout => undef }; } else { header( 'Content-Type' => 'text/comma-separated-values' ); - template 'ajax/report/devicebylocation_csv.tt', { results => $set, }, - { layout => undef }; + template 'ajax/report/devicebylocation_csv.tt', + { results => \@results }, + { layout => undef }; } }; -true; +1; diff --git a/Netdisco/share/views/ajax/report/devicebylocation.tt b/Netdisco/share/views/ajax/report/devicebylocation.tt index ab662cf2..79095418 100644 --- a/Netdisco/share/views/ajax/report/devicebylocation.tt +++ b/Netdisco/share/views/ajax/report/devicebylocation.tt @@ -1,4 +1,4 @@ - +
@@ -8,32 +8,47 @@ - - [% WHILE (row = results.next) %] - [% NEXT UNLESS row.vendor AND row.model %] - - - - - - - - [% END %] -
LocationModel
- [% IF row.location %] - - [% row.location | html_entity %] - [% ELSE %] - [Not Set] - [% END %] - [% row.dns || row.ip | html_entity %] - [% row.name | html_entity %] - - - [% row.vendor | html_entity %] - - - [% row.model | html_entity %] -
+ diff --git a/Netdisco/share/views/ajax/report/devicebylocation_csv.tt b/Netdisco/share/views/ajax/report/devicebylocation_csv.tt index fb81572d..d1ccc222 100644 --- a/Netdisco/share/views/ajax/report/devicebylocation_csv.tt +++ b/Netdisco/share/views/ajax/report/devicebylocation_csv.tt @@ -1,7 +1,7 @@ [% USE CSV -%] [% CSV.dump([ 'Location' 'Device' 'System Name' 'Vendor' 'Model' ]) %] -[% WHILE (row = results.next) %] +[% FOREACH row IN results %] [% mylist = [] %] [% device = row.dns || row.ip %] [% FOREACH col IN [ row.location device row.name row.vendor row.model ] %]