From d704a04760963a15c0f87f1acd6cad67c1c8bd08 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Tue, 10 Jan 2012 20:37:30 +0000 Subject: [PATCH] could the ports sidebar be finished? --- Netdisco/lib/Netdisco/Web.pm | 74 ++++++++++-------- Netdisco/public/css/style.css | 5 ++ Netdisco/views/ajax/search/node_by_ip.tt | 2 +- Netdisco/views/ajax/search/node_by_mac.tt | 4 +- Netdisco/views/ajax/search/port.tt | 2 +- Netdisco/views/ajax/search/vlan.tt | 12 +-- Netdisco/views/inc/device/ports.tt | 93 +++++++++++++++-------- Netdisco/views/inc/js/device.js | 24 +++++- 8 files changed, 142 insertions(+), 74 deletions(-) diff --git a/Netdisco/lib/Netdisco/Web.pm b/Netdisco/lib/Netdisco/Web.pm index 87fcc4c5..e7fe36a4 100644 --- a/Netdisco/lib/Netdisco/Web.pm +++ b/Netdisco/lib/Netdisco/Web.pm @@ -24,16 +24,54 @@ hook 'before' => sub { # make hash lookups of query lists foreach my $opt (qw/model vendor os_ver/) { - my $p = (ref '' eq ref param($opt) ? [param($opt)] : param($opt)); + my $p = (ref [] eq ref param($opt) ? param($opt) : (param($opt) ? param($opt) : [])); var("${opt}_lkp" => { map { $_ => 1 } @$p }); } + # list of port detail columns + var('port_columns' => [ + { name => 'c_port', label => 'Port', default => 'on' }, + { name => 'c_descr', label => 'Description', default => '' }, + { name => 'c_type', label => 'Type', default => '' }, + { name => 'c_duplex', label => 'Duplex', default => 'on' }, + { name => 'c_lastchange', label => 'Last Change', default => '' }, + { name => 'c_name', label => 'Name', default => 'on' }, + { name => 'c_speed', label => 'Speed', default => 'on' }, + { name => 'c_mac', label => 'Port MAC', default => '' }, + { name => 'c_mtu', label => 'MTU', default => '' }, + { name => 'c_vlan', label => 'Native VLAN', default => 'on' }, + { name => 'c_vmember', label => 'VLAN Membership', default => 'on' }, + { name => 'c_connected', label => 'Connected Devices', default => '' }, + { name => 'c_stp', label => 'Spanning Tree', default => '' }, + { name => 'c_up', label => 'Status', default => '' }, + ]); + + # view settings for port connected devices + var('connected_properties' => [ + { name => 'n_age', label => 'Age Stamp', default => '' }, + { name => 'n_ip', label => 'IP Address', default => 'on' }, + { name => 'n_archived', label => 'Archived Data', default => '' }, + ]); + # set up default search options for each type - if (not param('tab') or param('tab') ne 'node') { - params->{'stamps'} = 'checked'; - } - if (not param('tab') or param('tab') ne 'device') { - params->{'matchall'} = 'checked'; + if (request->path =~ m{^/device}) { + if (not param('tab') or param('tab') ne 'ports' or scalar keys %{params()} < 4) { + foreach my $col (@{ var('port_columns') }) { + params->{$col->{name}} = 'checked' if $col->{default} eq 'on'; + } + foreach my $col (@{ var('connected_properties') }) { + params->{$col->{name}} = 'checked' if $col->{default} eq 'on'; + } + params->{'age_num'} = 3; + params->{'age_unit'} = 'months'; + } + } elsif (request->path =~ m{^/search}) { + if (not param('tab') or param('tab') ne 'node') { + params->{'stamps'} = 'checked'; + } + if (not param('tab') or param('tab') ne 'device') { + params->{'matchall'} = 'checked'; + } } # set up query string defaults for hyperlinks to templates with forms @@ -76,30 +114,6 @@ get '/device' => sub { return; } - # list of columns - var('port_columns' => [ - { name => 'port', label => 'Port' }, - { name => 'description', label => 'Description' }, - { name => 'type', label => 'Type' }, - { name => 'duplex', label => 'Duplex' }, - { name => 'lastchange', label => 'Last Change' }, - { name => 'name', label => 'Name' }, - { name => 'speed', label => 'Speed' }, - { name => 'mac', label => 'Port Mac' }, - { name => 'mtu', label => 'MTU' }, - { name => 'native', label => 'Native VLAN' }, - { name => 'vlan', label => 'VLAN Membership' }, - { name => 'connected', label => 'Connected Devices' }, - { name => 'stp', label => 'Spanning Tree' }, - { name => 'status', label => 'Status' }, - ]); - - # details for connected devices - var('connected_properties' => [ - { name => 'age', label => 'Age Stamp' }, - { name => 'ip', label => 'IP Address' }, - ]); - # list of tabs var('tabs' => [ { id => 'details', label => 'Details' }, diff --git a/Netdisco/public/css/style.css b/Netdisco/public/css/style.css index 9499e4b0..fdc0f391 100644 --- a/Netdisco/public/css/style.css +++ b/Netdisco/public/css/style.css @@ -132,3 +132,8 @@ form .clearfix.success input { border-right: 7px solid transparent; border-top: 8px solid #F89406; } + +/* nudge the port name/vlan filter over a little */ +.nd_port_query { + margin-left: -2px !important; +} diff --git a/Netdisco/views/ajax/search/node_by_ip.tt b/Netdisco/views/ajax/search/node_by_ip.tt index 8c2b1c27..2f27e542 100644 --- a/Netdisco/views/ajax/search/node_by_ip.tt +++ b/Netdisco/views/ajax/search/node_by_ip.tt @@ -38,7 +38,7 @@   [% END %] Switch Port - [% node.switch %] [ [% node.port %] ] + [% node.switch %] [ [% node.port %] ] [% ' (' _ node.device.dns.remove(settings.domain_suffix) _ ')' IF node.device.dns %] [% ' a' IF NOT node.active %] diff --git a/Netdisco/views/ajax/search/node_by_mac.tt b/Netdisco/views/ajax/search/node_by_mac.tt index 1df74fda..8f6ab594 100644 --- a/Netdisco/views/ajax/search/node_by_mac.tt +++ b/Netdisco/views/ajax/search/node_by_mac.tt @@ -53,7 +53,7 @@   [% END %] Switch Port - [% node.switch %] [ [% node.port %] ] + [% node.switch %] [ [% node.port %] ] [% ' (' _ node.device.dns.remove(settings.domain_suffix) _ ')' IF node.device.dns %] [% ' a' IF NOT node.active %] @@ -70,7 +70,7 @@   [% END %] Switch Port - [% port.ip %] [ [% port.port %] ] + [% port.ip %] [ [% port.port %] ] [% ' (' _ port.device.dns.remove(settings.domain_suffix) _ ')' IF port.device.dns %] [% IF params.stamps %] diff --git a/Netdisco/views/ajax/search/port.tt b/Netdisco/views/ajax/search/port.tt index 7c80c8f6..e8a7f9c8 100644 --- a/Netdisco/views/ajax/search/port.tt +++ b/Netdisco/views/ajax/search/port.tt @@ -11,7 +11,7 @@ [% WHILE (row = results.next) %] [% row.name %] - [% row.ip %] [ [% row.port %] ] + [% row.ip %] [ [% row.port %] ] [% ' (' _ row.device.dns.remove(settings.domain_suffix) _ ')' IF row.device.dns %] [% row.descr %] diff --git a/Netdisco/views/ajax/search/vlan.tt b/Netdisco/views/ajax/search/vlan.tt index 581883ee..cddf3e76 100644 --- a/Netdisco/views/ajax/search/vlan.tt +++ b/Netdisco/views/ajax/search/vlan.tt @@ -13,17 +13,17 @@ [% WHILE (row = results.next) %] [% row.vlan.vlan %] + href="/device?tab=ports&ip=[% row.ip %]&q=[% row.vlan.vlan %]">[% row.vlan.vlan %] [% row.dns %] + href="/device?tab=ports&ip=[% row.ip %]&q=[% row.vlan.vlan %]">[% row.dns %] [% row.vlan.description %] + href="/device?tab=ports&ip=[% row.ip %]&q=[% row.vlan.vlan %]">[% row.vlan.description %] [% row.model %] + href="/device?tab=ports&ip=[% row.ip %]&q=[% row.vlan.vlan %]">[% row.model %] [% row.os %] + href="/device?tab=ports&ip=[% row.ip %]&q=[% row.vlan.vlan %]">[% row.os %] [% row.vendor %] + href="/device?tab=ports&ip=[% row.ip %]&q=[% row.vlan.vlan %]">[% row.vendor %] [% END %] diff --git a/Netdisco/views/inc/device/ports.tt b/Netdisco/views/inc/device/ports.tt index 7d566e90..56d53bfd 100644 --- a/Netdisco/views/inc/device/ports.tt +++ b/Netdisco/views/inc/device/ports.tt @@ -2,7 +2,37 @@
- +
+ +
+
+ +
    +
  • + d  Admin Disabled +
  • +
  • + l  Link Down +
  • +
  • + f  Port Free (Down) +
  • +
  • + b  Blocking +
  • +
  • + p  IP Phone +
  • +
  • + n  Neighbor Inacessible +
  • +
  • + a  Archived Data +
  • +
+
@@ -10,7 +40,7 @@ [% FOREACH item IN vars.port_columns %]
  • @@ -18,6 +48,36 @@
    +
    + +
    +
      +
    • + +
    • +

      +
    • + + + + +
    • +
    +
    +
    @@ -25,7 +85,7 @@ [% FOREACH item IN vars.connected_properties %]
  • @@ -33,33 +93,6 @@
    -
    - - - - - -
    -
    -
    - - -