« blib/lib/App/Netdisco/Web/Plugin/Report/DevicePoeStatus.pm
↑ Summary
blib/lib/App/Netdisco/Web/Plugin/Report/HalfDuplex.pm »
| 1 | package App::Netdisco::Web::Plugin::Report::DuplexMismatch; | ||
| 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 => 'Port', | ||
| 11 | tag => 'duplexmismatch', | ||
| 12 | label => 'Mismatched Duplex', | ||
| 13 | provides_csv => 1, | ||
| 14 | api_endpoint => 1, | ||
| 15 | } | ||
| 16 | ); | ||
| 17 | |||
| 18 | get '/ajax/content/report/duplexmismatch' => require_login sub { | ||
| 19 | my @results | ||
| 20 | = schema(vars->{'tenant'})->resultset('Virtual::DuplexMismatch')->hri->all; | ||
| 21 | |||
| 22 | return unless scalar @results; | ||
| 23 | |||
| 24 | if ( request->is_ajax ) { | ||
| 25 | my $json = to_json( \@results ); | ||
| 26 | template 'ajax/report/duplexmismatch.tt', { results => $json, }, { layout => 'noop' }; | ||
| 27 | } | ||
| 28 | else { | ||
| 29 | header( 'Content-Type' => 'text/comma-separated-values' ); | ||
| 30 | template 'ajax/report/duplexmismatch_csv.tt', | ||
| 31 | { results => \@results, }, { layout => 'noop' }; | ||
| 32 | } | ||
| 33 | }; | ||
| 34 | |||
| 35 | 1; |