mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-01 15:07:43 +00:00
perf: 优化 protocol setting
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
:destroy-on-close="true"
|
:destroy-on-close="true"
|
||||||
:show-cancel="false"
|
:show-cancel="false"
|
||||||
:show-confirm="false"
|
:show-confirm="false"
|
||||||
:title="$tc('assets.PlatformProtocolConfig') + ':' + item.name"
|
:title="$tc('assets.PlatformProtocolConfig') + ':' + protocol.name"
|
||||||
class="setting-dialog"
|
class="setting-dialog"
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
width="70%"
|
width="70%"
|
||||||
@@ -38,7 +38,7 @@ export default {
|
|||||||
AutoDataForm
|
AutoDataForm
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
item: {
|
protocol: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => ({})
|
default: () => ({})
|
||||||
},
|
},
|
||||||
@@ -51,23 +51,13 @@ export default {
|
|||||||
const vm = this
|
const vm = this
|
||||||
const platform = this.$route.query.platform
|
const platform = this.$route.query.platform
|
||||||
return {
|
return {
|
||||||
baseAttrs: ['primary', 'required', 'default', 'public'], // 基础属性, 放到 setting 中处理了,处理完成后,还得返回回去
|
|
||||||
defaultSetting: {
|
|
||||||
sftp_enabled: true,
|
|
||||||
sftp_home: '/tmp',
|
|
||||||
username_selector: '#username',
|
|
||||||
password_selector: '#password',
|
|
||||||
submit_selector: '.btn-submit',
|
|
||||||
security: 'any',
|
|
||||||
console: false
|
|
||||||
},
|
|
||||||
loading: true,
|
loading: true,
|
||||||
form: {},
|
form: this.protocol,
|
||||||
platformDetail: platform ? '#/console/assets/platforms/' + platform : '',
|
platformDetail: platform ? '#/console/assets/platforms/' + platform : '',
|
||||||
config: {
|
config: {
|
||||||
hasSaveContinue: false,
|
hasSaveContinue: false,
|
||||||
hasButtons: !this.disabled,
|
hasButtons: !this.disabled,
|
||||||
url: '/api/v1/assets/protocol-settings/?name=' + this.item.name,
|
url: '/api/v1/assets/protocol-settings/?name=' + this.protocol.name,
|
||||||
fields: [
|
fields: [
|
||||||
[vm.$t('common.Basic'), [
|
[vm.$t('common.Basic'), [
|
||||||
'primary', 'required', 'default', 'public'
|
'primary', 'required', 'default', 'public'
|
||||||
@@ -82,25 +72,11 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
|
||||||
this.form = this.item.setting
|
|
||||||
if (!this.form || !this.item) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
for (const i of this.baseAttrs) {
|
|
||||||
this.form[i] = !!this.item[i]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
onSubmit(form) {
|
onSubmit(form) {
|
||||||
for (const i of this.baseAttrs) {
|
this.protocol = Object.assign(this.protocol, form)
|
||||||
if (form.hasOwnProperty(i)) {
|
|
||||||
this.item[i] = form[i]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.item.setting = form
|
|
||||||
this.$emit('update:visible', false)
|
this.$emit('update:visible', false)
|
||||||
this.$emit('confirm', this.item)
|
this.$emit('confirm', this.protocol)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -62,7 +62,7 @@
|
|||||||
<ProtocolSettingDialog
|
<ProtocolSettingDialog
|
||||||
v-if="showDialog"
|
v-if="showDialog"
|
||||||
:disabled="settingReadonly || readonly"
|
:disabled="settingReadonly || readonly"
|
||||||
:item="settingItem"
|
:protocol="currentProtocol"
|
||||||
:visible.sync="showDialog"
|
:visible.sync="showDialog"
|
||||||
@confirm="handleSettingConfirm"
|
@confirm="handleSettingConfirm"
|
||||||
/>
|
/>
|
||||||
@@ -108,7 +108,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
name: '',
|
name: '',
|
||||||
items: [],
|
items: [],
|
||||||
settingItem: {},
|
currentProtocol: {},
|
||||||
showDialog: false,
|
showDialog: false,
|
||||||
loading: false
|
loading: false
|
||||||
}
|
}
|
||||||
@@ -167,20 +167,20 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleSettingConfirm() {
|
handleSettingConfirm() {
|
||||||
if (this.settingItem.primary) {
|
if (this.currentProtocol.primary) {
|
||||||
const others = this.items
|
const others = this.items
|
||||||
.filter(item => item.name !== this.settingItem.name)
|
.filter(item => item.name !== this.currentProtocol.name)
|
||||||
.map(item => {
|
.map(item => {
|
||||||
item.primary = false
|
item.primary = false
|
||||||
return item
|
return item
|
||||||
})
|
})
|
||||||
this.items = [this.settingItem, ...others]
|
this.items = [this.currentProtocol, ...others]
|
||||||
}
|
}
|
||||||
if (this.settingItem.name === 'winrm') {
|
if (this.currentProtocol.name === 'winrm') {
|
||||||
if (this.settingItem.setting?.use_ssl) {
|
if (this.currentProtocol.setting?.use_ssl) {
|
||||||
this.settingItem.port = 5986
|
this.currentProtocol.port = 5986
|
||||||
} else {
|
} else {
|
||||||
this.settingItem.port = 5985
|
this.currentProtocol.port = 5985
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -271,7 +271,7 @@ export default {
|
|||||||
return protocols
|
return protocols
|
||||||
},
|
},
|
||||||
onSettingClick(item) {
|
onSettingClick(item) {
|
||||||
this.settingItem = item
|
this.currentProtocol = item
|
||||||
this.showDialog = true
|
this.showDialog = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user