Commit a6c097d8 by Oláh István Gergely

dashboard: modify node status change in node-list

parent b28159d2
...@@ -48,9 +48,7 @@ function changeNodeStatus(data) { ...@@ -48,9 +48,7 @@ function changeNodeStatus(data) {
if(!data['redirect']) { if(!data['redirect']) {
selected = []; selected = [];
addMessage(re['message'], 'success'); addMessage(re['message'], 'success');
$('a[data-'+data['type']+'-pk="' + data['pk'] + '"]').closest('tr').fadeOut(function() {
$(this).remove();
});
} else { } else {
window.location.replace('/dashboard'); window.location.replace('/dashboard');
} }
......
...@@ -132,9 +132,8 @@ $(function() { ...@@ -132,9 +132,8 @@ $(function() {
return false; return false;
}); });
function enabletableSuccess(unit){ function statuschangeSuccess(tr){
var tr= $(unit).closest("tr"); var tspan=tr.children('.enabled').children();
var tspan=tr.children('.enabled').children();
var buttons=tr.children('.actions').children('.btn-group').children('.dropdown-menu').children('li').children('.node-enable'); var buttons=tr.children('.actions').children('.btn-group').children('.dropdown-menu').children('li').children('.node-enable');
buttons.each(function(index){ buttons.each(function(index){
...@@ -158,29 +157,10 @@ $(function() { ...@@ -158,29 +157,10 @@ $(function() {
colortable(); colortable();
} }
function enabledetailsSuccess(){
// change big status span
$('#node-info-pane').load(location.href+" #node-info-data");
$('#activity-timeline-wrapper').load(location.href+" #activity-timeline");
}
$('#table_container').on('click','.node-enable',function() { $('#table_container').on('click','.node-enable',function() {
enablenode($(this).attr('data-node-pk'), $(this).attr('data-status'),enabletableSuccess,this); var tr= $(this).closest("tr");
return false; var pk =$(this).attr('data-node-pk');
});
// on node details, change node status, with calling enable node, refresh status span, resources div
$('#node-info-pane').on('click','.node-enable',function(){
// post, change node status
enablenode($(this).attr('data-node-pk'),$(this).attr('data-status'),enabledetailsSuccess);
return false;
});
// enabling / disabling node
function enablenode(pk,new_status,onsuccess,params) {
var url = '/dashboard/node/' + pk + '/'; var url = '/dashboard/node/' + pk + '/';
$.ajax({ $.ajax({
method: 'POST', method: 'POST',
...@@ -188,13 +168,18 @@ $(function() { ...@@ -188,13 +168,18 @@ $(function() {
data: {'change_status':''}, data: {'change_status':''},
headers: {"X-CSRFToken": getCookie('csrftoken')}, headers: {"X-CSRFToken": getCookie('csrftoken')},
success: function(data, textStatus, xhr) { success: function(data, textStatus, xhr) {
onsuccess(params); statuschangeSuccess(tr);
}, },
error: function(xhr, textStatus, error) { error: function(xhr, textStatus, error) {
addMessage("Error!", "danger"); addMessage("Error!", "danger");
} }
}); });
return false; return false;
});
// enabling / disabling node
function enablenode(pk,new_status,onsuccess,params) {
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment