Commit 99dc70e8 by Oláh István Gergely

dashboard: fix node enabling in node-details

parent 6ff1e05a
......@@ -145,14 +145,46 @@ $(':not(#anything)').on('click', function (e) {
});
// on node list, change node status with calling enable node, refresh table
$('#table_container').on('click','#node-list-enable-button',function(){
enablenode($(this).attr('data-node-pk'),$(this).attr('data-status'));
enablenode($(this).attr('data-node-pk'),$(this).attr('data-status'),contentrefresh,["#table_container","#rendered_table"]);
});
// on node details, change node status, with calling enable node, refresh status span, resources div
$('#node-info-pane').on('click','#node-list-enable-button',function(){
enablenode($(this).attr('data-node-pk'),$(this).attr('data-status'),contentrefresh,["#node-info-pane","#node-info-data","#resources","#vm-details-resources-form"]);
});
// enabling / disabling node
function enablenode(pk,new_status,refresh, elements) {
var url = '/dashboard/node/' + pk + '/';
console.log('success');
$.ajax({
method: 'POST',
url: url,
data: {'new_status':new_status},
headers: {"X-CSRFToken": getCookie('csrftoken')},
success: function(data, textStatus, xhr) {
console.log("x++");
refresh(elements);
},
error: function(xhr, textStatus, error) {
addMessage("uhoh", "danger");
}
});
return false;
}
// refresh the given contents, parameter is the array of contents, in pair
function contentrefresh(elements){
for (var i = 0; i < elements.length; i+=2) {
$(elements[i]).load(location.href+" "+elements[i+1]);
}
}
// enabling / disabling node
function enablenode(pk,new_status) {
function enablenode2(pk,new_status) {
var url = '/dashboard/node/' + pk + '/';
console.log('success');
$.ajax({
......@@ -161,7 +193,8 @@ $(':not(#anything)').on('click', function (e) {
data: {'new_status':new_status},
headers: {"X-CSRFToken": getCookie('csrftoken')},
success: function(data, textStatus, xhr) {
$('#table_container').load(location.href+" "+'#rendered_table');
$('#node-info-pane').load(location.href+" "+'#node-info-data');
$('#resources').load(location.href+" "+'#vm-details-resources-form');
},
error: function(xhr, textStatus, error) {
addMessage("uhoh", "danger");
......
......@@ -8,8 +8,8 @@
</div>
<div class="row">
<div class="col-md-4" id="node-info-pane">
<div class="big">
<span class="label {% if node.state == 'online' %}label-success
<div id="node-info-data" class="big">
<span id="node-status-label" class="label {% if node.state == 'online' %}label-success
{% elif node.state == 'missing' %}label-danger
{% elif node.state == 'disabled' %}label-warning
{% elif node.state == 'offline' %}label-warning
......@@ -42,7 +42,7 @@
{% trans "Activity" %}</a></li>
</ul>
<div class="tab-content panel-body">
<div id="panel-body" class="tab-content panel-body">
<div class="tab-pane active" id="home">{% include "dashboard/node-detail-home.html" %}</div>
<div class="tab-pane" id="resources">{% include "dashboard/node-detail-resources.html" %}</div>
<div class="tab-pane" id="activity">{% include "dashboard/node-detail-activity.html" %}</div>
......
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