DataTables for port SSID and SSID inventory reports

This commit is contained in:
Eric A. Miller
2014-05-28 23:42:43 -04:00
parent f7a3ed2bed
commit 998ca5a92a
4 changed files with 88 additions and 43 deletions

View File

@@ -44,26 +44,34 @@ get '/ajax/content/report/portssid' => require_login sub {
if ( defined $ssid ) {
$rs
= $rs->search( { ssid => $ssid } )
->prefetch( [qw/ device port /] )
->order_by( [qw/ port.ip port.port /] )->hri;
$rs = $rs->search(
{ ssid => $ssid },
{ '+columns' => [
qw/ device.dns device.name device.model device.vendor port.port/
],
join => [qw/ device port /],
collapse => 1,
}
)->order_by( [qw/ port.ip port.port /] )->hri;
}
else {
$rs = $rs->get_ssids->hri;
}
return unless $rs->has_rows;
my @results = $rs->all;
return unless scalar @results;
if ( request->is_ajax ) {
template 'ajax/report/portssid.tt', { results => $rs, opt => $ssid },
my $json = to_json( \@results );
template 'ajax/report/portssid.tt',
{ results => $json, opt => $ssid },
{ layout => undef };
}
else {
header( 'Content-Type' => 'text/comma-separated-values' );
template 'ajax/report/portssid_csv.tt',
{ results => $rs, opt => $ssid },
{ results => \@results, opt => $ssid },
{ layout => undef };
}
};

View File

@@ -15,16 +15,19 @@ register_report(
);
get '/ajax/content/report/ssidinventory' => require_login sub {
my $rs = schema('netdisco')->resultset('DevicePortSsid')->get_ssids->hri;
return unless $rs->has_rows;
my @results = schema('netdisco')->resultset('DevicePortSsid')
->get_ssids->hri->all;
return unless scalar @results;
if ( request->is_ajax ) {
template 'ajax/report/portssid.tt', { results => $rs, },
my $json = to_json( \@results );
template 'ajax/report/portssid.tt', { results => $json },
{ layout => undef };
}
else {
header( 'Content-Type' => 'text/comma-separated-values' );
template 'ajax/report/portssid_csv.tt', { results => $rs, },
template 'ajax/report/portssid_csv.tt', { results => \@results },
{ layout => undef };
}
};