perf: 改密与推送保持一致

This commit is contained in:
feng
2023-06-23 22:52:26 +08:00
committed by Bryan
parent aa790944f6
commit 433f3a34cb
8 changed files with 81 additions and 37 deletions

View File

@@ -34,6 +34,7 @@
import { Dialog, AutoDataForm } from '@/components'
export default {
componentName: 'AutomationParams',
components: {
Dialog,
AutoDataForm
@@ -57,6 +58,10 @@ export default {
type: Array,
default: () => []
},
method: {
type: String,
default: ''
},
url: {
type: String,
default: `/api/v1/assets/platform-automation-methods/`
@@ -110,18 +115,17 @@ export default {
this.remoteMeta = data.actions[this.config.method.toUpperCase()] || {}
},
async getFilterPlatforms() {
const res = await this.$axios.post(
return await this.$axios.post(
'/api/v1/assets/platforms/filter-nodes-assets/',
{
'node_ids': this.node_ids,
'asset_ids': this.asset_ids
}
)
return res
},
async onFieldChangeHandle() {
const platforms = await this.getFilterPlatforms()
let pushAccountMethods = platforms.map(i => i.automation?.push_account_method)
let pushAccountMethods = platforms.map(i => i.automation[this.method])
pushAccountMethods = _.uniq(pushAccountMethods)
//
const hasCanSettingPushMethods = _.intersection(pushAccountMethods, Object.keys(this.remoteMeta))

View File

@@ -15,6 +15,7 @@ export { default as RelationCard } from './RelationCard'
export { default as Select2 } from './FormFields/Select2'
export { default as UploadKey } from './FormFields/UploadKey.vue'
export { default as AssetSelect } from './AssetSelect'
export { default as AutomationParams } from './AutomationParams'
export { default as SvgIcon } from './SvgIcon'
export { default as TreeTable } from './TreeTable'
export { default as AssetTreeTable } from './AssetTreeTable'

View File

@@ -32,6 +32,7 @@
},
"AccountChangeSecret": {
"Result": "Result",
"ParamsHelpText": "The change secret parameter settings are currently only effective for assets with a platform type of host.",
"ExecutionTimes": "Execution times",
"TaskList": "Task record",
"TimerPeriod": "Timed execution cycle",
@@ -93,7 +94,7 @@
"AccountPushExecutionList": "Execution list",
"AccountPushCreate": "Account push create",
"AccountPushUpdate": "Account push update",
"AutoPushHelpText": "The push parameter settings are currently only effective for assets with a platform type of host.",
"ParamsHelpText": "The push parameter settings are currently only effective for assets with a platform type of host.",
"AccountPushList": "Account push list"
},
"AccountBackup": {

View File

@@ -32,6 +32,7 @@
},
"AccountChangeSecret": {
"Result": "結果",
"ParamsHelpText": "改密パラメータの設定は、プラットフォームの種類がホストである資産に対してのみ有効です。",
"ExecutionTimes": "実行時間",
"TaskList": "タスク レコード",
"TimerPeriod": "時限実行サイクル",
@@ -93,7 +94,7 @@
"AccountPushExecutionList": "実行リスト",
"AccountPushCreate": "アカウントのプッシュ作成",
"AccountPushUpdate": "アカウントプッシュ更新",
"AutoPushHelpText": "Pushパラメータの設定は、プラットフォームの種類がホストである資産に対してのみ有効です。",
"ParamsHelpText": "Pushパラメータの設定は、プラットフォームの種類がホストである資産に対してのみ有効です。",
"AccountPushList": "アカウントプッシュ"
},
"AccountBackup": {

View File

@@ -29,7 +29,7 @@
"AccountPushList": "账号推送",
"AccountPushCreate": "账号推送创建",
"AccountPushUpdate": "账号推送更新",
"AutoPushHelpText": "推送参数设置,目前仅对平台种类为主机的资产生效。",
"ParamsHelpText": "推送参数设置,目前仅对平台种类为主机的资产生效。",
"AccountPushExecutionList": "执行列表"
},
"AccountBackup": {
@@ -45,6 +45,7 @@
"Reason": "原因"
},
"AccountChangeSecret": {
"ParamsHelpText": "改密参数设置,目前仅对平台种类为主机的资产生效。",
"ContainAttachment": "含附件",
"AddAsset": "添加资产",
"MailRecipient": "邮件收件人",

View File

@@ -5,6 +5,7 @@
<script>
import { GenericCreateUpdatePage } from '@/layout/components'
import { getChangeSecretFields } from '@/views/accounts/AccountChangeSecret/fields'
import { AssetSelect, AutomationParams } from '@/components'
export default {
name: 'AccountChangeSecretCreateUpdate',
@@ -13,6 +14,8 @@ export default {
},
data() {
return {
node_ids: [],
asset_ids: [],
initial: {
is_periodic: true,
password_rules: {
@@ -33,14 +36,57 @@ export default {
[
'secret_strategy', 'secret_type', 'secret',
'password_rules', 'ssh_key_change_strategy',
'ssh_key', 'passphrase'
'ssh_key', 'passphrase', 'params'
]
],
[this.$t('xpack.Timer'), ['is_periodic', 'crontab', 'interval']],
[this.$t('common.Other'), ['is_active', 'recipients', 'comment']]
],
fieldsMeta: {
...getChangeSecretFields()
...getChangeSecretFields(),
assets: {
label: this.$t('xpack.Asset'),
type: 'assetSelect',
component: AssetSelect,
rules: [
{ required: false }
],
el: {
baseUrl: '/api/v1/assets/assets/?change_secret_enabled=true'
},
on: {
input: ([value]) => {
this.asset_ids = value
}
}
},
nodes: {
label: this.$t('xpack.Node'),
el: {
value: [],
ajax: {
url: '/api/v1/assets/nodes/',
transformOption: (item) => {
return { label: item.full_value, value: item.id }
}
}
},
on: {
input: ([value]) => {
this.node_ids = value?.map(i => i.pk)
}
}
},
params: {
component: AutomationParams,
label: this.$t('assets.ChangeSecretParams'),
el: {
method: 'change_secret_method',
assets: this.asset_ids,
nodes: this.node_ids
},
helpText: this.$t('accounts.AccountChangeSecret.ParamsHelpText')
}
},
createSuccessNextRoute: { name: 'AccountChangeSecretList' },
updateSuccessNextRoute: { name: 'AccountChangeSecretList' },
@@ -55,6 +101,20 @@ export default {
}
}
},
watch: {
node_ids: {
handler(val) {
this.fieldsMeta.params.el.nodes = val
},
deep: true
},
asset_ids: {
handler(val) {
this.fieldsMeta.params.el.assets = val
},
deep: true
}
},
methods: {
handleAfterGetRemoteMeta(meta) {
const needSetOptionFields = [

View File

@@ -1,5 +1,5 @@
import i18n from '@/i18n/i18n'
import { AssetSelect, CronTab } from '@/components'
import { CronTab } from '@/components'
import { TagInput, UpdateToken } from '@/components/FormFields'
import { Required } from '@/components/DataForm/rules'
@@ -46,29 +46,6 @@ function generatePasswordRulesItemsFields(obType) {
export const getChangeSecretFields = () => {
return {
assets: {
type: 'assetSelect',
component: AssetSelect,
rules: [
{ required: false }
],
el: {
baseUrl: '/api/v1/assets/assets/?change_secret_enabled=true'
},
label: i18n.t('xpack.Asset')
},
nodes: {
label: i18n.t('xpack.Node'),
el: {
value: [],
ajax: {
url: '/api/v1/assets/nodes/',
transformOption: (item) => {
return { label: item.full_value, value: item.id }
}
}
}
},
secret_type: {
type: 'radio-group',
options: []
@@ -149,7 +126,6 @@ export const getChangeSecretFields = () => {
label: i18n.t('common.Username'),
component: TagInput
}
}
}

View File

@@ -6,8 +6,7 @@
import i18n from '@/i18n/i18n'
import { GenericCreateUpdatePage } from '@/layout/components'
import { getChangeSecretFields } from '@/views/accounts/AccountChangeSecret/fields'
import { AssetSelect } from '@/components'
import AccountAutoPush from './AccountAutoPush.vue'
import { AssetSelect, AutomationParams } from '@/components'
export default {
name: 'AccountPushCreateUpdate',
@@ -96,13 +95,14 @@ export default {
disabled: !this.$store.getters.hasValidLicense
},
params: {
component: AccountAutoPush,
component: AutomationParams,
label: this.$t('assets.PushParams'),
el: {
method: 'push_account_method',
assets: this.asset_ids,
nodes: this.node_ids
},
helpText: this.$t('accounts.AccountPush.AutoPushHelpText')
helpText: this.$t('accounts.AccountPush.ParamsHelpText')
}
},
createSuccessNextRoute: { name: 'AccountPushList' },