mirror of https://github.com/jumpserver/jumpserver
添加权限支持搜索
parent
70fe42f359
commit
46cc593a9e
|
@ -8,6 +8,7 @@ urlpatterns = patterns('jperm.views',
|
|||
|
||||
(r'^perm_edit/$', 'perm_edit'),
|
||||
(r'^perm_list/$', 'perm_list'),
|
||||
(r'^perm_list_ajax/$', 'perm_list_ajax'),
|
||||
(r'^perm_detail/$', 'perm_detail'),
|
||||
(r'^perm_del/$', 'perm_del'),
|
||||
(r'^perm_asset_detail/$', 'perm_asset_detail'),
|
||||
|
|
|
@ -65,6 +65,41 @@ def perm_list(request):
|
|||
return render_to_response('jperm/perm_list.html', locals())
|
||||
|
||||
|
||||
def perm_list_ajax(request):
|
||||
tab = request.POST.get('tab', 'tab1')
|
||||
search = request.POST.get('search', '')
|
||||
|
||||
if tab == 'tab1':
|
||||
groups = contact_list = UserGroup.objects.filter(name__icontains=search).order_by('type')
|
||||
p = paginator = Paginator(contact_list, 10)
|
||||
|
||||
try:
|
||||
page = int(request.GET.get('page', '1'))
|
||||
except ValueError:
|
||||
page = 1
|
||||
|
||||
try:
|
||||
contacts = paginator.page(page)
|
||||
except (EmptyPage, InvalidPage):
|
||||
contacts = paginator.page(paginator.num_pages)
|
||||
|
||||
else:
|
||||
users = contact_list2 = User.objects.filter(name__icontains=search).order_by('id')
|
||||
p2 = paginator2 = Paginator(contact_list2, 10)
|
||||
|
||||
try:
|
||||
page = int(request.GET.get('page', '1'))
|
||||
except ValueError:
|
||||
page = 1
|
||||
|
||||
try:
|
||||
contacts2 = paginator2.page(page)
|
||||
except (EmptyPage, InvalidPage):
|
||||
contacts2 = paginator2.page(paginator2.num_pages)
|
||||
|
||||
return render_to_response('jperm/perm_list_ajax.html', locals())
|
||||
|
||||
|
||||
def perm_edit(request):
|
||||
if request.method == 'GET':
|
||||
header_title, path1, path2 = u'缂栬緫鎺堟潈 | Perm Host Edit.', u'jperm', u'perm_edit'
|
||||
|
|
|
@ -80,7 +80,7 @@ def perm_count(group_id):
|
|||
@register.filter(name='group_type_to_str')
|
||||
def group_type_to_str(type_name):
|
||||
group_types = {
|
||||
'P': '绉佹湁缁',
|
||||
'P': '鐢ㄦ埛',
|
||||
'M': '閮ㄩ棬',
|
||||
'A': '鐢ㄦ埛缁',
|
||||
}
|
||||
|
|
|
@ -259,7 +259,6 @@ def group_add(request, group_type_select='A'):
|
|||
msg = ''
|
||||
header_title, path1, path2 = '娣诲姞灞炵粍 | Add Group', 'juser', 'group_add'
|
||||
group_types = {
|
||||
# 'P': '绉佹湁缁',
|
||||
'M': '閮ㄩ棬',
|
||||
'A': '鐢ㄦ埛缁',
|
||||
}
|
||||
|
@ -345,7 +344,6 @@ def group_edit(request):
|
|||
msg = ''
|
||||
header_title, path1, path2 = '淇敼灞炵粍 | Edit Group', 'juser', 'group_edit'
|
||||
group_types = {
|
||||
# 'P': '绉佹湁缁',
|
||||
'M': '閮ㄩ棬',
|
||||
'A': '鐢ㄦ埛缁',
|
||||
}
|
||||
|
@ -367,7 +365,6 @@ def group_edit(request):
|
|||
users_selected = request.POST.getlist('users_selected')
|
||||
group_type = request.POST.get('group_type')
|
||||
group = UserGroup.objects.filter(id=group_id)
|
||||
# return HttpResponse(group_type)
|
||||
group.update(name=group_name, comment=comment, type=group_type)
|
||||
group_update_user(group_id, users_selected)
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
maxHeight: false,
|
||||
scalePhotos: true,
|
||||
scrolling: true,
|
||||
opacity: 0.9,
|
||||
opacity: 0.3,
|
||||
preloading: true,
|
||||
className: false,
|
||||
overlayClose: true,
|
||||
|
@ -418,7 +418,8 @@
|
|||
$overlay.css({
|
||||
opacity: opacity === opacity ? opacity : '',
|
||||
cursor: settings.get('overlayClose') ? 'pointer' : '',
|
||||
visibility: 'visible'
|
||||
visibility: 'visible',
|
||||
// 'background-color': 'black'
|
||||
}).show();
|
||||
|
||||
if (settings.get('closeButton')) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<!-- Mainly scripts -->
|
||||
<script src="/static/js/jquery-2.1.1.js"></script>
|
||||
<script src="/static/js/bootstrap.min.js"></script>
|
||||
{#<script src="/static/js/jquery-2.1.1.js"></script>#}
|
||||
{#<script src="/static/js/bootstrap.min.js"></script>#}
|
||||
<script src="/static/js/plugins/metisMenu/jquery.metisMenu.js"></script>
|
||||
<script src="/static/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
|
||||
<script src="/static/js/bootstrap-dialog.js"></script>
|
||||
|
@ -21,7 +21,8 @@
|
|||
|
||||
<script src="/static/js/base.js"></script>
|
||||
|
||||
|
||||
<!-- pop windows -->
|
||||
<script src="/static/js/jquery.colorbox.js"></script>
|
||||
|
||||
<!-- active menu -->
|
||||
<script>
|
||||
|
@ -29,4 +30,10 @@
|
|||
var str1 = document.location.pathname.split("/")[2];
|
||||
$("#"+str).addClass('active');
|
||||
$("#"+str1).addClass('active');
|
||||
</script>
|
||||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$(".iframe").colorbox({iframe:true, width:"70%", height:"80%"});
|
||||
});
|
||||
</script>
|
|
@ -15,9 +15,6 @@
|
|||
|
||||
|
||||
|
||||
<!-- pop windows -->
|
||||
<script src="/static/js/jquery.colorbox.js"></script>
|
||||
|
||||
<!-- validator js -->
|
||||
<script src="/static/js/validator/jquery.validator.js"></script>
|
||||
<script src="/static/js/validator/zh_CN.js"></script>
|
||||
|
|
|
@ -33,8 +33,20 @@
|
|||
<div class="panel-heading">
|
||||
<div class="panel-options">
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active"><a data-toggle="tab" href="#tab-1">鎺堟潈缂栬緫</a></li>
|
||||
<li class=""><a data-toggle="tab" href="#tab-2">鏌ョ湅鎺堟潈</a></li>
|
||||
<li id="tab1" class="active"><a data-toggle="tab" href="#tab-1">鎺堟潈缂栬緫</a></li>
|
||||
<li id="tab2" class=""><a data-toggle="tab" href="#tab-2">鏌ョ湅鎺堟潈</a></li>
|
||||
<li style="float: right">
|
||||
<form method="get" action="" class="pull-right mail-search">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control input-sm" id="search_input" name="search" placeholder="Search">
|
||||
<div class="input-group-btn">
|
||||
<button id='search_btn' type="button" class="btn btn-sm btn-primary">
|
||||
Search
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -47,13 +59,15 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th class="text-center">缁勫悕</th>
|
||||
<th class="text-center">绫诲瀷</th>
|
||||
<th class="text-center">
|
||||
<span class="text-muted text-xs block">绫诲瀷</span>
|
||||
</th>
|
||||
<th class="text-center">鎴愬憳鏁伴噺</th>
|
||||
<th class="text-center">鎺堟潈鏁伴噺</th>
|
||||
<th class="text-center">鎿嶄綔</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tbody id="perm_edit">
|
||||
{% for group in contacts.object_list %}
|
||||
<tr class="gradeX">
|
||||
<td class="text-center"> {{ group.name }} </td>
|
||||
|
@ -61,7 +75,7 @@
|
|||
<td class="text-center"> {{ group.id|member_count }} </td>
|
||||
<td class="text-center"> {{ group.id|perm_count }} </td>
|
||||
<td class="text-center">
|
||||
<a href="../perm_detail/?id={{ group.id }}" class="iframe btn btn-xs btn-primary">璇︽儏</a>
|
||||
<a title="[ {{ group.name }} 鎺堟潈璇︽儏 ]" href="../perm_detail/?id={{ group.id }}" class="iframe btn btn-xs btn-primary">璇︽儏</a>
|
||||
<a href="../perm_edit/?id={{ group.id }}" class="btn btn-xs btn-info">缂栬緫</a>
|
||||
<a href="../perm_del/?id={{ group.id }}" class="btn btn-xs btn-danger">鍒犻櫎</a>
|
||||
</td>
|
||||
|
@ -120,7 +134,7 @@
|
|||
<th class="text-center">鎿嶄綔</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tbody id="perm_list">
|
||||
{% for user in contacts2.object_list %}
|
||||
<tr class="gradeX">
|
||||
<td class="text-center"> {{ user.name }} </td>
|
||||
|
@ -128,7 +142,7 @@
|
|||
<td class="text-center"> {{ user.username | groups_str }} </td>
|
||||
<td class="text-center"> {{ user.id | perm_asset_count }} </td>
|
||||
<td class="text-center">
|
||||
<a href="../perm_asset_detail/?id={{ user.id }}" class="iframe btn btn-xs btn-primary">璇︽儏</a>
|
||||
<a title="[ {{ user.name }} ] 鎺堟潈璇︽儏" href="../perm_asset_detail/?id={{ user.id }}" class="iframe btn btn-xs btn-primary">璇︽儏</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
@ -192,6 +206,29 @@
|
|||
$(document).ready(function(){
|
||||
$(".iframe").colorbox({iframe:true, width:"70%", height:"70%"});
|
||||
});
|
||||
|
||||
$(document).ready(function(){
|
||||
$('#search_btn').click(function(){
|
||||
if ($('#tab2').attr('class') == 'active'){
|
||||
var tab='tab2'
|
||||
} else {
|
||||
var tab='tab1'
|
||||
}
|
||||
|
||||
var search=$('#search_input').val()
|
||||
|
||||
$.post('/jperm/perm_list_ajax/',
|
||||
{'tab': tab, 'search': search},
|
||||
function(data){
|
||||
if ($('#tab2').attr('class') == 'active'){
|
||||
$('#tab-2').html(data)
|
||||
} else {
|
||||
$('#tab-1').html(data)
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1,132 @@
|
|||
{% load mytags %}
|
||||
{% ifequal tab 'tab1' %}
|
||||
<table class="table table-striped table-bordered table-hover " id="editable" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-center">缁勫悕</th>
|
||||
<th class="text-center">
|
||||
<span class="text-muted text-xs block">绫诲瀷</span>
|
||||
</th>
|
||||
<th class="text-center">鎴愬憳鏁伴噺</th>
|
||||
<th class="text-center">鎺堟潈鏁伴噺</th>
|
||||
<th class="text-center">鎿嶄綔</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="perm_edit">
|
||||
{% for group in contacts.object_list %}
|
||||
<tr class="gradeX">
|
||||
<td class="text-center"> {{ group.name }} </td>
|
||||
<td class="text-center"> {{ group.type|group_type_to_str }} </td>
|
||||
<td class="text-center"> {{ group.id|member_count }} </td>
|
||||
<td class="text-center"> {{ group.id|perm_count }} </td>
|
||||
<td class="text-center">
|
||||
<a title="[ {{ group.name }} ] 鎺堟潈璇︽儏" href="../perm_detail/?id={{ group.id }}" class="iframe btn btn-xs btn-primary">璇︽儏</a>
|
||||
<a href="../perm_edit/?id={{ group.id }}" class="btn btn-xs btn-info">缂栬緫</a>
|
||||
<a href="../perm_del/?id={{ group.id }}" class="btn btn-xs btn-danger">鍒犻櫎</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<div class="dataTables_info" id="editable_info" role="status" aria-live="polite">
|
||||
Showing {{ contacts.start_index }} to {{ contacts.end_index }} of {{ p.count }} entries
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="dataTables_paginate paging_simple_numbers" id="editable_paginate">
|
||||
<ul class="pagination" style="margin-top: 0; float: right">
|
||||
{% if contacts.has_previous %}
|
||||
<li class="paginate_button previous" aria-controls="editable" tabindex="0" id="editable_previous">
|
||||
<a href="?page={{ contacts.previous_page_number }}">Previous</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="paginate_button previous disabled" aria-controls="editable" tabindex="0" id="editable_previous">
|
||||
<a href="#">Previous</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% for page in p.page_range %}
|
||||
{% ifequal offset1 page %}
|
||||
<li class="paginate_button active" aria-controls="editable" tabindex="0"><a href="?page={{ page }}" title="绗瑊{ page }}椤">{{ page }}</a></li>
|
||||
{% else %}
|
||||
<li class="paginate_button" aria-controls="editable" tabindex="0"><a href="?page={{ page }}" title="绗瑊{ page }}椤">{{ page }}</a></li>
|
||||
{% endifequal %}
|
||||
{% endfor %}
|
||||
{% if contacts.has_next %}
|
||||
<li class="paginate_button next" aria-controls="editable" tabindex="0" id="editable_next">
|
||||
<a href="?page={{ contacts.next_page_number }}">Next</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="paginate_button next disabled" aria-controls="editable" tabindex="0" id="editable_next">
|
||||
<a href="#">Next</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<table class="table table-striped table-bordered table-hover " id="editable" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-center">鐢ㄦ埛</th>
|
||||
<th class="text-center">瑙掕壊</th>
|
||||
<th class="text-center">灞炵粍</th>
|
||||
<th class="text-center">涓绘満鏁伴噺</th>
|
||||
<th class="text-center">鎿嶄綔</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="perm_list">
|
||||
{% for user in contacts2.object_list %}
|
||||
<tr class="gradeX">
|
||||
<td class="text-center"> {{ user.name }} </td>
|
||||
<td class="text-center"> {{ user.id | get_role }} </td>
|
||||
<td class="text-center"> {{ user.username | groups_str }} </td>
|
||||
<td class="text-center"> {{ user.id | perm_asset_count }} </td>
|
||||
<td class="text-center">
|
||||
<a title="{{ user.name }} ] 鎺堟潈璇︽儏" href="../perm_asset_detail/?id={{ user.id }}" class="iframe btn btn-xs btn-primary">璇︽儏</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<div class="dataTables_info" id="editable_info" role="status" aria-live="polite">
|
||||
Showing {{ contacts2.start_index }} to {{ contacts2.end_index }} of {{ p2.count }} entries
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="dataTables_paginate paging_simple_numbers" id="editable_paginate">
|
||||
<ul class="pagination" style="margin-top: 0; float: right">
|
||||
{% if contacts2.has_previous %}
|
||||
<li class="paginate_button previous" aria-controls="editable" tabindex="0" id="editable_previous">
|
||||
<a href="?page={{ contacts2.previous_page_number }}">Previous</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="paginate_button previous disabled" aria-controls="editable" tabindex="0" id="editable_previous">
|
||||
<a href="#">Previous</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% for page in p2.page_range %}
|
||||
{% ifequal offset1 page %}
|
||||
<li class="paginate_button active" aria-controls="editable" tabindex="0"><a href="?page={{ page }}" title="绗瑊{ page }}椤">{{ page }}</a></li>
|
||||
{% else %}
|
||||
<li class="paginate_button" aria-controls="editable" tabindex="0"><a href="?page={{ page }}" title="绗瑊{ page }}椤">{{ page }}</a></li>
|
||||
{% endifequal %}
|
||||
{% endfor %}
|
||||
{% if contacts2.has_next %}
|
||||
<li class="paginate_button next" aria-controls="editable" tabindex="0" id="editable_next">
|
||||
<a href="?page={{ contacts2.next_page_number }}">Next</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="paginate_button next disabled" aria-controls="editable" tabindex="0" id="editable_next">
|
||||
<a href="#">Next</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endifequal %}
|
|
@ -53,7 +53,7 @@
|
|||
<td class="text-center"> {{ group.id|member_count }} </td>
|
||||
<td class="text-center"> {{ group.comment }} </td>
|
||||
<td class="text-center">
|
||||
<a href="../group_detail/?id={{ group.id }}" class="iframe btn btn-xs btn-primary">鎴愬憳</a>
|
||||
<a title="[ {{ group.name }} ] 鎴愬憳淇℃伅" href="../group_detail/?id={{ group.id }}" class="iframe btn btn-xs btn-primary">鎴愬憳</a>
|
||||
<a href="../group_edit/?id={{ group.id }}" class="btn btn-xs btn-info">缂栬緫</a>
|
||||
<a href="../group_del/?id={{ group.id }}" class="btn btn-xs btn-danger">鍒犻櫎</a>
|
||||
</td>
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
<td class="text-center">{{ user.id|get_role }}</td>
|
||||
<td class="text-center">{{ user.is_active|bool2str }}</td>
|
||||
<td class="text-center">
|
||||
<a href="../user_detail/?id={{ user.id }}" class="iframe btn btn-xs btn-primary">璇︽儏</a>
|
||||
<a title="[ {{ user.name }} ] 璇︽儏" href="../user_detail/?id={{ user.id }}" class="iframe btn btn-xs btn-primary">璇︽儏</a>
|
||||
<a href="../user_edit/?id={{ user.id }}" class="btn btn-xs btn-info">缂栬緫</a>
|
||||
<a href="../user_del/?id={{ user.id }}" class="btn btn-xs btn-danger">鍒犻櫎</a>
|
||||
</td>
|
||||
|
@ -115,10 +115,5 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$(".iframe").colorbox({iframe:true, width:"70%", height:"70%"});
|
||||
});
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<li id="juser">
|
||||
<a href="#"><i class="fa fa-rebel"></i> <span class="nav-label">鐢ㄦ埛绠$悊</span><span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-second-level">
|
||||
<li id="user_list"><a href="/juser/user_list/">鏌ョ湅鐢ㄦ埛</a></li>
|
||||
<li id="user_list"><a href="/juser/user_list/">鏌ョ湅鐢ㄦ埛<span class="label label-primary pull-right">16/24</span></a></li>
|
||||
<li id="user_add"><a href="/juser/user_add/">娣诲姞鐢ㄦ埛</a></li>
|
||||
<li id="group_list"><a href="/juser/group_list/">鏌ョ湅灞炵粍</a></li>
|
||||
<li id="group_add"><a href="/juser/group_add/">娣诲姞灞炵粍</a></li>
|
||||
|
|
Loading鈥
Reference in New Issue