add csv download to ap channel distribution report
This commit is contained in:
@@ -14,7 +14,7 @@ register_report(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
ajax '/ajax/content/report/apchanneldist' => require_login sub {
|
sub get_rs_apchdist {
|
||||||
my $set = schema('netdisco')->resultset('DevicePortWireless')->search(
|
my $set = schema('netdisco')->resultset('DevicePortWireless')->search(
|
||||||
{ channel => { '!=', '0' } },
|
{ channel => { '!=', '0' } },
|
||||||
{ select => [ 'channel', { count => 'channel' } ],
|
{ select => [ 'channel', { count => 'channel' } ],
|
||||||
@@ -23,6 +23,11 @@ ajax '/ajax/content/report/apchanneldist' => require_login sub {
|
|||||||
order_by => { -desc => [qw/count/] },
|
order_by => { -desc => [qw/count/] },
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
return $set;
|
||||||
|
}
|
||||||
|
|
||||||
|
ajax '/ajax/content/report/apchanneldist' => require_login sub {
|
||||||
|
my $set = get_rs_apchdist();
|
||||||
|
|
||||||
return unless $set->count;
|
return unless $set->count;
|
||||||
|
|
||||||
@@ -31,4 +36,23 @@ ajax '/ajax/content/report/apchanneldist' => require_login sub {
|
|||||||
{ layout => undef };
|
{ layout => undef };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
get '/ajax/content/report/apchanneldist' => require_login sub {
|
||||||
|
my $format = param('format');
|
||||||
|
my $set = get_rs_apchdist();
|
||||||
|
|
||||||
|
return unless $set->count;
|
||||||
|
|
||||||
|
if ( $format eq 'csv' ) {
|
||||||
|
|
||||||
|
header( 'Content-Type' => 'text/comma-separated-values' );
|
||||||
|
header( 'Content-Disposition' =>
|
||||||
|
"attachment; filename=\"apchanneldist.csv\"" );
|
||||||
|
template 'ajax/report/apchanneldist_csv.tt', { results => $set, },
|
||||||
|
{ layout => undef };
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
true;
|
true;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
[% INCLUDE "download_as.tt" %]
|
||||||
<table class="table table-bordered table-condensed table-striped nd_floatinghead">
|
<table class="table table-bordered table-condensed table-striped nd_floatinghead">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
10
Netdisco/share/views/ajax/report/apchanneldist_csv.tt
Normal file
10
Netdisco/share/views/ajax/report/apchanneldist_csv.tt
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
[% USE CSV -%]
|
||||||
|
[% CSV.dump([ 'Channel' 'Count' ]) %]
|
||||||
|
|
||||||
|
[% WHILE (row = results.next) %]
|
||||||
|
[% mylist = [] %]
|
||||||
|
[% mylist.push(row.channel) %]
|
||||||
|
[% mylist.push(row.get_column('ch_count')) %]
|
||||||
|
[% CSV.dump(mylist) %]
|
||||||
|
|
||||||
|
[% END %]
|
||||||
Reference in New Issue
Block a user