Commit 359099ed by Kálmán Viktor

network: bootbox for bootstrap 3

parent 02e4350c
...@@ -3,23 +3,30 @@ ...@@ -3,23 +3,30 @@
$('i[class="icon-remove"]').click(function() { $('i[class="icon-remove"]').click(function() {
href = $(this).parent('a').attr('href'); href = $(this).parent('a').attr('href');
csrf = getCookie('csrftoken'); csrf = getCookie('csrftoken');
var click_this = this; var click_this = this;
bootbox.dialog("Are you sure?", [ host = $('.page-header').children('h2').text()
{ group = $(this).closest('h4').text();
"label": "Cancel",
"class": "btn-info", text = gettext('Are you sure you want to remove host group <strong>"%(group)s"</strong> from <strong>"%(host)s"</strong>?');
"callback": function () {} s = interpolate(text, {'group': group, 'host': host}, true);
}, bootbox.dialog({
{ message: s,
"label": "Remove", buttons: {
"class": "btn-danger", cancel: {
"callback": function() { 'label': "Cancel",
delete_rule_or_group(click_this); 'className': "btn-info",
'callback': function () {}
},
remove: {
'label': "Remove",
'className': "btn-danger",
'callback': function() {
delete_rule_or_group(click_this);
}
} }
} }
]); });
return false; return false;
}); });
......
...@@ -82,6 +82,7 @@ ...@@ -82,6 +82,7 @@
<script src="http://code.jquery.com/jquery-latest.js"></script> <script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="{% url network.js_catalog %}"></script> <script src="{% url network.js_catalog %}"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="{% static "js/bootbox.min.js" %}"></script>
<!--<script src="{% static "js/select2-3.4.0/select2.min.js" %}"></script>--> <!--<script src="{% static "js/select2-3.4.0/select2.min.js" %}"></script>-->
<script src="{% static "js/network.js" %}"></script> <script src="{% static "js/network.js" %}"></script>
<script> <script>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<h1>Remove <small></small></h1> <h1>Remove <small></small></h1>
</div> </div>
<form action="" method="post">{% csrf_token %} <form action="" method="post">{% csrf_token %}
<p>Are you sure you want to remove hostgroup <strong>"{{ group }}"</strong> <p>Are you sure you want to remove host group <strong>"{{ group }}"</strong>
from <strong>"{{ host }}"</strong>?</p> from <strong>"{{ host }}"</strong>?</p>
<input type="hidden" value="{{ request.GET.from }}" name="next" /> <input type="hidden" value="{{ request.GET.from }}" name="next" />
<a href="{{ request.GET.from }}" class="btn btn-info">Back</a> <a href="{{ request.GET.from }}" class="btn btn-info">Back</a>
......
...@@ -618,11 +618,12 @@ def remove_host_group(request, **kwargs): ...@@ -618,11 +618,12 @@ def remove_host_group(request, **kwargs):
# for post we actually remove the group from the host # for post we actually remove the group from the host
elif request.method == "POST": elif request.method == "POST":
host.groups.remove(group) host.groups.remove(group)
messages.success(request, _("Successfully removed %(host)s from " if not request.is_ajax():
"%(group)s group!" % { messages.success(request, _("Successfully removed %(host)s from "
'host': host, "%(group)s group!" % {
'group': group 'host': host,
})) 'group': group
}))
return redirect(reverse_lazy('network.host', return redirect(reverse_lazy('network.host',
kwargs={'pk': kwargs['pk']})) kwargs={'pk': kwargs['pk']}))
...@@ -633,9 +634,10 @@ def add_host_group(request, **kwargs): ...@@ -633,9 +634,10 @@ def add_host_group(request, **kwargs):
host = Host.objects.get(pk=kwargs['pk']) host = Host.objects.get(pk=kwargs['pk'])
group = Group.objects.get(pk=group_pk) group = Group.objects.get(pk=group_pk)
host.groups.add(group) host.groups.add(group)
messages.success(request, _("Successfully added %(host)s to group " if not request.is_ajax():
"%(group)s!" % { messages.success(request, _("Successfully added %(host)s to group"
'host': host, " %(group)s!" % {
'group': group 'host': host,
})) 'group': group
}))
return redirect(reverse_lazy('network.host', kwargs=kwargs)) return redirect(reverse_lazy('network.host', kwargs=kwargs))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment