add csv download to duplex mismatch, half duplex, and port utilization reports
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user