implement register_report() and replace More menu with Reports menu
This commit is contained in:
@@ -7,6 +7,8 @@ set(
|
|||||||
'navbar_items' => [],
|
'navbar_items' => [],
|
||||||
'search_tabs' => [],
|
'search_tabs' => [],
|
||||||
'device_tabs' => [],
|
'device_tabs' => [],
|
||||||
|
'reports' => {},
|
||||||
|
'report_order' => [qw/Device Port Node VLAN Network Wireless/],
|
||||||
);
|
);
|
||||||
|
|
||||||
# this is what Dancer::Template::TemplateToolkit does by default
|
# this is what Dancer::Template::TemplateToolkit does by default
|
||||||
@@ -77,6 +79,29 @@ register 'register_device_tab' => sub {
|
|||||||
_register_tab('device', $config);
|
_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;
|
register_plugin;
|
||||||
true;
|
true;
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,6 @@
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
[%
|
[%
|
||||||
more_dd = { "Reports" = "/reports" }
|
|
||||||
user_dd = [
|
user_dd = [
|
||||||
{ "title" = "Settings", "link" = "/settings" },
|
{ "title" = "Settings", "link" = "/settings" },
|
||||||
{ "title" = "Help", "link" = "/help" },
|
{ "title" = "Help", "link" = "/help" },
|
||||||
@@ -57,17 +56,23 @@
|
|||||||
<a href="[% uri_for(ni.path) %]">[% ni.label | html_entity %]</a>
|
<a href="[% uri_for(ni.path) %]">[% ni.label | html_entity %]</a>
|
||||||
</li>
|
</li>
|
||||||
[% END %]
|
[% END %]
|
||||||
[% IF more_dd.size %]
|
<li class="dropdown[% ' active' IF vars.nav == 'reports' %]">
|
||||||
<li class="dropdown">
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Reports <b class="caret"></b></a>
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
|
||||||
More <b class="caret"></b></a>
|
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
[% FOREACH title IN more_dd.keys.sort %]
|
[% FOREACH category IN settings.report_order %]
|
||||||
<li><a href="[% uri_for(more_dd.$title) %]">[% title | html_entity %]</a></li>
|
[% IF vars.reports.$category.size %]
|
||||||
|
<li class="dropdown-submenu">
|
||||||
|
<a href="#">[% category | html_entity %]</a>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
[% FOREACH item IN settings.reports.$category %]
|
||||||
|
<li><a href="[% uri_for(item.path) %]">[% item.label | html_entity %]</a></li>
|
||||||
|
[% END %]
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
[% END %]
|
[% END %]
|
||||||
|
[% END %]
|
||||||
</ul>
|
</ul>
|
||||||
</li> <!-- /dropdown -->
|
</li> <!-- /dropdown -->
|
||||||
[% END %]
|
|
||||||
</ul>
|
</ul>
|
||||||
<form class="navbar-search pull-left" method="get" action="[% uri_for('/search') %]">
|
<form class="navbar-search pull-left" method="get" action="[% uri_for('/search') %]">
|
||||||
<input placeholder="Find Anything" class="search-query span3"
|
<input placeholder="Find Anything" class="search-query span3"
|
||||||
|
|||||||
Reference in New Issue
Block a user