perf: 资产添加标签显示,更加易读

pref: 添加翻译
pull/7301/head
ibuler 2021-11-26 15:16:14 +08:00 committed by Jiangjie.Bai
parent a313e011ef
commit de006bc664
4 changed files with 109 additions and 99 deletions

View File

@ -147,7 +147,7 @@ class AssetTaskCreateApi(AssetsTaskMixin, generics.CreateAPIView):
asset = data['asset']
system_users = data.get('system_users')
if not system_users:
system_users = asset.get_all_systemusers()
system_users = asset.get_all_system_users()
if action == 'push_system_user':
task = push_system_users_a_asset.delay(system_users, asset=asset)
elif action == 'test_system_user':

View File

@ -299,6 +299,12 @@ class Asset(AbsConnectivity, AbsHardwareInfo, ProtocolsMixin, NodesRelationMixin
names.append(n.full_value)
return names
def labels_display(self):
names = []
for n in self.labels.all():
names.append(n.name + ':' + n.value)
return names
def as_node(self):
from .node import Node
fake_node = Node()
@ -338,7 +344,7 @@ class Asset(AbsConnectivity, AbsHardwareInfo, ProtocolsMixin, NodesRelationMixin
tree_node = TreeNode(**data)
return tree_node
def get_all_systemusers(self):
def get_all_system_users(self):
from .user import SystemUser
system_user_ids = SystemUser.assets.through.objects.filter(asset=self)\
.values_list('systemuser_id', flat=True)

View File

@ -69,6 +69,9 @@ class AssetSerializer(BulkOrgResourceModelSerializer):
nodes_display = serializers.ListField(
child=serializers.CharField(), label=_('Nodes name'), required=False
)
labels_display = serializers.ListField(
child=serializers.CharField(), label=_('Labels name'), required=False, read_only=True
)
"""
资产的数据结构
@ -91,7 +94,7 @@ class AssetSerializer(BulkOrgResourceModelSerializer):
'domain', 'domain_display', 'platform', 'admin_user', 'admin_user_display'
]
fields_m2m = [
'nodes', 'nodes_display', 'labels',
'nodes', 'nodes_display', 'labels', 'labels_display',
]
read_only_fields = [
'connectivity', 'date_verified', 'cpu_info', 'hardware_info',

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: JumpServer 0.3.3\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-11-19 15:28+0800\n"
"POT-Creation-Date: 2021-11-26 15:16+0800\n"
"PO-Revision-Date: 2021-05-20 10:54+0800\n"
"Last-Translator: ibuler <ibuler@qq.com>\n"
"Language-Team: JumpServer team<ibuler@qq.com>\n"
@ -35,12 +35,12 @@ msgid "Name"
msgstr "名称"
#: acls/models/base.py:27 assets/models/cmd_filter.py:54
#: assets/models/user.py:199
#: assets/models/user.py:200
msgid "Priority"
msgstr "优先级"
#: acls/models/base.py:28 assets/models/cmd_filter.py:54
#: assets/models/user.py:199
#: assets/models/user.py:200
msgid "1-100, the lower the value will be match first"
msgstr "优先级可选范围为 1-100 (数值越小越优先)"
@ -84,7 +84,7 @@ msgstr "登录复核"
#: audits/models.py:74 audits/serializers.py:94 authentication/models.py:47
#: orgs/models.py:19 orgs/models.py:433 perms/models/base.py:45
#: templates/index.html:78 terminal/backends/command/models.py:18
#: terminal/backends/command/serializers.py:12 terminal/models/session.py:38
#: terminal/backends/command/serializers.py:12 terminal/models/session.py:39
#: terminal/notifications.py:90 terminal/notifications.py:138
#: tickets/models/comment.py:17 users/const.py:14 users/models/user.py:169
#: users/models/user.py:751 users/models/user.py:777
@ -128,11 +128,11 @@ msgstr "系统用户"
#: acls/models/login_asset_acl.py:22
#: applications/serializers/attrs/application_category/remote_app.py:37
#: assets/models/asset.py:350 assets/models/authbook.py:18
#: assets/models/gathered_user.py:14 assets/serializers/system_user.py:258
#: assets/models/asset.py:356 assets/models/authbook.py:18
#: assets/models/gathered_user.py:14 assets/serializers/system_user.py:259
#: audits/models.py:38 perms/models/asset_permission.py:99
#: templates/index.html:82 terminal/backends/command/models.py:19
#: terminal/backends/command/serializers.py:13 terminal/models/session.py:40
#: terminal/backends/command/serializers.py:13 terminal/models/session.py:41
#: terminal/notifications.py:89
#: users/templates/users/user_asset_permission.html:40
#: users/templates/users/user_asset_permission.html:70
@ -207,7 +207,7 @@ msgid ""
msgstr "格式为逗号分隔的字符串, * 表示匹配所有. 可选的协议有: {}"
#: acls/serializers/login_asset_acl.py:55 assets/models/asset.py:214
#: assets/models/domain.py:63 assets/models/user.py:200
#: assets/models/domain.py:63 assets/models/user.py:201
#: terminal/serializers/session.py:30 terminal/serializers/storage.py:69
msgid "Protocol"
msgstr "协议"
@ -258,16 +258,16 @@ msgstr "数据库"
msgid "Remote app"
msgstr "远程应用"
#: applications/const.py:28
#: applications/const.py:29
msgid "Custom"
msgstr "自定义"
#: applications/models/account.py:11 assets/models/authbook.py:19
#: assets/models/user.py:291 audits/models.py:39
#: assets/models/user.py:292 audits/models.py:39
#: perms/models/application_permission.py:32
#: perms/models/asset_permission.py:101 templates/_nav.html:45
#: terminal/backends/command/models.py:20
#: terminal/backends/command/serializers.py:14 terminal/models/session.py:42
#: terminal/backends/command/serializers.py:14 terminal/models/session.py:43
#: users/templates/users/_granted_assets.html:27
#: users/templates/users/user_asset_permission.html:42
#: users/templates/users/user_asset_permission.html:76
@ -304,7 +304,7 @@ msgstr "类别"
#: applications/models/application.py:171
#: applications/serializers/application.py:90 assets/models/cmd_filter.py:53
#: assets/models/user.py:198 perms/models/application_permission.py:23
#: assets/models/user.py:199 perms/models/application_permission.py:23
#: perms/serializers/application/user_permission.py:34
#: terminal/models/storage.py:55 terminal/models/storage.py:116
#: tickets/models/flow.py:51 tickets/models/ticket.py:48
@ -366,6 +366,7 @@ msgstr "主机"
#: applications/serializers/attrs/application_type/mysql_workbench.py:22
#: applications/serializers/attrs/application_type/oracle.py:11
#: applications/serializers/attrs/application_type/pgsql.py:11
#: applications/serializers/attrs/application_type/sqlserver.py:11
#: assets/models/asset.py:215 assets/models/domain.py:62
#: settings/serializers/auth/radius.py:15
#: xpack/plugins/cloud/serializers/account_attrs.py:61
@ -380,7 +381,7 @@ msgid "Application path"
msgstr "应用路径"
#: applications/serializers/attrs/application_category/remote_app.py:45
#: assets/serializers/system_user.py:157
#: assets/serializers/system_user.py:158
#: xpack/plugins/change_auth_plan/serializers/asset.py:65
#: xpack/plugins/change_auth_plan/serializers/asset.py:68
#: xpack/plugins/change_auth_plan/serializers/asset.py:71
@ -403,7 +404,6 @@ msgstr "目标URL"
#: authentication/templates/authentication/login.html:151
#: settings/serializers/auth/ldap.py:44 users/forms/profile.py:21
#: users/templates/users/_msg_user_created.html:13
#: users/templates/users/user_otp_check_password.html:15
#: users/templates/users/user_password_update.html:43
#: users/templates/users/user_password_verify.html:18
#: xpack/plugins/change_auth_plan/models/base.py:39
@ -445,7 +445,7 @@ msgstr "基础"
msgid "Charset"
msgstr "编码"
#: assets/models/asset.py:142 assets/serializers/asset.py:175
#: assets/models/asset.py:142 assets/serializers/asset.py:178
#: tickets/models/ticket.py:50
msgid "Meta"
msgstr "元数据"
@ -521,7 +521,7 @@ msgstr "主机名原始"
msgid "Protocols"
msgstr "协议组"
#: assets/models/asset.py:219 assets/models/user.py:190
#: assets/models/asset.py:219 assets/models/user.py:191
#: perms/models/asset_permission.py:100
#: xpack/plugins/change_auth_plan/models/asset.py:44
#: xpack/plugins/gathered_user/models.py:24
@ -534,7 +534,7 @@ msgid "Is active"
msgstr "激活"
#: assets/models/asset.py:223 assets/models/cluster.py:19
#: assets/models/user.py:187 assets/models/user.py:340 templates/_nav.html:44
#: assets/models/user.py:188 assets/models/user.py:341 templates/_nav.html:44
msgid "Admin user"
msgstr "特权用户"
@ -656,7 +656,7 @@ msgstr "系统"
msgid "Default Cluster"
msgstr "默认Cluster"
#: assets/models/cmd_filter.py:33 assets/models/user.py:205
#: assets/models/cmd_filter.py:33 assets/models/user.py:206
msgid "Command filter"
msgstr "命令过滤器"
@ -665,7 +665,7 @@ msgid "Regex"
msgstr "正则表达式"
#: assets/models/cmd_filter.py:41 ops/models/command.py:25
#: terminal/backends/command/serializers.py:15 terminal/models/session.py:49
#: terminal/backends/command/serializers.py:15 terminal/models/session.py:50
#: terminal/templates/terminal/_msg_command_alert.html:12
#: terminal/templates/terminal/_msg_command_execute_alert.html:10
msgid "Command"
@ -765,7 +765,7 @@ msgstr "全称"
msgid "Parent key"
msgstr "ssh私钥"
#: assets/models/node.py:559 assets/serializers/system_user.py:257
#: assets/models/node.py:559 assets/serializers/system_user.py:258
#: users/templates/users/user_asset_permission.html:41
#: users/templates/users/user_asset_permission.html:73
#: users/templates/users/user_asset_permission.html:158
@ -773,75 +773,75 @@ msgstr "ssh私钥"
msgid "Node"
msgstr "节点"
#: assets/models/user.py:181
#: assets/models/user.py:182
msgid "Automatic managed"
msgstr "托管密码"
#: assets/models/user.py:182
#: assets/models/user.py:183
msgid "Manually input"
msgstr "手动输入"
#: assets/models/user.py:186
#: assets/models/user.py:187
msgid "Common user"
msgstr "普通用户"
#: assets/models/user.py:189
#: assets/models/user.py:190
msgid "Username same with user"
msgstr "用户名与用户相同"
#: assets/models/user.py:192 assets/serializers/domain.py:29
#: assets/models/user.py:193 assets/serializers/domain.py:29
#: templates/_nav.html:39
#: terminal/templates/terminal/_msg_command_execute_alert.html:16
#: xpack/plugins/change_auth_plan/models/asset.py:40
msgid "Assets"
msgstr "资产"
#: assets/models/user.py:196 templates/_nav.html:17
#: assets/models/user.py:197 templates/_nav.html:17
#: users/views/profile/pubkey.py:37
msgid "Users"
msgstr "用户管理"
#: assets/models/user.py:197
#: assets/models/user.py:198
msgid "User groups"
msgstr "用户组"
#: assets/models/user.py:201
#: assets/models/user.py:202
msgid "Auto push"
msgstr "自动推送"
#: assets/models/user.py:202
#: assets/models/user.py:203
msgid "Sudo"
msgstr "Sudo"
#: assets/models/user.py:203
#: assets/models/user.py:204
msgid "Shell"
msgstr "Shell"
#: assets/models/user.py:204
#: assets/models/user.py:205
msgid "Login mode"
msgstr "认证方式"
#: assets/models/user.py:206
#: assets/models/user.py:207
msgid "SFTP Root"
msgstr "SFTP根路径"
#: assets/models/user.py:207 authentication/models.py:45
#: assets/models/user.py:208 authentication/models.py:45
msgid "Token"
msgstr ""
#: assets/models/user.py:208
#: assets/models/user.py:209
msgid "Home"
msgstr "家目录"
#: assets/models/user.py:209
#: assets/models/user.py:210
msgid "System groups"
msgstr "用户组"
#: assets/models/user.py:212
#: assets/models/user.py:213
msgid "User switch"
msgstr "用户切换"
#: assets/models/user.py:213
#: assets/models/user.py:214
msgid "Switch from"
msgstr "切换自"
@ -870,15 +870,19 @@ msgstr "网域名称"
msgid "Nodes name"
msgstr "节点名称"
#: assets/serializers/asset.py:104
#: assets/serializers/asset.py:73
msgid "Labels name"
msgstr "标签名称"
#: assets/serializers/asset.py:107
msgid "Hardware info"
msgstr "硬件信息"
#: assets/serializers/asset.py:105
#: assets/serializers/asset.py:108
msgid "Admin user display"
msgstr "特权用户名称"
#: assets/serializers/asset.py:106
#: assets/serializers/asset.py:109
msgid "CPU info"
msgstr "CPU信息"
@ -887,7 +891,7 @@ msgid "private key invalid"
msgstr "密钥不合法"
#: assets/serializers/domain.py:13 assets/serializers/label.py:12
#: assets/serializers/system_user.py:57
#: assets/serializers/system_user.py:58
#: perms/serializers/asset/permission.py:72
msgid "Assets amount"
msgstr "资产数量"
@ -921,68 +925,68 @@ msgstr "密钥指纹"
msgid "Apps amount"
msgstr "应用数量"
#: assets/serializers/system_user.py:56
#: assets/serializers/system_user.py:57
#: perms/serializers/asset/permission.py:73
msgid "Nodes amount"
msgstr "节点数量"
#: assets/serializers/system_user.py:58 assets/serializers/system_user.py:259
#: assets/serializers/system_user.py:59 assets/serializers/system_user.py:260
msgid "Login mode display"
msgstr "认证方式名称"
#: assets/serializers/system_user.py:60
#: assets/serializers/system_user.py:61
msgid "Ad domain"
msgstr "Ad 网域"
#: assets/serializers/system_user.py:61
#: assets/serializers/system_user.py:62
msgid "Is asset protocol"
msgstr "资产协议"
#: assets/serializers/system_user.py:62
#: assets/serializers/system_user.py:63
msgid "Only ssh and automatic login system users are supported"
msgstr "仅支持ssh协议和自动登录的系统用户"
#: assets/serializers/system_user.py:102
#: assets/serializers/system_user.py:103
msgid "Username same with user with protocol {} only allow 1"
msgstr "用户名和用户相同的一种协议只允许存在一个"
#: assets/serializers/system_user.py:112 common/validators.py:14
#: assets/serializers/system_user.py:113 common/validators.py:14
msgid "Special char not allowed"
msgstr "不能包含特殊字符"
#: assets/serializers/system_user.py:121
#: assets/serializers/system_user.py:122
msgid "* Automatic login mode must fill in the username."
msgstr "自动登录模式,必须填写用户名"
#: assets/serializers/system_user.py:136
#: assets/serializers/system_user.py:137
msgid "Path should starts with /"
msgstr "路径应该以 / 开头"
#: assets/serializers/system_user.py:148
#: assets/serializers/system_user.py:149
msgid "Password or private key required"
msgstr "密码或密钥密码需要一个"
#: assets/serializers/system_user.py:162
#: assets/serializers/system_user.py:163
msgid "Only ssh protocol system users are allowed"
msgstr "仅允许ssh协议的系统用户"
#: assets/serializers/system_user.py:166
#: assets/serializers/system_user.py:167
msgid "The protocol must be consistent with the current user: {}"
msgstr "协议必须和当前用户保持一致: {}"
#: assets/serializers/system_user.py:170
#: assets/serializers/system_user.py:171
msgid "Only system users with automatic login are allowed"
msgstr "仅允许自动登录的系统用户"
#: assets/serializers/system_user.py:275
#: assets/serializers/system_user.py:276
msgid "System user name"
msgstr "系统用户名称"
#: assets/serializers/system_user.py:276 orgs/mixins/serializers.py:26
#: assets/serializers/system_user.py:277 orgs/mixins/serializers.py:26
msgid "Org name"
msgstr "组织名称"
#: assets/serializers/system_user.py:285
#: assets/serializers/system_user.py:286
msgid "Asset hostname"
msgstr "资产主机名"
@ -1136,7 +1140,7 @@ msgid "Symlink"
msgstr "建立软链接"
#: audits/models.py:37 audits/models.py:60 audits/models.py:76
#: terminal/models/session.py:45 terminal/models/sharing.py:76
#: terminal/models/session.py:46 terminal/models/sharing.py:76
msgid "Remote addr"
msgstr "远端地址"
@ -1153,7 +1157,7 @@ msgid "Success"
msgstr "成功"
#: audits/models.py:43 ops/models/command.py:30 perms/models/base.py:49
#: terminal/models/session.py:52
#: terminal/models/session.py:53
#: tickets/serializers/ticket/meta/ticket_type/apply_application.py:57
#: tickets/serializers/ticket/meta/ticket_type/apply_asset.py:47
#: xpack/plugins/change_auth_plan/models/base.py:105
@ -1671,15 +1675,15 @@ msgstr "该 时间段 不被允许登录"
msgid "SSO auth closed"
msgstr "SSO 认证关闭了"
#: authentication/errors.py:300 authentication/mixins.py:360
#: authentication/errors.py:300 authentication/mixins.py:359
msgid "Your password is too simple, please change it for security"
msgstr "你的密码过于简单,为了安全,请修改"
#: authentication/errors.py:309 authentication/mixins.py:367
#: authentication/errors.py:309 authentication/mixins.py:366
msgid "You should to change your password before login"
msgstr "登录完成前,请先修改密码"
#: authentication/errors.py:318 authentication/mixins.py:374
#: authentication/errors.py:318 authentication/mixins.py:373
msgid "Your password has expired, please reset before logging in"
msgstr "您的密码已过期,先修改再登录"
@ -1771,11 +1775,11 @@ msgstr "设置手机号码启用"
msgid "Clear phone number to disable"
msgstr "清空手机号码禁用"
#: authentication/mixins.py:315
#: authentication/mixins.py:314
msgid "The MFA type ({}) is not enabled"
msgstr "该 MFA ({}) 方式没有启用"
#: authentication/mixins.py:350
#: authentication/mixins.py:349
msgid "Please change your password"
msgstr "请修改密码"
@ -1976,7 +1980,7 @@ msgid "MFA Auth"
msgstr "MFA 多因子认证"
#: authentication/templates/authentication/login_mfa.html:19
#: users/templates/users/user_otp_check_password.html:18
#: users/templates/users/user_otp_check_password.html:12
#: users/templates/users/user_otp_enable_bind.html:24
#: users/templates/users/user_otp_enable_install_app.html:29
#: users/templates/users/user_verify_mfa.html:30
@ -4295,15 +4299,15 @@ msgstr "不支持批量创建"
msgid "Storage is invalid"
msgstr "存储无效"
#: terminal/models/session.py:44 terminal/models/sharing.py:81
#: terminal/models/session.py:45 terminal/models/sharing.py:81
msgid "Login from"
msgstr "登录来源"
#: terminal/models/session.py:48
#: terminal/models/session.py:49
msgid "Replay"
msgstr "回放"
#: terminal/models/session.py:53
#: terminal/models/session.py:54
msgid "Date end"
msgstr "结束日期"
@ -5400,19 +5404,7 @@ msgstr "不包含"
#: users/templates/users/user_otp_check_password.html:6
msgid "Enable OTP"
msgstr "启用 MFA (OTP)"
#: users/templates/users/user_otp_check_password.html:10
msgid "Please enter the password of"
msgstr "请输入"
#: users/templates/users/user_otp_check_password.html:10
msgid "account"
msgstr "账户"
#: users/templates/users/user_otp_check_password.html:10
msgid "to complete the binding operation"
msgstr "的密码完成绑定操作"
msgstr "启用 MFA(OTP)"
#: users/templates/users/user_otp_enable_bind.html:6
msgid "Bind one-time password authenticator"
@ -5422,12 +5414,12 @@ msgstr "绑定MFA验证器"
msgid ""
"Use the MFA Authenticator application to scan the following qr code for a 6-"
"bit verification code"
msgstr "使用MFA验证器应用扫描以下二维码获取6位验证码"
msgstr "使用 MFA 验证器应用扫描以下二维码获取6位验证码"
#: users/templates/users/user_otp_enable_bind.html:22
#: users/templates/users/user_verify_mfa.html:27
msgid "Six figures"
msgstr "6位数字"
msgstr "6 位数字"
#: users/templates/users/user_otp_enable_install_app.html:6
msgid "Install app"
@ -5437,7 +5429,7 @@ msgstr "安装应用"
msgid ""
"Download and install the MFA Authenticator application on your phone or "
"applet of WeChat"
msgstr "请在手机端或微信小程序下载并安装MFA验证器应用"
msgstr "请在手机端或微信小程序下载并安装 MFA 验证器应用"
#: users/templates/users/user_otp_enable_install_app.html:18
msgid "Android downloads"
@ -5476,33 +5468,33 @@ msgstr "账号保护已开启,请根据提示完成以下操作"
msgid "Open MFA Authenticator and enter the 6-bit dynamic code"
msgstr "请打开 MFA 验证器,输入 6 位动态码"
#: users/views/profile/otp.py:80
#: users/views/profile/otp.py:86
msgid "Already bound"
msgstr "已经绑定"
#: users/views/profile/otp.py:81
#: users/views/profile/otp.py:87
msgid "MFA already bound, disable first, then bound"
msgstr "MFA (OTP) 已经绑定,请先禁用,再绑定"
msgstr "MFA(OTP) 已经绑定,请先禁用,再绑定"
#: users/views/profile/otp.py:108
#: users/views/profile/otp.py:114
msgid "OTP enable success"
msgstr "MFA (OTP) 启用成功"
msgstr "MFA(OTP) 启用成功"
#: users/views/profile/otp.py:109
#: users/views/profile/otp.py:115
msgid "OTP enable success, return login page"
msgstr "MFA (OTP) 启用成功,返回到登录页面"
msgstr "MFA(OTP) 启用成功,返回到登录页面"
#: users/views/profile/otp.py:151
#: users/views/profile/otp.py:157
msgid "Disable OTP"
msgstr "禁用虚拟 MFA(OTP)"
#: users/views/profile/otp.py:157
#: users/views/profile/otp.py:163
msgid "OTP disable success"
msgstr "MFA (OTP) 禁用成功"
msgstr "MFA(OTP) 禁用成功"
#: users/views/profile/otp.py:158
#: users/views/profile/otp.py:164
msgid "OTP disable success, return login page"
msgstr "MFA (OTP) 禁用成功,返回登录页面"
msgstr "MFA(OTP) 禁用成功,返回登录页面"
#: users/views/profile/password.py:36 users/views/profile/password.py:41
msgid "Password invalid"
@ -6136,3 +6128,12 @@ msgstr "旗舰版"
#: xpack/plugins/license/models.py:77
msgid "Community edition"
msgstr "社区版"
#~ msgid "Please enter the password of"
#~ msgstr "请输入"
#~ msgid "account"
#~ msgstr "账户"
#~ msgid "to complete the binding operation"
#~ msgstr "的密码完成绑定操作"