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 %] - + [% row.dns || row.name || row.ip | html_entity %] [% IF row.location %] diff --git a/Netdisco/share/views/ajax/device/netmap.tt b/Netdisco/share/views/ajax/device/netmap.tt index f75e91b2..f0f960e4 100644 --- a/Netdisco/share/views/ajax/device/netmap.tt +++ b/Netdisco/share/views/ajax/device/netmap.tt @@ -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 %]'; } diff --git a/Netdisco/share/views/ajax/device/ports.tt b/Netdisco/share/views/ajax/device/ports.tt index 9e0ce64f..12a35090 100644 --- a/Netdisco/share/views/ajax/device/ports.tt +++ b/Netdisco/share/views/ajax/device/ports.tt @@ -254,7 +254,7 @@ $(document).ready(function() { [% ELSE %] "render": function ( data, type, row, meta ) { if (row.native_vlan && type === 'display') { - return '' + data + ''; + return '' + data + ''; } 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 + ''; + return '' + a + ''; }); if (row.vlan_membership.length > 10) { return '
(' diff --git a/Netdisco/share/views/ajax/report/apradiochannelpower.tt b/Netdisco/share/views/ajax/report/apradiochannelpower.tt index 3a283562..a0b7936d 100644 --- a/Netdisco/share/views/ajax/report/apradiochannelpower.tt +++ b/Netdisco/share/views/ajax/report/apradiochannelpower.tt @@ -25,7 +25,7 @@ function groupString(d) { "use strict"; var s = ''; s = s + 'Device: '; - s = s + ''; + s = s + ''; s = s + he.encode(d.dns || d.device_name || d.ip); if (d.dns || d.device_name) { s = s + ' (' + he.encode(d.ip) + ') '; diff --git a/Netdisco/share/views/ajax/report/devicepoestatus.tt b/Netdisco/share/views/ajax/report/devicepoestatus.tt index 76e0ec33..c6eee84b 100644 --- a/Netdisco/share/views/ajax/report/devicepoestatus.tt +++ b/Netdisco/share/views/ajax/report/devicepoestatus.tt @@ -51,7 +51,7 @@ function groupString(d) { "use strict"; var s = ''; s = s + 'Device: '; - s = s + ''; + s = s + ''; s = s + he.encode(d.dns || d.name || d.ip); if (d.dns || d.name) { s = s + ' (' + he.encode(d.ip) + ') '; diff --git a/Netdisco/share/views/ajax/report/moduleinventory.tt b/Netdisco/share/views/ajax/report/moduleinventory.tt index 19c0ab6c..d9eff292 100644 --- a/Netdisco/share/views/ajax/report/moduleinventory.tt +++ b/Netdisco/share/views/ajax/report/moduleinventory.tt @@ -39,7 +39,7 @@ $(document).ready(function() { { "data": 'ip', "render": function(data, type, row, meta) { - return '' + he.encode(row.device.dns || row.device.name || row.ip) + ''; + return '' + he.encode(row.device.dns || row.device.name || row.ip) + ''; } }, { "data": 'description', diff --git a/Netdisco/share/views/ajax/report/vlaninventory.tt b/Netdisco/share/views/ajax/report/vlaninventory.tt index 5b27c15d..d732866d 100644 --- a/Netdisco/share/views/ajax/report/vlaninventory.tt +++ b/Netdisco/share/views/ajax/report/vlaninventory.tt @@ -18,12 +18,12 @@ $(document).ready(function() { { "data": 'vlan', "render": function(data, type, row, meta) { - return '' + data + ''; + return '' + data + ''; } }, { "data": 'description', "render": function(data, type, row, meta) { - return '' + he.encode(data || '') + ''; + return '' + he.encode(data || '') + ''; } }, { "data": 'dcount', diff --git a/Netdisco/share/views/device.tt b/Netdisco/share/views/device.tt index 63b978ee..7f56b79c 100644 --- a/Netdisco/share/views/device.tt +++ b/Netdisco/share/views/device.tt @@ -13,10 +13,9 @@
[% FOREACH tab IN settings._device_tabs %] -