feat: 命令过滤器支持多维度绑定

This commit is contained in:
Michael Bai 2021-12-09 17:19:04 +08:00 committed by 老广
parent 3eff78817b
commit 90adcaf843
6 changed files with 84 additions and 5 deletions

View File

@ -243,6 +243,7 @@
"ReLogin": "重新登录" "ReLogin": "重新登录"
}, },
"common": { "common": {
"Correlation": "关联",
"UserLoginLimit": "用户登录限制", "UserLoginLimit": "用户登录限制",
"IPLoginLimit": "IP 登录限制", "IPLoginLimit": "IP 登录限制",
"Setting": "设置", "Setting": "设置",

View File

@ -237,6 +237,7 @@
"ReLogin": "Re-Login" "ReLogin": "Re-Login"
}, },
"common": { "common": {
"Correlation": "Correlation",
"UserLoginLimit": "User login limit", "UserLoginLimit": "User login limit",
"IPLoginLimit": "IP login limit", "IPLoginLimit": "IP login limit",
"Setting": "Setting", "Setting": "Setting",

View File

@ -4,6 +4,7 @@
<script> <script>
import GenericCreateUpdatePage from '@/layout/components/GenericCreateUpdatePage' import GenericCreateUpdatePage from '@/layout/components/GenericCreateUpdatePage'
import AssetSelect from '@/components/AssetSelect/index'
export default { export default {
name: 'CommandFilterCreateUpdate', name: 'CommandFilterCreateUpdate',
components: { GenericCreateUpdatePage }, components: { GenericCreateUpdatePage },
@ -13,9 +14,66 @@ export default {
}, },
fields: [ fields: [
[this.$t('common.Basic'), ['name', 'comment']] [this.$t('common.Basic'), ['name']],
[this.$t('common.Correlation'), ['users', 'user_groups', 'assets', 'applications', 'system_users']],
[this.$t('common.Other'), ['is_active', 'comment']]
], ],
fieldsMeta: { fieldsMeta: {
users: {
el: {
value: [],
ajax: {
url: '/api/v1/users/users/?fields_size=mini',
transformOption: (item) => {
return { label: item.name + '(' + item.username + ')', value: item.id }
}
}
}
},
user_groups: {
el: {
value: [],
url: '/api/v1/users/groups/'
}
},
assets: {
type: 'assetSelect',
component: AssetSelect,
label: this.$t('perms.Asset'),
rules: [{
required: false
}],
el: {
value: []
}
},
applications: {
label: this.$t('assets.Applications'),
el: {
value: [],
ajax: {
url: `/api/v1/applications/applications/?category=db`,
transformOption: (item) => {
return { label: item.name + ' (' + item.type_display + ')', value: item.id }
}
}
}
},
system_users: {
el: {
value: [],
ajax: {
url: `/api/v1/assets/system-users/?protocol__in=ssh,telnet,mysql,postgresql,mariadb,oracle,sqlserver,k8s`,
transformOption: (item) => {
if (this.$route.query.type === 'k8s') {
return { label: item.name, value: item.id }
}
const username = item.username || '*'
return { label: item.name + '(' + username + ')', value: item.id }
}
}
}
}
}, },
url: '/api/v1/assets/cmd-filters/' url: '/api/v1/assets/cmd-filters/'

View File

@ -20,7 +20,7 @@ export default {
return { return {
tableConfig: { tableConfig: {
url: `/api/v1/assets/cmd-filters/${this.object.id}/rules/`, url: `/api/v1/assets/cmd-filters/${this.object.id}/rules/`,
columns: ['type', 'content', 'priority', 'action', 'comment', 'actions'], columns: ['type', 'content', 'priority', 'action', 'comment', 'pattern', 'actions'],
columnsMeta: { columnsMeta: {
type: { type: {
width: '100px' width: '100px'

View File

@ -15,12 +15,12 @@ export default {
tableConfig: { tableConfig: {
url: '/api/v1/assets/cmd-filters/', url: '/api/v1/assets/cmd-filters/',
columns: [ columns: [
'name', 'rules', 'system_users', 'is_active', 'name', 'rules', 'users', 'user_groups', 'assets', 'applications', 'system_users', 'is_active',
'created_by', 'date_created', 'comment', 'org_name', 'actions' 'created_by', 'date_created', 'comment', 'org_name', 'actions'
], ],
columnsShow: { columnsShow: {
min: ['name', 'actions'], min: ['name', 'actions'],
default: ['name', 'rules', 'system_users', 'comment', 'actions'] default: ['name', 'rules', 'comment', 'actions']
}, },
columnsMeta: { columnsMeta: {
rules: { rules: {
@ -38,6 +38,26 @@ export default {
date_created: { date_created: {
label: this.$t('users.DateJoined') label: this.$t('users.DateJoined')
}, },
users: {
formatter: function(row, col, cell) {
return cell.length
}
},
user_groups: {
formatter: function(row, col, cell) {
return cell.length
}
},
assets: {
formatter: function(row, col, cell) {
return cell.length
}
},
applications: {
formatter: function(row, col, cell) {
return cell.length
}
},
system_users: { system_users: {
label: this.$t('assets.SystemUsers'), label: this.$t('assets.SystemUsers'),
formatter: DetailFormatter, formatter: DetailFormatter,

View File

@ -6,7 +6,6 @@
<el-col :span="10"> <el-col :span="10">
<QuickActions type="primary" :actions="quickActions" /> <QuickActions type="primary" :actions="quickActions" />
<RelationCard <RelationCard
v-if="object.protocol === 'ssh'"
ref="RelationCard" ref="RelationCard"
v-bind="nodeRelationConfig" v-bind="nodeRelationConfig"
type="info" type="info"