From b56d73ba9ee110a921758513d7672f3ea6f22f58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=B9=BF?= Date: Mon, 17 Dec 2018 20:09:25 +0800 Subject: [PATCH] Node asset amount (#2192) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [Bugfix] 修复错误 * [Update] 优化用户api --- .../templates/assets/_asset_list_modal.html | 30 +++------ apps/locale/zh/LC_MESSAGES/django.mo | Bin 59786 -> 59907 bytes apps/locale/zh/LC_MESSAGES/django.po | 60 +++++++++++------- apps/users/api/group.py | 4 +- apps/users/models/user.py | 12 ++++ apps/users/serializers/v1.py | 29 +++------ apps/users/templates/users/user_list.html | 24 +++++-- 7 files changed, 84 insertions(+), 75 deletions(-) diff --git a/apps/assets/templates/assets/_asset_list_modal.html b/apps/assets/templates/assets/_asset_list_modal.html index fe50ac2b3..9c3cf0b1d 100644 --- a/apps/assets/templates/assets/_asset_list_modal.html +++ b/apps/assets/templates/assets/_asset_list_modal.html @@ -71,14 +71,14 @@ function initTable2() { function onSelected2(event, treeNode) { var url = asset_table2.ajax.url(); - url = setUrlParam(url, "node_id", treeNode.node_id); - setCookie('node_selected', treeNode.id); + url = setUrlParam(url, "node_id", treeNode.meta.node.id); asset_table2.ajax.url(url); asset_table2.ajax.reload(); } function initTree2() { + var url = '{% url 'api-assets:node-children-tree' %}?assets=0'; var setting = { view: { dblClickExpand: false, @@ -89,29 +89,17 @@ function initTree2() { enable: true } }, + async: { + enable: true, + url: url, + autoParam: ["id=key", "name=n", "level=lv"], + type: 'get' + }, callback: { onSelected: onSelected2 } }; - - var zNodes = []; - $.get("{% url 'api-assets:node-list' %}", function(data, status){ - $.each(data, function (index, value) { - value["node_id"] = value["id"]; - value["id"] = value["tree_id"]; - value["pId"] = value["tree_parent"]; - {#value["open"] = true;#} - if (value["key"] === "0") { - value["open"] = true; - } - value["name"] = value["value"] + ' (' + value['assets_amount'] + ')'; - }); - zNodes = data; - $.fn.zTree.init($("#assetTree2"), setting, zNodes); - zTree2 = $.fn.zTree.getZTreeObj("assetTree2"); - var root = zTree2.getNodes()[0]; - zTree2.expandNode(root); - }); + zTree2 = $.fn.zTree.init($("#assetTree2"), setting); } diff --git a/apps/locale/zh/LC_MESSAGES/django.mo b/apps/locale/zh/LC_MESSAGES/django.mo index a740d8a47f141f91ac011e1c77c31c8805242c43..bbbee180bb402790b79c2a3e0ad2573935d7d393 100644 GIT binary patch delta 17868 zcmYk@2Y6M**2eKo2@psq2_X<#sDaQzLN5Y>R4IaV5TqArQWQiE5PDUS4oZ~{LMTe_ zO5fD+n|9fWfeD3ENf3w!ip0@Wn2fW@1XHvwUP2sy1l5)DoRXK&{<-n8? zp4T*`=iQG}*7K^q<9U;@8Vyk@mLZ!bpI@x1KGJ?}wX^0Wum zcjI2g5aO2@hQSRyFO}!{ynIxGNkn5hEQeXJ2Ij`r$a=ibFcybnB}~BL_!v84?uMRM z0OPR`t}svIHR8Wf<6mmzd7+qushHn;NkuzP_MYcu#$1>h<1jr|MBP{ygRq&|5j9X> zWGCJzb0TU(UttDZfZ_N(>i)yXVSDE=komozsb~SWQAgx8_PjI@irFy-`cKC4H83yv z`l$Q*qE2WsYT;jDMx2A%&?*eT-Ix{+nu+MkMB)k+t@I&wz<*IY_^^rR6~sPR7-wJ~ z+>QM)=6(NKy(LJ>dv4Zi>hj-WS@KU%3y5y!PAUd<0%e6FZ z{1ED0ID?`12Wo+-o4cKdp~i_o9dRV;(G|liSP3;w6U(kMhj=>X z$1SKMyMh|<7mUVdSPb*D;2B~=)POBf_jN%%f{Ca{I1lyK|A2hJyc4K*<~JV|9sOg} z3cZ$Y!XVTUg`+xVM?K@bsEML1E`>U&@~DN>!(7-DHSPe6!BN(}2{qm>Yxfd0%N7St9sPFK`Idt){nj+~Isn?ofl ziB+f_??>Hu*gS1sF_X;4s87jD)KRBs%_(4J)PxOC3u}s6cw1EeUa0X0VR3!_hf^s* zVjXHn*HI^N2X)l{Lk;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`_oF`wJbyUJyl#7(h6dhkVymOovpIiz`9m>1JH*o#i zXHfm7lGsec2uf|r07_@_)hPohL0m*f9C;n@(7!z8Q%WId7fXkE+L3 JySX#u{{cZHoQnVe diff --git a/apps/locale/zh/LC_MESSAGES/django.po b/apps/locale/zh/LC_MESSAGES/django.po index dfce43982..7f42c17be 100644 --- a/apps/locale/zh/LC_MESSAGES/django.po +++ b/apps/locale/zh/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Jumpserver 0.3.3\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-12-17 17:51+0800\n" +"POT-Creation-Date: 2018-12-17 20:06+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: ibuler \n" "Language-Team: Jumpserver team\n" @@ -480,7 +480,7 @@ msgid "Default" msgstr "默认" #: assets/models/cluster.py:36 assets/models/label.py:14 -#: users/models/user.py:420 +#: users/models/user.py:432 msgid "System" msgstr "系统" @@ -617,7 +617,7 @@ msgstr "默认资产组" #: terminal/templates/terminal/command_list.html:72 #: terminal/templates/terminal/session_list.html:33 #: terminal/templates/terminal/session_list.html:71 users/forms.py:314 -#: users/models/user.py:33 users/models/user.py:408 +#: users/models/user.py:33 users/models/user.py:420 #: users/templates/users/user_group_detail.html:78 #: users/templates/users/user_group_list.html:13 users/views/user.py:386 #: xpack/plugins/orgs/forms.py:26 @@ -1021,7 +1021,7 @@ msgstr "测试" #: users/templates/users/user_detail.html:25 #: users/templates/users/user_group_detail.html:28 #: users/templates/users/user_group_list.html:43 -#: users/templates/users/user_list.html:77 +#: users/templates/users/user_list.html:80 #: users/templates/users/user_profile.html:155 #: users/templates/users/user_profile.html:185 #: users/templates/users/user_profile.html:194 @@ -1055,8 +1055,8 @@ msgstr "更新" #: users/templates/users/user_detail.html:30 #: users/templates/users/user_group_detail.html:32 #: users/templates/users/user_group_list.html:45 -#: users/templates/users/user_list.html:81 -#: users/templates/users/user_list.html:85 +#: users/templates/users/user_list.html:84 +#: users/templates/users/user_list.html:88 #: xpack/plugins/cloud/templates/cloud/account_detail.html:29 #: xpack/plugins/cloud/templates/cloud/account_list.html:40 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:32 @@ -1090,7 +1090,7 @@ msgstr "选择节点" #: users/templates/users/user_detail.html:480 #: users/templates/users/user_group_create_update.html:32 #: users/templates/users/user_group_list.html:88 -#: users/templates/users/user_list.html:205 +#: users/templates/users/user_list.html:208 #: users/templates/users/user_profile.html:236 #: xpack/plugins/cloud/templates/cloud/account_create_update.html:34 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_create.html:36 @@ -1175,7 +1175,6 @@ msgstr "快速修改" #: users/templates/users/user_detail.html:144 #: users/templates/users/user_granted_asset.html:46 #: users/templates/users/user_group_granted_asset.html:46 -#: users/templates/users/user_list.html:28 #: users/templates/users/user_profile.html:63 msgid "Active" msgstr "激活中" @@ -1308,7 +1307,7 @@ msgstr "重命名失败,不能更改root节点的名称" #: users/templates/users/user_detail.html:406 #: users/templates/users/user_detail.html:474 #: users/templates/users/user_group_list.html:82 -#: users/templates/users/user_list.html:199 +#: users/templates/users/user_list.html:202 msgid "Are you sure?" msgstr "你确认吗?" @@ -1324,7 +1323,7 @@ msgstr "删除选择资产" #: users/templates/users/user_detail.html:478 #: users/templates/users/user_group_create_update.html:31 #: users/templates/users/user_group_list.html:86 -#: users/templates/users/user_list.html:203 +#: users/templates/users/user_list.html:206 #: xpack/plugins/orgs/templates/orgs/org_create_update.html:32 msgid "Cancel" msgstr "取消" @@ -3330,7 +3329,7 @@ msgstr "添加到用户组" msgid "Public key should not be the same as your old one." msgstr "不能和原来的密钥相同" -#: users/forms.py:114 users/forms.py:249 users/serializers/v1.py:51 +#: users/forms.py:114 users/forms.py:249 users/serializers/v1.py:38 msgid "Not a valid ssh public key" msgstr "ssh密钥不合法" @@ -3457,7 +3456,7 @@ msgstr "Agent" msgid "Date login" msgstr "登录日期" -#: users/models/user.py:32 users/models/user.py:416 +#: users/models/user.py:32 users/models/user.py:428 msgid "Administrator" msgstr "管理员" @@ -3503,7 +3502,7 @@ msgstr "用户来源" msgid "Date password last updated" msgstr "最后更新密码日期" -#: users/models/user.py:419 +#: users/models/user.py:431 msgid "Administrator is the super user of system" msgstr "Administrator是初始的超级管理员" @@ -3924,23 +3923,37 @@ msgstr "用户组删除" msgid "UserGroup Deleting failed." msgstr "用户组删除失败" -#: users/templates/users/user_list.html:200 +#: users/templates/users/user_list.html:28 xpack/plugins/cloud/models.py:52 +#: xpack/plugins/cloud/templates/cloud/account_detail.html:60 +#: xpack/plugins/cloud/templates/cloud/account_list.html:14 +msgid "Validity" +msgstr "账户状态" + +#: users/templates/users/user_list.html:203 msgid "This will delete the selected users !!!" msgstr "删除选中用户 !!!" -#: users/templates/users/user_list.html:209 +#: users/templates/users/user_list.html:212 msgid "User Deleted." msgstr "已被删除" -#: users/templates/users/user_list.html:210 -#: users/templates/users/user_list.html:215 +#: users/templates/users/user_list.html:213 +#: users/templates/users/user_list.html:218 msgid "User Delete" msgstr "删除" -#: users/templates/users/user_list.html:214 +#: users/templates/users/user_list.html:217 msgid "User Deleting failed." msgstr "用户删除失败" +#: users/templates/users/user_list.html:253 +msgid "User is expired" +msgstr "用户已失效" + +#: users/templates/users/user_list.html:256 +msgid "User is inactive" +msgstr "用户已禁用" + #: users/templates/users/user_otp_authentication.html:6 #: users/templates/users/user_password_authentication.html:6 msgid "Authenticate" @@ -4407,12 +4420,6 @@ msgstr "" msgid "Access key secret" msgstr "" -#: xpack/plugins/cloud/models.py:52 -#: xpack/plugins/cloud/templates/cloud/account_detail.html:60 -#: xpack/plugins/cloud/templates/cloud/account_list.html:14 -msgid "Validity" -msgstr "账户状态" - #: xpack/plugins/cloud/models.py:120 msgid "Regions" msgstr "地域" @@ -4606,6 +4613,11 @@ msgstr "创建组织" msgid "Update org" msgstr "更新组织" +#, fuzzy +#~| msgid "Validity" +#~ msgid "Valid" +#~ msgstr "账户状态" + #~ msgid "You can't update the root node name" #~ msgstr "不能修改根节点名称" diff --git a/apps/users/api/group.py b/apps/users/api/group.py index 2b738722c..8cf9fcb0e 100644 --- a/apps/users/api/group.py +++ b/apps/users/api/group.py @@ -6,7 +6,7 @@ from rest_framework_bulk import BulkModelViewSet from rest_framework.pagination import LimitOffsetPagination from ..serializers import UserGroupSerializer, \ - UserGroupUpdateMemeberSerializer + UserGroupUpdateMemberSerializer from ..models import UserGroup from common.permissions import IsOrgAdmin from common.mixins import IDInFilterMixin @@ -26,5 +26,5 @@ class UserGroupViewSet(IDInFilterMixin, BulkModelViewSet): class UserGroupUpdateUserApi(generics.RetrieveUpdateAPIView): queryset = UserGroup.objects.all() - serializer_class = UserGroupUpdateMemeberSerializer + serializer_class = UserGroupUpdateMemberSerializer permission_classes = (IsOrgAdmin,) diff --git a/apps/users/models/user.py b/apps/users/models/user.py index 3a86eab9c..9cdbc9f77 100644 --- a/apps/users/models/user.py +++ b/apps/users/models/user.py @@ -142,6 +142,18 @@ class User(AbstractUser): return True return False + @property + def groups_display(self): + return ' '.join(self.groups.all().values_list('name', flat=True)) + + @property + def role_display(self): + return self.get_role_display() + + @property + def source_display(self): + return self.get_source_display() + @property def is_expired(self): if self.date_expired and self.date_expired < timezone.now(): diff --git a/apps/users/serializers/v1.py b/apps/users/serializers/v1.py index cf0e75d1f..270ab239f 100644 --- a/apps/users/serializers/v1.py +++ b/apps/users/serializers/v1.py @@ -13,31 +13,18 @@ signer = get_signer() class UserSerializer(BulkSerializerMixin, serializers.ModelSerializer): - groups_display = serializers.SerializerMethodField() - groups = serializers.PrimaryKeyRelatedField( - many=True, queryset=UserGroup.objects.all(), required=False - ) class Meta: model = User list_serializer_class = BulkListSerializer - exclude = [ - 'first_name', 'last_name', 'password', '_private_key', - '_public_key', '_otp_secret_key', 'user_permissions' + fields = [ + 'id', 'name', 'username', 'email', 'groups', 'groups_display', + 'role', 'role_display', 'avatar_url', 'wechat', 'phone', + 'otp_level', 'comment', 'source', 'source_display', + 'is_valid', 'is_expired', 'is_active', + 'created_by', 'is_first_login', + 'date_password_last_updated', 'date_expired', ] - # validators = [] - - def get_field_names(self, declared_fields, info): - fields = super(UserSerializer, self).get_field_names(declared_fields, info) - fields.extend([ - 'groups_display', 'get_role_display', - 'get_source_display', 'is_valid' - ]) - return fields - - @staticmethod - def get_groups_display(obj): - return " ".join([group.name for group in obj.groups.all()]) class UserPKUpdateSerializer(serializers.ModelSerializer): @@ -74,7 +61,7 @@ class UserGroupSerializer(BulkSerializerMixin, serializers.ModelSerializer): return [user.name for user in obj.users.all()] -class UserGroupUpdateMemeberSerializer(serializers.ModelSerializer): +class UserGroupUpdateMemberSerializer(serializers.ModelSerializer): users = serializers.PrimaryKeyRelatedField(many=True, queryset=User.objects.all()) class Meta: diff --git a/apps/users/templates/users/user_list.html b/apps/users/templates/users/user_list.html index f2b1804cc..2ebfa6664 100644 --- a/apps/users/templates/users/user_list.html +++ b/apps/users/templates/users/user_list.html @@ -25,7 +25,7 @@ {% trans 'Role' %} {% trans 'User group' %} {% trans 'Source' %} - {% trans 'Active' %} + {% trans 'Validity' %} {% trans 'Action' %} @@ -66,11 +66,14 @@ function initTable() { var innerHtml = cellData.length > 20 ? cellData.substring(0, 20) + '...': cellData; $(td).html('' + innerHtml + ''); }}, - {targets: 6, createdCell: function (td, cellData) { - if (!cellData) { - $(td).html('') - } else { + {targets: 6, createdCell: function (td, cellData, rowData) { + if (cellData) { $(td).html('') + } else if (!rowData.is_active) { + + $(td).html('') + } else if (rowData.is_expired) { + $(td).html('') } }}, {targets: 7, createdCell: function (td, cellData, rowData) { @@ -91,9 +94,9 @@ function initTable() { ajax_url: '{% url "api-users:user-list" %}', columns: [ {data: "id"}, {data: "name" }, {data: "username" }, - {data: "get_role_display", orderable: false}, + {data: "role_display", orderable: false}, {data: "groups_display", orderable: false}, - {data: "get_source_display", orderable: false}, + {data: "source_display", orderable: false}, {data: "is_valid", orderable: false}, {data: "id", orderable: false} ], @@ -246,6 +249,13 @@ $(document).ready(function(){ var uid = $this.data('uid'); var the_url = '{% url "api-users:user-detail" pk=DEFAULT_PK %}'.replace("{{ DEFAULT_PK }}", uid); objectDelete($this, name, the_url); +}).on('click', '.expired', function () { + var msg = '{% trans "User is expired" %}'; + toastr.error(msg) +}).on('click', '.inactive', function () { + var msg = '{% trans 'User is inactive' %}'; + toastr.error(msg) + }) {% endblock %}