diff --git a/lib/App/Netdisco/DB/Result/DevicePort.pm b/lib/App/Netdisco/DB/Result/DevicePort.pm index e12f6290..457ef6a2 100644 --- a/lib/App/Netdisco/DB/Result/DevicePort.pm +++ b/lib/App/Netdisco/DB/Result/DevicePort.pm @@ -175,8 +175,7 @@ device port. __PACKAGE__->might_have( properties => 'App::Netdisco::DB::Result::DevicePortProperties', { 'foreign.ip' => 'self.ip', 'foreign.port' => 'self.port', - }, { join_type => 'LEFT OUTER' } -); +}); =head2 ssid @@ -308,6 +307,15 @@ ID assigned to untagged frames received on the port). sub native { return (shift)->vlan } +=head2 error_disable_cause + +Returns the textual reason given by the device if the port is in an error +state, or else `undef` if the port is not in an error state. + +=cut + +sub error_disable_cause { return (shift)->get_column('properties_error_disable_cause') } + =head2 vlan_count Returns the number of VLANs active on this device port. Enable this column by diff --git a/lib/App/Netdisco/DB/ResultSet/DevicePort.pm b/lib/App/Netdisco/DB/ResultSet/DevicePort.pm index 84b619c6..ff270ba8 100644 --- a/lib/App/Netdisco/DB/ResultSet/DevicePort.pm +++ b/lib/App/Netdisco/DB/ResultSet/DevicePort.pm @@ -104,6 +104,32 @@ sub only_free_ports { ); } +=head2 with_properties + +This is a modifier for any C which +will add the following additional synthesized columns to the result set: + +=over 4 + +=item error_disable_cause + +=back + +=cut + +sub with_properties { + my ($rs, $cond, $attrs) = @_; + + return $rs + ->search_rs($cond, $attrs) + ->search({}, + { + '+select' => ['properties.error_disable_cause'], + '+as' => ['properties_error_disable_cause'], + join => 'properties', + }); +} + =head2 with_vlan_count This is a modifier for any C (including the helpers below) which diff --git a/lib/App/Netdisco/Web/Plugin/Device/Ports.pm b/lib/App/Netdisco/Web/Plugin/Device/Ports.pm index 0e9f66b8..2e0619fa 100644 --- a/lib/App/Netdisco/Web/Plugin/Device/Ports.pm +++ b/lib/App/Netdisco/Web/Plugin/Device/Ports.pm @@ -18,7 +18,7 @@ get '/ajax/content/device/ports' => require_login sub { my $device = schema('netdisco')->resultset('Device') ->search_for_device($q) or send_error('Bad device', 400); - my $set = $device->ports; + my $set = $device->ports->with_properties; # refine by ports if requested my $f = param('f'); diff --git a/share/views/ajax/device/ports.tt b/share/views/ajax/device/ports.tt index 7aa67ab3..7312cd3a 100644 --- a/share/views/ajax/device/ports.tt +++ b/share/views/ajax/device/ports.tt @@ -25,7 +25,9 @@ [% IF row.up_admin != 'up' %] [% ELSIF row.up == 'up' AND row.stp == 'blocking' AND vlans.$portname.vlan_count < 2 %] - + + [% ELSIF row.error_disable_cause %] + [% ELSIF row.has_column_loaded('is_free') AND row.is_free %] [% ELSIF row.up_admin == 'up' AND (row.up != 'up' AND row.up != 'dormant') %] diff --git a/share/views/sidebar/device/ports.tt b/share/views/sidebar/device/ports.tt index e6bcb12b..fb56d353 100644 --- a/share/views/sidebar/device/ports.tt +++ b/share/views/sidebar/device/ports.tt @@ -36,7 +36,8 @@
  •   Link Down
  •   Port Free
  •   Admin Disabled
  • -
  •   Blocking
  • +
  •   Error Disabled
  • +
  •   Blocking
  •   Manual Topology
  •   Neighbor Device
  •   Neighbor Inacessible