mirror of
https://github.com/jumpserver/lina.git
synced 2025-07-13 06:54:18 +00:00
perf: 修改 protocol selector
This commit is contained in:
parent
3ec02a299c
commit
c97b3ffbdf
@ -0,0 +1,118 @@
|
|||||||
|
<template>
|
||||||
|
<Dialog
|
||||||
|
:title="'平台协议配置:' + item.name"
|
||||||
|
:destroy-on-close="true"
|
||||||
|
:show-cancel="false"
|
||||||
|
:show-confirm="false"
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
class="setting-dialog"
|
||||||
|
width="70%"
|
||||||
|
v-bind="$attrs"
|
||||||
|
@open="onOpen"
|
||||||
|
v-on="$listeners"
|
||||||
|
>
|
||||||
|
<el-alert type="success">
|
||||||
|
继承自平台配置,如需更改,请更改平台中的配置
|
||||||
|
<el-link :href="platformDetail" class="link-more" target="_blank">查看</el-link>
|
||||||
|
<i class="fa fa-external-link" />
|
||||||
|
</el-alert>
|
||||||
|
<DataForm
|
||||||
|
class="data-form"
|
||||||
|
:form="form"
|
||||||
|
:disabled="iDisabled"
|
||||||
|
v-bind="config"
|
||||||
|
@submit="onSubmit"
|
||||||
|
/>
|
||||||
|
</Dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { Dialog, DataForm } from '@/components'
|
||||||
|
export default {
|
||||||
|
name: 'ProtocolSetting',
|
||||||
|
components: {
|
||||||
|
Dialog,
|
||||||
|
DataForm
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
item: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({})
|
||||||
|
},
|
||||||
|
disabled: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: this.item.setting || {},
|
||||||
|
iDisabled: this.disabled,
|
||||||
|
platformDetail: '#/console/assets/platforms/' + this.$route.query['platform'],
|
||||||
|
config: {
|
||||||
|
hasSaveContinue: false,
|
||||||
|
hasButtons: !this.disabled,
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
id: 'required',
|
||||||
|
label: '必须配置',
|
||||||
|
helpText: '资产上必须开启该协议',
|
||||||
|
type: 'switch'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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_home',
|
||||||
|
label: 'SFTP home',
|
||||||
|
type: 'input',
|
||||||
|
helpText: this.$t('assets.SFTPHelpMessage'),
|
||||||
|
hidden: () => this.item.name !== 'sftp'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
onSubmit(form) {
|
||||||
|
this.item.setting = form
|
||||||
|
this.$emit('update:visible', false)
|
||||||
|
},
|
||||||
|
onOpen() {
|
||||||
|
this.form = this.item.setting
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.data-form >>> .el-form-item.form-buttons {
|
||||||
|
padding-top: 10px;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.setting-dialog >>> .el-dialog__body {
|
||||||
|
padding-top: 10px;
|
||||||
|
}
|
||||||
|
.link-more {
|
||||||
|
font-size: 10px;
|
||||||
|
margin-left: 10px;
|
||||||
|
border-bottom: solid 1px;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
</style>
|
@ -14,7 +14,6 @@
|
|||||||
v-if="showSetting(item)"
|
v-if="showSetting(item)"
|
||||||
slot="append"
|
slot="append"
|
||||||
icon="el-icon-setting"
|
icon="el-icon-setting"
|
||||||
:disabled="disableSetting(item)"
|
|
||||||
@click="onSettingClick(item)"
|
@click="onSettingClick(item)"
|
||||||
/>
|
/>
|
||||||
</el-input>
|
</el-input>
|
||||||
@ -38,11 +37,19 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<ProtocolSettingDialog
|
||||||
|
:visible.sync="showDialog"
|
||||||
|
:item="settingItem"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import ProtocolSettingDialog from './ProtocolSettingDialog'
|
||||||
export default {
|
export default {
|
||||||
|
components: {
|
||||||
|
ProtocolSettingDialog
|
||||||
|
},
|
||||||
props: {
|
props: {
|
||||||
value: {
|
value: {
|
||||||
type: [Array],
|
type: [Array],
|
||||||
@ -59,19 +66,7 @@ export default {
|
|||||||
showSetting: {
|
showSetting: {
|
||||||
type: Function,
|
type: Function,
|
||||||
default: (item) => {
|
default: (item) => {
|
||||||
return false
|
return true
|
||||||
}
|
|
||||||
},
|
|
||||||
disableSetting: {
|
|
||||||
type: Function,
|
|
||||||
default: (item) => {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onSettingClick: {
|
|
||||||
type: Function,
|
|
||||||
default: (item) => {
|
|
||||||
alert('Click setting: ' + item.name + ', port: ' + item.port)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -79,7 +74,8 @@ export default {
|
|||||||
return {
|
return {
|
||||||
name: '',
|
name: '',
|
||||||
items: [],
|
items: [],
|
||||||
settingItem: {}
|
settingItem: {},
|
||||||
|
showDialog: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -131,6 +127,10 @@ export default {
|
|||||||
if (choices.length !== 0) {
|
if (choices.length !== 0) {
|
||||||
this.items = [choices[0]]
|
this.items = [choices[0]]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
onSettingClick(item) {
|
||||||
|
this.settingItem = item
|
||||||
|
this.showDialog = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,3 @@
|
|||||||
import DatetimeRangePicker from './DatetimeRangePicker'
|
|
||||||
import Link from './Link'
|
import Link from './Link'
|
||||||
import PasswordInput from './PasswordInput'
|
import PasswordInput from './PasswordInput'
|
||||||
import Select2 from './Select2'
|
import Select2 from './Select2'
|
||||||
@ -11,6 +10,7 @@ import UpdateToken from './UpdateToken'
|
|||||||
import JsonEditor from './JsonEditor'
|
import JsonEditor from './JsonEditor'
|
||||||
import Text from './Text'
|
import Text from './Text'
|
||||||
import NestedObjectSelect2 from './NestedObjectSelect2'
|
import NestedObjectSelect2 from './NestedObjectSelect2'
|
||||||
|
import DatetimeRangePicker from './DatetimeRangePicker'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
DatetimeRangePicker,
|
DatetimeRangePicker,
|
||||||
|
@ -21,7 +21,6 @@ export default {
|
|||||||
initial: {
|
initial: {
|
||||||
is_active: true,
|
is_active: true,
|
||||||
platform: parseInt(platformId),
|
platform: parseInt(platformId),
|
||||||
protocols: ['mysql/22'],
|
|
||||||
nodes: nodesInitial
|
nodes: nodesInitial
|
||||||
},
|
},
|
||||||
url: '/api/v1/assets/databases/',
|
url: '/api/v1/assets/databases/',
|
||||||
|
@ -34,8 +34,12 @@ export default {
|
|||||||
hasDetailInMsg: false
|
hasDetailInMsg: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
async mounted() {
|
||||||
this.setPlatformInitial()
|
try {
|
||||||
|
await this.setPlatformInitial()
|
||||||
|
} finally {
|
||||||
|
this.loading = false
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async setPlatformInitial() {
|
async setPlatformInitial() {
|
||||||
@ -56,7 +60,6 @@ export default {
|
|||||||
|
|
||||||
const constraints = this.platform['type_constraints']
|
const constraints = this.platform['type_constraints']
|
||||||
this.fieldsMeta.protocols.el.choices = constraints['protocols']
|
this.fieldsMeta.protocols.el.choices = constraints['protocols']
|
||||||
this.loading = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,8 +98,7 @@ export default {
|
|||||||
onSettingClick: (item) => {
|
onSettingClick: (item) => {
|
||||||
this.settingItem = item
|
this.settingItem = item
|
||||||
this.showDialog = true
|
this.showDialog = true
|
||||||
},
|
}
|
||||||
disableSetting: (item) => item.name !== 'rdp'
|
|
||||||
},
|
},
|
||||||
hidden: (formValue) => !formValue['protocols_enabled']
|
hidden: (formValue) => !formValue['protocols_enabled']
|
||||||
},
|
},
|
||||||
|
@ -7,9 +7,10 @@
|
|||||||
:close-on-click-modal="false"
|
:close-on-click-modal="false"
|
||||||
width="70%"
|
width="70%"
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
|
@open="onOpen"
|
||||||
v-on="$listeners"
|
v-on="$listeners"
|
||||||
>
|
>
|
||||||
<DataForm class="data-form" v-bind="config" @submit="onSubmit" />
|
<DataForm class="data-form" :form="form" v-bind="config" @submit="onSubmit" />
|
||||||
</Dialog>
|
</Dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -24,28 +25,37 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
item: {
|
item: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => ({})
|
default: () => ({ name: '', port: 0 })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
form: this.item.setting || {},
|
||||||
config: {
|
config: {
|
||||||
form: {
|
|
||||||
console: true,
|
|
||||||
security: 'any'
|
|
||||||
},
|
|
||||||
hasSaveContinue: false,
|
hasSaveContinue: false,
|
||||||
fields: [
|
fields: [
|
||||||
|
{
|
||||||
|
id: 'required',
|
||||||
|
label: '必须配置',
|
||||||
|
helpText: '资产上必须开启该协议',
|
||||||
|
type: 'switch'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'console',
|
id: 'console',
|
||||||
label: 'Console',
|
label: 'Console',
|
||||||
type: 'switch'
|
type: 'switch',
|
||||||
|
hidden: () => this.item.name !== 'rdp'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'security',
|
id: 'security',
|
||||||
label: 'Security',
|
label: 'Security',
|
||||||
|
hidden: () => this.item.name !== 'rdp',
|
||||||
type: 'radio-group',
|
type: 'radio-group',
|
||||||
options: [
|
options: [
|
||||||
|
{
|
||||||
|
label: 'Any',
|
||||||
|
value: 'any'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: 'RDP',
|
label: 'RDP',
|
||||||
value: 'rdp'
|
value: 'rdp'
|
||||||
@ -57,12 +67,15 @@ export default {
|
|||||||
{
|
{
|
||||||
label: 'TLS',
|
label: 'TLS',
|
||||||
value: 'tls'
|
value: 'tls'
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Any',
|
|
||||||
value: 'any'
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'sftp_home',
|
||||||
|
label: 'SFTP home',
|
||||||
|
type: 'input',
|
||||||
|
helpText: this.$t('assets.SFTPHelpMessage'),
|
||||||
|
hidden: () => this.item.name !== 'sftp'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -72,6 +85,9 @@ export default {
|
|||||||
onSubmit(form) {
|
onSubmit(form) {
|
||||||
this.item.setting = form
|
this.item.setting = form
|
||||||
this.$emit('update:visible', false)
|
this.$emit('update:visible', false)
|
||||||
|
},
|
||||||
|
onOpen() {
|
||||||
|
this.form = this.item.setting
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user