mirror of
https://github.com/jumpserver/lina.git
synced 2026-01-29 21:28:52 +00:00
perf: 修改 platform
This commit is contained in:
@@ -54,7 +54,7 @@ export default {
|
||||
computed: {
|
||||
protocols() {
|
||||
return this.choices.map(item => {
|
||||
const proto = item.value.split('/')
|
||||
const proto = item.split('/')
|
||||
return { name: proto[0], port: proto[1] }
|
||||
})
|
||||
},
|
||||
@@ -83,22 +83,15 @@ export default {
|
||||
},
|
||||
immediate: true,
|
||||
deep: true
|
||||
},
|
||||
choices: {
|
||||
handler(value) {
|
||||
this.setDefaultItems()
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.value.length !== 0) {
|
||||
const items = this.value.map(item => {
|
||||
const proto = item.split('/')
|
||||
return { name: proto[0], port: proto[1] }
|
||||
})
|
||||
const protocolsNames = this.protocols.map(item => item.name)
|
||||
this.items = items.filter(item => {
|
||||
return protocolsNames[item.name]
|
||||
})
|
||||
} else {
|
||||
this.items.push({ ...this.protocols[0] })
|
||||
}
|
||||
console.log('Choices: ', this.choices)
|
||||
this.setDefaultItems()
|
||||
},
|
||||
methods: {
|
||||
onInput(val) {
|
||||
@@ -116,6 +109,21 @@ export default {
|
||||
const selected = this.protocols.find(item => item.name === evt)
|
||||
item.name = selected.name
|
||||
item.port = selected.port
|
||||
},
|
||||
setDefaultItems() {
|
||||
let items = []
|
||||
if (this.value.length !== 0) {
|
||||
items = this.value.map(item => {
|
||||
const proto = item.split('/')
|
||||
return { name: proto[0], port: proto[1] }
|
||||
})
|
||||
const protocolsNames = this.protocols.map(item => item.name)
|
||||
items = items.filter(item => protocolsNames[item.name])
|
||||
}
|
||||
if (items.length === 0) {
|
||||
items.push({ ...this.protocols[0] })
|
||||
}
|
||||
this.items = items
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@ const actions = {
|
||||
apiGetCategoryTypes().then(data => {
|
||||
commit('SET_CATEGORIES', data)
|
||||
commit('SET_CATEGORIES_DROPDOWN', data)
|
||||
console.log('Set done')
|
||||
resolve(true)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ export default {
|
||||
nodes: nodesInitial,
|
||||
admin_user: this.platform['admin_user_default']
|
||||
}
|
||||
this.fieldsMeta.protocols.el.choices = this.platform
|
||||
this.initial = initial
|
||||
this.loading = false
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ export default {
|
||||
loading: true,
|
||||
initial: {
|
||||
comment: 'Hello world',
|
||||
charset: 'utf8'
|
||||
// category_type: ['host', 'linux']
|
||||
charset: 'utf8',
|
||||
category_type: ['host', 'linux']
|
||||
},
|
||||
fields: [
|
||||
[this.$t('common.Basic'), [
|
||||
@@ -86,11 +86,27 @@ export default {
|
||||
el: {
|
||||
multiple: false,
|
||||
options: this.$store.state.assets.assetCategoriesCascader
|
||||
},
|
||||
on: {
|
||||
change: ([event], formValue) => {
|
||||
const category = event[0]
|
||||
const type = event[1]
|
||||
const url = `/api/v1/assets/platforms/type-limits/?category=${category}&type=${type}`
|
||||
this.$axios.get(url).then(limits => {
|
||||
this.changeLimits(limits)
|
||||
})
|
||||
console.log('On change: ', event)
|
||||
}
|
||||
}
|
||||
},
|
||||
domain_default: assetFieldsMeta.domain,
|
||||
admin_user_default: assetFieldsMeta.admin_user,
|
||||
protocols_default: assetFieldsMeta.protocols
|
||||
protocols_default: assetFieldsMeta.protocols,
|
||||
domain_enabled: {
|
||||
el: {
|
||||
disabled: true
|
||||
}
|
||||
}
|
||||
},
|
||||
url: `/api/v1/assets/platforms/?category=${category}&type=${type}`,
|
||||
cleanFormValue: (values) => {
|
||||
@@ -113,6 +129,7 @@ export default {
|
||||
setCategoryOnCreate() {
|
||||
const category = this.$route.query.category
|
||||
const type = this.$route.query.type
|
||||
console.log('Category rdop down: ', this.$store.state.assets.assetCategoriesCascader)
|
||||
if (!category || !type) {
|
||||
return
|
||||
}
|
||||
@@ -122,6 +139,14 @@ export default {
|
||||
label: choice['display_name'],
|
||||
value: choice['value']
|
||||
}
|
||||
},
|
||||
changeLimits(limits) {
|
||||
console.log('Limits: ', limits)
|
||||
const hasDomain = limits['has_domain']
|
||||
const protocolLimits = limits['protocols_limit']
|
||||
this.fieldsMeta.domain_enabled.el.disabled = !hasDomain
|
||||
this.fieldsMeta.domain_default.el.disabled = !hasDomain
|
||||
this.fieldsMeta.protocols_default.el.choices = protocolLimits
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,16 +58,16 @@ export default {
|
||||
hasRightActions: true,
|
||||
hasMoreActions: false,
|
||||
hasBulkDelete: false,
|
||||
createRoute: 'PlatformCreate',
|
||||
moreCreates: {
|
||||
callback: (item) => {
|
||||
this.$router.push({
|
||||
name: 'PlatformCreate',
|
||||
query: { type: item.name, category: item.category }
|
||||
})
|
||||
},
|
||||
dropdown: this.$store.state.assets.assetCategoriesDropdown
|
||||
}
|
||||
createRoute: 'PlatformCreate'
|
||||
// moreCreates: {
|
||||
// callback: (item) => {
|
||||
// this.$router.push({
|
||||
// name: 'PlatformCreate',
|
||||
// query: { type: item.name, category: item.category }
|
||||
// })
|
||||
// },
|
||||
// dropdown: this.$store.state.assets.assetCategoriesDropdown
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,10 @@ export const AssetCascader = groupedDropdownToCascader(AssetProtocols)
|
||||
|
||||
export const assetFieldsMeta = {
|
||||
protocols: {
|
||||
component: ProtocolSelector
|
||||
component: ProtocolSelector,
|
||||
el: {
|
||||
choices: []
|
||||
}
|
||||
},
|
||||
platform: {
|
||||
el: {
|
||||
@@ -50,6 +53,7 @@ export const assetFieldsMeta = {
|
||||
}
|
||||
},
|
||||
domain: {
|
||||
disabled: false,
|
||||
el: {
|
||||
multiple: false,
|
||||
clearable: true,
|
||||
|
||||
Reference in New Issue
Block a user