Change from ?tab=tabname param to .../tabname path
The reason for this is that DataTables keys local data on the page path, so each tab should have its own path. We're already doing this for reports and admin tasks, so it also makes sense to have consistency with search and device tabs. Squashed commit of the following: commit 4ad33a23a81122496adfe561ad14f039e6255eff Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Oct 25 14:46:17 2014 +0100 fix search preference selection commit 363e094935d386961e8773f787af41c46b83129a Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Oct 25 14:36:45 2014 +0100 fix css selector to match begins with /search commit 43c972ee0d9401f74dcc3bd30052dba130b0d068 Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Oct 25 14:18:24 2014 +0100 fix history push commit 84f83eb46874b0222c0484014389713e4f027c8a Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Oct 25 14:06:44 2014 +0100 update sidebar form for tab-path, remove hidden tab name field commit 344d4679a83f714c998cd475c041f8effab0c696 Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Oct 25 14:05:49 2014 +0100 update template links for tab path commit 9cf370d7eb4413aac6fc19c2c13a9bf670600965 Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Oct 25 14:04:57 2014 +0100 move tab-specific JS from common into specific includes files commit c2d8592a18e389535368d1e74fed29fe5a0eabd8 Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Oct 25 14:02:46 2014 +0100 fix mode commit 52487cea47eaaea7f5c74536ad6d4bb2a8d6ba4c Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Oct 25 14:01:15 2014 +0100 move from tab param to tabname template var commit b5a2424631a0050d5de3bc658746a40cd822e869 Merge:531782bd8102bfAuthor: Oliver Gorwits <oliver@cpan.org> Date: Sat Oct 25 10:50:00 2014 +0100 Merge branch 'master' into em-device-ports-json
This commit is contained in:
@@ -326,7 +326,7 @@ sub graph_addnode {
|
||||
$node{URL} = "/device?&q=$ip";
|
||||
}
|
||||
else {
|
||||
$node{URL} = "/search?tab=node&q=$ip";
|
||||
$node{URL} = "/search/node?q=$ip";
|
||||
# Overrides any colors given to nodes above. Bug 1094208
|
||||
$node{fillcolor} = $CONFIG{'node_problem'} || 'red';
|
||||
}
|
||||
|
||||
@@ -64,11 +64,10 @@ ajax '/ajax/control/admin/delete' => require_role admin => sub {
|
||||
get '/admin/*' => require_role admin => sub {
|
||||
my ($tag) = splat;
|
||||
|
||||
# trick the ajax into working as if this were a tabbed page
|
||||
params->{tab} = $tag;
|
||||
|
||||
var(nav => 'admin');
|
||||
template 'admintask', {
|
||||
# trick the ajax into working as if this were a tabbed page
|
||||
tabname => $tag,
|
||||
task => setting('_admin_tasks')->{ $tag },
|
||||
};
|
||||
};
|
||||
|
||||
@@ -55,7 +55,7 @@ hook 'before' => sub {
|
||||
{ name => 'n_archived', label => 'Archived Data', default => '' },
|
||||
]);
|
||||
|
||||
return unless (request->path eq uri_for('/device')->path
|
||||
return unless (index(request->path, uri_for('/device')->path) == 0
|
||||
or index(request->path, uri_for('/ajax/content/device')->path) == 0);
|
||||
|
||||
# override ports form defaults with cookie settings
|
||||
@@ -121,7 +121,7 @@ hook 'before_template' => sub {
|
||||
my $tokens = shift;
|
||||
|
||||
# new searches will use these defaults in their sidebars
|
||||
$tokens->{device_ports} = uri_for('/device', { tab => 'ports' });
|
||||
$tokens->{device_ports} = uri_for('/device/ports');
|
||||
|
||||
# copy ports form defaults into helper values for building template links
|
||||
|
||||
@@ -143,7 +143,7 @@ hook 'before_template' => sub {
|
||||
$tokens->{device_ports}->query_param($col->{name}, 'checked');
|
||||
}
|
||||
|
||||
return unless (request->path eq uri_for('/device')->path
|
||||
return unless (index(request->path, uri_for('/device')->path) == 0
|
||||
or index(request->path, uri_for('/ajax/content/device')->path) == 0);
|
||||
|
||||
# for templates to link to same page with modified query but same options
|
||||
@@ -154,8 +154,9 @@ hook 'before_template' => sub {
|
||||
$tokens->{self_options} = $self_uri->query_form_hash;
|
||||
};
|
||||
|
||||
get '/device' => require_login sub {
|
||||
my $handler = sub {
|
||||
my $q = param('q');
|
||||
my ($tab) = splat;
|
||||
my $schema = schema('netdisco')->resultset('Device');
|
||||
|
||||
# we are passed either dns or ip
|
||||
@@ -175,11 +176,13 @@ get '/device' => require_login sub {
|
||||
my $first = $dev->first;
|
||||
my $others = ($schema->search({dns => $first->dns})->count() - 1);
|
||||
|
||||
params->{'tab'} ||= 'details';
|
||||
template 'device', {
|
||||
display_name => ($others ? $first->ip : $first->dns),
|
||||
device => params->{'tab'},
|
||||
tabname => ($tab || 'details'),
|
||||
};
|
||||
};
|
||||
|
||||
get '/device' => require_login $handler;
|
||||
get '/device/*' => require_login $handler;
|
||||
|
||||
true;
|
||||
|
||||
@@ -48,12 +48,11 @@ get '/report/*' => require_login sub {
|
||||
];
|
||||
}
|
||||
|
||||
# trick the ajax into working as if this were a tabbed page
|
||||
params->{tab} = $tag;
|
||||
|
||||
var( nav => 'reports' );
|
||||
template 'report',
|
||||
{
|
||||
# trick the ajax into working as if this were a tabbed page
|
||||
tabname => $tag,
|
||||
report => setting('_reports')->{$tag},
|
||||
domain_list => $domain_list,
|
||||
class_list => $class_list,
|
||||
|
||||
@@ -38,8 +38,8 @@ hook 'before_template' => sub {
|
||||
my $tokens = shift;
|
||||
|
||||
# new searches will use these defaults in their sidebars
|
||||
$tokens->{search_node} = uri_for('/search', {tab => 'node'});
|
||||
$tokens->{search_device} = uri_for('/search', {tab => 'device'});
|
||||
$tokens->{search_node} = uri_for('/search/node');
|
||||
$tokens->{search_device} = uri_for('/search/device');
|
||||
|
||||
foreach my $col (@{ var('node_options') }) {
|
||||
next unless $col->{default} eq 'on';
|
||||
@@ -62,18 +62,24 @@ hook 'before_template' => sub {
|
||||
}
|
||||
};
|
||||
|
||||
get '/search' => require_login sub {
|
||||
my $handler = sub {
|
||||
my $q = param('q');
|
||||
my ($tab) = splat;
|
||||
my $s = schema('netdisco');
|
||||
|
||||
if (not param('tab')) {
|
||||
my $prefer = param('prefer');
|
||||
$prefer = ''
|
||||
unless defined $prefer and $prefer =~ m/^(?:device|node|vlan|port)$/;
|
||||
$tab ||= param('prefer');
|
||||
|
||||
if (not $tab) {
|
||||
if (not $q) {
|
||||
return redirect uri_for('/')->path;
|
||||
}
|
||||
|
||||
# pick most likely tab for initial results
|
||||
if ($q =~ m/^\d+$/) {
|
||||
params->{'tab'} = 'vlan';
|
||||
$tab = 'vlan';
|
||||
}
|
||||
else {
|
||||
my $nd = $s->resultset('Device')->search_fuzzy($q);
|
||||
@@ -82,15 +88,14 @@ get '/search' => require_login sub {
|
||||
if ($nd and $nd->count) {
|
||||
if ($nd->count == 1) {
|
||||
# redirect to device details for the one device
|
||||
return redirect uri_for('/device', {
|
||||
tab => 'details',
|
||||
return redirect uri_for('/device/details', {
|
||||
q => $nd->first->ip,
|
||||
f => '',
|
||||
})->path_query;
|
||||
}
|
||||
|
||||
# multiple devices
|
||||
params->{'tab'} = 'device';
|
||||
$tab = 'device';
|
||||
}
|
||||
elsif ($s->resultset('DevicePort')
|
||||
->search({
|
||||
@@ -101,12 +106,12 @@ get '/search' => require_login sub {
|
||||
],
|
||||
})->count) {
|
||||
|
||||
params->{'tab'} = 'port';
|
||||
$tab = 'port';
|
||||
}
|
||||
}
|
||||
|
||||
# if all else fails
|
||||
params->{'tab'} ||= 'node';
|
||||
$tab ||= 'node';
|
||||
}
|
||||
|
||||
# used in the device search sidebar to populate select inputs
|
||||
@@ -115,11 +120,14 @@ get '/search' => require_login sub {
|
||||
my $vendor_list = [ $s->resultset('Device')->get_distinct_col('vendor') ];
|
||||
|
||||
template 'search', {
|
||||
search => params->{'tab'},
|
||||
tabname => $tab,
|
||||
model_list => $model_list,
|
||||
os_ver_list => $os_ver_list,
|
||||
vendor_list => $vendor_list,
|
||||
};
|
||||
};
|
||||
|
||||
get '/search' => require_login $handler;
|
||||
get '/search/*' => require_login $handler;
|
||||
|
||||
true;
|
||||
|
||||
0
Netdisco/share/public/javascripts/dataTables.colVis.js
Executable file → Normal file
0
Netdisco/share/public/javascripts/dataTables.colVis.js
Executable file → Normal file
@@ -94,7 +94,7 @@ function update_content(from, to) {
|
||||
is_from_history_plugin = 1;
|
||||
window.History.pushState(
|
||||
{name: to, fields: $(to_form).serializeArray()},
|
||||
pgtitle, uri_base + '/' + path + '?' + $(to_form).serialize()
|
||||
pgtitle, uri_base + '/' + path + '/' + to + '?' + $(to_form).serialize()
|
||||
);
|
||||
is_from_history_plugin = 0;
|
||||
}
|
||||
@@ -145,7 +145,7 @@ function device_form_state(e) {
|
||||
$(id).show();
|
||||
|
||||
// if form still has any field val, set strikethough
|
||||
if (e.parents('form[action="/search"]').length > 0 && with_val != 0) {
|
||||
if (e.parents('form[action^="/search"]').length > 0 && with_val != 0) {
|
||||
$('#nq').css('text-decoration', 'line-through');
|
||||
}
|
||||
|
||||
@@ -184,8 +184,8 @@ $(document).ready(function() {
|
||||
if ($('#nq').val()) {
|
||||
$(this).parents('form').append(
|
||||
$(document.createElement('input')).attr('type', 'hidden')
|
||||
.attr('name', 'tab')
|
||||
.attr('value', $(this).data('tab'))
|
||||
.attr('name', 'prefer')
|
||||
.attr('value', $(this).data('prefer'))
|
||||
).submit();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
<tbody>
|
||||
[% FOREACH row IN network %]
|
||||
<tr>
|
||||
<td><a href="[% uri_for('/device') %]?tab=netmap&q=[% row.ip | uri %]">
|
||||
<td><a href="[% uri_for('/device/netmap') %]?q=[% row.ip | uri %]">
|
||||
[% row.dns || row.name || row.ip | html_entity %]</a></td>
|
||||
<td>
|
||||
[% IF row.location %]
|
||||
|
||||
@@ -56,8 +56,8 @@ function to_class(name) { return 'nd_' + name.replace(/\./g, "_") }
|
||||
|
||||
// handler for clicking on a circle - redirect to that device's netmap
|
||||
function circleClick(d) {
|
||||
window.location = '[% uri_for('/device') %]?tab=netmap'
|
||||
+ '&q=' + d.fullname
|
||||
window.location = '[% uri_for('/device/netmap') %]'
|
||||
+ '?q=' + d.fullname
|
||||
+ '&depth=[% params.depth | uri %]'
|
||||
+ '&vlan=[% params.vlan | uri %]';
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ $(document).ready(function() {
|
||||
[% ELSE %]
|
||||
"render": function ( data, type, row, meta ) {
|
||||
if (row.native_vlan && type === 'display') {
|
||||
return '<a class="nd_linkcell" href="[% uri_for('/search') %]?tab=vlan&q=' + encodeURIComponent(data) + '">' + data + '</a>';
|
||||
return '<a class="nd_linkcell" href="[% uri_for('/search/vlan') %]?q=' + encodeURIComponent(data) + '">' + data + '</a>';
|
||||
}
|
||||
else {
|
||||
return data;
|
||||
@@ -272,7 +272,7 @@ $(document).ready(function() {
|
||||
var arr = row.vlan_membership;
|
||||
arr = arr.sort(function(a, b){return a-b});
|
||||
arr = jQuery.map( arr, function( a ) {
|
||||
return '<a href="[% uri_for('/search') %]?tab=vlan&q=' + a + '">' + a + '</a>';
|
||||
return '<a href="[% uri_for('/search/vlan') %]?q=' + a + '">' + a + '</a>';
|
||||
});
|
||||
if (row.vlan_membership.length > 10) {
|
||||
return '<div class="nd_vlan-total">('
|
||||
|
||||
@@ -25,7 +25,7 @@ function groupString(d) {
|
||||
"use strict";
|
||||
var s = '';
|
||||
s = s + 'Device: ';
|
||||
s = s + '<a href="[% uri_for('/device') %]?tab=details&q=' + encodeURIComponent(d.ip) + '">';
|
||||
s = s + '<a href="[% uri_for('/device/details') %]?q=' + encodeURIComponent(d.ip) + '">';
|
||||
s = s + he.encode(d.dns || d.device_name || d.ip);
|
||||
if (d.dns || d.device_name) {
|
||||
s = s + ' (' + he.encode(d.ip) + ') ';
|
||||
|
||||
@@ -51,7 +51,7 @@ function groupString(d) {
|
||||
"use strict";
|
||||
var s = '';
|
||||
s = s + 'Device: ';
|
||||
s = s + '<a href="[% uri_for('/device') %]?tab=details&q=' + encodeURIComponent(d.ip) + '">';
|
||||
s = s + '<a href="[% uri_for('/device/details') %]?q=' + encodeURIComponent(d.ip) + '">';
|
||||
s = s + he.encode(d.dns || d.name || d.ip);
|
||||
if (d.dns || d.name) {
|
||||
s = s + ' (' + he.encode(d.ip) + ') ';
|
||||
|
||||
@@ -39,7 +39,7 @@ $(document).ready(function() {
|
||||
{
|
||||
"data": 'ip',
|
||||
"render": function(data, type, row, meta) {
|
||||
return '<a href="[% uri_for('/device') %]?tab=modules&q=' + encodeURIComponent(data) + '">' + he.encode(row.device.dns || row.device.name || row.ip) + '</a>';
|
||||
return '<a href="[% uri_for('/device/modules') %]?q=' + encodeURIComponent(data) + '">' + he.encode(row.device.dns || row.device.name || row.ip) + '</a>';
|
||||
}
|
||||
}, {
|
||||
"data": 'description',
|
||||
|
||||
@@ -18,12 +18,12 @@ $(document).ready(function() {
|
||||
{
|
||||
"data": 'vlan',
|
||||
"render": function(data, type, row, meta) {
|
||||
return '<a href="[% uri_for('/search') %]?tab=vlan&q=' + encodeURIComponent(data) + '">' + data + '</a>';
|
||||
return '<a href="[% uri_for('/search/vlan') %]?q=' + encodeURIComponent(data) + '">' + data + '</a>';
|
||||
}
|
||||
}, {
|
||||
"data": 'description',
|
||||
"render": function(data, type, row, meta) {
|
||||
return '<a href="[% uri_for('/search') %]?tab=vlan&q=' + encodeURIComponent(data) + '">' + he.encode(data || '') + '</a>';
|
||||
return '<a href="[% uri_for('/search/vlan') %]?q=' + encodeURIComponent(data) + '">' + he.encode(data || '') + '</a>';
|
||||
}
|
||||
}, {
|
||||
"data": 'dcount',
|
||||
|
||||
@@ -13,10 +13,9 @@
|
||||
</a>
|
||||
<div class="tab-content">
|
||||
[% FOREACH tab IN settings._device_tabs %]
|
||||
<div id="[% tab.tag %]_search" class="tab-pane [% 'active' IF params.tab == tab.tag %]">
|
||||
<div id="[% tab.tag %]_search" class="tab-pane [% 'active' IF tabname == tab.tag %]">
|
||||
<form id="[% tab.tag %]_form" class="nd_sidebar-form form-stacked"
|
||||
method="get" action="[% uri_for('/device') %]">
|
||||
<input name="tab" value="[% tab.tag %]" type="hidden"/>
|
||||
method="get" action="[% uri_for("/device/${tab.tag}") %]">
|
||||
[% TRY %]
|
||||
<script type="text/javascript">has_sidebar["[% tab.tag %]"] = 1;</script>
|
||||
[% INCLUDE "sidebar/device/${tab.tag}.tt" %]
|
||||
@@ -36,7 +35,9 @@
|
||||
<div class="content">
|
||||
<ul id="nd_search-results" class="nav nav-tabs">
|
||||
[% FOREACH tab IN settings._device_tabs %]
|
||||
<li[% ' class="active"' IF params.tab == tab.tag %]><a id="[% tab.tag %]_link" href="#[% tab.tag %]_pane">[% tab.label %]</a></li>
|
||||
<li[% ' class="active"' IF tabname == tab.tag %]>
|
||||
<a id="[% tab.tag %]_link" href="#[% tab.tag %]_pane">[% tab.label %]</a>
|
||||
</li>
|
||||
[% END %]
|
||||
<span id="nd_device-name">
|
||||
[% display_name | html_entity %]
|
||||
@@ -47,7 +48,7 @@
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
[% FOREACH tab IN settings._device_tabs %]
|
||||
<div class="tab-pane[% ' active' IF params.tab == tab.tag %]" id="[% tab.tag %]_pane"></div>
|
||||
<div class="tab-pane[% ' active' IF tabname == tab.tag %]" id="[% tab.tag %]_pane"></div>
|
||||
[% END %]
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -179,4 +179,11 @@
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// for the admin pages
|
||||
$('[% "#${task.tag}_form" %]').submit(function (event) {
|
||||
update_page_title('[% task.tag %]');
|
||||
update_csv_download_link('admin', '[% task.tag %]', '1');
|
||||
do_search(event, '[% task.tag %]');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -36,16 +36,15 @@
|
||||
|
||||
if (window.History && window.History.enabled) {
|
||||
is_from_history_plugin = 1;
|
||||
var target = uri_base + '/' + path + '/' + tab + query;
|
||||
|
||||
if (push.length) {
|
||||
var target = uri_base + '/' + path + '/' + tab + query;
|
||||
if (location.pathname == target) { return };
|
||||
window.History.pushState(
|
||||
{name: tab, fields: $(form).serializeArray()}, pgtitle, target
|
||||
);
|
||||
}
|
||||
else {
|
||||
var target = uri_base + '/' + path + query;
|
||||
window.History.replaceState(
|
||||
{name: tab, fields: $(form).serializeArray()}, pgtitle, target
|
||||
);
|
||||
@@ -70,81 +69,12 @@
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
[% IF search %]
|
||||
// search tabs
|
||||
[% FOREACH tab IN settings._search_tabs %]
|
||||
$('[% "#${tab.tag}_form" %]').submit(function (event) {
|
||||
var pgtitle = update_page_title('[% tab.tag %]');
|
||||
copy_navbar_to_sidebar('[% tab.tag %]');
|
||||
update_browser_history('[% tab.tag %]', pgtitle, '');
|
||||
update_csv_download_link('search', '[% tab.tag %]', '[% tab.provides_csv %]');
|
||||
do_search(event, '[% tab.tag %]');
|
||||
});
|
||||
[% END %]
|
||||
[% END %]
|
||||
|
||||
[% IF device %]
|
||||
// device tabs
|
||||
[% FOREACH tab IN settings._device_tabs %]
|
||||
$('[% "#${tab.tag}_form" %]').submit(function (event) {
|
||||
var pgtitle = update_page_title('[% tab.tag %]');
|
||||
copy_navbar_to_sidebar('[% tab.tag %]');
|
||||
update_browser_history('[% tab.tag %]', pgtitle, '');
|
||||
update_csv_download_link('device', '[% tab.tag %]', '[% tab.provides_csv %]');
|
||||
|
||||
[% IF tab.tag == 'ports' %]
|
||||
// to be fair I can't remember why we do this in JS and not from the app
|
||||
// perhaps because selecting form fields to go in the cookie is easier?
|
||||
var cookie = $('#ports_form').find('input,select')
|
||||
.not('#nd_port-query,input[name="q"],input[name="tab"]')
|
||||
.serializeArray();
|
||||
$('#ports_form').find('input[type="checkbox"]').map(function() {
|
||||
cookie.push({'name': 'columns', 'value': $(this).attr('name')});
|
||||
});
|
||||
$.cookie('nd_ports-form', $.param(cookie) ,{ expires: 365 });
|
||||
|
||||
// form reset icon on ports tab
|
||||
$('#nd_sidebar-reset-link').attr('href', uri_base + '/device?tab=[% tab.tag %]&reset=on&' +
|
||||
$('#ports_form')
|
||||
.find('input[name="q"],input[name="f"],input[name="partial"],input[name="invert"]')
|
||||
.serialize());
|
||||
|
||||
[% ELSIF tab.tag == 'netmap' %]
|
||||
// form reset icon on netmap tab
|
||||
$('#nd_sidebar-reset-link').attr('href', uri_base + '/device?tab=[% tab.tag %]&reset=on&' +
|
||||
$('#netmap_form').find('input[name="q"]').serialize());
|
||||
[% END %]
|
||||
|
||||
do_search(event, '[% tab.tag %]');
|
||||
});
|
||||
[% END %]
|
||||
[% END %]
|
||||
|
||||
[% IF report %]
|
||||
// for the report pages
|
||||
$('[% "#${report.tag}_form" %]').submit(function (event) {
|
||||
var pgtitle = update_page_title('[% report.tag %]');
|
||||
update_browser_history('[% report.tag %]', pgtitle, '1');
|
||||
update_csv_download_link('report', '[% report.tag %]', '1');
|
||||
do_search(event, '[% report.tag %]');
|
||||
});
|
||||
[% END -%]
|
||||
|
||||
[% IF task %]
|
||||
// for the admin pages
|
||||
$('[% "#${task.tag}_form" %]').submit(function (event) {
|
||||
update_page_title('[% task.tag %]');
|
||||
update_csv_download_link('admin', '[% task.tag %]', '1');
|
||||
do_search(event, '[% task.tag %]');
|
||||
});
|
||||
[% END %]
|
||||
|
||||
// on page load, load the content for the active tab
|
||||
[% IF params.tab %]
|
||||
[% IF params.tab == 'ipinventory' OR params.tab == 'subnets' %]
|
||||
$('#[% params.tab %]_submit').click();
|
||||
[% IF tabname %]
|
||||
[% IF tabname == 'ipinventory' OR tabname == 'subnets' %]
|
||||
$('#[% tabname %]_submit').click();
|
||||
[% ELSE %]
|
||||
$('#[% params.tab %]_form').trigger("submit");
|
||||
$('#[% tabname %]_form').trigger("submit");
|
||||
[% END %]
|
||||
[% END %]
|
||||
});
|
||||
|
||||
@@ -138,4 +138,39 @@
|
||||
$('#nd_devdel-log').val('');
|
||||
$('#nd_devdel-archive').attr('checked', false);
|
||||
});
|
||||
|
||||
// device tabs
|
||||
[% FOREACH tab IN settings._device_tabs %]
|
||||
$('[% "#${tab.tag}_form" %]').submit(function (event) {
|
||||
var pgtitle = update_page_title('[% tab.tag %]');
|
||||
copy_navbar_to_sidebar('[% tab.tag %]');
|
||||
update_browser_history('[% tab.tag %]', pgtitle, '');
|
||||
update_csv_download_link('device', '[% tab.tag %]', '[% tab.provides_csv %]');
|
||||
|
||||
[% IF tab.tag == 'ports' %]
|
||||
// to be fair I can't remember why we do this in JS and not from the app
|
||||
// perhaps because selecting form fields to go in the cookie is easier?
|
||||
var cookie = $('#ports_form').find('input,select')
|
||||
.not('#nd_port-query,input[name="q"],input[name="tab"]')
|
||||
.serializeArray();
|
||||
$('#ports_form').find('input[type="checkbox"]').map(function() {
|
||||
cookie.push({'name': 'columns', 'value': $(this).attr('name')});
|
||||
});
|
||||
$.cookie('nd_ports-form', $.param(cookie) ,{ expires: 365 });
|
||||
|
||||
// form reset icon on ports tab
|
||||
$('#nd_sidebar-reset-link').attr('href', uri_base + '/device/[% tab.tag %]?reset=on&' +
|
||||
$('#ports_form')
|
||||
.find('input[name="q"],input[name="f"],input[name="partial"],input[name="invert"]')
|
||||
.serialize());
|
||||
|
||||
[% ELSIF tab.tag == 'netmap' %]
|
||||
// form reset icon on netmap tab
|
||||
$('#nd_sidebar-reset-link').attr('href', uri_base + '/device/[% tab.tag %]?reset=on&' +
|
||||
$('#netmap_form').find('input[name="q"]').serialize());
|
||||
[% END %]
|
||||
|
||||
do_search(event, '[% tab.tag %]');
|
||||
});
|
||||
[% END %]
|
||||
});
|
||||
|
||||
@@ -52,4 +52,12 @@
|
||||
,delay: 150
|
||||
,minLength: 3
|
||||
});
|
||||
|
||||
// for the report pages
|
||||
$('[% "#${report.tag}_form" %]').submit(function (event) {
|
||||
var pgtitle = update_page_title('[% report.tag %]');
|
||||
update_browser_history('[% report.tag %]', pgtitle, '1');
|
||||
update_csv_download_link('report', '[% report.tag %]', '1');
|
||||
do_search(event, '[% report.tag %]');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -36,4 +36,15 @@
|
||||
input.val('');
|
||||
device_form_state(input); // will hide copy icons
|
||||
});
|
||||
|
||||
// search tabs
|
||||
[% FOREACH tab IN settings._search_tabs %]
|
||||
$('[% "#${tab.tag}_form" %]').submit(function (event) {
|
||||
var pgtitle = update_page_title('[% tab.tag %]');
|
||||
copy_navbar_to_sidebar('[% tab.tag %]');
|
||||
update_browser_history('[% tab.tag %]', pgtitle, '');
|
||||
update_csv_download_link('search', '[% tab.tag %]', '[% tab.provides_csv %]');
|
||||
do_search(event, '[% tab.tag %]');
|
||||
});
|
||||
[% END %]
|
||||
});
|
||||
|
||||
@@ -148,10 +148,10 @@
|
||||
<span class="caret" style="border-top-color: #999; border-bottom-color: #999"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="nd_navsearchgo-specific" href="" data-tab="device">Search Devices</a></li>
|
||||
<li><a class="nd_navsearchgo-specific" href="" data-tab="node">Search Nodes</a></li>
|
||||
<li><a class="nd_navsearchgo-specific" href="" data-tab="vlan">Search VLANs</a></li>
|
||||
<li><a class="nd_navsearchgo-specific" href="" data-tab="port">Search Ports</a></li>
|
||||
<li><a class="nd_navsearchgo-specific" href="" data-prefer="device">Search Devices</a></li>
|
||||
<li><a class="nd_navsearchgo-specific" href="" data-prefer="node">Search Nodes</a></li>
|
||||
<li><a class="nd_navsearchgo-specific" href="" data-prefer="vlan">Search VLANs</a></li>
|
||||
<li><a class="nd_navsearchgo-specific" href="" data-prefer="port">Search Ports</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
rel="tooltip" data-placement="left" data-offset="5" data-title="Pin Sidebar" data-container="body"></i>
|
||||
<div class="tab-content">
|
||||
[% FOREACH tab IN settings._search_tabs %]
|
||||
<div id="[% tab.tag %]_search" class="tab-pane [% 'active' IF params.tab == tab.tag %]">
|
||||
<form id="[% tab.tag %]_form" class="nd_sidebar-form form-stacked" method="get" action="[% uri_for('/search') %]">
|
||||
<input name="tab" value="[% tab.tag %]" type="hidden"/>
|
||||
<div id="[% tab.tag %]_search" class="tab-pane [% 'active' IF tabname == tab.tag %]">
|
||||
<form id="[% tab.tag %]_form" class="nd_sidebar-form form-stacked"
|
||||
method="get" action="[% uri_for("/search/${tab.tag}") %]">
|
||||
[% TRY %]
|
||||
<script type="text/javascript">has_sidebar["[% tab.tag %]"] = 1;</script>
|
||||
[% INCLUDE "sidebar/search/${tab.tag}.tt" %]
|
||||
@@ -30,7 +30,7 @@
|
||||
<div class="content">
|
||||
<ul id="nd_search-results" class="nav nav-tabs">
|
||||
[% FOREACH tab IN settings._search_tabs %]
|
||||
<li[% ' class="active"' IF params.tab == tab.tag %]><a id="[% tab.tag %]_link" href="#[% tab.tag %]_pane">[% tab.label %]</a></li>
|
||||
<li[% ' class="active"' IF tabname == tab.tag %]><a id="[% tab.tag %]_link" href="#[% tab.tag %]_pane">[% tab.label %]</a></li>
|
||||
[% END %]
|
||||
<span id="nd_device-name">
|
||||
<a id="nd_csv-download" href="#" download="netdisco.csv">
|
||||
@@ -40,7 +40,7 @@
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
[% FOREACH tab IN settings._search_tabs %]
|
||||
<div class="tab-pane[% ' active' IF params.tab == tab.tag %]" id="[% tab.tag %]_pane"></div>
|
||||
<div class="tab-pane[% ' active' IF tabname == tab.tag %]" id="[% tab.tag %]_pane"></div>
|
||||
[% END %]
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user