From 03c0d4f97626b371c020345d4dcbfe2611472d00 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 22 Sep 2013 13:26:40 +0100 Subject: [PATCH 01/11] need to avoid nasty EPIPE issue --- Netdisco/Makefile.PL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Netdisco/Makefile.PL b/Netdisco/Makefile.PL index 3e2d8440..9ab197cf 100644 --- a/Netdisco/Makefile.PL +++ b/Netdisco/Makefile.PL @@ -32,7 +32,7 @@ requires 'Plack' => 1.0023; requires 'Plack::Middleware::Expires' => 0.03; requires 'Role::Tiny' => 1.002005; requires 'Socket6' => 0.23; -requires 'Starman' => 0.3008; +requires 'Starman' => 0.4008; requires 'SNMP::Info' => 3.05; requires 'SQL::Translator' => 0.11016; requires 'Template' => 2.24; From 052f3ed29a7a47159c061cb6455868642598756e Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 22 Sep 2013 13:32:31 +0100 Subject: [PATCH 02/11] must update sidebar form fields before serializing them --- Netdisco/share/views/js/common.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Netdisco/share/views/js/common.js b/Netdisco/share/views/js/common.js index 61d246f0..a75f0e7c 100644 --- a/Netdisco/share/views/js/common.js +++ b/Netdisco/share/views/js/common.js @@ -44,14 +44,14 @@ } // each sidebar search form has a hidden copy of the main navbar search - // query. when the tab query takes place, copy the navbar locally, then - // replicate to all other tabs. function copy_navbar_to_sidebar (tab) { var form = '#' + tab + '_form'; + // copy navbar value to currently active sidebar form if ($('#nq').val()) { $(form).find("input[name=q]").val( $('#nq').val() ); } + // then copy to all other inactive tab sidebars $('form').find("input[name=q]").each( function() { $(this).val( $(form).find("input[name=q]").val() ); }); @@ -63,9 +63,9 @@ [% FOREACH tab IN settings._search_tabs %] $('[% "#${tab.tag}_form" %]').submit(function (event) { var pgtitle = update_page_title('[% tab.tag %]'); - update_csv_download_link('search', '[% tab.tag %]', '[% tab.provides_csv %]'); - update_browser_history('[% tab.tag %]', pgtitle); 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 %] @@ -76,9 +76,9 @@ [% FOREACH tab IN settings._device_tabs %] $('[% "#${tab.tag}_form" %]').submit(function (event) { var pgtitle = update_page_title('[% tab.tag %]'); - update_csv_download_link('device', '[% tab.tag %]', '[% tab.provides_csv %]'); - update_browser_history('[% tab.tag %]', pgtitle); 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 From 06df98cf55baa344ad51f40933f6d3e4d8bcb832 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 22 Sep 2013 13:58:57 +0100 Subject: [PATCH 03/11] try to make clear intent of each search button --- Netdisco/share/public/css/netdisco.css | 1 + Netdisco/share/views/layouts/main.tt | 3 ++- Netdisco/share/views/sidebar/device/ports.tt | 3 ++- Netdisco/share/views/sidebar/search/device.tt | 3 ++- Netdisco/share/views/sidebar/search/node.tt | 3 ++- Netdisco/share/views/sidebar/search/port.tt | 3 ++- 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Netdisco/share/public/css/netdisco.css b/Netdisco/share/public/css/netdisco.css index d5f77577..b82e49e0 100644 --- a/Netdisco/share/public/css/netdisco.css +++ b/Netdisco/share/public/css/netdisco.css @@ -9,6 +9,7 @@ body { /* magnifying glass icon for search box */ .nd_navbar-icon { vertical-align: sub; + margin-top: 4px; cursor: pointer; } diff --git a/Netdisco/share/views/layouts/main.tt b/Netdisco/share/views/layouts/main.tt index 51b77422..208ef22d 100644 --- a/Netdisco/share/views/layouts/main.tt +++ b/Netdisco/share/views/layouts/main.tt @@ -88,7 +88,8 @@ - + [% IF user_has_role('admin') %] diff --git a/Netdisco/share/views/sidebar/device/ports.tt b/Netdisco/share/views/sidebar/device/ports.tt index 46022683..fb305029 100644 --- a/Netdisco/share/views/sidebar/device/ports.tt +++ b/Netdisco/share/views/sidebar/device/ports.tt @@ -124,4 +124,5 @@ - + diff --git a/Netdisco/share/views/sidebar/search/device.tt b/Netdisco/share/views/sidebar/search/device.tt index ae5aed96..12974662 100644 --- a/Netdisco/share/views/sidebar/search/device.tt +++ b/Netdisco/share/views/sidebar/search/device.tt @@ -77,4 +77,5 @@ Match All Options - + diff --git a/Netdisco/share/views/sidebar/search/node.tt b/Netdisco/share/views/sidebar/search/node.tt index cce60746..0d53105d 100644 --- a/Netdisco/share/views/sidebar/search/node.tt +++ b/Netdisco/share/views/sidebar/search/node.tt @@ -46,4 +46,5 @@ [% END %] - + diff --git a/Netdisco/share/views/sidebar/search/port.tt b/Netdisco/share/views/sidebar/search/port.tt index 9ea2cabb..92ef81b4 100644 --- a/Netdisco/share/views/sidebar/search/port.tt +++ b/Netdisco/share/views/sidebar/search/port.tt @@ -10,4 +10,5 @@ Partial Name - + From 3f455db8e1bb35cb6466fa7029643e8a9cfc12d1 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 22 Sep 2013 14:02:32 +0100 Subject: [PATCH 04/11] minor fix for defaults icon hover style --- Netdisco/share/public/css/netdisco.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Netdisco/share/public/css/netdisco.css b/Netdisco/share/public/css/netdisco.css index b82e49e0..7c57b780 100644 --- a/Netdisco/share/public/css/netdisco.css +++ b/Netdisco/share/public/css/netdisco.css @@ -206,7 +206,7 @@ td > form.nd_inline-form { font-weight: normal; } -#nd_csv-download:hover { +#nd_csv-download:hover, #nd_sidebar-reset-link:hover { text-decoration: none; } From 21b5f3c20c120de55e642a1c6feaac7f6ab79ffb Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 22 Sep 2013 14:08:09 +0100 Subject: [PATCH 05/11] port display legend improvements --- Netdisco/share/views/admintask.tt | 2 +- Netdisco/share/views/ajax/device/ports.tt | 1 + Netdisco/share/views/sidebar/device/ports.tt | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Netdisco/share/views/admintask.tt b/Netdisco/share/views/admintask.tt index d246e2b9..fbaf3d01 100644 --- a/Netdisco/share/views/admintask.tt +++ b/Netdisco/share/views/admintask.tt @@ -31,7 +31,7 @@ [% IF task.tag == 'jobqueue' %] - + diff --git a/Netdisco/share/views/ajax/device/ports.tt b/Netdisco/share/views/ajax/device/ports.tt index 27117abe..9f011e32 100644 --- a/Netdisco/share/views/ajax/device/ports.tt +++ b/Netdisco/share/views/ajax/device/ports.tt @@ -210,6 +210,7 @@ [% IF params.c_neighbors AND (row.remote_ip OR row.is_uplink) %] [% IF row.neighbor %] + [% row.neighbor.dns.remove(settings.domain_suffix) || row.neighbor.ip | html_entity %] diff --git a/Netdisco/share/views/sidebar/device/ports.tt b/Netdisco/share/views/sidebar/device/ports.tt index fb305029..84c0c003 100644 --- a/Netdisco/share/views/sidebar/device/ports.tt +++ b/Netdisco/share/views/sidebar/device/ports.tt @@ -29,12 +29,13 @@
  •   Port Free
  •   Admin Disabled
  •   Blocking
  • +
  •   Neighbor Device
  •   Neighbor Inacessible
  •   IP Phone
  •   Wireless Client
  •   Archived Data
  • [% IF user_has_role('port_control') %] -
  •   Click "Update View"
  • +
  •   Click "Update View"
  • [% END %] From 0481d4f731fb3961a86ee7619c7e23c5c8cf76c6 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 22 Sep 2013 14:13:29 +0100 Subject: [PATCH 06/11] make sure navbar is always set on device_search link --- Netdisco/share/views/ajax/device/addresses.tt | 2 +- Netdisco/share/views/ajax/device/details.tt | 8 ++++---- Netdisco/share/views/inventory.tt | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Netdisco/share/views/ajax/device/addresses.tt b/Netdisco/share/views/ajax/device/addresses.tt index 36231a3c..4eb5c3ea 100644 --- a/Netdisco/share/views/ajax/device/addresses.tt +++ b/Netdisco/share/views/ajax/device/addresses.tt @@ -17,7 +17,7 @@ href="[% device_ports %]&q=[% params.q | uri %]&f=[% row.port | uri %]">[% row.port | html_entity %]
    [% row.device_port.name | html_entity %] [% row.subnet | html_entity %] + href="[% search_device %]&q=[% row.subnet | uri %]&ip=[% row.subnet | uri %]">[% row.subnet | html_entity %] [% END %] diff --git a/Netdisco/share/views/ajax/device/details.tt b/Netdisco/share/views/ajax/device/details.tt index 0d52e979..21c3cfde 100644 --- a/Netdisco/share/views/ajax/device/details.tt +++ b/Netdisco/share/views/ajax/device/details.tt @@ -19,7 +19,7 @@ [% ELSE %] [% d.location | html_entity %] + href="[% search_device %]&q=[% d.location | uri %]&location=[% d.location | uri %]">[% d.location | html_entity %] [% END %] @@ -42,10 +42,10 @@ Vendor / Model [% d.vendor | html_entity %] + href="[% search_device %]&q=[% d.vendor | uri %]&vendor=[% d.vendor | uri %]">[% d.vendor | html_entity %] / [% d.model | html_entity %] + href="[% search_device %]&q=[% d.model | uri %]&model=[% d.model | uri %]">[% d.model | html_entity %] @@ -53,7 +53,7 @@ [% d.os | html_entity %] / [% d.os_ver | html_entity %] + href="[% search_device %]&q=[% d.os_ver | uri %]&os_ver=[% d.os_ver | uri %]">[% d.os_ver | html_entity %] diff --git a/Netdisco/share/views/inventory.tt b/Netdisco/share/views/inventory.tt index df7fa2c1..47cc0484 100644 --- a/Netdisco/share/views/inventory.tt +++ b/Netdisco/share/views/inventory.tt @@ -17,12 +17,12 @@ + href="[% search_device %]&q=[% platform.vendor | uri %]&vendor=[% platform.vendor | uri %]"> [% platform.vendor | html_entity %] + href="[% search_device %]&q=[% platform.model | uri %]&model=[% platform.model | uri %]"> [% platform.model | html_entity %] [% platform.get_column('count') | html_entity %] @@ -48,7 +48,7 @@ [% release.os | html_entity %] + href="[% search_device %]&q=[% release.os_ver | uri %]&os_ver=[% release.os_ver | uri %]"> [% release.os_ver | html_entity %] [% release.get_column('count') | html_entity %] From 79591e3998fab42bb6c746d11aeca761a65656e0 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 22 Sep 2013 14:33:36 +0100 Subject: [PATCH 07/11] fix bug when input field has whitespace --- Netdisco/share/views/js/common.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Netdisco/share/views/js/common.js b/Netdisco/share/views/js/common.js index a75f0e7c..d673dfe2 100644 --- a/Netdisco/share/views/js/common.js +++ b/Netdisco/share/views/js/common.js @@ -20,8 +20,8 @@ // browser function update_page_title (tab) { var pgtitle = 'Netdisco'; - if ($('#nd_device-name').text().length) { - var pgtitle = $('#nd_device-name').text() +' - '+ $('#'+ tab + '_link').text(); + if ($.trim($('#nd_device-name').text()).length) { + pgtitle = $.trim($('#nd_device-name').text()) +' - '+ $('#'+ tab + '_link').text(); } return pgtitle; } From 5f028adc47d77fd502b37dc77a1656ed0496297a Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 22 Sep 2013 14:57:51 +0100 Subject: [PATCH 08/11] fix width of sidebar fields --- Netdisco/share/public/css/netdisco.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Netdisco/share/public/css/netdisco.css b/Netdisco/share/public/css/netdisco.css index 7c57b780..97c034ac 100644 --- a/Netdisco/share/public/css/netdisco.css +++ b/Netdisco/share/public/css/netdisco.css @@ -399,7 +399,7 @@ td > form.nd_inline-form { /* fixup for prepended checkbox in sidebar */ .nd_searchcheckbox { - width: 123px; + width: 121px; padding-left: 8px; cursor: pointer; } @@ -435,7 +435,7 @@ td > form.nd_inline-form { /* placement of form field in sidebar */ .nd_side-input { margin-left: -3px; - width: 152px; + width: 151px; } /* placement of form field in sidebar */ From 230c6e3c0c5f1c42e9768712f341081b3dd132fc Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 22 Sep 2013 16:15:45 +0100 Subject: [PATCH 09/11] make strikethrough of navbar work in more cases --- Netdisco/share/public/javascripts/netdisco.js | 45 +++++++++++-------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/Netdisco/share/public/javascripts/netdisco.js b/Netdisco/share/public/javascripts/netdisco.js index 42be2719..7ac3f787 100644 --- a/Netdisco/share/public/javascripts/netdisco.js +++ b/Netdisco/share/public/javascripts/netdisco.js @@ -39,7 +39,7 @@ function do_search (event, tab) { ); return; } - if (response === "") { + if (response == "") { $(target).html( '
    No matching records.
    ' ); @@ -111,32 +111,41 @@ if (window.History && window.History.enabled) { // if any field in Search Options has content, highlight in green function device_form_state(e) { - if (e.prop('value') != "") { - e.parent(".clearfix").addClass('success'); + var with_val = $.grep(form_inputs, + function(n,i) {return($(n).prop('value') != "")}).length; + var with_text = $.grep(form_inputs.not('select'), + function(n,i) {return($(n).val() != "")}).length; - if (e.parents('#device_form').length) { - $('#nq').css('text-decoration', 'line-through'); - - if (e.attr('type') == 'text') { - $('.nd_field-copy-icon').hide(); - } - } - - var id = '#' + e.attr('name') + '_clear_btn'; - $(id).show(); - } - else { + if (e.prop('value') == "") { e.parent(".clearfix").removeClass('success'); var id = '#' + e.attr('name') + '_clear_btn'; $(id).hide(); - var num_empty = $.grep(form_inputs, - function(n,i) {return($(n).val() != "")}).length; - if (num_empty === 3) { + // if form has no field val, clear strikethough + if (with_val == 0) { $('#nq').css('text-decoration', 'none'); + } + + // for text inputs only, extra formatting + if (with_text == 0) { $('.nd_field-copy-icon').show(); } } + else { + e.parent(".clearfix").addClass('success'); + var id = '#' + e.attr('name') + '_clear_btn'; + $(id).show(); + + // if form still has any field val, set strikethough + if (e.parents('form[action="/search"]').length > 0 && with_val != 0) { + $('#nq').css('text-decoration', 'line-through'); + } + + // if we're text, hide copy icon when we get a val + if (e.attr('type') == 'text') { + $('.nd_field-copy-icon').hide(); + } + } } $(document).ready(function() { From 108e1b52016c1df60dc701f40d6cc49eb8aa25ee Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 22 Sep 2013 16:40:10 +0100 Subject: [PATCH 10/11] add invert port search option, fix wildcarding on partial --- .../App/Netdisco/Web/Plugin/Device/Ports.pm | 11 +++++--- Netdisco/share/public/css/netdisco.css | 25 +++++++++++++++++-- Netdisco/share/views/js/common.js | 4 ++- Netdisco/share/views/sidebar/device/ports.tt | 7 ++++++ 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm index 6940b8f4..0f0f04f1 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm @@ -36,10 +36,15 @@ ajax '/ajax/content/device/ports' => require_login sub { $f =~ s/\*/%/g; $f =~ s/\?/_/g; # set wilcards at param boundaries - $f =~ s/^\%*/%/; - $f =~ s/\%*$/%/; + if ($f !~ m/[%_]/) { + $f =~ s/^\%*/%/; + $f =~ s/\%*$/%/; + } # enable ILIKE op - $f = { '-ilike' => $f }; + $f = { (param('invert') ? '-not_ilike' : '-ilike') => $f }; + } + elsif (param('invert')) { + $f = { '!=' => $f }; } if ($set->search({'me.port' => $f})->count) { diff --git a/Netdisco/share/public/css/netdisco.css b/Netdisco/share/public/css/netdisco.css index 97c034ac..922fb7c2 100644 --- a/Netdisco/share/public/css/netdisco.css +++ b/Netdisco/share/public/css/netdisco.css @@ -406,8 +406,8 @@ td > form.nd_inline-form { /* fixup for prepended partial port name checkbox in sidebar */ .nd_port-partial-checkbox { - width: 136px; - padding: 0px 0px 0px 11px !important; + width: 84px; + padding: 0px 0px 0px 5px !important; cursor: pointer; } @@ -421,6 +421,27 @@ td > form.nd_inline-form { margin-bottom: 5px !important; } +/* fixup for prepended invert port name checkbox in sidebar */ +.nd_port-invert-checkbox { + width: 30px; + padding: 0px 0px 0px 5px !important; + cursor: pointer; +} + +.nd_port-invert-label { + padding: 0px !important; + /* for some reason only .add-on:first-child gets these */ + -webkit-border-radius: 4px 0 0 4px !important; + -moz-border-radius: 4px 0 0 4px !important; + border-radius: 4px 0 0 4px !important; +} + +.nd_port-invert { + margin-left: 5px !important; + margin-top: -5px; + margin-bottom: 5px !important; +} + /* fixup for prepended checkbox in sidebar */ .nd_sidebar .input-prepend { margin-left: -2px; diff --git a/Netdisco/share/views/js/common.js b/Netdisco/share/views/js/common.js index d673dfe2..6385df6d 100644 --- a/Netdisco/share/views/js/common.js +++ b/Netdisco/share/views/js/common.js @@ -93,7 +93,9 @@ // form reset icon on ports tab $('#nd_sidebar-reset-link').attr('href', '/device?tab=ports&reset=on&' + - $('#ports_form').find('input[name="q"],input[name="f"],input[name="partial"]').serialize()) + $('#ports_form') + .find('input[name="q"],input[name="f"],input[name="partial"],input[name="invert"]') + .serialize()) [% END %] do_search(event, '[% tab.tag %]'); diff --git a/Netdisco/share/views/sidebar/device/ports.tt b/Netdisco/share/views/sidebar/device/ports.tt index 84c0c003..8c9e366b 100644 --- a/Netdisco/share/views/sidebar/device/ports.tt +++ b/Netdisco/share/views/sidebar/device/ports.tt @@ -15,6 +15,13 @@ + +
    From b60fc28be60710b9b07d41eaaf22de26100b385e Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 22 Sep 2013 16:56:36 +0100 Subject: [PATCH 11/11] treat dormant interfaces as up (dialers) --- Netdisco/share/views/ajax/device/ports.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Netdisco/share/views/ajax/device/ports.tt b/Netdisco/share/views/ajax/device/ports.tt index 9f011e32..5210ac13 100644 --- a/Netdisco/share/views/ajax/device/ports.tt +++ b/Netdisco/share/views/ajax/device/ports.tt @@ -24,7 +24,7 @@ [% ELSIF row.has_column_loaded('is_free') AND row.is_free %] - [% ELSIF row.up_admin == 'up' AND row.up != 'up' %] + [% ELSIF row.up_admin == 'up' AND (row.up != 'up' AND row.up != 'dormant') %] [% ELSE %]