port up and down control now updates table details
also update tooltip for sidebar pin icon depending on state
This commit is contained in:
@@ -6,14 +6,30 @@ function port_control (e) {
|
||||
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')
|
||||
device: td.attr('data-for-device')
|
||||
,port: td.attr('data-for-port')
|
||||
,field: td.attr('data-field')
|
||||
,action: td.attr('data-action')
|
||||
,value: td.text().trim()
|
||||
}
|
||||
,success: function() {
|
||||
toastr.info('Submitted change request');
|
||||
|
||||
// update all the screen furniture for port up/down control
|
||||
if ($.trim(td.attr('data-action')) == 'down') {
|
||||
td.prev('td').html('<span class="label">S</span>');
|
||||
$(e).toggleClass('icon-hand-down');
|
||||
$(e).toggleClass('icon-hand-up');
|
||||
$(e).data('tooltip').options.title = 'Click to Enable';
|
||||
td.attr('data-action', 'up');
|
||||
}
|
||||
else if ($.trim(td.attr('data-action')) == 'up') {
|
||||
td.prev('td').html('<span class="label"><i class="icon-refresh"></i></span>');
|
||||
$(e).toggleClass('icon-hand-up');
|
||||
$(e).toggleClass('icon-hand-down');
|
||||
$(e).data('tooltip').options.title = 'Click to Disable';
|
||||
td.attr('data-action', 'down');
|
||||
}
|
||||
}
|
||||
,error: function() {
|
||||
toastr.error('Failed to submit change request');
|
||||
@@ -28,16 +44,12 @@ function port_control (e) {
|
||||
$.ajax({
|
||||
url: uri_base + '/ajax/userlog'
|
||||
,success: function(data) {
|
||||
// console.log(data);
|
||||
|
||||
for (var i = 0; i < data['error'].length; i++) {
|
||||
toastr.error(data['error'][i], 'Failed Change Request');
|
||||
}
|
||||
|
||||
for (var i = 0; i < data['done'].length; i++) {
|
||||
toastr.success(data['done'][i], 'Successful Change Request');
|
||||
}
|
||||
|
||||
// Schedule next request when the current one's complete
|
||||
setTimeout(worker, 5000);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user