code reformating
This commit is contained in:
parent
8402fd4fd3
commit
a935871722
2 changed files with 56 additions and 68 deletions
|
@ -1,5 +1,4 @@
|
|||
|
||||
$( document ).ready(function() {
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#confirm-cancel').on('click', '.btn-ok', function(e) {
|
||||
var url = $('#virtual_machine_cancel_form').attr('action');
|
||||
|
@ -16,14 +15,13 @@ $( document ).ready(function() {
|
|||
$('#confirm-cancel').modal('hide');
|
||||
$.post(url)
|
||||
.done(function(data) {
|
||||
console.log( "success" , data);
|
||||
console.log("success", data);
|
||||
if (data.status == true) {
|
||||
$container.addClass('terminate-success')
|
||||
.find('.vm-item-lg').text(data.text);
|
||||
$btn.remove();
|
||||
window.location = data.redirect;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$container.addClass('terminate-fail')
|
||||
.find('.vm-item-lg').text(text);
|
||||
$container.find('.btn').prop('disabled', false);
|
||||
|
@ -44,7 +42,7 @@ $( document ).ready(function() {
|
|||
var hash = window.location.hash;
|
||||
hash && $('ul.nav a[href="' + hash + '"]').tab('show');
|
||||
|
||||
$('.nav-tabs a').click(function (e) {
|
||||
$('.nav-tabs a').click(function(e) {
|
||||
$(this).tab('show');
|
||||
var scrollmem = $('body').scrollTop() || $('html').scrollTop();
|
||||
window.location.hash = this.hash;
|
||||
|
|
|
@ -957,6 +957,14 @@ class VirtualMachineView(LoginRequiredMixin, View):
|
|||
response['text'] = ugettext(
|
||||
'Error terminating VM') + opennebula_vm_id
|
||||
else:
|
||||
for t in range(150):
|
||||
try:
|
||||
manager.get_vm(self.kwargs.get('pk'))
|
||||
except BaseException:
|
||||
break
|
||||
else:
|
||||
sleep(2)
|
||||
|
||||
context = {
|
||||
'vm': vm_data,
|
||||
'base_url': "{0}://{1}".format(self.request.scheme,
|
||||
|
@ -973,28 +981,10 @@ class VirtualMachineView(LoginRequiredMixin, View):
|
|||
}
|
||||
email = BaseEmail(**email_data)
|
||||
email.send()
|
||||
|
||||
# messages.error(
|
||||
# request,
|
||||
# _('VM %(VM_ID)s terminated successfully') % {
|
||||
# 'VM_ID': opennebula_vm_id}
|
||||
# )
|
||||
t = 0
|
||||
while True:
|
||||
if t < 150:
|
||||
t += 1
|
||||
try:
|
||||
manager.get_vm(self.kwargs.get('pk'))
|
||||
except BaseException:
|
||||
break
|
||||
else:
|
||||
sleep(2)
|
||||
else:
|
||||
break
|
||||
|
||||
response['status'] = True
|
||||
response['redirect'] = self.get_success_url()
|
||||
response['text'] = ugettext('Terminated')
|
||||
|
||||
return HttpResponse(
|
||||
json.dumps(response),
|
||||
content_type="application/json"
|
||||
|
|
Loading…
Reference in a new issue