From 9d3f3ee17962ba4ff6d1fc06db9b4b12abb71414 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Fri, 6 Sep 2013 00:23:31 +0100 Subject: [PATCH] add Half Duplex Ports report --- .../Netdisco/Web/Plugin/Report/HalfDuplex.pm | 29 +++++++++++++++++++ Netdisco/share/config.yml | 1 + .../share/views/ajax/report/duplexmismatch.tt | 4 +-- .../share/views/ajax/report/halfduplex.tt | 23 +++++++++++++++ 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 Netdisco/lib/App/Netdisco/Web/Plugin/Report/HalfDuplex.pm create mode 100644 Netdisco/share/views/ajax/report/halfduplex.tt diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/Report/HalfDuplex.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/HalfDuplex.pm new file mode 100644 index 00000000..7a5c7a12 --- /dev/null +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/HalfDuplex.pm @@ -0,0 +1,29 @@ +package App::Netdisco::Web::Plugin::Report::HalfDuplex; + +use Dancer ':syntax'; +use Dancer::Plugin::Ajax; +use Dancer::Plugin::DBIC; +use Dancer::Plugin::Auth::Extensible; + +use App::Netdisco::Web::Plugin; + +register_report({ + category => 'Port', + tag => 'halfduplex', + label => 'Ports in Half Duplex Mode', +}); + +ajax '/ajax/content/report/halfduplex' => require_login sub { + my $set = schema('netdisco')->resultset('DevicePort')->search( + { up => 'up', duplex => { '-ilike' => 'half' } }, + { order_by => [qw/device.dns port/], prefetch => 'device' }, + ); + return unless $set->count; + + content_type('text/html'); + template 'ajax/report/halfduplex.tt', { + results => $set, + }, { layout => undef }; +}; + +true; diff --git a/Netdisco/share/config.yml b/Netdisco/share/config.yml index 8d2fec9b..ccf7d041 100644 --- a/Netdisco/share/config.yml +++ b/Netdisco/share/config.yml @@ -34,6 +34,7 @@ path: '/' web_plugins: - Inventory - Report::PortUtilization + - Report::HalfDuplex - Report::DuplexMismatch - AdminTask::PseudoDevice - AdminTask::Topology diff --git a/Netdisco/share/views/ajax/report/duplexmismatch.tt b/Netdisco/share/views/ajax/report/duplexmismatch.tt index f9632348..1d9ad1c4 100644 --- a/Netdisco/share/views/ajax/report/duplexmismatch.tt +++ b/Netdisco/share/views/ajax/report/duplexmismatch.tt @@ -2,10 +2,10 @@ Left Device - Interface + Port Duplex Right Device - Interface + Port Duplex diff --git a/Netdisco/share/views/ajax/report/halfduplex.tt b/Netdisco/share/views/ajax/report/halfduplex.tt new file mode 100644 index 00000000..f5594292 --- /dev/null +++ b/Netdisco/share/views/ajax/report/halfduplex.tt @@ -0,0 +1,23 @@ + + + + + + + + + + + [% WHILE (row = results.next) %] + + + + + + + [% END %] + +
DevicePortDescriptionDuplex
[% row.device.dns || row.device.ip | html_entity %] + [% row.port | html_entity %][% row.name | html_entity %][% row.duplex.ucfirst | html_entity %]
+