Merge pull request #13 from jumpserver/jym_dev

[Update]  资产授权列表显示expand值
This commit is contained in:
八千流
2020-04-09 21:16:47 +08:00
committed by GitHub
6 changed files with 101 additions and 37 deletions

View File

@@ -42,7 +42,9 @@
v-else-if="data.type === 'checkbox-group'"
:key="opt.label"
v-bind="opt"
/>
>
{{ opt.value }}
</el-checkbox>
<!-- WARNING: radio label 属性来表示 value 的含义 -->
<!-- FYI: radio value 属性可以在没有 radio-group 时用来关联到同一个 v-model -->
<el-radio

View File

@@ -0,0 +1,37 @@
<template>
<div style="border: none; background: none;">
<span v-show="row.users.length"><label>{{ this.$t('perms.User') }}:</label>{{ format(row.users) }}<br></span>
<span v-show="row.user_groups.length"><label>{{ this.$t('perms.UserGroups') }}:</label>{{ format(row.user_groups) }}<br></span>
<span v-show="row.assets.length"><label>{{ this.$t('perms.Asset') }}:</label>{{ format(row.assets) }}<br></span>
<span v-show="row.nodes.length"><label>{{ this.$t('perms.Node') }}</label>:{{ format(row.nodes) }}<br></span>
<span v-show="row.system_users.length"><label>{{ this.$t('perms.SystemUser') }}:</label>{{ format(row.system_users) }}<br></span>
<span v-show="row.actions.length"><label>{{ this.$t('perms.Actions') }}:</label>{{ format(row.actions) }}</span>
</div>
</template>
<script>
import BaseFormatter from '@/components/ListTable/formatters/base'
export default {
name: 'ExpandAssetPermissionFormatter',
extends: BaseFormatter,
methods: {
format(val) {
if (val instanceof Array) {
return val.join(',')
}
return val
}
}
}
</script>
<style scoped>
label {
display: inline-block;
max-width: 100%;
margin: 5px;
font-weight: 700;
}
</style>

View File

@@ -4,6 +4,9 @@ import BooleanFormatter from './ChoicesFormatter'
import ActionsFormatter from './ActionsFormatter'
import ExpandPreFormatter from './ExpandPreFormatter'
import LengthFormatter from './LengthFormatter'
import RouterFormatter from './RouterFormatter'
import OutputExpandFormatter from './OutputExpandFormatter'
import ExpandAssetPermissionFormatter from './ExpandAssetPermissionFormatter'
export default {
DetailFormatter,
@@ -11,7 +14,10 @@ export default {
BooleanFormatter,
ActionsFormatter,
ExpandPreFormatter,
LengthFormatter
LengthFormatter,
RouterFormatter,
OutputExpandFormatter,
ExpandAssetPermissionFormatter
}
export {
@@ -20,5 +26,8 @@ export {
BooleanFormatter,
ActionsFormatter,
ExpandPreFormatter,
LengthFormatter
LengthFormatter,
RouterFormatter,
OutputExpandFormatter,
ExpandAssetPermissionFormatter
}

View File

@@ -322,41 +322,22 @@ const cn = {
'app_path': '应用路径'
},
perms: {
'asset_permission': '资产授权',
'asset_permission_list': '资产授权列表',
'asset_permission_detail': '资产授权详情',
'create_asset_permission': '创建资产授权规则',
'update_asset_permission': '更新资产授权规则',
'Asset permissions': '资产授权',
'name': '名称',
'user': '用户',
'userGroup': '用户组',
'asset': '资产',
'node': '节点',
'systemUser': '系统用户',
'validity': '有效',
'action': '动作',
'update': '更新',
'delete': '删除',
'search': '搜索',
'user_count': '用户数量',
'user_group_count': '用户组数量',
'asset_count': '资产数量',
'node_count': '节点数量',
'system_user_count': '系统用户数量',
'date_start': '开始日期',
'date_expired': '失效日期',
'date_created': '创建日期',
'created_by': '创建者',
'comment': '备注',
'quick_update': '快速更新',
'active': '激活中',
'users_and_user_groups': '用户或用户组',
'assets_and_node': '资产或节点',
'RefreshPermissionCache': '刷新授权缓存',
'ReFreshSuccess': '刷新成功',
'ReFreshFail': '刷新失败',
'All': '全部',
'Connect': '连接',
'UpDownload': '上传下载',
'UploadFile': '上传文件',
'DownloadFile': '下载文件',
'Basic': '基本',
'User': '用户',
'Asset': '资产',
'Actions': '动作',
'UserGroups': '用户组',
'Node': '节点',
'SystemUser': '系统用户',
//
'RemoteApp': '远程应用',
//

View File

@@ -11,6 +11,8 @@ export default {
data() {
return {
form: {
is_active: true,
actions: ['all', 'connect', 'updownload', 'upload_file', 'download_file'],
date_expired: '2099-12-31 00:00:00 +0800'
},
fields: [
@@ -53,7 +55,15 @@ export default {
}
},
actions: {
label: this.$t('perms.Actions')
label: this.$t('perms.Actions'),
type: 'checkbox-group',
options: [
{ label: 'all', value: this.$t('perms.All') },
{ label: 'connect', value: this.$t('perms.Connect') },
{ label: 'updownload', value: this.$t('perms.UpDownload') },
{ label: 'upload_file', value: this.$t('perms.UploadFile') },
{ label: 'download_file', value: this.$t('perms.DownloadFile') }
]
},
is_active: {
type: 'checkbox'

View File

@@ -4,7 +4,7 @@
<script>
import { GenericListPage } from '@/layout/components'
import { LengthFormatter } from '@/components/ListTable/formatters/index'
import { LengthFormatter, ExpandAssetPermissionFormatter } from '@/components/ListTable/formatters/index'
export default {
components: {
@@ -14,8 +14,13 @@ export default {
return {
tableConfig: {
url: '/api/v1/perms/asset-permissions/',
columns: ['name', 'users', 'user_groups', 'assets', 'nodes', 'system_users', 'is_active', 'actions'],
hasSelection: false,
columns: ['expand', 'name', 'users', 'user_groups', 'assets', 'nodes', 'system_users', 'is_active', 'actions'],
columnsMeta: {
expand: {
type: 'expand',
formatter: ExpandAssetPermissionFormatter
},
users: {
formatter: LengthFormatter
},
@@ -36,8 +41,28 @@ export default {
headerActions: {
hasDelete: false,
hasUpdate: false,
createRoute: 'AssetPermissionCreate'
hasBulkDelete: false,
createRoute: 'AssetPermissionCreate',
extraActions: [
{
name: 'RefreshPermissionCache',
title: this.$t('perms.RefreshPermissionCache'),
type: 'primary',
has: true,
callback: this.HandleRefreshPermissionCache
}
]
}
}
},
methods: {
HandleRefreshPermissionCache() {
const url = '/api/v1/perms/asset-permissions/cache/refresh/'
this.$axios.get(url).then(res => {
this.$message.success(this.$t('perms.ReFreshSuccess'))
}).catch(err => {
this.$message.error(this.$t('perms.ReFreshFail') + ':' + err)
})
}
}
}