Commit f068fe84 by Őry Máté

Merge branch 'issue-115' into 'master'

Issue 115

Fixes issue #115 + node js cleanup
parents 8a7407ff 77309d9b
...@@ -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,54 +157,25 @@ $(function() { ...@@ -158,54 +157,25 @@ $(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');
}); var url = $(this).attr('href');
// 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 + '/';
$.ajax({ $.ajax({
method: 'POST', method: 'POST',
url: url, url: url,
data: {'new_status':new_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;
} });
// refresh the given contents, parameter is the array of contents, in pair
function contentrefresh(elements,callbacks){
for (var i = 0; i < elements.length; i+=2) {
$(elements[i]).load(location.href+" "+elements[i+1],callbacks[i/2]);
}
}
/* group actions */ /* group actions */
......
{% load i18n %}
<div class="modal fade" id="confirmation-modal" tabindex="-1" role="dialog"> <div class="modal fade" id="confirmation-modal" tabindex="-1" role="dialog">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
<ul class="dropdown-menu nojs-dropdown-toogle" role="menu"> <ul class="dropdown-menu nojs-dropdown-toogle" role="menu">
<li><a href="#" class="node-details-rename-button"><i class="icon-pencil"></i> {% trans "Rename" %}</a></li> <li><a href="#" class="node-details-rename-button"><i class="icon-pencil"></i> {% trans "Rename" %}</a></li>
<li><a data-node-pk="{{ record.pk }}" class="real-link node-flush" href="{% url "dashboard.views.flush-node" pk=record.pk %}"><i class="icon-cloud-upload"></i>{% trans "Flush" %}</a> <li><a data-node-pk="{{ record.pk }}" class="real-link node-flush" href="{% url "dashboard.views.flush-node" pk=record.pk %}"><i class="icon-cloud-upload"></i>{% trans "Flush" %}</a>
<li><a style={% if record.enabled %}"display:none"{% else %}"display:block"{% endif %} data-status="enable" data-node-pk="{{ record.pk }}" class="real-link node-enable" href="{% url "dashboard.views.status-node" pk=record.pk %}?next={{ request.path }}&status=enable"><i class="icon-check"></i>{% trans "Enable" %}</a> <li><a style={% if record.enabled %}"display:none"{% else %}"display:block"{% endif %} data-node-pk="{{ record.pk }}" class="real-link node-enable" href="{% url "dashboard.views.status-node" pk=record.pk %}?next={{ request.path }}"><i class="icon-check"></i>{% trans "Enable" %}</a>
<a style={% if record.enabled %}"display:block"{% else %}"display:none"{% endif %} data-status="disable" data-node-pk="{{ record.pk }}" class="real-link node-enable" href="{% url "dashboard.views.status-node" pk=record.pk %}?next={{ request.path }}&status=disable"><i class="icon-remove"></i>{% trans "Disable" %}</a></li> <a style={% if record.enabled %}"display:block"{% else %}"display:none"{% endif %} data-node-pk="{{ record.pk }}" class="real-link node-enable" href="{% url "dashboard.views.status-node" pk=record.pk %}?next={{ request.path }}"><i class="icon-remove"></i>{% trans "Disable" %}</a></li>
<li><a data-node-pk="{{ record.pk }}" class="real-link node-delete" href="{% url "dashboard.views.delete-node" pk=record.pk %}?next={{ request.path }}"><i class="icon-trash"></i>{% trans "Delete" %}</a></li> <li><a data-node-pk="{{ record.pk }}" class="real-link node-delete" href="{% url "dashboard.views.delete-node" pk=record.pk %}?next={{ request.path }}"><i class="icon-trash"></i>{% trans "Delete" %}</a></li>
</ul> </ul>
</div> </div>
{% load i18n %}
<a class="btn btn-default btn-xs" title="{% trans "Flush" %}"> <a class="btn btn-default btn-xs" title="{% trans "Flush" %}">
<i class="icon-cloud-upload"></i> <i class="icon-cloud-upload"></i>
</a> </a>
......
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