DataTables for VLAN inventory report

This commit is contained in:
Eric A. Miller
2014-05-28 23:43:13 -04:00
parent 998ca5a92a
commit 0e2c006efb
3 changed files with 48 additions and 26 deletions

View File

@@ -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 };
}
};