« blib/lib/App/Netdisco/Web/Plugin/Report/ApRadioChannelPower.pm
↑ Summary
blib/lib/App/Netdisco/Web/Plugin/Report/DeviceByLocation.pm »
| 1 | package App::Netdisco::Web::Plugin::Report::DeviceAddrNoDNS; | ||
| 2 | |||
| 3 | use Dancer ':syntax'; | ||
| 4 | use Dancer::Plugin::DBIC; | ||
| 5 | use Dancer::Plugin::Auth::Extensible; | ||
| 6 | |||
| 7 | use App::Netdisco::Web::Plugin; | ||
| 8 | |||
| 9 | register_report( | ||
| 10 | { category => 'Device', | ||
| 11 | tag => 'deviceaddrnodns', | ||
| 12 | label => 'IPs without DNS Entries', | ||
| 13 | provides_csv => 1, | ||
| 14 | api_endpoint => 1, | ||
| 15 | } | ||
| 16 | ); | ||
| 17 | |||
| 18 | get '/ajax/content/report/deviceaddrnodns' => require_login sub { | ||
| 19 | my @results = schema(vars->{'tenant'})->resultset('Device')->search( | ||
| 20 | { 'device_ips.dns' => undef }, | ||
| 21 | { select => [ 'ip', 'dns', 'name', 'location', 'contact' ], | ||
| 22 | join => [qw/device_ips/], | ||
| 23 | '+columns' => [ { 'alias' => 'device_ips.alias' }, ], | ||
| 24 | order_by => { -asc => [qw/me.ip device_ips.alias/] }, | ||
| 25 | } | ||
| 26 | )->hri->all; | ||
| 27 | |||
| 28 | return unless scalar @results; | ||
| 29 | |||
| 30 | if ( request->is_ajax ) { | ||
| 31 | my $json = to_json (\@results); | ||
| 32 | template 'ajax/report/deviceaddrnodns.tt', { results => $json }, { layout => 'noop' }; | ||
| 33 | } | ||
| 34 | else { | ||
| 35 | header( 'Content-Type' => 'text/comma-separated-values' ); | ||
| 36 | template 'ajax/report/deviceaddrnodns_csv.tt', | ||
| 37 | { results => \@results, }, { layout => 'noop' }; | ||
| 38 | } | ||
| 39 | }; | ||
| 40 | |||
| 41 | 1; |