Commit a16d972b by Oláh István Gergely

dashboard: cleanup node-list.js, highlighting disabled nodes

parent 99dc70e8
...@@ -59,40 +59,15 @@ $(function() { ...@@ -59,40 +59,15 @@ $(function() {
return retval; return retval;
}); });
/*
$('.popover-link').popover();
$(':not(#anything)').on('click', function (e) {
$('.popover-link').each(function () {
//the 'is' for buttons that trigger popups
//the 'has' for icons and other elements within a button that triggers a popup
if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
$(this).popover('hide');
return;
}
});
});
*/
$(':not(#anything)').on('click', function (e) {
$('.node-list-details').each(function () {
//the 'is' for buttons that trigger popups
// //the 'has' for icons and other elements within a button that triggers a popup
if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
$(this).popover('hide');
return;
}
});
});
$('#node-list-group-migrate').click(function() { $('#node-list-group-migrate').click(function() {
console.log(collectIds(selected)); console.log(collectIds(selected));
}); });
$('.node-list-details').popover({ $('#table_container').popover({
'placement': 'auto', selector : '.node-list-details',
'html': true, placement : 'auto',
'trigger': 'click' html : true,
trigger : 'click',
}); });
...@@ -109,6 +84,16 @@ $(':not(#anything)').on('click', function (e) { ...@@ -109,6 +84,16 @@ $(':not(#anything)').on('click', function (e) {
} }
}); });
// find disabled nodes, set danger (red) on the rows
function colortable() {
var tr= $('.false').closest("tr");
tr.addClass('danger');
}
$( document ).on('ready reload', function() {
colortable();
});
/* rename */ /* rename */
$("#node-list-rename-button, .node-details-rename-button").click(function() { $("#node-list-rename-button, .node-details-rename-button").click(function() {
$("#node-list-column-name", $(this).closest("tr")).hide(); $("#node-list-column-name", $(this).closest("tr")).hide();
...@@ -147,26 +132,24 @@ $(':not(#anything)').on('click', function (e) { ...@@ -147,26 +132,24 @@ $(':not(#anything)').on('click', function (e) {
// on node list, change node status with calling enable node, refresh table // on node list, change node status with calling enable node, refresh table
$('#table_container').on('click','#node-list-enable-button',function(){ $('#table_container').on('click','#node-list-enable-button',function(){
enablenode($(this).attr('data-node-pk'),$(this).attr('data-status'),contentrefresh,["#table_container","#rendered_table"]); enablenode($(this).attr('data-node-pk'),$(this).attr('data-status'),contentrefresh,["#table_container","#rendered_table"],[colortable]);
}); });
// on node details, change node status, with calling enable node, refresh status span, resources div // 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(){ $('#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"]); 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 // enabling / disabling node
function enablenode(pk,new_status,refresh, elements) { function enablenode(pk,new_status,refresh, elements,callback) {
var url = '/dashboard/node/' + pk + '/'; var url = '/dashboard/node/' + pk + '/';
console.log('success');
$.ajax({ $.ajax({
method: 'POST', method: 'POST',
url: url, url: url,
data: {'new_status':new_status}, data: {'new_status':new_status},
headers: {"X-CSRFToken": getCookie('csrftoken')}, headers: {"X-CSRFToken": getCookie('csrftoken')},
success: function(data, textStatus, xhr) { success: function(data, textStatus, xhr) {
console.log("x++"); refresh(elements,callback);
refresh(elements);
}, },
error: function(xhr, textStatus, error) { error: function(xhr, textStatus, error) {
addMessage("uhoh", "danger"); addMessage("uhoh", "danger");
...@@ -176,31 +159,10 @@ $(':not(#anything)').on('click', function (e) { ...@@ -176,31 +159,10 @@ $(':not(#anything)').on('click', function (e) {
} }
// refresh the given contents, parameter is the array of contents, in pair // refresh the given contents, parameter is the array of contents, in pair
function contentrefresh(elements){ function contentrefresh(elements,callbacks){
for (var i = 0; i < elements.length; i+=2) { for (var i = 0; i < elements.length; i+=2) {
$(elements[i]).load(location.href+" "+elements[i+1]); $(elements[i]).load(location.href+" "+elements[i+1],callbacks[i/2]);
}
} }
// enabling / disabling node
function enablenode2(pk,new_status) {
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) {
$('#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");
}
});
return false;
} }
/* group actions */ /* group actions */
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
</p> </p>
</div> </div>
<div id="table_container"> <div id="table_container">
<div id="rendered_table" class="panel-body"> <div id="rendered_table" class="panel-body">
{% render_table table %} {% render_table table %}
</div> </div>
...@@ -35,7 +36,6 @@ ...@@ -35,7 +36,6 @@
</div> </div>
</div> </div>
</div> </div>
<style> <style>
.popover { .popover {
max-width: 600px; max-width: 600px;
......
<a class="btn btn-info btn-xs node-list-details" href="#" data-toggle="popover" <a class="btn btn-info btn-xs node-list-details" rel="popover" href="#" data-toggle="popover"
data-content=' data-content='
<h4>Quick details</h4> <h4>Quick details</h4>
<dl class="dl-horizontal"> <dl class="dl-horizontal">
...@@ -11,4 +11,4 @@ ...@@ -11,4 +11,4 @@
<dt>IPv6 address:</dt><dd> 2001:2001:2001:2001:2001:2001::</dd> <dt>IPv6 address:</dt><dd> 2001:2001:2001:2001:2001:2001::</dd>
<dt>DNS name:</dt><dd>1825.vm.ik.bme.hu</dd> <dt>DNS name:</dt><dd>1825.vm.ik.bme.hu</dd>
</ul> </ul>
'>Details</a> '>Details</a>
...@@ -60,7 +60,6 @@ class Node(TimeStampedModel): ...@@ -60,7 +60,6 @@ class Node(TimeStampedModel):
def num_cores(self): def num_cores(self):
"""Number of CPU threads available to the virtual machines. """Number of CPU threads available to the virtual machines.
""" """
return self.remote_query(vm_tasks.get_core_num) return self.remote_query(vm_tasks.get_core_num)
@property @property
...@@ -94,11 +93,13 @@ class Node(TimeStampedModel): ...@@ -94,11 +93,13 @@ class Node(TimeStampedModel):
def get_remote_queue_name(self, queue_id): def get_remote_queue_name(self, queue_id):
return self.host.hostname + "." + queue_id return self.host.hostname + "." + queue_id
def remote_query(self, task, timeout=30, raise_=False, default=None): def remote_query(self, task, timeout=1, raise_=False, default=None):
"""Query the given task, and get the result. """Query the given task, and get the result.
If the result is not ready in timeout secs, return default value or If the result is not ready in timeout secs, return default value or
raise a TimeoutError.""" raise a TimeoutError."""
if task != vm_tasks.ping and not self.online:
return default
r = task.apply_async( r = task.apply_async(
queue=self.get_remote_queue_name('vm'), expires=timeout + 60) queue=self.get_remote_queue_name('vm'), expires=timeout + 60)
try: try:
......
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