[#108] Port Bounce port control feature (down and up in succession)
This commit is contained in:
		| @@ -1,5 +1,9 @@ | ||||
| 2.028014 | ||||
|  | ||||
|   [ENHANCEMENTS] | ||||
|  | ||||
|   * [#108] Port Bounce port control feature (down and up in succession) | ||||
|  | ||||
|   [BUG FIXES] | ||||
|  | ||||
|   * Missing action to netdisco-do should not throw Perl error | ||||
|   | ||||
| @@ -27,7 +27,16 @@ sub set_portcontrol { | ||||
|   (my $sa = $job->subaction) =~ s/-\w+//; | ||||
|   $job->subaction($sa); | ||||
|  | ||||
|   return _set_port_generic($job, 'up_admin'); | ||||
|   if ($sa eq 'bounce') { | ||||
|       $job->subaction('down'); | ||||
|       my @stat = _set_port_generic($job, 'up_admin'); | ||||
|       return @stat if $stat[0] ne 'done'; | ||||
|       $job->subaction('up'); | ||||
|       return _set_port_generic($job, 'up_admin'); | ||||
|   } | ||||
|   else { | ||||
|       return _set_port_generic($job, 'up_admin'); | ||||
|   } | ||||
| } | ||||
|  | ||||
| sub set_vlan { | ||||
|   | ||||
| @@ -22,7 +22,7 @@ function port_control (e) { | ||||
|       device:  td.data('for-device') | ||||
|       ,port:   td.data('for-port') | ||||
|       ,field:  td.data('field') | ||||
|       ,action: td.data('action') | ||||
|       ,action: ($(e).data('action') || td.data('action')) | ||||
|       ,value:  td.text().trim() | ||||
|       ,reason: reason | ||||
|       ,log:    logmessage | ||||
| @@ -30,31 +30,35 @@ function port_control (e) { | ||||
|     ,success: function() { | ||||
|       toastr.info('Submitted change request'); | ||||
|  | ||||
|       // update all the screen furniture for port up/down control | ||||
|       if ($.trim(td.data('action')) == 'down') { | ||||
|         td.prev('td').html('<i class="icon-remove"></i>'); | ||||
|         $(e).toggleClass('icon-hand-down'); | ||||
|         $(e).toggleClass('icon-hand-up'); | ||||
|         $(e).data('tooltip').options.title = 'Click to Enable'; | ||||
|         td.data('action', 'up'); | ||||
|       } | ||||
|       else if ($.trim(td.data('action')) == 'up') { | ||||
|         td.prev('td').html('<i class="icon-refresh icon-spin"></i>'); | ||||
|         $(e).toggleClass('icon-hand-up'); | ||||
|         $(e).toggleClass('icon-hand-down'); | ||||
|         $(e).data('tooltip').options.title = 'Click to Disable'; | ||||
|         td.data('action', 'down'); | ||||
|       } | ||||
|       else if ($.trim(td.data('action')) == 'false') { | ||||
|         $(e).next('span').text(''); | ||||
|         $(e).toggleClass('nd_power-on'); | ||||
|         $(e).data('tooltip').options.title = 'Click to Enable'; | ||||
|         td.data('action', 'true'); | ||||
|       } | ||||
|       else if ($.trim(td.data('action')) == 'true') { | ||||
|         $(e).toggleClass('nd_power-on'); | ||||
|         $(e).data('tooltip').options.title = 'Click to Disable'; | ||||
|         td.data('action', 'false'); | ||||
|       // update all the screen furniture unless bouncing | ||||
|       if (! $(e).hasClass('icon-bullseye')) { | ||||
|         if ($.trim(td.data('action')) == 'down') { | ||||
|           td.prev('td').html('<i class="icon-remove"></i>'); | ||||
|           $(e).toggleClass('icon-hand-down'); | ||||
|           $(e).toggleClass('icon-hand-up'); | ||||
|           $(e).siblings('.icon-bullseye').hide(); | ||||
|           $(e).data('tooltip').options.title = 'Enable Port'; | ||||
|           td.data('action', 'up'); | ||||
|         } | ||||
|         else if ($.trim(td.data('action')) == 'up') { | ||||
|           td.prev('td').html('<i class="icon-refresh icon-spin"></i>'); | ||||
|           $(e).toggleClass('icon-hand-up'); | ||||
|           $(e).toggleClass('icon-hand-down'); | ||||
|           $(e).siblings('.icon-bullseye').show(); | ||||
|           $(e).data('tooltip').options.title = 'Disable Port'; | ||||
|           td.data('action', 'down'); | ||||
|         } | ||||
|         else if ($.trim(td.data('action')) == 'false') { | ||||
|           $(e).next('span').text(''); | ||||
|           $(e).toggleClass('nd_power-on'); | ||||
|           $(e).data('tooltip').options.title = 'Enable Power'; | ||||
|           td.data('action', 'true'); | ||||
|         } | ||||
|         else if ($.trim(td.data('action')) == 'true') { | ||||
|           $(e).toggleClass('nd_power-on'); | ||||
|           $(e).data('tooltip').options.title = 'Disable Power'; | ||||
|           td.data('action', 'false'); | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|     ,error: function() { | ||||
| @@ -118,7 +122,7 @@ $(document).ready(function() { | ||||
|   }); | ||||
|  | ||||
|   // activity for port up/down control, power enable/disable control | ||||
|   $('#ports_pane').on('click', '.icon-hand-up,.icon-hand-down,.nd_power-icon', function() { | ||||
|   $('#ports_pane').on('click', '.icon-hand-up,.icon-hand-down,.nd_power-icon,.icon-bullseye', function() { | ||||
|     var clicked = this; // create a closure | ||||
|     $('#nd_portlog').one('hidden', function() { | ||||
|       port_control(clicked); // save | ||||
|   | ||||
| @@ -62,16 +62,26 @@ | ||||
|       <td nowrap class="nd_editable-cell" data-action="down" | ||||
|         data-order="[% row.port | html_entity %]" data-filter="[% row.port | html_entity %]" | ||||
|         data-field="c_port" data-for-device="[% device.ip | html_entity %]" data-for-port="[% row.port | html_entity %]"> | ||||
|         <i class="icon-hand-down nd_hand-icon" | ||||
|           rel="tooltip" data-placement="top" data-offset="3" | ||||
|           data-animation="" data-title="Click to Disable"></i> | ||||
|         <span class="nd_hand-icon"> | ||||
|           <i class="icon-bullseye" data-action="bounce" | ||||
|             rel="tooltip" data-placement="top" data-offset="3" | ||||
|             data-animation="" data-title="Bounce Port"></i> | ||||
|           <i class="icon-hand-down" | ||||
|             rel="tooltip" data-placement="top" data-offset="3" | ||||
|             data-animation="" data-title="Disable Port"></i> | ||||
|         </span> | ||||
|       [% ELSE %] | ||||
|       <td nowrap class="nd_editable-cell" data-action="up" | ||||
|         data-order="[% row.port | html_entity %]" data-filter="[% row.port | html_entity %]" | ||||
|         data-field="c_port" data-for-device="[% device.ip | html_entity %]" data-for-port="[% row.port | html_entity %]"> | ||||
|         <i class="icon-hand-up nd_hand-icon" | ||||
|           rel="tooltip" data-placement="top" data-offset="3" | ||||
|           data-animation="" data-title="Click to Enable"></i> | ||||
|         <span class="nd_hand-icon"> | ||||
|           <i class="icon-bullseye" data-action="bounce" style="display: none" | ||||
|             rel="tooltip" data-placement="top" data-offset="3" | ||||
|             data-animation="" data-title="Bounce Port"></i> | ||||
|           <i class="icon-hand-up" | ||||
|             rel="tooltip" data-placement="top" data-offset="3" | ||||
|             data-animation="" data-title="Enable Port"></i> | ||||
|         </span> | ||||
|       [% END %] | ||||
|         <a class="nd_log-icon" | ||||
|           href="[% uri_for('/report/portlog') %]?q=[% device.ip | uri %]&f=[% row.port | uri %]"> | ||||
| @@ -208,7 +218,7 @@ | ||||
|  | ||||
|                 <i class="icon-off nd_power-icon nd_power-on" | ||||
|                   rel="tooltip" data-placement="top" data-offset="3" | ||||
|                   data-animation="" data-title="Click to Disable"></i> | ||||
|                   data-animation="" data-title="Disable Power"></i> | ||||
|             [% ELSE %] | ||||
|               <td nowrap> | ||||
|                 <i class="icon-off nd_power-on"></i> | ||||
| @@ -228,7 +238,7 @@ | ||||
|  | ||||
|                 <i class="icon-off nd_power-icon" | ||||
|                   rel="tooltip" data-placement="top" data-offset="3" | ||||
|                   data-animation="" data-title="Click to Enable"></i> | ||||
|                   data-animation="" data-title="Enable Power"></i> | ||||
|             [% ELSE %] | ||||
|               <td> | ||||
|                 <i class="icon-off"></i> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user