1package App::Netdisco::Web::Plugin::Report::PortAdminDown; 2 3use Dancer ':syntax'; 4use Dancer::Plugin::DBIC; 5use Dancer::Plugin::Auth::Extensible; 6 7use App::Netdisco::Web::Plugin; 8 9register_report( 10 { category => 'Port', 11 tag => 'portadmindown', 12 label => 'Ports administratively disabled', 13 provides_csv => 1, 14 api_endpoint => 1, 15 } 16); 17 18get '/ajax/content/report/portadmindown' => require_login sub { 19 my @results = schema('netdisco')->resultset('Device')->search( 20 { 'up_admin' => 'down' }, 21 { select => [ 'ip', 'dns', 'name' ], 22 join => [ 'ports' ], 23 '+columns' => [ 24 { 'port' => 'ports.port' }, 25 { 'description' => 'ports.name' }, 26 { 'up_admin' => 'ports.up_admin' }, 27 ] 28 } 29 )->hri->all; 30 31 return unless scalar @results; 32 33 if ( request->is_ajax ) { 34 my $json = to_json (\@results); 35 template 'ajax/report/portadmindown.tt', { results => $json }; 36 } 37 else { 38 header( 'Content-Type' => 'text/comma-separated-values' ); 39 template 'ajax/report/portadmindown_csv.tt', 40 { results => \@results, }; 41 } 42}; 43 441; 45