diff --git a/apps/jumpserver/urls.py b/apps/jumpserver/urls.py index c93a30439..e593e60a8 100644 --- a/apps/jumpserver/urls.py +++ b/apps/jumpserver/urls.py @@ -17,7 +17,6 @@ from django.conf.urls import url, include from django.conf import settings from django.conf.urls.static import static from django.views.generic.base import TemplateView -from django.http import HttpResponseRedirect urlpatterns = [ diff --git a/apps/static/js/jumpserver.js b/apps/static/js/jumpserver.js index bb815c02a..8bd303f2c 100644 --- a/apps/static/js/jumpserver.js +++ b/apps/static/js/jumpserver.js @@ -214,4 +214,30 @@ function APIUpdateAttr(props) { return true; } +// Sweet Alert for Delete +function objectDelete(obj, name, url){ + swal({ + title: 'Are you sure delete ?', + text: "【" + name + "】", + type: "warning", + showCancelButton: true, + cancelButtonText: 'Cancel', + confirmButtonColor: "#DD6B55", + confirmButtonText: 'Yes, delete it!', + closeOnConfirm: false + }, function () { + $.ajax({ + type : "post", + url : url, + data : { + }, + dataType : "text", + success : function(data) { + swal('Deleted!' , "【"+name+"】"+"has been deleted.", "success"); + $(obj).parent().parent().remove(); + } + }) + }); +} + var jumpserver = {}; diff --git a/apps/templates/_foot_js.html b/apps/templates/_foot_js.html index b6b0851c5..04bac17dd 100644 --- a/apps/templates/_foot_js.html +++ b/apps/templates/_foot_js.html @@ -16,32 +16,4 @@ $('textarea').attr('rows', 5); }); - -// Sweet Alert for Delete -// Todo: Change name to objectDelete(obj, name, url) -function objectDelete(obj, name, url){ - swal({ - title: "{% trans 'Are you sure delete ?' %}", - text: "【" + name + "】", - type: "warning", - showCancelButton: true, - cancelButtonText: "{% trans 'Cancel' %}", - confirmButtonColor: "#DD6B55", - confirmButtonText: "{% trans 'Yes, delete it!' %}", - closeOnConfirm: false - }, function () { - $.ajax({ - type : "post", - url : url, - data : { - }, - dataType : "text", - success : function(data) { - swal("{% trans 'Deleted!' %}", "【"+name+"】"+"{% trans 'has been deleted.' %}", "success"); - $(obj).parent().parent().remove(); - } - }) - }); -} -