diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin.pm b/Netdisco/lib/App/Netdisco/Web/Plugin.pm index 9c64a75d..37da9f85 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin.pm @@ -7,6 +7,8 @@ set( 'navbar_items' => [], 'search_tabs' => [], 'device_tabs' => [], + 'reports' => {}, + 'report_order' => [qw/Device Port Node VLAN Network Wireless/], ); # this is what Dancer::Template::TemplateToolkit does by default @@ -77,6 +79,29 @@ register 'register_device_tab' => sub { _register_tab('device', $config); }; +register 'register_report' => sub { + my ($self, $config) = plugin_args(@_); + my @categories = @{ setting('report_order') }; + + if (!length $config->{category} + or !length $config->{path} + or !length $config->{label} + or 0 == scalar grep {$config->{category} eq $_} @categories) { + + error "bad config to register_report"; + return; + } + + foreach my $item (@{setting('reports')->{ $config->{category} }}) { + if ($item->{label} eq $config->{label}) { + $item = $config; + return; + } + } + + push @{setting('reports')->{ $config->{category} }}, $config; +}; + register_plugin; true; diff --git a/Netdisco/share/views/layouts/main.tt b/Netdisco/share/views/layouts/main.tt index 74ef8640..dc07e4db 100644 --- a/Netdisco/share/views/layouts/main.tt +++ b/Netdisco/share/views/layouts/main.tt @@ -38,7 +38,6 @@
[% - more_dd = { "Reports" = "/reports" } user_dd = [ { "title" = "Settings", "link" = "/settings" }, { "title" = "Help", "link" = "/help" }, @@ -57,17 +56,23 @@ [% ni.label | html_entity %] [% END %] - [% IF more_dd.size %] -