add device inventory by location report
This commit is contained in:
@@ -0,0 +1,35 @@
|
|||||||
|
package App::Netdisco::Web::Plugin::Report::DeviceByLocation;
|
||||||
|
|
||||||
|
use Dancer ':syntax';
|
||||||
|
use Dancer::Plugin::DBIC;
|
||||||
|
use Dancer::Plugin::Auth::Extensible;
|
||||||
|
|
||||||
|
use App::Netdisco::Web::Plugin;
|
||||||
|
|
||||||
|
register_report(
|
||||||
|
{ category => 'Device',
|
||||||
|
tag => 'devicebylocation',
|
||||||
|
label => 'By Location',
|
||||||
|
provides_csv => 1,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
get '/ajax/content/report/devicebylocation' => require_login sub {
|
||||||
|
my $set
|
||||||
|
= schema('netdisco')->resultset('Device')
|
||||||
|
->search( {},
|
||||||
|
{ order_by => [qw/ location name ip vendor model /], } );
|
||||||
|
return unless $set->count;
|
||||||
|
|
||||||
|
if ( request->is_ajax ) {
|
||||||
|
template 'ajax/report/devicebylocation.tt', { results => $set, },
|
||||||
|
{ layout => undef };
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
header( 'Content-Type' => 'text/comma-separated-values' );
|
||||||
|
template 'ajax/report/devicebylocation_csv.tt', { results => $set, },
|
||||||
|
{ layout => undef };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
true;
|
||||||
@@ -37,6 +37,7 @@ web_plugins:
|
|||||||
- Report::ApChannelDist
|
- Report::ApChannelDist
|
||||||
- Report::ApRadioChannelPower
|
- Report::ApRadioChannelPower
|
||||||
- Report::HalfDuplex
|
- Report::HalfDuplex
|
||||||
|
- Report::DeviceByLocation
|
||||||
- Report::DuplexMismatch
|
- Report::DuplexMismatch
|
||||||
- Report::SsidInventory
|
- Report::SsidInventory
|
||||||
- Report::VlanInventory
|
- Report::VlanInventory
|
||||||
|
|||||||
39
Netdisco/share/views/ajax/report/devicebylocation.tt
Normal file
39
Netdisco/share/views/ajax/report/devicebylocation.tt
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<table class="table table-bordered table-condensed table-striped nd_floatinghead">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="nd_center-cell">Location</th>
|
||||||
|
<th class="nd_center-cell">Device</th>
|
||||||
|
<th class="nd_center-cell">System Name</th>
|
||||||
|
<th class="nd_center-cell">Vendor</th>
|
||||||
|
<th class="nd_center-cell">Model</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
</tbody>
|
||||||
|
[% WHILE (row = results.next) %]
|
||||||
|
[% NEXT UNLESS row.vendor AND row.model %]
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
[% IF row.location %]
|
||||||
|
<a href="[% search_device %]&q=[% row.location | uri %]&location=[% row.location | uri %]">
|
||||||
|
[% row.location | html_entity %]</a>
|
||||||
|
[% ELSE %]
|
||||||
|
[Not Set]
|
||||||
|
[% END %]
|
||||||
|
</td>
|
||||||
|
<td><a href="[% uri_for('/device') %]?q=[% row.dns || row.ip | uri %]">[% row.dns || row.ip | html_entity %]</a></td>
|
||||||
|
<td><a href="[% search_device %]&q=[% row.name | uri %]&name=[% row.name | uri %]">
|
||||||
|
[% row.name | html_entity %]</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a href="[% search_device %]&q=[% row.vendor | uri %]&vendor=[% row.vendor | uri %]">
|
||||||
|
[% row.vendor | html_entity %]</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a href="[% search_device %]&q=[% row.model | uri %]&model=[% row.model | uri %]">
|
||||||
|
[% row.model | html_entity %]</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
[% END %]
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
12
Netdisco/share/views/ajax/report/devicebylocation_csv.tt
Normal file
12
Netdisco/share/views/ajax/report/devicebylocation_csv.tt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
[% USE CSV -%]
|
||||||
|
[% CSV.dump([ 'Location' 'Device' 'System Name' 'Vendor' 'Model' ]) %]
|
||||||
|
|
||||||
|
[% WHILE (row = results.next) %]
|
||||||
|
[% mylist = [] %]
|
||||||
|
[% device = row.dns || row.ip %]
|
||||||
|
[% FOREACH col IN [ row.location device row.name row.vendor row.model ] %]
|
||||||
|
[% mylist.push(col) %]
|
||||||
|
[% END %]
|
||||||
|
[% CSV.dump(mylist) %]
|
||||||
|
|
||||||
|
[% END %]
|
||||||
Reference in New Issue
Block a user