remove error msg on successful termination
This commit is contained in:
		
					parent
					
						
							
								0c3f605735
							
						
					
				
			
			
				commit
				
					
						77f2454e3c
					
				
			
		
					 2 changed files with 16 additions and 9 deletions
				
			
		| 
						 | 
				
			
			@ -1,14 +1,16 @@
 | 
			
		|||
function VMTerminateStatus($container, url) {
 | 
			
		||||
    $.get(url)
 | 
			
		||||
        .done(function(data) {
 | 
			
		||||
    $.ajax({
 | 
			
		||||
        url: url,
 | 
			
		||||
        dataType: 'json',
 | 
			
		||||
        success: function(data) {
 | 
			
		||||
            VMTerminateSuccess($container, data);
 | 
			
		||||
        },
 | 
			
		||||
        error: function() {
 | 
			
		||||
            setTimeout(function(){
 | 
			
		||||
                VMTerminateStatus($container, url);
 | 
			
		||||
            }, 4000);
 | 
			
		||||
        })
 | 
			
		||||
        .fail(function(data) {
 | 
			
		||||
            VMTerminateSuccess($container, data)
 | 
			
		||||
            window.location.reload(true);
 | 
			
		||||
        });
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function VMTerminateActive($container, altText) {
 | 
			
		||||
| 
						 | 
				
			
			@ -25,6 +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;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function VMTerminateFail($container, data, text) {
 | 
			
		||||
| 
						 | 
				
			
			@ -50,7 +53,6 @@ $(document).ready(function() {
 | 
			
		|||
                console.log("success", data);
 | 
			
		||||
                if (data.status == true) {
 | 
			
		||||
                    VMTerminateSuccess($container, data);
 | 
			
		||||
                    window.location = data.redirect;
 | 
			
		||||
                } else {
 | 
			
		||||
                    if ('text' in data) {
 | 
			
		||||
                        VMTerminateFail($container, data, text);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -926,9 +926,14 @@ class VirtualMachineView(LoginRequiredMixin, View):
 | 
			
		|||
            if self.request.is_ajax():
 | 
			
		||||
                storage = messages.get_messages(request)
 | 
			
		||||
                storage.used = True
 | 
			
		||||
                raise Http404()
 | 
			
		||||
                return HttpResponse(
 | 
			
		||||
                    json.dumps({'redirect': self.get_success_url()}),
 | 
			
		||||
                    content_type="application/json"
 | 
			
		||||
                )
 | 
			
		||||
            else:
 | 
			
		||||
                return redirect(reverse('hosting:virtual_machines'))
 | 
			
		||||
        elif self.request.is_ajax():
 | 
			
		||||
            return HttpResponse()
 | 
			
		||||
        try:
 | 
			
		||||
            serializer = VirtualMachineSerializer(vm)
 | 
			
		||||
            context = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue