change id for tag in device and search tab plugins

This commit is contained in:
Oliver Gorwits
2013-03-10 18:37:19 +00:00
parent b818d4156f
commit af8f124bb2
13 changed files with 31 additions and 31 deletions

View File

@@ -52,7 +52,7 @@ sub _register_tab {
my ($nav, $config) = @_;
my $stash = setting("${nav}_tabs");
if (!length $config->{id}
if (!length $config->{tag}
or !length $config->{label}) {
error "bad config to register_${nav}_item";
@@ -60,7 +60,7 @@ sub _register_tab {
}
foreach my $item (@{ $stash }) {
if ($item->{id} eq $config->{id}) {
if ($item->{tag} eq $config->{tag}) {
$item = $config;
return;
}

View File

@@ -6,7 +6,7 @@ use Dancer::Plugin::DBIC;
use App::Netdisco::Web::Plugin;
register_device_tab({ id => 'addresses', label => 'Addresses' });
register_device_tab({ tag => 'addresses', label => 'Addresses' });
# device interface addresses
ajax '/ajax/content/device/addresses' => sub {

View File

@@ -6,7 +6,7 @@ use Dancer::Plugin::DBIC;
use App::Netdisco::Web::Plugin;
register_device_tab({ id => 'details', label => 'Details' });
register_device_tab({ tag => 'details', label => 'Details' });
# device details table
ajax '/ajax/content/device/details' => sub {

View File

@@ -5,7 +5,7 @@ use Dancer::Plugin::Ajax;
use App::Netdisco::Web::Plugin;
register_device_tab({ id => 'modules', label => 'Modules' });
register_device_tab({ tag => 'modules', label => 'Modules' });
ajax '/ajax/content/device/:thing' => sub {
return "<p>Hello, this is where the ". param('thing') ." content goes.</p>";

View File

@@ -6,7 +6,7 @@ use Dancer::Plugin::DBIC;
use App::Netdisco::Web::Plugin;
register_device_tab({ id => 'netmap', label => 'Neighbors' });
register_device_tab({ tag => 'netmap', label => 'Neighbors' });
ajax '/ajax/content/device/netmap' => sub {
content_type('text/html');

View File

@@ -7,7 +7,7 @@ use Dancer::Plugin::DBIC;
use App::Netdisco::Util::Web (); # for sort_port
use App::Netdisco::Web::Plugin;
register_device_tab({ id => 'ports', label => 'Ports' });
register_device_tab({ tag => 'ports', label => 'Ports' });
# device ports with a description (er, name) matching
ajax '/ajax/content/device/ports' => sub {

View File

@@ -8,7 +8,7 @@ use List::MoreUtils ();
use App::Netdisco::Web::Plugin;
register_search_tab({id => 'device', label => 'Device'});
register_search_tab({ tag => 'device', label => 'Device' });
# device with various properties or a default match-all
ajax '/ajax/content/search/device' => sub {

View File

@@ -9,7 +9,7 @@ use Net::MAC ();
use App::Netdisco::Web::Plugin;
register_search_tab({ id => 'node', label => 'Node' });
register_search_tab({ tag => 'node', label => 'Node' });
# nodes matching the param as an IP or DNS hostname or MAC
ajax '/ajax/content/search/node' => sub {

View File

@@ -6,7 +6,7 @@ use Dancer::Plugin::DBIC;
use App::Netdisco::Web::Plugin;
register_search_tab({ id => 'port', label => 'Port' });
register_search_tab({ tag => 'port', label => 'Port' });
# device ports with a description (er, name) matching
ajax '/ajax/content/search/port' => sub {

View File

@@ -6,7 +6,7 @@ use Dancer::Plugin::DBIC;
use App::Netdisco::Web::Plugin;
register_search_tab({ id => 'vlan', label => 'VLAN' });
register_search_tab({ tag => 'vlan', label => 'VLAN' });
# devices carrying vlan xxx
ajax '/ajax/content/search/vlan' => sub {

View File

@@ -20,18 +20,18 @@
rel="tooltip" data-placement="left" data-offset="5" data-title="Unpin Sidebar"></i>
<div class="tab-content">
[% FOREACH tab IN settings.device_tabs %]
<div id="[% tab.id %]_search" class="tab-pane [% 'active' IF params.tab == tab.id %]">
<form id="[% tab.id %]_form" class="nd_sidesearchform form-stacked"
<div id="[% tab.tag %]_search" class="tab-pane [% 'active' IF params.tab == tab.tag %]">
<form id="[% tab.tag %]_form" class="nd_sidesearchform form-stacked"
method="get" action="[% uri_for('/device') %]">
<input name="tab" value="[% tab.id %]" type="hidden"/>
<input name="tab" value="[% tab.tag %]" type="hidden"/>
[% TRY %]
[% INCLUDE "sidebar/device/${tab.id}.tt" %]
<script type="text/javascript">has_sidebar["[% tab.id %]"] = 1;</script>
[% INCLUDE "sidebar/device/${tab.tag}.tt" %]
<script type="text/javascript">has_sidebar["[% tab.tag %]"] = 1;</script>
[% CATCH %]
<!-- no "[% tab.id %]" search options -->
<!-- no "[% tab.tag %]" search options -->
<input name="q" value="[% params.q | html_entity %]" type="hidden"/>
<input name="f" value="[% params.f | html_entity %]" type="hidden"/>
<script type="text/javascript">has_sidebar["[% tab.id %]"] = 0;</script>
<script type="text/javascript">has_sidebar["[% tab.tag %]"] = 0;</script>
[% END %]
</form>
</div> <!-- /tab-pane -->
@@ -43,13 +43,13 @@
<div class="content">
<ul id="search_results" class="nav nav-tabs">
[% FOREACH tab IN settings.device_tabs %]
<li[% ' class="active"' IF params.tab == tab.id %]><a id="[% tab.id %]_link" href="#[% tab.id %]_pane">[% tab.label %]</a></li>
<li[% ' class="active"' IF params.tab == tab.tag %]><a id="[% tab.tag %]_link" href="#[% tab.tag %]_pane">[% tab.label %]</a></li>
[% END %]
<span id="nd_device_name">[% d.dns || d.name | html_entity %]</span>
</ul>
<div class="tab-content">
[% FOREACH tab IN settings.device_tabs %]
<div class="tab-pane[% ' active' IF params.tab == tab.id %]" id="[% tab.id %]_pane"></div>
<div class="tab-pane[% ' active' IF params.tab == tab.tag %]" id="[% tab.tag %]_pane"></div>
[% END %]
</div>
</div>

View File

@@ -1,10 +1,10 @@
$(document).ready(function() {
// search hook for each tab
[% FOREACH tab IN settings.search_tabs %]
$('[% "#${tab.id}_form" %]').submit(function(event){ do_search(event, '[% tab.id %]'); });
$('[% "#${tab.tag}_form" %]').submit(function(event){ do_search(event, '[% tab.tag %]'); });
[% END %]
[% FOREACH tab IN settings.device_tabs %]
$('[% "#${tab.id}_form" %]').submit(function(event){ do_search(event, '[% tab.id %]'); });
$('[% "#${tab.tag}_form" %]').submit(function(event){ do_search(event, '[% tab.tag %]'); });
[% END %]
// on page load, load the content for the active tab

View File

@@ -9,16 +9,16 @@
rel="tooltip" data-placement="left" data-offset="5" data-title="Pin Sidebar"></i>
<div class="tab-content">
[% FOREACH tab IN settings.search_tabs %]
<div id="[% tab.id %]_search" class="tab-pane [% 'active' IF params.tab == tab.id %]">
<form id="[% tab.id %]_form" class="nd_sidesearchform form-stacked" method="get" action="[% uri_for('/search') %]">
<input name="tab" value="[% tab.id %]" type="hidden"/>
<div id="[% tab.tag %]_search" class="tab-pane [% 'active' IF params.tab == tab.tag %]">
<form id="[% tab.tag %]_form" class="nd_sidesearchform form-stacked" method="get" action="[% uri_for('/search') %]">
<input name="tab" value="[% tab.tag %]" type="hidden"/>
[% TRY %]
[% INCLUDE "sidebar/search/${tab.id}.tt" %]
<script type="text/javascript">has_sidebar["[% tab.id %]"] = 1;</script>
[% INCLUDE "sidebar/search/${tab.tag}.tt" %]
<script type="text/javascript">has_sidebar["[% tab.tag %]"] = 1;</script>
[% CATCH %]
<!-- no "[% tab.id %]" search options -->
<!-- no "[% tab.tag %]" search options -->
<input name="q" value="[% params.q | html_entity %]" type="hidden"/>
<script type="text/javascript">has_sidebar["[% tab.id %]"] = 0;</script>
<script type="text/javascript">has_sidebar["[% tab.tag %]"] = 0;</script>
[% END %]
</form>
</div> <!-- /tab-pane -->
@@ -30,12 +30,12 @@
<div class="content">
<ul id="search_results" class="nav nav-tabs">
[% FOREACH tab IN settings.search_tabs %]
<li[% ' class="active"' IF params.tab == tab.id %]><a id="[% tab.id %]_link" href="#[% tab.id %]_pane">[% tab.label %]</a></li>
<li[% ' class="active"' IF params.tab == tab.tag %]><a id="[% tab.tag %]_link" href="#[% tab.tag %]_pane">[% tab.label %]</a></li>
[% END %]
</ul>
<div class="tab-content">
[% FOREACH tab IN settings.search_tabs %]
<div class="tab-pane[% ' active' IF params.tab == tab.id %]" id="[% tab.id %]_pane"></div>
<div class="tab-pane[% ' active' IF params.tab == tab.tag %]" id="[% tab.tag %]_pane"></div>
[% END %]
</div>
</div>