From 46cc593a9ec9d121c01647c0af5cc6e749eea7f9 Mon Sep 17 00:00:00 2001 From: guanghongwei Date: Tue, 3 Feb 2015 23:03:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9D=83=E9=99=90=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jperm/urls.py | 1 + jperm/views.py | 35 ++++++++ jumpserver/templatetags/mytags.py | 2 +- juser/views.py | 3 - static/js/jquery.colorbox.js | 5 +- templates/foot_script.html | 13 ++- templates/head_script.html | 3 - templates/jperm/perm_list.html | 51 +++++++++-- templates/jperm/perm_list_ajax.html | 132 ++++++++++++++++++++++++++++ templates/juser/group_list.html | 2 +- templates/juser/user_list.html | 7 +- templates/nav.html | 2 +- 12 files changed, 229 insertions(+), 27 deletions(-) create mode 100644 templates/jperm/perm_list_ajax.html diff --git a/jperm/urls.py b/jperm/urls.py index 80d8f8630..89e6c05f1 100644 --- a/jperm/urls.py +++ b/jperm/urls.py @@ -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'), diff --git a/jperm/views.py b/jperm/views.py index b9da25c6b..b0d18201e 100644 --- a/jperm/views.py +++ b/jperm/views.py @@ -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' diff --git a/jumpserver/templatetags/mytags.py b/jumpserver/templatetags/mytags.py index 20ba40fd4..d64387d24 100644 --- a/jumpserver/templatetags/mytags.py +++ b/jumpserver/templatetags/mytags.py @@ -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': '用户组', } diff --git a/juser/views.py b/juser/views.py index a93d267b4..be12c67dc 100644 --- a/juser/views.py +++ b/juser/views.py @@ -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) diff --git a/static/js/jquery.colorbox.js b/static/js/jquery.colorbox.js index c0348849e..162e2e9fd 100755 --- a/static/js/jquery.colorbox.js +++ b/static/js/jquery.colorbox.js @@ -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')) { diff --git a/templates/foot_script.html b/templates/foot_script.html index acab8b8a3..f10a44698 100644 --- a/templates/foot_script.html +++ b/templates/foot_script.html @@ -1,6 +1,6 @@ - - +{##} +{##} @@ -21,7 +21,8 @@ - + + + + \ No newline at end of file diff --git a/templates/head_script.html b/templates/head_script.html index c452e8d37..f87c0f370 100644 --- a/templates/head_script.html +++ b/templates/head_script.html @@ -15,9 +15,6 @@ - - - diff --git a/templates/jperm/perm_list.html b/templates/jperm/perm_list.html index dd8436d6c..a9b3f9d20 100644 --- a/templates/jperm/perm_list.html +++ b/templates/jperm/perm_list.html @@ -33,8 +33,20 @@
@@ -47,13 +59,15 @@ 组名 - 类型 + + 类型 + 成员数量 授权数量 操作 - + {% for group in contacts.object_list %} {{ group.name }} @@ -61,7 +75,7 @@ {{ group.id|member_count }} {{ group.id|perm_count }} - 详情 + 详情 编辑 删除 @@ -120,7 +134,7 @@ 操作 - + {% for user in contacts2.object_list %} {{ user.name }} @@ -128,7 +142,7 @@ {{ user.username | groups_str }} {{ user.id | perm_asset_count }} - 详情 + 详情 {% 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) + } + }) + + }) + }) {% endblock %} \ No newline at end of file diff --git a/templates/jperm/perm_list_ajax.html b/templates/jperm/perm_list_ajax.html new file mode 100644 index 000000000..64a15a0f2 --- /dev/null +++ b/templates/jperm/perm_list_ajax.html @@ -0,0 +1,132 @@ +{% load mytags %} +{% ifequal tab 'tab1' %} + + + + + + + + + + + + {% for group in contacts.object_list %} + + + + + + + + {% endfor %} + +
组名 + 类型 + 成员数量授权数量操作
{{ group.name }} {{ group.type|group_type_to_str }} {{ group.id|member_count }} {{ group.id|perm_count }} + 详情 + 编辑 + 删除 +
+
+
+
+ Showing {{ contacts.start_index }} to {{ contacts.end_index }} of {{ p.count }} entries +
+
+
+
+
    + {% if contacts.has_previous %} + + {% else %} + + {% endif %} + {% for page in p.page_range %} + {% ifequal offset1 page %} +
  • {{ page }}
  • + {% else %} +
  • {{ page }}
  • + {% endifequal %} + {% endfor %} + {% if contacts.has_next %} + + {% else %} + + {% endif %} +
+
+
+
+{% else %} + + + + + + + + + + + + {% for user in contacts2.object_list %} + + + + + + + + {% endfor %} + +
用户角色属组主机数量操作
{{ user.name }} {{ user.id | get_role }} {{ user.username | groups_str }} {{ user.id | perm_asset_count }} + 详情 +
+
+
+
+ Showing {{ contacts2.start_index }} to {{ contacts2.end_index }} of {{ p2.count }} entries +
+
+
+
+
    + {% if contacts2.has_previous %} + + {% else %} + + {% endif %} + {% for page in p2.page_range %} + {% ifequal offset1 page %} +
  • {{ page }}
  • + {% else %} +
  • {{ page }}
  • + {% endifequal %} + {% endfor %} + {% if contacts2.has_next %} + + {% else %} + + {% endif %} +
+
+
+
+{% endifequal %} \ No newline at end of file diff --git a/templates/juser/group_list.html b/templates/juser/group_list.html index 0a045d8f7..50cb1c795 100644 --- a/templates/juser/group_list.html +++ b/templates/juser/group_list.html @@ -53,7 +53,7 @@ {{ group.id|member_count }} {{ group.comment }} - 成员 + 成员 编辑 删除 diff --git a/templates/juser/user_list.html b/templates/juser/user_list.html index e7efcd216..3855a786e 100644 --- a/templates/juser/user_list.html +++ b/templates/juser/user_list.html @@ -63,7 +63,7 @@ {{ user.id|get_role }} {{ user.is_active|bool2str }} - 详情 + 详情 编辑 删除 @@ -115,10 +115,5 @@ - {% endblock %} diff --git a/templates/nav.html b/templates/nav.html index f4c069580..29cc7ff9b 100644 --- a/templates/nav.html +++ b/templates/nav.html @@ -14,7 +14,7 @@
  • 用户管理