success modal added

This commit is contained in:
Arvind Tiwari 2017-09-18 21:52:59 +05:30
parent d49e90bd20
commit 226f744bae
3 changed files with 27 additions and 6 deletions

View file

@ -27,7 +27,7 @@ function VMTerminateSuccess($container, data) {
$container.addClass('terminate-success')
.find('.vm-item-lg').text(data.text);
$container.find('.btn').remove();
window.location = data.redirect;
$('#terminate-success').modal('show');
}
function VMTerminateFail($container, data, text) {

View file

@ -116,4 +116,21 @@
</div>
</div>
<!-- / Cancel Modal -->
<!-- Success Modal -->
<div class="modal fade" id="terminate-success" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
</div>
<div class="modal-body">
<div class="modal-icon"><i class="fa fa-ban" aria-hidden="true"></i></div>
<h4 class="modal-title" id="ModalLabel">{% trans "Your Virtual Machine" %} {{vm.id}} {% trans "was successfully terminated!" %}</h4>
<div class="modal-footer">
<a href="{% url 'hosting:virtual_machines' %}" class="btn btn-danger btn-wide">{% trans "Close" %}</a>
</div>
</div>
</div>
</div>
</div>
<!-- / Cancel Modal -->
{%endblock%}

View file

@ -961,7 +961,13 @@ class VirtualMachineView(LoginRequiredMixin, View):
password=owner.password
)
try:
vm_data = VirtualMachineSerializer(manager.get_vm(vm.id)).data
except BaseException:
return redirect(
reverse('hosting:virtual_machines',
kwargs={'pk': opennebula_vm_id})
)
terminated = manager.delete_vm(vm.id)
@ -971,12 +977,10 @@ class VirtualMachineView(LoginRequiredMixin, View):
else:
for t in range(15):
try:
manager.get_vm(self.kwargs.get('pk'))
manager.get_vm(opennebula_vm_id)
except WrongIdError:
response['status'] = True
response['redirect'] = self.get_success_url()
response['text'] = ugettext('Terminated')
self.send_mail()
break
except BaseException:
break