diff --git a/Netdisco/lib/App/Netdisco/Util/Graph.pm b/Netdisco/lib/App/Netdisco/Util/Graph.pm index ba5c2747..630ec1b6 100644 --- a/Netdisco/lib/App/Netdisco/Util/Graph.pm +++ b/Netdisco/lib/App/Netdisco/Util/Graph.pm @@ -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'; } diff --git a/Netdisco/lib/App/Netdisco/Web/AdminTask.pm b/Netdisco/lib/App/Netdisco/Web/AdminTask.pm index e0986398..3cee326b 100644 --- a/Netdisco/lib/App/Netdisco/Web/AdminTask.pm +++ b/Netdisco/lib/App/Netdisco/Web/AdminTask.pm @@ -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 }, }; }; diff --git a/Netdisco/lib/App/Netdisco/Web/Device.pm b/Netdisco/lib/App/Netdisco/Web/Device.pm index a2de2486..e4fccf93 100644 --- a/Netdisco/lib/App/Netdisco/Web/Device.pm +++ b/Netdisco/lib/App/Netdisco/Web/Device.pm @@ -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; diff --git a/Netdisco/lib/App/Netdisco/Web/Report.pm b/Netdisco/lib/App/Netdisco/Web/Report.pm index 740cd950..208c732d 100644 --- a/Netdisco/lib/App/Netdisco/Web/Report.pm +++ b/Netdisco/lib/App/Netdisco/Web/Report.pm @@ -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, diff --git a/Netdisco/lib/App/Netdisco/Web/Search.pm b/Netdisco/lib/App/Netdisco/Web/Search.pm index 54fa0b6d..9d8d6998 100644 --- a/Netdisco/lib/App/Netdisco/Web/Search.pm +++ b/Netdisco/lib/App/Netdisco/Web/Search.pm @@ -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; diff --git a/Netdisco/share/public/javascripts/dataTables.colVis.js b/Netdisco/share/public/javascripts/dataTables.colVis.js old mode 100755 new mode 100644 diff --git a/Netdisco/share/public/javascripts/netdisco.js b/Netdisco/share/public/javascripts/netdisco.js index 1750106d..103f6fb0 100644 --- a/Netdisco/share/public/javascripts/netdisco.js +++ b/Netdisco/share/public/javascripts/netdisco.js @@ -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(); } }); diff --git a/Netdisco/share/views/ajax/admintask/orphaned.tt b/Netdisco/share/views/ajax/admintask/orphaned.tt index d0a9bda2..64ce2968 100644 --- a/Netdisco/share/views/ajax/admintask/orphaned.tt +++ b/Netdisco/share/views/ajax/admintask/orphaned.tt @@ -75,7 +75,7 @@
[% FOREACH row IN network %]