refactor device ports sidebar params handling

This commit is contained in:
Oliver Gorwits
2017-12-10 11:47:51 +00:00
parent 9e91431411
commit f8cee4cff6
6 changed files with 98 additions and 161 deletions

View File

@@ -87,23 +87,56 @@ web_plugins:
extra_web_plugins: []
sidebar_defaults:
search_node:
stamps: checked
deviceports: checked
show_vendor: null
archived: null
partial: null
age_invert: null
daterange: null
mac_format: IEEE
stamps: {default: checked }
deviceports: {default: checked }
show_vendor: {default: null }
archived: {default: null }
partial: {default: null }
age_invert: {default: null }
daterange: {default: null }
mac_format: {default: IEEE }
search_port:
partial: null
uplink: null
ethernet: checked
partial: {default: null }
uplink: {default: null }
ethernet: {default: checked }
search_device:
matchall: checked
matchall: {default: checked }
device_ports:
c_admin: { label: 'Port Controls', default: null, idx: 0 }
c_port: { label: 'Port', default: checked, idx: 1 }
c_descr: { label: 'Description', default: null, idx: 2 }
c_comment: { label: 'Last Comment', default: null, idx: 3 }
c_type: { label: 'Type', default: null, idx: 4 }
c_duplex: { label: 'Duplex', default: null, idx: 5 }
c_lastchange: { label: 'Last Change', default: null, idx: 6 }
c_name: { label: 'Name', default: checked, idx: 7 }
c_speed: { label: 'Speed', default: null, idx: 8 }
c_mac: { label: 'Port MAC', default: null, idx: 9 }
c_mtu: { label: 'MTU', default: null, idx: 10 }
c_pvid: { label: 'Native VLAN', default: checked, idx: 11 }
c_vmember: { label: 'VLAN Membership', default: checked, idx: 12 }
c_power: { label: 'PoE', default: null, idx: 13 }
c_ssid: { label: 'SSID', default: null, idx: 14 }
c_nodes: { label: 'Connected Nodes', default: null, idx: 15 }
c_neighbors: { label: 'Connected Devices', default: checked, idx: 16 }
c_stp: { label: 'Spanning Tree', default: null, idx: 17 }
c_up: { label: 'Status', default: null, idx: 18 }
n_age: { label: 'Age Stamp', default: null, idx: 0 }
n_ip4: { label: 'IPv4 Addresses', default: checked, idx: 1 }
n_ip6: { label: 'IPv6 Addresses', default: checked, idx: 2 }
n_netbios: { label: 'NetBIOS Name', default: checked, idx: 3 }
n_ssid: { label: 'SSID', default: checked, idx: 4 }
n_vendor: { label: 'Vendor', default: null, idx: 5 }
n_archived: { label: 'Archived Data', default: null, idx: 6 }
age_num: { default: 3 }
age_unit: { default: months }
mac_format: { default: IEEE }
report_moduleinventory:
fruonly: checked
matchall: checked
fruonly: {default: checked }
matchall: {default: checked }
device_port_col_idx_left: 0
device_port_col_idx_mid: 2
device_port_col_idx_right: -1
jobqueue_refresh: 10
safe_password_store: true
reports: []

View File

@@ -96,15 +96,13 @@
</span>
[% END %]
[% END %]
<a class="nd_this-port-only nd_port-only-first" href="[% uri_for('/device',
self_options) %]&q=[% params.q | uri %]&f=[% row.port | uri %]&prefer=port">
<a class="nd_this-port-only nd_port-only-first" href="[% device_ports %]&q=[% params.q | uri %]&f=[% row.port | uri %]&prefer=port">
[% IF row.is_master %]
<small><i class="icon-group muted"></i></small>&nbsp;
[% END %]
[% row.port | html_entity %]</a>
[% IF row.slave_of %]<br/>
<a class="nd_this-port-only" href="[% uri_for('/device',
self_options) %]&q=[% params.q | uri %]&f=[% row.slave_of | uri %]&prefer=port">
<a class="nd_this-port-only" href="[% device_ports %]&q=[% params.q | uri %]&f=[% row.slave_of | uri %]&prefer=port">
[% row.slave_of | html_entity %]</a>
[% END %]
</td>
@@ -268,11 +266,11 @@
[% ELSIF row.remote_type AND row.remote_type.match('^AP:\s') %]
<i class="icon-signal"></i>&nbsp;
[% END %]
<a href="[% uri_for('/device', self_options) %]&q=[% row.get_column('neighbor_ip') | uri %]">
<a href="[% device_ports %]&q=[% row.get_column('neighbor_ip') | uri %]">
[% row.get_column('neighbor_dns').remove(settings.domain_suffix) || row.get_column('neighbor_ip') | html_entity %]</a>
[% IF row.remote_port %]
-
<a href="[% uri_for('/device', self_options) %]&q=[% row.get_column('neighbor_ip') | uri %]&f=[% row.remote_port | uri %]&prefer=port">
<a href="[% device_ports %]&q=[% row.get_column('neighbor_ip') | uri %]&f=[% row.remote_port | uri %]&prefer=port">
[% row.remote_port | html_entity %]</a>
[% END %]
<br/>

View File

@@ -94,13 +94,13 @@
[% 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 });
// 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&' +

View File

@@ -15,7 +15,7 @@
<!-- <script type="text/javascript" src="http://code.jquery.com/jquery-migrate-1.1.1.js"></script> -->
<script type="text/javascript" src="[% uri_base %]/javascripts/jquery-ui.custom.min.js"></script>
<script type="text/javascript" src="[% uri_base %]/javascripts/jquery-history.js"></script>
<script type="text/javascript" src="[% uri_base %]/javascripts/jquery.cookie.js"></script>
<!-- <script type="text/javascript" src="[% uri_base %]/javascripts/jquery.cookie.js"></script> -->
<script type="text/javascript" src="[% uri_base %]/javascripts/jquery-deserialize.js"></script>
<script type="text/javascript" src="[% uri_base %]/javascripts/bootstrap.min.js"></script>
<script type="text/javascript" src="[% uri_base %]/javascripts/underscore.min.js"></script>