add csv output to access point radios channel and power report
This commit is contained in:
@@ -11,6 +11,7 @@ register_report(
|
|||||||
{ category => 'Wireless',
|
{ category => 'Wireless',
|
||||||
tag => 'apradiochannelpower',
|
tag => 'apradiochannelpower',
|
||||||
label => 'Access Point Radios Channel and Power',
|
label => 'Access Point Radios Channel and Power',
|
||||||
|
provides_csv => 1,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -47,16 +48,22 @@ sub port_tree {
|
|||||||
return \%ports;
|
return \%ports;
|
||||||
}
|
}
|
||||||
|
|
||||||
ajax '/ajax/content/report/apradiochannelpower' => require_login sub {
|
get '/ajax/content/report/apradiochannelpower' => require_login sub {
|
||||||
my @set
|
my @set
|
||||||
= schema('netdisco')->resultset('Virtual::ApRadioChannelPower')->all;
|
= schema('netdisco')->resultset('Virtual::ApRadioChannelPower')->all;
|
||||||
|
|
||||||
my $results = port_tree( \@set );
|
my $results = port_tree( \@set );
|
||||||
return unless scalar %$results;
|
return unless scalar %$results;
|
||||||
|
|
||||||
content_type('text/html');
|
if (request->is_ajax) {
|
||||||
template 'ajax/report/apradiochannelpower.tt', { results => $results, },
|
template 'ajax/report/apradiochannelpower.tt', { results => $results, },
|
||||||
{ layout => undef };
|
{ layout => undef };
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
header( 'Content-Type' => 'text/comma-separated-values' );
|
||||||
|
template 'ajax/report/apradiochannelpower_csv.tt', { results => $results, },
|
||||||
|
{ layout => undef };
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
true;
|
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