some fix on delete action

Change-Id: I0cda12e120c92ded03bdd7c87c66aceb410ea927
Signed-off-by: lombardofr <lombardo@everyup.it>
diff --git a/vimhandler/template/vim_list.html b/vimhandler/template/vim_list.html
index 6823c72..07cb857 100644
--- a/vimhandler/template/vim_list.html
+++ b/vimhandler/template/vim_list.html
@@ -96,7 +96,30 @@
         function deleteVim(url) {
             bootbox.confirm("Are you sure want to delete?", function (result) {
                 if (result) {
-                    location.href = url//'/vims/' + vim_uuid + '/delete'
+                    var dialog = bootbox.dialog({
+                        message: '<div class="text-center"><i class="fa fa-spin fa-spinner"></i> Loading...</div>',
+                        closeButton: true
+                    });
+                    $.ajax({
+                        url: url,
+                        type: 'GET',
+                        dataType: "json",
+                        contentType: "application/json;charset=utf-8",
+                        success: function (result) {
+                            if (result['error'] == true) {
+                                dialog.modal('hide');
+                                bootbox.alert("An error occurred.");
+                            }
+                            else {
+                                dialog.modal('hide');
+                                location.reload();
+                            }
+                        },
+                        error: function (error) {
+                            dialog.modal('hide');
+                            bootbox.alert("An error occurred.");
+                        }
+                    });
                 }
             })
         }
diff --git a/vimhandler/views.py b/vimhandler/views.py
index d41ff82..c40e4e9 100644
--- a/vimhandler/views.py
+++ b/vimhandler/views.py
@@ -86,7 +86,7 @@
         del_res = client.vim_delete(user.get_token(), vim_id)
     except Exception as e:
         log.exception(e)
-    return __response_handler(request, {}, 'vims:list', to_redirect=True, )
+    return __response_handler(request, del_res, 'vims:list', to_redirect=True, )
 
 @login_required
 def show(request, vim_id=None):