Commit 00502ce3 authored by xiaoyu's avatar xiaoyu

trivial js style changes; bugfix for patch method

parent 89923333
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
</ul> </ul>
</div> </div>
<div class="tab-content"> <div class="tab-content">
<div class="col-sm-7" style="padding-left: 0px;"> <div class="col-sm-7" style="padding-left: 0">
<div class="ibox float-e-margins"> <div class="ibox float-e-margins">
<div class="ibox-title"> <div class="ibox-title">
<span class="label"><b>{{ user_object.name }}</b></span> <span class="label"><b>{{ user_object.name }}</b></span>
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
<div class="col-sm-5" style="padding-left: 0;padding-right: 0"> <div class="col-sm-5" style="padding-left: 0;padding-right: 0">
<div class="panel panel-primary"> <div class="panel panel-primary">
<div class="panel-heading"> <div class="panel-heading">
<i class="fa fa-info-circle"></i> {% trans 'Quick update' %} <i class="fa fa-info-circle"></i> {% trans 'Quick modify' %}
</div> </div>
<div class="panel-body"> <div class="panel-body">
<table class="table"> <table class="table">
...@@ -191,7 +191,7 @@ ...@@ -191,7 +191,7 @@
<tr> <tr>
<td ><b class="bdg_user_group" data-gid={{ group.id }}>{{ group.name }}</b></td> <td ><b class="bdg_user_group" data-gid={{ group.id }}>{{ group.name }}</b></td>
<td> <td>
<button class="btn btn-danger btn-xs btn_delete_user_group" type="button" style="float: right;"><i class="fa fa-minus"></i></button> <button class="btn btn-danger btn-sm btn_delete_user_group" type="button" style="float: right;"><i class="fa fa-minus"></i></button>
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
...@@ -205,12 +205,10 @@ ...@@ -205,12 +205,10 @@
</div> </div>
</div> </div>
</div> </div>
</div>
{% endblock %} {% endblock %}
{% block custom_foot_js %} {% block custom_foot_js %}
<script> <script>
jumpserver.selected_groups = new Object(); jumpserver.selected_groups = {};
function updateUserGroups(user_groups) { function updateUserGroups(user_groups) {
var the_url = "{% url 'users:user-group-edit-api' pk=user_object.id%}"; var the_url = "{% url 'users:user-group-edit-api' pk=user_object.id%}";
var body = { var body = {
...@@ -234,36 +232,35 @@ function updateUserGroups(user_groups) { ...@@ -234,36 +232,35 @@ function updateUserGroups(user_groups) {
// clear jumpserver.selected_groups // clear jumpserver.selected_groups
jumpserver.selected_groups = {}; jumpserver.selected_groups = {};
toastr.success('{% trans "Update success!" %}') toastr.success('{% trans "Update success!" %}')
} };
APIUpdateAttr({ url: the_url, body: JSON.stringify(body), success: success, method: 'PUT'}); APIUpdateAttr({ url: the_url, body: JSON.stringify(body), success: success, method: 'PUT'});
} }
$(document).ready(function () { $(document).ready(function () {
$('.select2').select2() $('.select2').select2()
.on('select2:select', function(evt, params) { .on('select2:select', function(evt) {
var data = evt.params.data; var data = evt.params.data;
jumpserver.selected_groups[data.id] = data.text; jumpserver.selected_groups[data.id] = data.text;
}).on('select2:unselect', function(evt) { }).on('select2:unselect', function(evt) {
var data = evt.params.data; var data = evt.params.data;
delete jumpserver.selected_groups[data.id] delete jumpserver.selected_groups[data.id]
}) })
}); }).on('click', '#is_active', function(){
$(document).on('click', '#is_active', function(){
var the_url = "{% url 'users:user-patch-api' pk=user_object.id %}"; var the_url = "{% url 'users:user-patch-api' pk=user_object.id %}";
var checked = !$(this).prop('checked'); var checked = !$(this).prop('checked');
var body = {'is_active': checked }; var body = {'is_active': checked };
var success = function(data) { var success = function() {
toastr.success('{% trans "Update success!" %}') toastr.success('{% trans "Update success!" %}')
} };
APIUpdateAttr({ url: the_url, body: body, success: success}); APIUpdateAttr({ url: the_url, body: JSON.stringify(body), success: success});
}).on('click', '#enable_otp', function(){ }).on('click', '#enable_otp', function(){
var the_url = "{% url 'users:user-patch-api' pk=user_object.id %}"; var the_url = "{% url 'users:user-patch-api' pk=user_object.id %}";
var checked = !$(this).prop('checked'); var checked = !$(this).prop('checked');
var body = {'enable_otp': checked }; var body = {'enable_otp': checked };
var success = function(data) { var success = function() {
toastr.success('{% trans "Update success!" %}') toastr.success('{% trans "Update success!" %}')
} };
APIUpdateAttr({ url: the_url, body: body, success: success}); APIUpdateAttr({ url: the_url, body: JSON.stringify(body), success: success});
}).on('click', '#btn_add_user_group', function(){ }).on('click', '#btn_add_user_group', function(){
if (Object.keys(jumpserver.selected_groups).length === 0) { if (Object.keys(jumpserver.selected_groups).length === 0) {
return false; return false;
...@@ -290,6 +287,6 @@ $(document).on('click', '#is_active', function(){ ...@@ -290,6 +287,6 @@ $(document).on('click', '#is_active', function(){
return $(this).data('gid'); return $(this).data('gid');
}).get(); }).get();
updateUserGroups(user_groups) updateUserGroups(user_groups)
}) });
</script> </script>
{% endblock %} {% endblock %}
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 to comment