perf: 优化用户列表和用户创建的角色 (#291)

* perf: 优化用户角色

Closes https://github.com/orgs/jumpserver/projects/1

* perf: 优化用户角色

Closes https://github.com/orgs/jumpserver/projects/1

Co-authored-by: OrangeM21 <orangemtony@gmail.com>
This commit is contained in:
fit2bot 2020-08-11 11:06:22 +08:00 committed by GitHub
parent 8f00dbf23e
commit 62a6d11332
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 5 deletions

View File

@ -794,6 +794,8 @@
"ResetAndDownloadSSHKey": "重置并下载密钥", "ResetAndDownloadSSHKey": "重置并下载密钥",
"ResetPublicKeyAndDownload": "重置并下载SSH密钥", "ResetPublicKeyAndDownload": "重置并下载SSH密钥",
"Role": "角色", "Role": "角色",
"SuperRole": "超级角色",
"OrgRole": "组织角色",
"SSHKey": "SSH公钥", "SSHKey": "SSH公钥",
"SSHKeySetting": "SSH公钥设置", "SSHKeySetting": "SSH公钥设置",
"Secure": "安全", "Secure": "安全",

View File

@ -791,6 +791,8 @@
"ResetAndDownloadSSHKey": "Reset and download SSH Key", "ResetAndDownloadSSHKey": "Reset and download SSH Key",
"ResetPublicKeyAndDownload": "Reset public key and download", "ResetPublicKeyAndDownload": "Reset public key and download",
"Role": "Role", "Role": "Role",
"SuperRole": "Super role",
"OrgRole": "Org role",
"SSHKey": "SSH Key", "SSHKey": "SSH Key",
"SSHKeySetting": "SSH Key setting", "SSHKeySetting": "SSH Key setting",
"Secure": "Secure", "Secure": "Secure",

View File

@ -9,6 +9,7 @@
import { GenericCreateUpdatePage } from '@/layout/components' import { GenericCreateUpdatePage } from '@/layout/components'
import UserPassword from '@/components/UserPassword' import UserPassword from '@/components/UserPassword'
import { getDayFuture } from '@/utils/common' import { getDayFuture } from '@/utils/common'
import { mapGetters } from 'vuex'
export default { export default {
components: { components: {
@ -21,12 +22,13 @@ export default {
mfa_level: 0, mfa_level: 0,
source: 'local', source: 'local',
role: 'User', role: 'User',
org_role: 'User',
date_expired: getDayFuture(36500, new Date()).toISOString() date_expired: getDayFuture(36500, new Date()).toISOString()
}, },
fields: [ fields: [
[this.$t('users.Account'), ['name', 'username', 'email', 'groups']], [this.$t('users.Account'), ['name', 'username', 'email', 'groups']],
[this.$t('users.Authentication'), ['password_strategy', 'update_password', 'password', 'set_public_key', 'public_key', 'mfa_level', 'source']], [this.$t('users.Authentication'), ['password_strategy', 'update_password', 'password', 'set_public_key', 'public_key', 'mfa_level', 'source']],
[this.$t('users.Secure'), ['role', 'date_expired']], [this.$t('users.Secure'), ['role', 'org_role', 'date_expired']],
[this.$t('common.Other'), ['phone', 'wechat', 'comment']] [this.$t('common.Other'), ['phone', 'wechat', 'comment']]
], ],
url: '/api/v1/users/users/', url: '/api/v1/users/users/',
@ -73,6 +75,18 @@ export default {
return !formValue.set_public_key return !formValue.set_public_key
} }
}, },
role: {
label: this.$t('users.SuperRole')
},
org_role: {
label: this.$t('users.OrgRole'),
hidden: () => {
return !this.publicSettings.XPACK_LICENSE_IS_VALID
},
el: {
// disabled: () => this.currentOrgIsDefault
}
},
groups: { groups: {
el: { el: {
multiple: true, multiple: true,
@ -85,6 +99,12 @@ export default {
} }
} }
}, },
computed: {
...mapGetters(['publicSettings', 'currentOrg']),
currentOrgIsDefault() {
return this.currentOrg.id === 'DEFAULT' || this.currentOrg.id === ''
}
},
methods: { methods: {
cleanFormValue(value) { cleanFormValue(value) {
const method = this.getMethod() const method = this.getMethod()

View File

@ -27,7 +27,7 @@ export default {
tableConfig: { tableConfig: {
url: '/api/v1/users/users/', url: '/api/v1/users/users/',
columns: [ columns: [
'name', 'username', 'groups_display', 'role', 'source', 'is_valid', 'actions' 'name', 'username', 'groups_display', 'total_role_display', 'source', 'is_valid', 'actions'
], ],
columnsMeta: { columnsMeta: {
username: { username: {
@ -36,9 +36,9 @@ export default {
source: { source: {
width: '120px' width: '120px'
}, },
// role: { total_role_display: {
// width: '100px' label: this.$t('users.Role')
// }, },
groups_display: { groups_display: {
width: '200px', width: '200px',
showOverflowTooltip: true showOverflowTooltip: true