add csv output to access point radios channel and power report
This commit is contained in:
@@ -11,6 +11,7 @@ register_report(
|
||||
{ category => 'Wireless',
|
||||
tag => 'apradiochannelpower',
|
||||
label => 'Access Point Radios Channel and Power',
|
||||
provides_csv => 1,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -47,16 +48,22 @@ sub port_tree {
|
||||
return \%ports;
|
||||
}
|
||||
|
||||
ajax '/ajax/content/report/apradiochannelpower' => require_login sub {
|
||||
get '/ajax/content/report/apradiochannelpower' => require_login sub {
|
||||
my @set
|
||||
= schema('netdisco')->resultset('Virtual::ApRadioChannelPower')->all;
|
||||
|
||||
my $results = port_tree( \@set );
|
||||
return unless scalar %$results;
|
||||
|
||||
content_type('text/html');
|
||||
if (request->is_ajax) {
|
||||
template 'ajax/report/apradiochannelpower.tt', { results => $results, },
|
||||
{ layout => undef };
|
||||
}
|
||||
else {
|
||||
header( 'Content-Type' => 'text/comma-separated-values' );
|
||||
template 'ajax/report/apradiochannelpower_csv.tt', { results => $results, },
|
||||
{ layout => undef };
|
||||
}
|
||||
};
|
||||
|
||||
true;
|
||||
|
||||
22
Netdisco/share/views/ajax/report/apradiochannelpower_csv.tt
Normal file
22
Netdisco/share/views/ajax/report/apradiochannelpower_csv.tt
Normal file
@@ -0,0 +1,22 @@
|
||||
[% USE CSV -%]
|
||||
[% CSV.dump([ 'Device' 'Model' 'Device Location' 'Port' ' Port Name'
|
||||
'Port Description' 'Channel' 'Tx Power mW' 'Tx Power dBm' ]) %]
|
||||
|
||||
[% FOREACH row IN results.keys.sort %]
|
||||
[% mydlist = [] %]
|
||||
[% mydevice = results.$row.device.dns || results.$row.device.name %]
|
||||
[% mydlist.push(mydevice) %]
|
||||
[% mydlist.push(results.$row.device.model) %]
|
||||
[% mydlist.push(results.$row.device.location) %]
|
||||
[% FOREACH p IN results.$row.ports %]
|
||||
[% myplist = [] %]
|
||||
[% NEXT UNLESS p.channel # No channel port is admin down %]
|
||||
[% FOREACH col IN [ p.port p.name p.descr p.channel p.power
|
||||
p.power2 ] %]
|
||||
[% myplist.push(col) %]
|
||||
[% END %]
|
||||
[% CALL mydlist.splice(3, 6, myplist ) %]
|
||||
[% CSV.dump(mydlist) %]
|
||||
|
||||
[% END %]
|
||||
[%END%]
|
||||
Reference in New Issue
Block a user