mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-19 17:54:37 +00:00
[fix]完成命令过滤
This commit is contained in:
@@ -196,7 +196,7 @@ export default {
|
||||
data = this.iAjax.processResults.bind(this)(data)
|
||||
data.results.forEach((v) => {
|
||||
if (!this.hasObjects.find((item) => item.value === v.value)) {
|
||||
this.HasObjects.push(v)
|
||||
this.iHasObjects.push(v)
|
||||
}
|
||||
})
|
||||
// 如果还有其它页,继续获取, 如果没有就停止
|
||||
|
@@ -308,6 +308,7 @@
|
||||
"create_command_filter":"创建命令过滤器",
|
||||
"update_command_filter":"更新命令过滤器",
|
||||
"commandFilterDetail":"命令过滤器详情",
|
||||
"commandFilterRules": "命令过滤器规则",
|
||||
"rules":"规则",
|
||||
"systemUser":"系统用户",
|
||||
"date_updated":"更新日期",
|
||||
|
@@ -4,10 +4,10 @@
|
||||
<DetailCard :items="detailCardItems" />
|
||||
</el-col>
|
||||
<el-col :span="10">
|
||||
<RelationCard v-bind="systemUserRelationConfig" />
|
||||
<RelationCard ref="systemUserRelation" v-bind="systemUserRelationConfig" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>a
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import DetailCard from '@/components/DetailCard'
|
||||
@@ -31,27 +31,51 @@ export default {
|
||||
icon: 'fa-info',
|
||||
title: this.$t('perms.Add System User to this permission'),
|
||||
objectsAjax: {
|
||||
url: '/api/v1/assets/system-users/'
|
||||
url: '/api/v1/assets/system-users/',
|
||||
processResults: (data) => {
|
||||
let results = data.results
|
||||
const notUndefined = anyValue => typeof anyValue !== 'undefined'
|
||||
results = results.map((item) => {
|
||||
if (item.protocol === 'ssh' || item.protocol === 'telnet') {
|
||||
return { label: `${item.name}(${item.username})`, value: item.id }
|
||||
}
|
||||
}).filter(notUndefined)
|
||||
const more = !!data.next
|
||||
return { results: results, pagination: more, total: data.count }
|
||||
}
|
||||
},
|
||||
hasObjectsId: this.object.system_users,
|
||||
performAdd: (items) => {
|
||||
// TODO: Orange API 待修复
|
||||
const relationUrl = `/api/v1/assets/cmd-filters/`
|
||||
const objectId = this.object.id
|
||||
const data = items.map(v => {
|
||||
return {
|
||||
cmd_filter: objectId,
|
||||
systemuser: v.value
|
||||
}
|
||||
const newData = []
|
||||
const value = this.$refs.systemUserRelation.iHasObjects
|
||||
value.map(v => {
|
||||
newData.push(v.value)
|
||||
})
|
||||
const relationUrl = `/api/v1/assets/cmd-filters/${this.object.id}/`
|
||||
items.map(v => {
|
||||
newData.push(v.value)
|
||||
})
|
||||
return this.$axios.patch(relationUrl, { system_users: newData }).then(res => {
|
||||
this.$message.success(this.$tc('Update success'))
|
||||
}).catch(err => {
|
||||
this.$message.error(this.$tc('Update failed' + ' ' + err))
|
||||
})
|
||||
return this.$axios.post(relationUrl, data)
|
||||
},
|
||||
performDelete: (item) => {
|
||||
const itemId = item.value
|
||||
const objectId = this.object.id
|
||||
// TODO: Orange API 待修复
|
||||
const relationUrl = `/api/v1/assets/cmd-filters/?cmd-filters=${objectId}&systemuser=${itemId}`
|
||||
return this.$axios.delete(relationUrl)
|
||||
const newData = []
|
||||
const value = this.$refs.systemUserRelation.iHasObjects
|
||||
value.map(v => {
|
||||
if (v.value !== itemId) {
|
||||
newData.push(v.value)
|
||||
}
|
||||
})
|
||||
const relationUrl = `/api/v1/assets/cmd-filters/${this.object.id}/`
|
||||
return this.$axios.patch(relationUrl, { system_users: newData }).then(res => {
|
||||
this.$message.success(this.$tc('Update success'))
|
||||
}).catch(err => {
|
||||
this.$message.error(this.$tc('Update failed' + ' ' + err))
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<GenericCreateUpdatePage :fields="fields" :initial="initial" :fields-meta="fieldsMeta" :url="url" />
|
||||
<GenericCreateUpdatePage :fields="fields" :initial="initial" :fields-meta="fieldsMeta" :url="url" :update-success-next-route="updateSuccessNextRoute" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -15,13 +15,17 @@ export default {
|
||||
priority: 50,
|
||||
action: 0
|
||||
},
|
||||
|
||||
fields: [
|
||||
['', ['filter', 'type', 'content', 'priority', 'action', 'comment']]
|
||||
],
|
||||
fieldsMeta: {
|
||||
filter: {
|
||||
type: 'input',
|
||||
el: {
|
||||
disabled: true
|
||||
disabled: true,
|
||||
multiple: false,
|
||||
value: this.$route.params.ruleid
|
||||
}
|
||||
},
|
||||
content: {
|
||||
@@ -36,6 +40,12 @@ export default {
|
||||
helpText: '优先级可选范围为1-100,1最低优先级,100最高优先级'
|
||||
}
|
||||
},
|
||||
updateSuccessNextRoute: {
|
||||
name: 'CommandFilterList'
|
||||
},
|
||||
createSuccessNextRoute: {
|
||||
name: 'CommandFilterList'
|
||||
},
|
||||
url: `/api/v1/assets/cmd-filters/${this.$route.params.ruleid}/rules/`
|
||||
}
|
||||
},
|
||||
|
@@ -25,11 +25,11 @@ export default {
|
||||
activeMenu: 'Detail',
|
||||
submenu: [
|
||||
{
|
||||
title: this.$t('assets.detail'),
|
||||
title: this.$t('assets.commandFilterDetail'),
|
||||
name: 'Detail'
|
||||
},
|
||||
{
|
||||
title: this.$t('assets.rules'),
|
||||
title: this.$t('assets.commandFilterRules'),
|
||||
name: 'rules'
|
||||
}
|
||||
],
|
||||
|
@@ -24,7 +24,10 @@ export default {
|
||||
},
|
||||
{
|
||||
prop: 'rules.length',
|
||||
label: this.$t('assets.rules')
|
||||
label: this.$t('assets.rules'),
|
||||
formatter: DetailFormatter,
|
||||
sortable: true,
|
||||
route: 'CommandFilterDetail'
|
||||
},
|
||||
{
|
||||
prop: 'system_users.length',
|
||||
|
Reference in New Issue
Block a user