Files
netdisco/Netdisco/share/public/javascripts/netdisco_portcontrol.js
Oliver Gorwits 642546fd24 LAG support.
Also, archive disappeared nodes from device after macsuck.

Squashed commit of the following:

commit 6d16cddaab
Merge: 37d9bda 3fdf780
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sun Jan 19 15:48:41 2014 +0000

    Merge branch 'master' of ssh://git.code.sf.net/p/netdisco/netdisco-ng into og-agg

commit 37d9bda2bb
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jan 13 18:50:22 2014 +0000

    release 2.021000_004

commit 3939a2a51c
Merge: cf23636 571d57d
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jan 13 18:45:14 2014 +0000

    Merge branch 'og-agg' of ssh://olly_g@git.code.sf.net/p/netdisco/netdisco-ng into og-agg

commit cf23636ddf
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jan 13 18:43:59 2014 +0000

    archive disappeared nodes from device - really important!

commit 571d57dcc7
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jan 13 18:20:51 2014 +0000

    release 2.021000_003

commit 444bc1e81d
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jan 13 17:51:54 2014 +0000

    protect sprintf from undefined remote_type

commit 5b875c4641
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jan 13 17:49:40 2014 +0000

    tidy connected device+node layout

commit c09dddb7d1
Merge: 4f5501c 95fc6b1
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jan 13 17:46:39 2014 +0000

    Merge branch 'og-agg' of ssh://olly_g@git.code.sf.net/p/netdisco/netdisco-ng into og-agg

commit 4f5501c613
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jan 13 17:46:23 2014 +0000

    allow sanity checks on lag member before moving node

commit 95fc6b18dc
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jan 13 14:02:19 2014 +0000

    release 2.021000_002

commit 8b809c445f
Merge: 04d486e fe3e8e3
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jan 13 13:58:31 2014 +0000

    Merge branch 'og-agg' of ssh://git.code.sf.net/p/netdisco/netdisco-ng into og-agg

commit fe3e8e3ef2
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jan 13 13:57:31 2014 +0000

    do not set master neigh if master is a slave

commit 04d486e433
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jan 13 13:38:45 2014 +0000

    display remote ip if only remote ip

commit 14f9eb01ad
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jan 13 13:35:54 2014 +0000

    show all members of lag when searching for lag master

commit 5b2a0a0a4b
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jan 13 13:35:16 2014 +0000

    fix copy of remote master to local master remote_port

commit 86a9854f39
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jan 13 10:00:13 2014 +0000

    show both link and device type icons

commit 88510552e5
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jan 13 09:57:29 2014 +0000

    hide neighbor device ID and add sidebar option to show

commit 29da3097cb
Merge: 8bca30d 9fe92fb
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jan 13 09:04:15 2014 +0000

    Merge branch 'og-agg' of ssh://git.code.sf.net/p/netdisco/netdisco-ng into og-agg

commit 9fe92fb5e8
Merge: 6620a03 5557811
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jan 13 09:03:02 2014 +0000

    Merge branch 'og-agg' of ssh://olly_g@git.code.sf.net/p/netdisco/netdisco-ng into og-agg

commit 6620a03686
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jan 13 08:56:13 2014 +0000

    also store master neighbor port

commit 8bca30d085
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jan 13 00:41:46 2014 +0000

    release 2.021000_001

commit 5557811aeb
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon Jan 13 00:38:18 2014 +0000

    fix icon placement in editable device port cells

commit 25292e1ce8
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sun Jan 12 22:20:08 2014 +0000

    fix name of class

commit 99ce56d794
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sun Jan 12 22:13:53 2014 +0000

    remove brackets from lag name

commit 27aa80ed93
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sun Jan 12 22:12:06 2014 +0000

    rename link agg legend

commit 84ed4c5008
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sun Jan 12 22:11:15 2014 +0000

    move lag member icon into port icon column

commit 67c9c783ec
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sun Jan 12 21:58:11 2014 +0000

    fix Cisco stack port ignore

commit 4531c61246
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sun Jan 12 21:51:41 2014 +0000

    move nodes to lag master port

commit ffc6b9c315
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sun Jan 12 20:45:58 2014 +0000

    use group icon for slave and master

commit 68fd345e37
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sun Jan 12 20:34:01 2014 +0000

    indicate aggregate master

commit 79c69f5a0f
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sun Jan 12 19:14:48 2014 +0000

    show aggreate parent in device ports

commit 3a4beed2f1
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sun Jan 12 18:46:25 2014 +0000

    store aggregate port into db

commit fd7bb0cd62
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sun Jan 12 17:49:39 2014 +0000

    add device_port cols for aggregate links data
2014-01-19 15:51:47 +00:00

181 lines
5.6 KiB
JavaScript

// to tell whether bootstrap's modal had Submit button pressed :(
var nd_save_ok = false;
// user clicked or asked for port changes to be submitted via ajax
function port_control (e) {
var td = $(e).closest('td'),
reason = $('#nd_portlog-reason').val(),
logmessage = $('#nd_portlog-log').val();
$('#nd_portlog-log').val('');
if (nd_save_ok == false) {
td.find('.nd_editable-cell-content').text(td.data('default'));
td.blur();
return;
}
nd_save_ok = false;
$.ajax({
type: 'POST'
,url: uri_base + '/ajax/portcontrol'
,data: {
device: td.data('for-device')
,port: td.data('for-port')
,field: td.data('field')
,action: td.data('action')
,value: td.text().trim()
,reason: reason
,log: logmessage
}
,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');
}
}
,error: function() {
toastr.error('Failed to submit change request');
td.find('.nd_editable-cell-content').text(td.data('default'));
td.blur();
}
});
}
// on load, establish global delegations for now and future
$(document).ready(function() {
// for growl-like functionality, check for notifications periodically
if (nd_check_userlog) {
(function worker() {
$.ajax({
url: uri_base + '/ajax/userlog'
,success: function(data) {
for (var i = 0; i < data['error'].length; i++) {
toastr.error(data['error'][i], 'Failed Job:');
}
for (var i = 0; i < data['done'].length; i++) {
toastr.success(data['done'][i], 'Successful Job:');
}
// Schedule next request when the current one's complete
setTimeout(worker, 5000);
}
,error: function() {
// after one failure, don't try again
toastr.warning('Unable to retrieve change request log')
}
});
})();
}
// toggle visibility of port up/down and edit controls
$('.tab-content').on('mouseenter', '.nd_editable-cell', function() {
$(this).children('.nd_hand-icon').show();
$(this).children('.nd_log-icon').css('visibility', 'visible');
if (! $(this).is(':focus')) {
$(this).children('.nd_edit-icon').show(); // ports
$(this).siblings('td').find('.nd_device-details-edit').show(); // details
}
});
$('.tab-content').on('mouseleave', '.nd_editable-cell', function() {
$(this).children('.nd_hand-icon').hide();
$(this).children('.nd_log-icon').css('visibility', 'hidden');
if (! $(this).is(':focus')) {
$(this).children('.nd_edit-icon').hide(); // ports
$(this).siblings('td').find('.nd_device-details-edit').hide(); // details
}
});
$('.tab-content').on('focus', '[contenteditable=true]', function() {
$(this).children('.nd_edit-icon').hide(); // ports
$(this).siblings('td').find('.nd_device-details-edit').hide(); // details
});
// to tell whether bootstrap's modal had Submit button pressed :(
$('#ports_pane').on('click', '#nd_portlog-submit', function() {
nd_save_ok = true;
});
// activity for port up/down control, power enable/disable control
$('#ports_pane').on('click', '.icon-hand-up,.icon-hand-down,.nd_power-icon', function() {
var clicked = this; // create a closure
$('#nd_portlog').one('hidden', function() {
port_control(clicked); // save
});
if ($(this).hasClass('icon-hand-up')) {
$('#nd_portlog-reason').val('resolved');
}
else {
$('#nd_portlog-reason').val('other');
}
$('#nd_portlog').modal('show');
});
// has cell content changed?
var dirty = false;
// activity for contenteditable control
$('.tab-content').on('keydown', '[contenteditable=true]', function(event) {
var cell = this,
td = $(cell).closest('td'),
esc = event.which == 27,
nl = event.which == 13;
if (esc) {
$(cell).blur();
}
else if (nl) {
event.preventDefault();
if (td.data('field') == 'c_pvid') {
$('#nd_portlog').one('hidden', function() {
port_control(cell); // save
});
$('#nd_portlog').modal('show');
}
else {
// no confirm for port descr change
nd_save_ok = true;
port_control(cell); // save
}
dirty = false;
$(cell).blur();
}
else {
dirty = true;
}
});
// activity for contenteditable control
$('.tab-content').on('blur', '[contenteditable=true]', function(event) {
if (dirty) {
document.execCommand('undo');
dirty = false;
$(this).blur();
}
});
});