diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/Report/DeviceByLocation.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/DeviceByLocation.pm new file mode 100644 index 00000000..24d01b99 --- /dev/null +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/DeviceByLocation.pm @@ -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; diff --git a/Netdisco/share/config.yml b/Netdisco/share/config.yml index 90014b48..3b753507 100644 --- a/Netdisco/share/config.yml +++ b/Netdisco/share/config.yml @@ -37,6 +37,7 @@ web_plugins: - Report::ApChannelDist - Report::ApRadioChannelPower - Report::HalfDuplex + - Report::DeviceByLocation - Report::DuplexMismatch - Report::SsidInventory - Report::VlanInventory diff --git a/Netdisco/share/views/ajax/report/devicebylocation.tt b/Netdisco/share/views/ajax/report/devicebylocation.tt new file mode 100644 index 00000000..d7aa3b67 --- /dev/null +++ b/Netdisco/share/views/ajax/report/devicebylocation.tt @@ -0,0 +1,39 @@ +
| Location | +Device | +System Name | +Vendor | +Model | +
|---|---|---|---|---|
| + [% IF row.location %] + + [% row.location | html_entity %] + [% ELSE %] + [Not Set] + [% END %] + | +[% row.dns || row.ip | html_entity %] | ++ [% row.name | html_entity %] + | ++ + [% row.vendor | html_entity %] + | ++ + [% row.model | html_entity %] + | +