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