diff --git a/Netdisco/lib/App/Netdisco/Web.pm b/Netdisco/lib/App/Netdisco/Web.pm index 59af5f3d..797b7283 100644 --- a/Netdisco/lib/App/Netdisco/Web.pm +++ b/Netdisco/lib/App/Netdisco/Web.pm @@ -12,6 +12,7 @@ use URI::QueryParam (); # part of URI, to add helper methods use App::Netdisco::Web::AuthN; use App::Netdisco::Web::Search; use App::Netdisco::Web::Device; +use App::Netdisco::Web::Report; use App::Netdisco::Web::TypeAhead; use App::Netdisco::Web::PortControl; diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin.pm b/Netdisco/lib/App/Netdisco/Web/Plugin.pm index b78c6654..851a4ed8 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin.pm @@ -7,6 +7,7 @@ set( 'navbar_items' => [], 'search_tabs' => [], 'device_tabs' => [], + 'reports_menu' => {}, 'reports' => {}, 'report_order' => [qw/Device Port Node VLAN Network Wireless/], ); @@ -92,14 +93,16 @@ register 'register_report' => sub { return; } - foreach my $item (@{setting('reports')->{ $config->{category} }}) { - if ($item->{tag} eq $config->{tag}) { - $item = $config; + foreach my $item (@{setting('reports_menu')->{ $config->{category} }}) { + if ($item eq $config->{tag}) { + $item = $config->{tag}; + setting('reports')->{$config->{tag}} = $config; return; } } - push @{setting('reports')->{ $config->{category} }}, $config; + push @{setting('reports_menu')->{ $config->{category} }}, $config->{tag}; + setting('reports')->{$config->{tag}} = $config; }; register_plugin; diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/Report/DuplexMismatch.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/DuplexMismatch.pm new file mode 100644 index 00000000..39efffe0 --- /dev/null +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/DuplexMismatch.pm @@ -0,0 +1,26 @@ +package App::Netdisco::Web::Plugin::Report::DuplexMismatch; + +use Dancer ':syntax'; +use Dancer::Plugin::Ajax; +use Dancer::Plugin::DBIC; + +use App::Netdisco::Web::Plugin; + +register_report({ + category => 'Port', + tag => 'duplexmismatch', + label => 'Duplex Mismatches Between Devices', +}); + +ajax '/ajax/content/report/duplexmismatch' => sub { +# my $q = param('q'); +# my $device = schema('netdisco')->resultset('Device') +# ->with_times()->search_for_device($q) or return; + + content_type('text/html'); + template 'ajax/report/duplexmismatch.tt', { +# d => $device, + }, { layout => undef }; +}; + +true; diff --git a/Netdisco/lib/App/Netdisco/Web/Report.pm b/Netdisco/lib/App/Netdisco/Web/Report.pm new file mode 100644 index 00000000..6d494978 --- /dev/null +++ b/Netdisco/lib/App/Netdisco/Web/Report.pm @@ -0,0 +1,14 @@ +package App::Netdisco::Web::Report; + +use Dancer ':syntax'; + +get '/report/*' => sub { + my ($tag) = splat; + + var(nav => 'reports'); + template 'report', { + report => setting('reports')->{ $tag }, + }; +}; + +true; diff --git a/Netdisco/share/views/layouts/main.tt b/Netdisco/share/views/layouts/main.tt index e96da4ed..0c3bc7aa 100644 --- a/Netdisco/share/views/layouts/main.tt +++ b/Netdisco/share/views/layouts/main.tt @@ -60,12 +60,12 @@ Reports