diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/Report/DuplexMismatch.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/DuplexMismatch.pm index 7cb026f4..7cd99e0c 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin/Report/DuplexMismatch.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/DuplexMismatch.pm @@ -7,20 +7,38 @@ use Dancer::Plugin::Auth::Extensible; use App::Netdisco::Web::Plugin; -register_report({ - category => 'Port', - tag => 'duplexmismatch', - label => 'Duplex Mismatches Between Devices', -}); +register_report( + { category => 'Port', + tag => 'duplexmismatch', + label => 'Duplex Mismatches Between Devices', + } +); ajax '/ajax/content/report/duplexmismatch' => require_login sub { my $set = schema('netdisco')->resultset('Virtual::DuplexMismatch'); return unless $set->count; content_type('text/html'); - template 'ajax/report/duplexmismatch.tt', { - results => $set, - }, { layout => undef }; + template 'ajax/report/duplexmismatch.tt', { results => $set, }, + { layout => undef }; +}; + +get '/ajax/content/report/duplexmismatch' => require_login sub { + my $format = param('format'); + my $set = schema('netdisco')->resultset('Virtual::DuplexMismatch'); + return unless $set->count; + + if ( $format eq 'csv' ) { + + header( 'Content-Type' => 'text/comma-separated-values' ); + header( 'Content-Disposition' => + "attachment; filename=\"duplexmismatch.csv\"" ); + template 'ajax/report/duplexmismatch_csv.tt', { results => $set, }, + { layout => undef }; + } + else { + return; + } }; true; diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/Report/HalfDuplex.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/HalfDuplex.pm index 7a5c7a12..64a41186 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin/Report/HalfDuplex.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/HalfDuplex.pm @@ -26,4 +26,25 @@ ajax '/ajax/content/report/halfduplex' => require_login sub { }, { layout => undef }; }; +get '/ajax/content/report/halfduplex' => require_login sub { + my $format = param('format'); + my $set = schema('netdisco')->resultset('DevicePort')->search( + { up => 'up', duplex => { '-ilike' => 'half' } }, + { order_by => [qw/device.dns port/], prefetch => 'device' }, + ); + return unless $set->count; + + if ( $format eq 'csv' ) { + + header( 'Content-Type' => 'text/comma-separated-values' ); + header( 'Content-Disposition' => + "attachment; filename=\"halfduplex.csv\"" ); + template 'ajax/report/halfduplex_csv.tt', { results => $set, }, + { layout => undef }; + } + else { + return; + } +}; + true; diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/Report/PortUtilization.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/PortUtilization.pm index defa9beb..657b82ad 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin/Report/PortUtilization.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/PortUtilization.pm @@ -7,20 +7,38 @@ use Dancer::Plugin::Auth::Extensible; use App::Netdisco::Web::Plugin; -register_report({ - category => 'Device', - tag => 'portutilization', - label => 'Port Utilization', -}); +register_report( + { category => 'Device', + tag => 'portutilization', + label => 'Port Utilization', + } +); ajax '/ajax/content/report/portutilization' => require_login sub { return unless schema('netdisco')->resultset('Device')->count; my $set = schema('netdisco')->resultset('Virtual::PortUtilization'); content_type('text/html'); - template 'ajax/report/portutilization.tt', { - results => $set, - }, { layout => undef }; + template 'ajax/report/portutilization.tt', { results => $set, }, + { layout => undef }; +}; + +get '/ajax/content/report/portutilization' => require_login sub { + my $format = param('format'); + return unless schema('netdisco')->resultset('Device')->count; + my $set = schema('netdisco')->resultset('Virtual::PortUtilization'); + + if ( $format eq 'csv' ) { + + header( 'Content-Type' => 'text/comma-separated-values' ); + header( 'Content-Disposition' => + "attachment; filename=\"portutilization.csv\"" ); + template 'ajax/report/portutilization_csv.tt', { results => $set, }, + { layout => undef }; + } + else { + return; + } }; true; diff --git a/Netdisco/share/views/ajax/report/duplexmismatch.tt b/Netdisco/share/views/ajax/report/duplexmismatch.tt index 1d9ad1c4..84ef703b 100644 --- a/Netdisco/share/views/ajax/report/duplexmismatch.tt +++ b/Netdisco/share/views/ajax/report/duplexmismatch.tt @@ -1,3 +1,4 @@ +[% INCLUDE "download_as.tt" %]