mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-20 02:31:43 +00:00
perf: 修改 添加 account
This commit is contained in:
@@ -4,8 +4,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import AutoDataForm from '@/components/AutoDataForm'
|
import AutoDataForm from '@/components/AutoDataForm'
|
||||||
import { UpdateToken } from '@/components/FormFields'
|
import { UpdateToken, UploadKey } from '@/components/FormFields'
|
||||||
import { UploadKey } from '@/components'
|
|
||||||
export default {
|
export default {
|
||||||
name: 'AccountCreateForm',
|
name: 'AccountCreateForm',
|
||||||
components: {
|
components: {
|
||||||
@@ -14,7 +13,7 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
protocols: {
|
protocols: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => ['ssh', 'rdp']
|
default: () => ([])
|
||||||
},
|
},
|
||||||
accounts: {
|
accounts: {
|
||||||
type: Array,
|
type: Array,
|
||||||
@@ -30,16 +29,16 @@ export default {
|
|||||||
url: '/api/v1/assets/accounts/',
|
url: '/api/v1/assets/accounts/',
|
||||||
form: this.account || { protocol: this.protocols[0] },
|
form: this.account || { protocol: this.protocols[0] },
|
||||||
fields: [
|
fields: [
|
||||||
'protocol', 'type', 'username', 'password',
|
'type', 'username', 'password',
|
||||||
'private_key', 'passphrase', 'comment'
|
'private_key', 'passphrase', 'comment'
|
||||||
],
|
],
|
||||||
fieldsMeta: {
|
fieldsMeta: {
|
||||||
protocol: {
|
protocol: {
|
||||||
type: 'radio-group',
|
type: 'radio-group',
|
||||||
label: this.$t('assets.Protocol'),
|
label: this.$t('assets.Protocol'),
|
||||||
default: this.protocols[0],
|
default: this.protocols[0].name,
|
||||||
options: this.protocols.map((item) => {
|
options: this.protocols.map((item) => {
|
||||||
return { label: item.toUpperCase(), value: item }
|
return { label: item.name.toUpperCase(), value: item.name }
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
password: {
|
password: {
|
||||||
@@ -55,6 +54,9 @@ export default {
|
|||||||
hasSaveContinue: false
|
hasSaveContinue: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
console.log('protocols: ', this.protocols)
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
confirm(form) {
|
confirm(form) {
|
||||||
if (this.account && this.account._id) {
|
if (this.account && this.account._id) {
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ActionsFormatter, DetailFormatter, DisplayFormatter } from '@/components/TableFormatters'
|
import { ActionsFormatter, DetailFormatter } from '@/components/TableFormatters'
|
||||||
import ShowSecretInfo from '../AccountListTable/ShowSecretInfo'
|
import ShowSecretInfo from '../AccountListTable/ShowSecretInfo'
|
||||||
import { GenericListPage } from '@/layout/components'
|
import { GenericListPage } from '@/layout/components'
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ export default {
|
|||||||
resource: 'authbook'
|
resource: 'authbook'
|
||||||
},
|
},
|
||||||
columns: [
|
columns: [
|
||||||
'hostname', 'ip', 'username', 'version',
|
'asset_name', 'ip', 'username', 'version',
|
||||||
'systemuser', 'date_created', 'date_updated', 'actions'
|
'systemuser', 'date_created', 'date_updated', 'actions'
|
||||||
],
|
],
|
||||||
columnsShow: {
|
columnsShow: {
|
||||||
@@ -60,9 +60,9 @@ export default {
|
|||||||
default: ['hostname', 'ip', 'username', 'version', 'actions']
|
default: ['hostname', 'ip', 'username', 'version', 'actions']
|
||||||
},
|
},
|
||||||
columnsMeta: {
|
columnsMeta: {
|
||||||
hostname: {
|
asset_name: {
|
||||||
prop: 'hostname',
|
prop: 'asset_name',
|
||||||
label: this.$t('assets.Hostname'),
|
label: this.$t('assets.Name'),
|
||||||
showOverflowTooltip: true,
|
showOverflowTooltip: true,
|
||||||
formatter: DetailFormatter,
|
formatter: DetailFormatter,
|
||||||
formatterArgs: {
|
formatterArgs: {
|
||||||
@@ -81,9 +81,6 @@ export default {
|
|||||||
username: {
|
username: {
|
||||||
showOverflowTooltip: true
|
showOverflowTooltip: true
|
||||||
},
|
},
|
||||||
systemuser: {
|
|
||||||
formatter: DisplayFormatter
|
|
||||||
},
|
|
||||||
version: {
|
version: {
|
||||||
width: '70px'
|
width: '70px'
|
||||||
},
|
},
|
||||||
|
@@ -40,7 +40,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
account: {
|
account: {
|
||||||
hostname: '',
|
name: '',
|
||||||
username: '',
|
username: '',
|
||||||
password: '',
|
password: '',
|
||||||
private_key: ''
|
private_key: ''
|
||||||
@@ -49,7 +49,7 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
protocols() {
|
protocols() {
|
||||||
return this.asset ? this.asset.protocols.map((item) => item.split('/')[0]) : []
|
return this.asset ? this.asset.protocol : []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@@ -17,8 +17,8 @@
|
|||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
<el-form label-position="right" label-width="80px" :model="authInfo">
|
<el-form label-position="right" label-width="80px" :model="authInfo">
|
||||||
<el-form-item :label="this.$t('assets.Hostname')">
|
<el-form-item :label="this.$t('assets.Name')">
|
||||||
<el-input v-model="account.hostname" readonly />
|
<el-input v-model="account['asset_name']" readonly />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="this.$t('assets.Username')">
|
<el-form-item :label="this.$t('assets.Username')">
|
||||||
<el-input v-model="account['username']" readonly />
|
<el-input v-model="account['username']" readonly />
|
||||||
|
@@ -9,8 +9,8 @@
|
|||||||
v-on="$listeners"
|
v-on="$listeners"
|
||||||
>
|
>
|
||||||
<el-form label-position="right" label-width="90px">
|
<el-form label-position="right" label-width="90px">
|
||||||
<el-form-item :label="this.$t('assets.Hostname')">
|
<el-form-item :label="this.$t('assets.Name')">
|
||||||
<el-input v-model="account.hostname" readonly />
|
<el-input v-model="account['asset_name']" readonly />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="this.$t('assets.Username')">
|
<el-form-item :label="this.$t('assets.Username')">
|
||||||
<el-input v-model="account['username']" readonly />
|
<el-input v-model="account['username']" readonly />
|
||||||
|
@@ -88,17 +88,17 @@ export default {
|
|||||||
this.items.push({ ...this.remainProtocols[0] })
|
this.items.push({ ...this.remainProtocols[0] })
|
||||||
},
|
},
|
||||||
handleProtocolChange(evt, item) {
|
handleProtocolChange(evt, item) {
|
||||||
const selected = this.protocols.find(item => item.name === evt)
|
const selected = this.choices.find(item => item.name === evt)
|
||||||
item.name = selected.name
|
item.name = selected.name
|
||||||
item.port = selected.port
|
item.port = selected.port
|
||||||
},
|
},
|
||||||
setDefaultItems(choices) {
|
setDefaultItems(choices) {
|
||||||
if (!this.value) {
|
if (this.value && this.value.length > 0) {
|
||||||
if (choices.length !== 0) {
|
|
||||||
this.items = [choices[0]]
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.items = [...this.value]
|
this.items = [...this.value]
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (choices.length !== 0) {
|
||||||
|
this.items = [choices[0]]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -50,7 +50,7 @@ export default {
|
|||||||
ajax: {
|
ajax: {
|
||||||
url: '/api/v1/assets/assets/?platform__base=Windows',
|
url: '/api/v1/assets/assets/?platform__base=Windows',
|
||||||
transformOption: (item) => {
|
transformOption: (item) => {
|
||||||
return { label: item.hostname, value: item.id }
|
return { label: item.name, value: item.id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
initial: {},
|
initial: {},
|
||||||
fields: [
|
fields: [
|
||||||
[this.$t('common.Basic'), ['hostname', 'ip', 'platform', 'domain']]
|
[this.$t('common.Basic'), ['name', 'ip', 'platform', 'domain']]
|
||||||
// [this.$t('assets.Protocol'), ['protocols']],
|
// [this.$t('assets.Protocol'), ['protocols']],
|
||||||
// [this.$t('assets.Node'), ['nodes']],
|
// [this.$t('assets.Node'), ['nodes']],
|
||||||
// this.$route.params.id ? null : [this.$t('assets.Account'), ['accounts']],
|
// this.$route.params.id ? null : [this.$t('assets.Account'), ['accounts']],
|
||||||
|
@@ -24,7 +24,12 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import GenericTreeListPage from '@/layout/components/GenericTreeListPage/index'
|
import GenericTreeListPage from '@/layout/components/GenericTreeListPage/index'
|
||||||
import { DetailFormatter, ActionsFormatter, TagsFormatter, NestedObjectFormatter } from '@/components/TableFormatters'
|
import {
|
||||||
|
DetailFormatter,
|
||||||
|
ActionsFormatter,
|
||||||
|
TagsFormatter,
|
||||||
|
NestedObjectFormatter
|
||||||
|
} from '@/components/TableFormatters'
|
||||||
import $ from '@/utils/jquery-vendor'
|
import $ from '@/utils/jquery-vendor'
|
||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
import { connectivityMeta } from '@/components/AccountListTable/const'
|
import { connectivityMeta } from '@/components/AccountListTable/const'
|
||||||
@@ -61,7 +66,7 @@ export default {
|
|||||||
url: '/api/v1/assets/assets/',
|
url: '/api/v1/assets/assets/',
|
||||||
hasTree: true,
|
hasTree: true,
|
||||||
columns: [
|
columns: [
|
||||||
'hostname', 'ip', 'protocols',
|
'name', 'ip', 'protocols',
|
||||||
'category', 'type', 'platform',
|
'category', 'type', 'platform',
|
||||||
'labels', 'nodes',
|
'labels', 'nodes',
|
||||||
'is_active', 'connectivity',
|
'is_active', 'connectivity',
|
||||||
|
@@ -15,9 +15,11 @@ export default {
|
|||||||
return {
|
return {
|
||||||
loading: true,
|
loading: true,
|
||||||
platform: {},
|
platform: {},
|
||||||
initial: { labels: [] },
|
initial: {
|
||||||
|
labels: []
|
||||||
|
},
|
||||||
fields: [
|
fields: [
|
||||||
[this.$t('common.Basic'), ['hostname', 'ip', 'platform', 'domain']],
|
[this.$t('common.Basic'), ['name', 'ip', 'platform', 'domain']],
|
||||||
[this.$t('assets.Protocols'), ['protocols']],
|
[this.$t('assets.Protocols'), ['protocols']],
|
||||||
[this.$t('assets.Node'), ['nodes']],
|
[this.$t('assets.Node'), ['nodes']],
|
||||||
this.$route.params.id ? null : [this.$t('assets.Account'), ['accounts']],
|
this.$route.params.id ? null : [this.$t('assets.Account'), ['accounts']],
|
||||||
@@ -45,13 +47,12 @@ export default {
|
|||||||
const initial = {
|
const initial = {
|
||||||
is_active: true,
|
is_active: true,
|
||||||
platform: parseInt(platformId),
|
platform: parseInt(platformId),
|
||||||
protocols: this.platform.protocols_default || ['ssh/22'],
|
protocols: this.platform.protocols_default,
|
||||||
nodes: nodesInitial,
|
nodes: nodesInitial,
|
||||||
domain: this.platform['domain_default'],
|
domain: this.platform.domain_default
|
||||||
admin_user: this.platform['admin_user_default']
|
|
||||||
}
|
}
|
||||||
const limits = this.platform['type_limits']
|
const constraints = this.platform['type_constraints']
|
||||||
this.fieldsMeta.protocols.el.choices = limits['protocols_limit']
|
this.fieldsMeta.protocols.el.choices = constraints['protocols']
|
||||||
this.initial = initial
|
this.initial = initial
|
||||||
this.loading = false
|
this.loading = false
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
loading: true,
|
loading: true,
|
||||||
initial: {
|
initial: {
|
||||||
comment: 'Hello world',
|
comment: '',
|
||||||
charset: 'utf8',
|
charset: 'utf8',
|
||||||
category_type: ['host', 'linux'],
|
category_type: ['host', 'linux'],
|
||||||
domain_enabled: false,
|
domain_enabled: false,
|
||||||
@@ -106,20 +106,16 @@ export default {
|
|||||||
},
|
},
|
||||||
protocols_enabled: {
|
protocols_enabled: {
|
||||||
el: {
|
el: {
|
||||||
disabled: false,
|
disabled: false
|
||||||
value: false
|
}
|
||||||
},
|
|
||||||
value: false
|
|
||||||
},
|
},
|
||||||
protocols_default: {
|
protocols_default: {
|
||||||
...assetMeta.protocols,
|
...assetMeta.protocols,
|
||||||
hidden: (formValue) => {
|
hidden: (formValue) => {
|
||||||
console.log('formValue', formValue)
|
|
||||||
return !formValue['protocols_enabled']
|
return !formValue['protocols_enabled']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
domain_enabled: {
|
domain_enabled: {
|
||||||
value: true,
|
|
||||||
el: {
|
el: {
|
||||||
disabled: false
|
disabled: false
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user