From 799358f86c21d212482fdc8bd22e3f4d5e06a099 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Mon, 3 Nov 2014 19:59:01 +0000 Subject: [PATCH] get rid of device_ports and self_options template vars --- .../lib/App/Netdisco/Manual/WritingPlugins.pod | 12 ------------ Netdisco/lib/App/Netdisco/Web.pm | 2 +- Netdisco/lib/App/Netdisco/Web/Device.pm | 14 -------------- .../views/ajax/admintask/undiscoveredneighbors.tt | 2 +- Netdisco/share/views/ajax/device/addresses.tt | 2 +- Netdisco/share/views/ajax/device/ports.tt | 8 ++++---- .../share/views/ajax/report/apradiochannelpower.tt | 2 +- Netdisco/share/views/ajax/report/duplexmismatch.tt | 4 ++-- Netdisco/share/views/ajax/report/halfduplex.tt | 2 +- Netdisco/share/views/ajax/report/nodemultiips.tt | 2 +- .../share/views/ajax/report/nodesdiscovered.tt | 2 +- Netdisco/share/views/ajax/report/nodevendor.tt | 2 +- Netdisco/share/views/ajax/report/portadmindown.tt | 2 +- Netdisco/share/views/ajax/report/portblocking.tt | 2 +- Netdisco/share/views/ajax/report/portmultinodes.tt | 2 +- Netdisco/share/views/ajax/report/portssid.tt | 2 +- .../share/views/ajax/report/portutilization.tt | 2 +- Netdisco/share/views/ajax/search/node_by_ip.tt | 2 +- Netdisco/share/views/ajax/search/node_by_mac.tt | 4 ++-- Netdisco/share/views/ajax/search/port.tt | 2 +- Netdisco/share/views/ajax/search/vlan.tt | 12 ++++++------ Netdisco/share/views/report.tt | 4 ++-- 22 files changed, 31 insertions(+), 57 deletions(-) diff --git a/Netdisco/lib/App/Netdisco/Manual/WritingPlugins.pod b/Netdisco/lib/App/Netdisco/Manual/WritingPlugins.pod index d5a2c8b0..76c9d48a 100644 --- a/Netdisco/lib/App/Netdisco/Manual/WritingPlugins.pod +++ b/Netdisco/lib/App/Netdisco/Manual/WritingPlugins.pod @@ -370,11 +370,6 @@ together with the correct default search options set. A path and query string which links to the Device tab of the Search page, together with the correct default search options set. -=item C - -A path and query sting which links to the Ports tab of the Device page, -together with the correct default column view options set. - =item C Used for linking to static content within App::Netdisco safely if the base of @@ -389,13 +384,6 @@ template safely if the base of the app is relocated: -=item C - -Available in the Device tabs, use this if you need to refer back to the -current page with some additional parameters, for example: - - - =back =head1 Javascript and Stylesheets diff --git a/Netdisco/lib/App/Netdisco/Web.pm b/Netdisco/lib/App/Netdisco/Web.pm index 64a0e197..b96964a0 100644 --- a/Netdisco/lib/App/Netdisco/Web.pm +++ b/Netdisco/lib/App/Netdisco/Web.pm @@ -82,7 +82,7 @@ hook 'before_template' => sub { # fix Plugin Template Variables to be only path+query $tokens->{$_} = $tokens->{$_}->path_query - for qw/search_node search_device device_ports/; + for qw/search_node search_device/; # shorthand access to section and tabname my @parts = split m{/}, request->path; diff --git a/Netdisco/lib/App/Netdisco/Web/Device.pm b/Netdisco/lib/App/Netdisco/Web/Device.pm index 488347a7..f3f5790b 100644 --- a/Netdisco/lib/App/Netdisco/Web/Device.pm +++ b/Netdisco/lib/App/Netdisco/Web/Device.pm @@ -5,20 +5,6 @@ use Dancer::Plugin::Ajax; use Dancer::Plugin::DBIC; use Dancer::Plugin::Auth::Extensible; -hook 'before_template' => sub { - my $tokens = shift; - - # new searches will use these defaults in their sidebars - $tokens->{device_ports} = uri_for('/device/ports'); - - # for templates to link to same page with modified query but same options - my $self_uri = uri_for(request->path, scalar params); - $self_uri->query_param_delete('q'); - $self_uri->query_param_delete('f'); - $self_uri->query_param_delete('prefer'); - $tokens->{self_options} = $self_uri->query_form_hash; -}; - my $handler = sub { my $q = param('q'); my ($tab) = splat; diff --git a/Netdisco/share/views/ajax/admintask/undiscoveredneighbors.tt b/Netdisco/share/views/ajax/admintask/undiscoveredneighbors.tt index 204b04f8..3e881207 100644 --- a/Netdisco/share/views/ajax/admintask/undiscoveredneighbors.tt +++ b/Netdisco/share/views/ajax/admintask/undiscoveredneighbors.tt @@ -10,7 +10,7 @@ [% FOREACH row IN results %] - + [% row.dns || row.name || row.ip | html_entity %] ( [% row.port | html_entity %] ) [% row.remote_ip | html_entity %] diff --git a/Netdisco/share/views/ajax/device/addresses.tt b/Netdisco/share/views/ajax/device/addresses.tt index 448bc385..fe799ad5 100644 --- a/Netdisco/share/views/ajax/device/addresses.tt +++ b/Netdisco/share/views/ajax/device/addresses.tt @@ -31,7 +31,7 @@ $(document).ready(function() { "type": 'portsort', "render": function(data, type, row, meta) { return type === 'display' ? - '' + he.encode(data || '') + '' : + '' + he.encode(data || '') + '' : data; } }, { diff --git a/Netdisco/share/views/ajax/device/ports.tt b/Netdisco/share/views/ajax/device/ports.tt index 40f06387..ced6c101 100644 --- a/Netdisco/share/views/ajax/device/ports.tt +++ b/Netdisco/share/views/ajax/device/ports.tt @@ -117,7 +117,7 @@ $(document).ready(function() { [% ELSE %] cell_str += ''; [% END %] - cell_str += ''; if (row.is_master) { cell_str += ' '; @@ -125,7 +125,7 @@ $(document).ready(function() { cell_str += he.encode(row.port) + ''; if (row.slave_of) { cell_str += '
' - + '' + he.encode(row.slave_of) + ''; } @@ -384,13 +384,13 @@ $(document).ready(function() { else if (row.remote_type && row.remote_type.match(/(cisco\s+AIR-[L|C]?AP|-K9W8-|^AP:\s)/)) { cell_str += ' '; } - cell_str += ''; var n_dns = row.neighbor_alias_dns ? row.neighbor_alias_dns.replace(d_suffix, '') : ''; cell_str += he.encode(n_dns || row.neighbor_alias_ip) + ''; if (row.remote_port) { cell_str += ' - ' - + '' + he.encode(row.remote_port || '') + ''; diff --git a/Netdisco/share/views/ajax/report/apradiochannelpower.tt b/Netdisco/share/views/ajax/report/apradiochannelpower.tt index a0b7936d..dd4b61ea 100644 --- a/Netdisco/share/views/ajax/report/apradiochannelpower.tt +++ b/Netdisco/share/views/ajax/report/apradiochannelpower.tt @@ -59,7 +59,7 @@ $(document).ready(function() { "type": 'portsort', "render": function(data, type, row, meta) { return type === 'display' ? - '' + he.encode(data) + '' : + '' + he.encode(data) + '' : data; } }, { diff --git a/Netdisco/share/views/ajax/report/duplexmismatch.tt b/Netdisco/share/views/ajax/report/duplexmismatch.tt index 17548fc3..e98578fa 100644 --- a/Netdisco/share/views/ajax/report/duplexmismatch.tt +++ b/Netdisco/share/views/ajax/report/duplexmismatch.tt @@ -27,7 +27,7 @@ $(document).ready(function() { "type": 'portsort', "render": function(data, type, row, meta) { return type === 'display' ? - '' + he.encode(data) + '' : + '' + he.encode(data) + '' : data; } }, { @@ -45,7 +45,7 @@ $(document).ready(function() { "type": 'portsort', "render": function(data, type, row, meta) { return type === 'display' ? - '' + he.encode(data) + '' : + '' + he.encode(data) + '' : data; } }, { diff --git a/Netdisco/share/views/ajax/report/halfduplex.tt b/Netdisco/share/views/ajax/report/halfduplex.tt index 4427ce99..fbedb8ff 100644 --- a/Netdisco/share/views/ajax/report/halfduplex.tt +++ b/Netdisco/share/views/ajax/report/halfduplex.tt @@ -25,7 +25,7 @@ $(document).ready(function() { "type": 'portsort', "render": function(data, type, row, meta) { return type === 'display' ? - '' + he.encode(data) + '' : + '' + he.encode(data) + '' : data; } }, { diff --git a/Netdisco/share/views/ajax/report/nodemultiips.tt b/Netdisco/share/views/ajax/report/nodemultiips.tt index 1d70e853..212eb2c4 100644 --- a/Netdisco/share/views/ajax/report/nodemultiips.tt +++ b/Netdisco/share/views/ajax/report/nodemultiips.tt @@ -30,7 +30,7 @@ $(document).ready(function() { }, { "data": 'port', "render": function(data, type, row, meta) { - return '' + he.encode(row.dns || row.name || row.switch) + '(' + he.encode(data) + ')'; + return '' + he.encode(row.dns || row.name || row.switch) + '(' + he.encode(data) + ')'; } }, { "data": 'ip_count', diff --git a/Netdisco/share/views/ajax/report/nodesdiscovered.tt b/Netdisco/share/views/ajax/report/nodesdiscovered.tt index 98db813e..df626346 100644 --- a/Netdisco/share/views/ajax/report/nodesdiscovered.tt +++ b/Netdisco/share/views/ajax/report/nodesdiscovered.tt @@ -27,7 +27,7 @@ $(document).ready(function() { "type": 'portsort', "render": function(data, type, row, meta) { return type === 'display' ? - '' + he.encode(data) + '' : + '' + he.encode(data) + '' : data; } }, { diff --git a/Netdisco/share/views/ajax/report/nodevendor.tt b/Netdisco/share/views/ajax/report/nodevendor.tt index 0f6f70b0..20d68ed3 100644 --- a/Netdisco/share/views/ajax/report/nodevendor.tt +++ b/Netdisco/share/views/ajax/report/nodevendor.tt @@ -48,7 +48,7 @@ $(document).ready(function() { }, { "data": 'port', "render": function(data, type, row, meta) { - return '' + he.encode(row.device.dns || row.device.name || row.switch) + '(' + he.encode(data) + ')'; + return '' + he.encode(row.device.dns || row.device.name || row.switch) + '(' + he.encode(data) + ')'; } }, { // Included for filtering diff --git a/Netdisco/share/views/ajax/report/portadmindown.tt b/Netdisco/share/views/ajax/report/portadmindown.tt index 9a8c516c..140e8db4 100644 --- a/Netdisco/share/views/ajax/report/portadmindown.tt +++ b/Netdisco/share/views/ajax/report/portadmindown.tt @@ -25,7 +25,7 @@ $(document).ready(function() { "type": 'portsort', "render": function(data, type, row, meta) { return type === 'display' ? - '' + he.encode(data) + '' : + '' + he.encode(data) + '' : data; } }, { diff --git a/Netdisco/share/views/ajax/report/portblocking.tt b/Netdisco/share/views/ajax/report/portblocking.tt index 5ff08dc9..24cd97bd 100644 --- a/Netdisco/share/views/ajax/report/portblocking.tt +++ b/Netdisco/share/views/ajax/report/portblocking.tt @@ -26,7 +26,7 @@ $(document).ready(function() { "type": 'portsort', "render": function(data, type, row, meta) { return type === 'display' ? - '' + he.encode(data) + '' : + '' + he.encode(data) + '' : data; } }, { diff --git a/Netdisco/share/views/ajax/report/portmultinodes.tt b/Netdisco/share/views/ajax/report/portmultinodes.tt index 8482edfd..dcc93ccc 100644 --- a/Netdisco/share/views/ajax/report/portmultinodes.tt +++ b/Netdisco/share/views/ajax/report/portmultinodes.tt @@ -26,7 +26,7 @@ $(document).ready(function() { "type": 'portsort', "render": function(data, type, row, meta) { return type === 'display' ? - '' + he.encode(data) + '' : + '' + he.encode(data) + '' : data; } }, { diff --git a/Netdisco/share/views/ajax/report/portssid.tt b/Netdisco/share/views/ajax/report/portssid.tt index 23e5e9e8..f7f1a6d2 100644 --- a/Netdisco/share/views/ajax/report/portssid.tt +++ b/Netdisco/share/views/ajax/report/portssid.tt @@ -33,7 +33,7 @@ $(document).ready(function() { { "data": 'ip', "render": function(data, type, row, meta) { - return '' + he.encode(row.device.dns || row.device.name || row.ip) + '(' + he.encode(row.port.port) + ')'; + return '' + he.encode(row.device.dns || row.device.name || row.ip) + '(' + he.encode(row.port.port) + ')'; } }, { "data": 'broadcast', diff --git a/Netdisco/share/views/ajax/report/portutilization.tt b/Netdisco/share/views/ajax/report/portutilization.tt index cb1ec9d7..9b87c1c2 100644 --- a/Netdisco/share/views/ajax/report/portutilization.tt +++ b/Netdisco/share/views/ajax/report/portutilization.tt @@ -19,7 +19,7 @@ $(document).ready(function() { { "data": 'ip', "render": function(data, type, row, meta) { - return '' + he.encode(row.dns || row.ip) + ''; + return '' + he.encode(row.dns || row.ip) + ''; } }, { "data": 'port_count', diff --git a/Netdisco/share/views/ajax/search/node_by_ip.tt b/Netdisco/share/views/ajax/search/node_by_ip.tt index e91df02d..f8943214 100644 --- a/Netdisco/share/views/ajax/search/node_by_ip.tt +++ b/Netdisco/share/views/ajax/search/node_by_ip.tt @@ -105,7 +105,7 @@ Switch Port + href="[% uri_for('/device/ports') %]&q=[% node.switch | uri %]&f=[% node.port | uri %]&c_nodes=on&c_neighbors=on"> [% node.switch | html_entity %] - [% node.port | html_entity %] [% ' ' IF NOT node.active %] [% IF node.device.dns AND node.device_port AND node.device_port.name %] diff --git a/Netdisco/share/views/ajax/search/node_by_mac.tt b/Netdisco/share/views/ajax/search/node_by_mac.tt index b54a24cd..cd51cdf7 100644 --- a/Netdisco/share/views/ajax/search/node_by_mac.tt +++ b/Netdisco/share/views/ajax/search/node_by_mac.tt @@ -45,7 +45,7 @@ Switch Port - + [% node.switch | html_entity %] - [% node.port | html_entity %] [% '  ' IF NOT node.active %] [% IF node.device.dns AND node.device_port AND node.device_port.name %] @@ -69,7 +69,7 @@ Switch Port - + [% port.ip | html_entity %] - [% port.descr | html_entity %] [% IF port.device.dns AND port.name %] ([% port.device.dns | html_entity %] - [% port.name | html_entity %]) diff --git a/Netdisco/share/views/ajax/search/port.tt b/Netdisco/share/views/ajax/search/port.tt index 4380c920..b23936b1 100644 --- a/Netdisco/share/views/ajax/search/port.tt +++ b/Netdisco/share/views/ajax/search/port.tt @@ -26,7 +26,7 @@ $(document).ready(function() { if (row.device.dns || row.device.name) { ddns = ' (' + he.encode(row.device.dns || row.device.name) + ')'; } - return '' + he.encode(data) + ' [' + he.encode(row.port) + ']' + ddns; } diff --git a/Netdisco/share/views/ajax/search/vlan.tt b/Netdisco/share/views/ajax/search/vlan.tt index aa75ce85..02bc6c5f 100644 --- a/Netdisco/share/views/ajax/search/vlan.tt +++ b/Netdisco/share/views/ajax/search/vlan.tt @@ -19,32 +19,32 @@ $(document).ready(function() { "columns": [{ "data": 'vlans.vlan', "render": function(data, type, row, meta) { - return '' + data + ''; + return '' + data + ''; } }, { "data": 'ip', "render": function(data, type, row, meta) { - return '' + he.encode(row.dns || row.ip) + ''; + return '' + he.encode(row.dns || row.ip) + ''; } }, { "data": 'vlans.description', "render": function(data, type, row, meta) { - return '' + he.encode(data || '') + ''; + return '' + he.encode(data || '') + ''; } }, { "data": 'model', "render": function(data, type, row, meta) { - return '' + he.encode(data || '') + ''; + return '' + he.encode(data || '') + ''; } }, { "data": 'os', "render": function(data, type, row, meta) { - return '' + he.encode(data || '') + ''; + return '' + he.encode(data || '') + ''; } }, { "data": 'vendor', "render": function(data, type, row, meta) { - return '' + he.encode(data || '') + ''; + return '' + he.encode(data || '') + ''; } } ], diff --git a/Netdisco/share/views/report.tt b/Netdisco/share/views/report.tt index a08d2c9a..ea7492d8 100644 --- a/Netdisco/share/views/report.tt +++ b/Netdisco/share/views/report.tt @@ -31,9 +31,9 @@ href="#[% report.tag %]_pane">[% report.label %] [% IF report.tag == 'portlog' %] - [% params.q %] + [% params.q %] - - [% params.f %] + [% params.f %] [% ELSIF report.provides_csv %]