perf: 修改平台

This commit is contained in:
ibuler 2022-10-17 17:21:59 +08:00
parent 2669c8fff0
commit 47a423284b
3 changed files with 92 additions and 51 deletions

View File

@ -61,55 +61,86 @@ export default {
hasButtons: !this.disabled,
url: '',
fields: [
{
id: 'console',
label: 'Console',
type: 'switch',
hidden: () => this.item.name !== 'rdp'
},
{
id: 'security',
label: 'Security',
hidden: () => this.item.name !== 'rdp',
type: 'radio-group',
options: [
{ label: 'Any', value: 'any' },
{ label: 'RDP', value: 'rdp' },
{ label: 'NLA', value: 'nla' },
{ label: 'TLS', value: 'tls' }
]
},
{
id: 'sftp_enabled',
label: '启用 SFTP',
type: 'switch',
hidden: () => this.item.name !== 'ssh'
},
{
id: 'sftp_home',
label: 'SFTP home',
type: 'input',
helpText: this.$t('assets.SFTPHelpMessage'),
hidden: (form) => this.item.name !== 'ssh' || !form['sftp_enabled']
},
{
id: 'username_selector',
label: '用户名输入框选择器',
type: 'input',
hidden: (form) => this.item.name !== 'http'
},
{
id: 'password_selector',
label: '密码输入框选择器',
type: 'input',
hidden: (form) => this.item.name !== 'http'
},
{
id: 'submit_selector',
label: '提交按钮选择器',
type: 'input',
hidden: (form) => this.item.name !== 'http'
}
[this.$t('common.Basic'), [
{
id: 'primary',
label: '主要的',
type: 'switch',
helpText: '主要的协议, 只能有一个',
on: {
change: ([event], updateForm) => {
if (event) {
updateForm({ required: true })
} else {
updateForm({ required: false })
}
}
}
},
{
id: 'required',
label: '必需的',
type: 'switch',
helpText: '必需的协议, 添加资产时必须选择'
},
{
id: 'default',
label: '默认的',
type: 'switch',
helpText: '默认的协议, 添加资产时默认会选择'
}
]],
['登录配置', [
{
id: 'console',
label: 'Console',
type: 'switch',
hidden: () => this.item.name !== 'rdp'
},
{
id: 'security',
label: 'Security',
hidden: () => this.item.name !== 'rdp',
type: 'radio-group',
options: [
{ label: 'Any', value: 'any' },
{ label: 'RDP', value: 'rdp' },
{ label: 'NLA', value: 'nla' },
{ label: 'TLS', value: 'tls' }
]
},
{
id: 'sftp_enabled',
label: '启用 SFTP',
type: 'switch',
hidden: () => this.item.name !== 'ssh'
},
{
id: 'sftp_home',
label: 'SFTP home',
type: 'input',
helpText: this.$t('assets.SFTPHelpMessage'),
hidden: (form) => this.item.name !== 'ssh' || !form['sftp_enabled']
},
{
id: 'username_selector',
label: '用户名输入框选择器',
type: 'input',
hidden: (form) => this.item.name !== 'http'
},
{
id: 'password_selector',
label: '密码输入框选择器',
type: 'input',
hidden: (form) => this.item.name !== 'http'
},
{
id: 'submit_selector',
label: '提交按钮选择器',
type: 'input',
hidden: (form) => this.item.name !== 'http'
}
]]
]
}
}

View File

@ -102,6 +102,11 @@ export default {
watch: {
choices: {
handler(value) {
if (!this.settingReadonly) {
this.value[0].primary = true
this.value[0].default = true
this.value[0].required = true
}
this.setDefaultItems(value)
}
},
@ -115,6 +120,7 @@ export default {
},
mounted() {
this.setDefaultItems(this.choices)
console.log('CHoices: ', this.choices)
},
methods: {
handleDelete(index) {
@ -122,6 +128,9 @@ export default {
return i !== index
})
},
canDelete(item) {
return this.item.primary || this.item.required
},
handleAdd(index) {
this.items.push({ ...this.remainProtocols[0] })
},

View File

@ -15,7 +15,7 @@ export const platformFieldsMeta = (vm) => {
'ping_enabled', 'ping_method',
'gather_facts_enabled', 'gather_facts_method',
'create_account_enabled', 'create_account_method',
'change_password_enabled', 'change_password_method',
'change_secret_enabled', 'change_secret_method',
'verify_account_enabled', 'verify_account_method'
],
fieldsMeta: {
@ -26,7 +26,7 @@ export const platformFieldsMeta = (vm) => {
ping_method: {},
gather_facts_method: {},
create_account_method: {},
change_password_method: {},
change_secret_method: {},
verify_account_method: {}
}
},
@ -110,5 +110,6 @@ export const setAutomations = (vm) => {
autoFieldsMeta[itemMethodKey].options = methods.map(method => {
return { value: method['id'], label: method['name'] }
})
_.set(initial, `${itemMethodKey}`, autoFieldsMeta[itemMethodKey].options[0]?.value)
}
}