implement system_reports and convert PortErrorDisabled to system report

This commit is contained in:
Oliver Gorwits
2018-02-22 21:31:17 +00:00
parent 2aaec6b059
commit 8d82023ac6
3 changed files with 20 additions and 49 deletions

View File

@@ -194,4 +194,7 @@ if (setting('reports') and ref {} eq ref setting('reports')) {
}} keys %{ setting('reports') } ]; }} keys %{ setting('reports') } ];
} }
# add system_reports onto reports
config->{'reports'} = [ @{setting('system_reports')}, @{setting('reports')} ];
true; true;

View File

@@ -1,49 +0,0 @@
package App::Netdisco::Web::Plugin::Report::PortErrorDisabled;
use Dancer ':syntax';
use Dancer::Plugin::DBIC;
use Dancer::Plugin::Auth::Extensible;
use App::Netdisco::Web::Plugin;
register_report(
{ category => 'Port',
tag => 'porterrordisabled',
label => 'Error Disabled Ports',
provides_csv => 1,
}
);
get '/ajax/content/report/porterrordisabled' => require_login sub {
my @results = schema('netdisco')->resultset('DevicePorts')
->with_properties->search({
'properties.error_disable_cause' => { '!=' => undef },
})->hri->all;
# { select => [ 'ip', 'dns', 'name' ],
# join => { 'ports' => [ 'wireless', 'nodes' ] },
# '+columns' => [
# { 'port' => 'ports.port' },
# { 'description' => 'ports.name' },
# { 'mac_count' => { count => 'nodes.mac' } },
# ],
# group_by => [qw/me.ip me.dns me.name ports.port ports.name/],
# having => \[ 'count(nodes.mac) > ?', [ count => 1 ] ],
# order_by => { -desc => [qw/count/] },
# }
return unless scalar @results;
if ( request->is_ajax ) {
my $json = to_json (\@results);
template 'ajax/report/porterrordisabled.tt', { results => $json },
{ layout => undef };
}
else {
header( 'Content-Type' => 'text/comma-separated-values' );
template 'ajax/report/porterrordisabled.tt',
{ results => \@results, },
{ layout => undef };
}
};
1;

View File

@@ -148,6 +148,23 @@ device_port_col_idx_right: -1
jobqueue_refresh: 10 jobqueue_refresh: 10
safe_password_store: true safe_password_store: true
reports: [] reports: []
system_reports:
- tag: portserrordisabled
label: 'Error Disabled Ports'
category: Port
columns:
- { ip: Device }
- { dns: DNS }
- { port: Port }
- { name: Description }
- { reason: Reason }
query: |
SELECT dp.ip, d.dns, dp.port, dp.name, properties.error_disable_cause AS reason
FROM device_port dp
INNER JOIN device_port_properties properties USING (ip, port)
LEFT JOIN device d USING (ip)
WHERE properties.error_disable_cause IS NOT NULL
ORDER BY dp.ip, dp.port
table_pagesize: 10 table_pagesize: 10
table_showrecordsmenu: table_showrecordsmenu:
- [10, 25, 50, 100, '-1'] - [10, 25, 50, 100, '-1']