implement register_report() and replace More menu with Reports menu

This commit is contained in:
Oliver Gorwits
2013-03-10 17:21:23 +00:00
parent 4a16e3fde3
commit f513000f08
2 changed files with 38 additions and 8 deletions

View File

@@ -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;