complete the code for admin tasks page loading

This commit is contained in:
Oliver Gorwits
2013-05-05 21:45:17 +01:00
parent 38f70624f3
commit 3271c01931
7 changed files with 63 additions and 17 deletions

View File

@@ -13,6 +13,7 @@ use App::Netdisco::Web::AuthN;
use App::Netdisco::Web::Search;
use App::Netdisco::Web::Device;
use App::Netdisco::Web::Report;
use App::Netdisco::Web::AdminTask;
use App::Netdisco::Web::TypeAhead;
use App::Netdisco::Web::PortControl;

View File

@@ -7,7 +7,7 @@ set(
'navbar_items' => [],
'search_tabs' => [],
'device_tabs' => [],
'admin_tasks' => [],
'admin_tasks' => {},
'reports_menu' => {},
'reports' => {},
'report_order' => [qw/Device Port Node VLAN Network Wireless/],
@@ -60,14 +60,7 @@ register 'register_admin_task' => sub {
return;
}
foreach my $item (@{ setting('admin_tasks') }) {
if ($item->{tag} eq $config->{tag}) {
$item = $config;
return;
}
}
push @{ setting('admin_tasks') }, $config;
setting('admin_tasks')->{ $config->{tag} } = $config;
};
sub _register_tab {

View File

@@ -44,8 +44,8 @@ function do_search (event, tab) {
// update browser search history with the new query.
// however if it's the same tab, this is a *replace* of the query url.
// and just skip this bit if it's the reports display.
if (path != 'report' && window.History && window.History.enabled) {
// and just skip this bit if it's the report or admin display.
if (path != 'report' && path != 'admin' && window.History && window.History.enabled) {
is_from_history_plugin = 1;
window.History.replaceState(
{name: tab, fields: $(form).serializeArray()},

View File

@@ -0,0 +1,38 @@
<i class="sidebar_toggle icon-wrench icon-large" id="sidebar_toggle_img_out"
rel="tooltip" data-placement="left" data-offset="5" data-title="Show Sidebar"></i>
<div class="container-fluid">
<div class="sidebar sidebar_pinned">
<div class="well">
<i class="sidebar_toggle icon-signout" id="sidebar_toggle_img_in"
rel="tooltip" data-placement="left" data-offset="5" data-title="Hide Sidebar"></i>
<i class="sidebar_pin icon-pushpin sidebar_pin_clicked"
rel="tooltip" data-placement="left" data-offset="5" data-title="Unpin Sidebar"></i>
<div class="tab-content">
<div id="[% task.tag %]_search" class="tab-pane active">
<form id="[% task.tag %]_form" class="nd_sidesearchform form-stacked"
method="get" action="[% uri_for('/admin') %]">
[% TRY %]
[% INCLUDE "sidebar/admintask/${task.tag}.tt" %]
<script type="text/javascript">has_sidebar["[% task.tag %]"] = 1;</script>
[% CATCH %]
<script type="text/javascript">has_sidebar["[% task.tag %]"] = 0;</script>
[% END %]
</form>
</div> <!-- /tab-pane -->
</div> <!-- /tab-content -->
</div>
</div>
<div class="content">
<ul id="search_results" class="nav nav-tabs">
<li class="active"><a id="[% task.tag %]_link" href="#[% task.tag %]_pane">[% task.label %]</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="[% task.tag %]_pane"></div>
</div>
</div>
<script type="text/javascript">
[%+ INCLUDE 'js/admintask.js' -%]
</script>

View File

@@ -0,0 +1,11 @@
// used by the tabbing interface to make sure the correct
// ajax content is loaded
var path = 'admin';
// this is called by do_search to support local code
// here, when tab changes need to strike/unstrike the navbar search
function inner_view_processing(tab) { }
// on load, check initial Device Search Options form state,
// and on each change to the form fields
$(document).ready(function() { });

View File

@@ -7,11 +7,16 @@
$('[% "#${tab.tag}_form" %]').submit(function(event){ do_search(event, '[% tab.tag %]'); });
[% END %]
// and for the reports page
// and for the report pages
[% IF report %]
$('[% "#${report.tag}_form" %]').submit(function(event){ do_search(event, '[% report.tag %]'); });
[% END %]
// and for the admin pages
[% IF task %]
$('[% "#${task.tag}_form" %]').submit(function(event){ do_search(event, '[% task.tag %]'); });
[% END %]
// on page load, load the content for the active tab
[% IF params.tab %]
$('#[% params.tab %]_form').trigger("submit");

View File

@@ -84,18 +84,16 @@
<i id="navsearchgo" class="icon-search navbar_icon"></i>
</span>
</form>
[% IF vars.user.admin %]
[% IF vars.user.admin AND settings.admin_tasks.size %]
<ul class="nav">
[% IF settings.admin_tasks.size %]
<li class="dropdown[% ' active' IF vars.nav == 'admin' %]">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Admin Tasks <b class="caret"></b></a>
<ul class="dropdown-menu">
[% FOREACH ai IN settings.admin_tasks %]
<li><a href="[% uri_for('/admin/' _ ai.tag) %]">[% ai.label | html_entity %]</a></li>
[% FOREACH ai IN settings.admin_tasks.keys.sort %]
<li><a href="[% uri_for('/admin/' _ ai) %]">[% settings.admin_tasks.$ai.label | html_entity %]</a></li>
[% END %]
</ul>
</li> <!-- /dropdown -->
[% END %]
</ul>
[% END %]
<ul class="nav pull-right">