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') $container.addClass('terminate-success')
.find('.vm-item-lg').text(data.text); .find('.vm-item-lg').text(data.text);
$container.find('.btn').remove(); $container.find('.btn').remove();
window.location = data.redirect; $('#terminate-success').modal('show');
} }
function VMTerminateFail($container, data, text) { function VMTerminateFail($container, data, text) {

View file

@ -103,7 +103,7 @@
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="modal-icon"><i class="fa fa-ban" aria-hidden="true"></i></div> <div class="modal-icon"><i class="fa fa-ban" aria-hidden="true"></i></div>
<h4 class="modal-title" id="ModalLabel">{% trans "Terminate your Virtual Machine"%}</h4> <h4 class="modal-title" id="ModalLabel">{% trans "Terminate your Virtual Machine" %}</h4>
<div class="modal-text"> <div class="modal-text">
<p>{% trans "Do you want to cancel your Virtual Machine" %} ?</p> <p>{% trans "Do you want to cancel your Virtual Machine" %} ?</p>
<p><strong>{{virtual_machine.name}}</strong></p> <p><strong>{{virtual_machine.name}}</strong></p>
@ -116,4 +116,21 @@
</div> </div>
</div> </div>
<!-- / Cancel Modal --> <!-- / 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%} {%endblock%}

View file

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