add wireless ssid inventory report

This commit is contained in:
Eric A. Miller
2013-09-24 23:53:14 -04:00
parent 2856271cd2
commit 23301e9f1e
4 changed files with 71 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
package App::Netdisco::Web::Plugin::Report::SsidInventory;
use Dancer ':syntax';
use Dancer::Plugin::DBIC;
use Dancer::Plugin::Auth::Extensible;
use App::Netdisco::Web::Plugin;
register_report(
{ category => 'Wireless',
tag => 'ssidinventory',
label => 'SSID Inventory',
provides_csv => 1,
}
);
get '/ajax/content/report/ssidinventory' => require_login sub {
my $set = schema('netdisco')->resultset('DevicePortSsid')->search(
{},
{ select => [ 'ssid', 'broadcast', { count => 'ssid' } ],
as => [qw/ ssid broadcast scount /],
group_by => [qw/ ssid broadcast /],
order_by => { -desc => [qw/count/] },
}
);
return unless $set->count;
if ( request->is_ajax ) {
template 'ajax/report/ssidinventory.tt', { results => $set, },
{ layout => undef };
}
else {
header( 'Content-Type' => 'text/comma-separated-values' );
template 'ajax/report/ssidinventory_csv.tt', { results => $set, },
{ layout => undef };
}
};
true;

View File

@@ -38,6 +38,7 @@ web_plugins:
- Report::ApRadioChannelPower
- Report::HalfDuplex
- Report::DuplexMismatch
- Report::SsidInventory
- Report::VlanInventory
- AdminTask::PseudoDevice
- AdminTask::Topology

View File

@@ -0,0 +1,20 @@
[% USE Number.Format %]
<table class="table table-bordered table-condensed table-striped nd_floatinghead">
<thead>
<tr>
<th class="nd_center-cell">SSID</th>
<th class="nd_center-cell">Broadcast</th>
<th class="nd_center-cell">Count</th>
</tr>
</thead>
</tbody>
[% WHILE (row = results.next) %]
<tr>
<td class="nd_center-cell">[% row.ssid %]</td>
<td class="nd_center-cell">[% row.broadcast ? 'Yes' : 'No' %]</td>
<td class="nd_center-cell">[% row.get_column('scount') | format_number %]</td>
</tr>
[% END %]
</tbody>
</table>

View File

@@ -0,0 +1,11 @@
[% USE CSV -%]
[% CSV.dump([ 'SSID' 'Broadcast' 'Count' ]) %]
[% WHILE (row = results.next) %]
[% mylist = [] %]
[% mylist.push(row.ssid) %]
[% mylist.push(row.broadcast ? 'Yes' : 'No') %]
[% mylist.push(row.get_column('scount')) %]
[% CSV.dump(mylist) %]
[% END %]