Commit 82a96649 by tarokkk

webui: Added stop,restart,resume functions

parent caef159a
......@@ -37,6 +37,18 @@ $(function() {
}
}
$('.wm .summary').unbind('click').click(toggleDetails);
$('.stop-vm-button').click(function() {
stop_vm($(this).data('id'), $(this).data('name'));
});
$('.resume-vm-button').click(function() {
manage_vm($(this).data('id'), "resume");
});
$('.delete-vm-button').click(function() {
delete_vm($(this).data('id'), $(this).data('name'));
});
$('.restart-vm-button').click(function() {
restart_vm($(this).data('id'), $(this).data('name'));
});
$('#new-wm-button').click(function() {
$('#modal').show();
$('#modal-container').html($('#new-wm').html());
......@@ -89,6 +101,58 @@ $(function() {
$('#new-group-semester').change(updateSummary);
$('#new-group-members').change(updateSummary);
});
/**
* Confirm pop-up window
*/
function vm_confirm_popup(confirm_message, button_text) {
return confirm(confirm_message);
}
/**
* Manage VM State (STOP)
*/
function stop_vm(id, name) {
confirm_message = interpolate(gettext("Are you sure stopping %s?"), [name])
if (vm_confirm_popup(confirm_message, gettext("Stop"))) {
manage_vm(id, "stop")
}
}
/**
* Manage VM State (DELETE)
*/
function delete_vm(id, name) {
confirm_message = interpolate(gettext("Are you sure deleting %s?"), [name])
if (vm_confirm_popup(confirm_message, gettext("Delete"))) {
manage_vm(id, "delete")
}
}
/**
* Manage VM State (RESET)
*/
function restart_vm(id, name) {
confirm_message = interpolate(gettext("Are you sure restarting %s?"), [name])
if (vm_confirm_popup(confirm_message, gettext("Restart"))) {
manage_vm(id, "restart")
}
}
/**
* Manage VM State (RESUME)
*/
function resume_vm(id, name) {
manage_vm(id, "resume")
}
/**
* Manage VM State generic
*/
function manage_vm(id, state) {
$.ajax({
type: 'POST',
data: '',
url: '/vm/'+state+'/'+id+'/',
success: function(data) {
}
})
}
/**
* Convert bytes to human readable format
......
......@@ -16,29 +16,29 @@
<a href="{{i.get_connect_uri}}" title="{% trans "Connect" %}">
<img src="/static/icons/plug.png" alt="{% trans "Connect" %}" />
</a>
<a href="/vm/suspend/{{i.id}}/" onclick="alert('Hamarosan a mozikban.'); return false" title="{% trans "Suspend" %}">
<a href="#" class="stop-vm-button" data-name="{{ i.name}}" data-id="{{ i.id }}" title="{% trans "Stop" %}">
<img src="/static/icons/control-pause.png" alt="{% trans "Suspend" %}" />
</a>
<a href="/vm/delete/{{i.id}}/" onclick="return confirm('Biztosan törli a gépet?')" title="{% trans "Delete" %}">
</span>
<a href="#" class="delete-vm-button" data-name="{{ i.name}}" data-id="{{ i.id }}" title="{% trans "Delete" %}">
<img src="/static/icons/minus-circle.png" alt="{% trans "Delete" %}" />
</a>
<a href="/vm/reset/{{i.id}}/" onclick="alert('Hamarosan a mozikban.'); return false" title="{% trans "Reboot" %}">
<a href="#" class="restart-vm-button" data-name="{{ i.name}}" data-id="{{ i.id }}" title="{% trans "Restart" %}">
<img src="/static/icons/arrow-circle-double.png" alt="↺" />
</a>
{% endif %}
{% if i.state == 'PENDING' %}
<img src="/static/load-2.gif" /> {% trans "starting…" %}
{% endif %}
{% if i.state == 'SUSPENDED' %}
<a href="/vm/continue/{{i.id}}/" title="{% trans "Resume" %}">
{% if i.state == 'STOPPED' %}
<a href="#" class="resume-vm-button" data-name="{{ i.name}}" data-id="{{ i.id }}" title="{% trans "Resume" %}">
<img src="/static/icons/control.png" alt="{% trans "Resume" %}" />
</a>
<a href="/vm/delete/{{i.id}}/" onclick="return confirm('Biztosan törli a gépet?')" title="{% trans "Delete" %}">
</span>
<a href="#" class="delete-vm-button" data-name="{{ i.name}}" data-id="{{ i.id }}" title="{% trans "Delete" %}">
<img src="/static/icons/minus-circle.png" alt="{% trans "Delete" %}" />
</a>
{% endif %}
{% if i.state == 'FAILED' %}
<a href="/vm/delete/{{i.id}}/" title="{% trans "Delete" %}">
<a href="#" class="delete-vm-button" data-name="{{ i.name}}" data-id="{{ i.id }}" title="{% trans "Delete" %}">
<img src="/static/icons/minus-circle.png" alt="{% trans "Delete" %}" />
</a>
{% endif %}
......
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