feat: 可查看全局被限制的ip 并且可以解锁

This commit is contained in:
feng
2023-08-23 14:21:43 +08:00
parent d5aa439fee
commit d06637afd4
7 changed files with 203 additions and 2 deletions

View File

@@ -0,0 +1,97 @@
<template>
<ListTable ref="ListTable" :table-config="tableConfig" :header-actions="headerActions" />
</template>
<script>
import ListTable from '@/components/Table/ListTable/index.vue'
export default {
name: 'BlockedIPList',
components: {
ListTable
},
props: {
object: {
type: Object,
required: false,
default: () => ({})
}
},
data() {
const vm = this
return {
tableConfig: {
url: '/api/v1/settings/security/block-ip/',
columns: [
'ip', 'actions'
],
columnsMeta: {
ip: {
label: this.$t('assets.ip')
},
actions: {
formatterArgs: {
hasDelete: false,
hasUpdate: false,
hasClone: false,
extraActions: [
{
name: 'UnlockIP',
title: this.$t('setting.Unblock'),
can: this.$hasPerm('settings.change_security'),
type: 'primary',
callback: ({ row }) => {
this.$axios.post(
'/api/v1/settings/security/unlock-ip/',
{ ips: [row.ip] }
).then(() => {
vm.$message.success(this.$tc('common.UnlockSuccessMsg'))
vm.$refs.ListTable.reloadTable()
})
}
}
]
}
}
}
},
headerActions: {
hasExport: false,
hasImport: false,
hasCreate: false,
hasSearch: false,
hasRefresh: true,
hasBulkDelete: false,
hasBulkUpdate: false,
hasLeftActions: true,
hasRightActions: true,
extraMoreActions: [
{
name: 'UnlockSelected',
title: this.$t('setting.BulkUnblock'),
type: 'primary',
can: ({ selectedRows }) => {
return selectedRows.length > 0
},
callback: function({ selectedRows }) {
vm.$axios.post(
'/api/v1/settings/security/unlock-ip/',
{
ips: selectedRows.map(v => { return v.ip })
}
).then(res => {
vm.$message.success(vm.$tc('common.UnlockSuccessMsg'))
vm.$refs.ListTable.reloadTable()
})
}
}
]
}
}
}
}
</script>
<style lang='less' scoped>
</style>

View File

@@ -0,0 +1,75 @@
<template>
<div>
<div>
<el-button
size="mini"
type="primary"
@click="onOpenDialog"
>{{ $tc('common.View') }}</el-button>
</div>
<Dialog
v-if="visible"
:visible.sync="visible"
:title="title"
width="40%"
:show-cancel="false"
:show-confirm="false"
:destroy-on-close="true"
v-bind="$attrs"
v-on="$listeners"
>
<BlockedIPList />
</Dialog>
</div>
</template>
<script>
import { Dialog } from '@/components'
import BlockedIPList from '@/components/Apps/BlockedIPs/BlockedIPList'
export default {
componentName: 'BlockedIPs',
components: {
BlockedIPList,
Dialog
},
props: {
value: {
type: Object,
default: () => ({})
},
title: {
type: String,
default: function() {
return this.$t('setting.BlockedIPS')
}
},
url: {
type: String,
default: `/api/v1/assets/platform-automation-methods/`
}
},
data() {
return {
remoteMeta: {},
visible: false,
form: this.value,
config: {
url: this.url,
hasSaveContinue: false,
hasButtons: true,
fields: [],
fieldsMeta: {}
}
}
},
methods: {
onOpenDialog() {
this.visible = true
}
}
}
</script>
<style scoped>
</style>

View File

@@ -16,6 +16,7 @@ export { default as Select2 } from './Form/FormFields/Select2'
export { default as UploadKey } from './Form/FormFields/UploadKey.vue'
export { default as AssetSelect } from './Apps/AssetSelect'
export { default as AutomationParams } from './Apps/AutomationParams'
export { default as BlockedIPs } from './Apps/BlockedIPs'
export { default as SvgIcon } from './Widgets/SvgIcon'
export { default as TreeTable } from './Table/TreeTable'
export { default as AssetTreeTable } from './Apps/AssetTreeTable'

View File

@@ -593,6 +593,7 @@
"TestSelectedSystemUsersConnective": "Test selected system users connective",
"UpdateAssetDetail": "Update more detail",
"AddSuccessMsg": "Add success",
"UnlockSuccessMsg": "Unlock success",
"AddFailMsg": "Add fail",
"Auth": "Authorization",
"BadRequestErrorMsg": "Bad request, please check again",
@@ -1530,6 +1531,10 @@
}
},
"setting": {
"BlockedIPS": "Blocked IPS",
"ViewBlockedIPSHelpText": "View the list of locked IPs",
"Unblock": "Unblock",
"BulkUnblock": "BulkUnblock",
"AppOps": "Task center",
"Ticket": "Ticket",
"TaskList": "Task list",

View File

@@ -582,6 +582,7 @@
"TemplateHelpText": "テンプレートを選択してアカウントを追加すると、資産の下では発生しないアカウントが自動的に作成され、プッシュされます",
"UpdateAssetDetail": "詳細情報の設定",
"AddSuccessMsg": "追加に成功しました",
"UnlockSuccessMsg": "ロック解除成功メッセージ",
"AddFailMsg": "追加に失敗しました",
"Auth": "認証",
"bind": "紐付け",
@@ -1525,6 +1526,10 @@
}
},
"setting": {
"BlockedIPS": "ロックされたIP",
"ViewBlockedIPSHelpText": "ロックされたIPリストの表示",
"Unblock": "ロック解除",
"BulkUnblock": "一括ロック解除",
"AppOps": "タスクセンター",
"Ticket": "チケット",
"TaskList": "タスクリスト",

View File

@@ -613,6 +613,7 @@
"Task": "任务",
"UpdateAssetDetail": "配置更多信息",
"AddSuccessMsg": "添加成功",
"UnlockSuccessMsg": "解锁成功",
"AddFailMsg": "添加失败",
"Auth": "认证",
"bind": "绑定",
@@ -1522,6 +1523,10 @@
"PublishStatus": "发布状态"
},
"setting": {
"BlockedIPS": "已锁定的 IP",
"ViewBlockedIPSHelpText": "查看已被锁定的 IP 列表",
"Unblock": "解锁",
"BulkUnblock": "批量解锁",
"AppOps": "任务中心",
"Ticket": "工单",
"TaskList": "任务列表",

View File

@@ -14,6 +14,7 @@
<script>
import GenericCreateUpdateForm from '@/layout/components/GenericCreateUpdateForm'
import IBox from '@/components/IBox/index.vue'
import { BlockedIPs } from '@/components'
export default {
name: 'EmailContent',
@@ -41,7 +42,8 @@ export default {
'SECURITY_LOGIN_IP_LIMIT_COUNT',
'SECURITY_LOGIN_IP_LIMIT_TIME',
'SECURITY_LOGIN_IP_WHITE_LIST',
'SECURITY_LOGIN_IP_BLACK_LIST'
'SECURITY_LOGIN_IP_BLACK_LIST',
'SECURITY_VIEW_BLOCKED_IPS'
]
],
[
@@ -54,7 +56,18 @@ export default {
]
],
successUrl: { name: 'Settings', params: { activeMenu: 'EmailContent' }},
fieldsMeta: {},
fieldsMeta: {
SECURITY_VIEW_BLOCKED_IPS: {
component: BlockedIPs,
label: this.$t('setting.BlockedIPS'),
el: {
method: 'push_account_method',
assets: this.asset_ids,
nodes: this.node_ids
},
helpText: this.$t('setting.ViewBlockedIPSHelpText')
}
},
cleanFormValue(value) {
const ipBlackList = value.SECURITY_LOGIN_IP_BLACK_LIST
const ipWhiltList = value.SECURITY_LOGIN_IP_WHITE_LIST