mirror of
https://github.com/jumpserver/lina.git
synced 2026-01-13 11:24:17 +00:00
fix: 修复资产详情里账号创建不成功问题;资产里不显示系统用户
This commit is contained in:
@@ -95,11 +95,12 @@ export default {
|
||||
},
|
||||
mounted() {
|
||||
console.log('protocols: ', this.protocols)
|
||||
console.log('this.account: ', this.account)
|
||||
},
|
||||
methods: {
|
||||
confirm(form) {
|
||||
console.log('Account form: accout is: ', this.account)
|
||||
if (this.account) {
|
||||
if (this.account?.name) {
|
||||
this.$emit('edit', form)
|
||||
} else {
|
||||
this.$emit('add', form)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<Dialog
|
||||
:title="this.$tc('assets.AddAccount')"
|
||||
:visible.sync="visible"
|
||||
:visible.sync="iVisible"
|
||||
:destroy-on-close="true"
|
||||
:show-cancel="false"
|
||||
:show-confirm="false"
|
||||
@@ -14,6 +14,7 @@
|
||||
:protocols="protocols"
|
||||
:account="account"
|
||||
@add="addAccount"
|
||||
@edit="editAccount"
|
||||
/>
|
||||
</Dialog>
|
||||
</template>
|
||||
@@ -35,19 +36,30 @@ export default {
|
||||
asset: {
|
||||
type: Object,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
account: {
|
||||
},
|
||||
account: {
|
||||
type: Object,
|
||||
default: () => ({
|
||||
name: '',
|
||||
username: '',
|
||||
password: '',
|
||||
private_key: ''
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
iVisible: {
|
||||
get() {
|
||||
return this.visible
|
||||
},
|
||||
set(val) {
|
||||
this.$emit('update:visible', val)
|
||||
}
|
||||
},
|
||||
protocols() {
|
||||
return this.asset ? this.asset.protocol : []
|
||||
}
|
||||
@@ -57,12 +69,19 @@ export default {
|
||||
const data = { asset: this.asset.id, ...form }
|
||||
this.$axios.post(`/api/v1/assets/accounts/`, data)
|
||||
.then(() => {
|
||||
this.visible = false
|
||||
this.iVisible = false
|
||||
this.$emit('add', true)
|
||||
})
|
||||
.catch(() => {
|
||||
this.$message.error(this.$tc('common.createErrorMsg'))
|
||||
})
|
||||
},
|
||||
editAccount(form) {
|
||||
const data = { asset: this.asset.id, ...form }
|
||||
this.$axios.patch(`/api/v1/assets/accounts/${this.asset.id}`, data).then(() => {
|
||||
this.iVisible = false
|
||||
this.$emit('add', true)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
v-if="showAddDialog"
|
||||
:visible.sync="showAddDialog"
|
||||
:asset="asset"
|
||||
:account="account"
|
||||
@add="addAccountSuccess"
|
||||
/>
|
||||
</div>
|
||||
@@ -168,9 +169,9 @@ export default {
|
||||
can: this.$hasPerm('assets.change_assetaccountsecret') && !this.$store.getters.currentOrgIsRoot,
|
||||
callback: ({ row }) => {
|
||||
vm.account = row
|
||||
vm.showUpdateSecretDialog = false
|
||||
vm.showAddDialog = false
|
||||
setTimeout(() => {
|
||||
vm.showUpdateSecretDialog = true
|
||||
vm.showAddDialog = true
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -196,6 +197,7 @@ export default {
|
||||
type: 'primary',
|
||||
can: vm.$hasPerm('assets.add_account'),
|
||||
callback: () => {
|
||||
this.account = null
|
||||
this.showAddDialog = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,222 +0,0 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-row :gutter="20">
|
||||
<el-col :md="16" :sm="24">
|
||||
<ListTable ref="ListTable" :table-config="tableConfig" :header-actions="headerActions" />
|
||||
</el-col>
|
||||
<el-col :md="8" :sm="24">
|
||||
<QuickActions type="primary" :actions="quickActions" />
|
||||
<RelationCard ref="systemUserRelation" style="margin-top: 15px" v-bind="systemUserRelationConfig" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import QuickActions from '@/components/QuickActions/index'
|
||||
import RelationCard from '@/components/RelationCard'
|
||||
import ListTable from '@/components/ListTable'
|
||||
import { DetailFormatter } from '@/components/TableFormatters'
|
||||
import { connectivityMeta } from '@/components/AccountListTable/const'
|
||||
import { openTaskPage } from '@/utils/jms'
|
||||
|
||||
export default {
|
||||
name: 'SystemUserList',
|
||||
components: {
|
||||
QuickActions,
|
||||
RelationCard,
|
||||
ListTable
|
||||
},
|
||||
props: {
|
||||
object: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
const vm = this
|
||||
return {
|
||||
tableConfig: {
|
||||
url: `/api/v1/assets/system-users-assets-relations/?asset=${this.object.id}`,
|
||||
columns: ['systemuser_display', 'connectivity', 'actions'],
|
||||
columnsMeta: {
|
||||
systemuser_display: {
|
||||
label: this.$t('assets.SystemUser'),
|
||||
showOverflowTooltip: true,
|
||||
formatter: DetailFormatter,
|
||||
formatterArgs: {
|
||||
getRoute({ row }) {
|
||||
return {
|
||||
name: 'SystemUserDetail',
|
||||
params: { id: row.systemuser }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
connectivity: connectivityMeta,
|
||||
actions: {
|
||||
formatterArgs: {
|
||||
hasUpdate: false, // can set function(row, value)
|
||||
hasDelete: false, // can set function(row, value)
|
||||
hasClone: false,
|
||||
moreActionsTitle: this.$t('common.More'),
|
||||
extraActions: [
|
||||
{
|
||||
name: 'Test',
|
||||
title: this.$t('common.Test'),
|
||||
type: 'primary',
|
||||
can: vm.$hasPerm('assets.test_assetconnectivity'),
|
||||
callback: ({ row }) => {
|
||||
const theUrl = `/api/v1/assets/system-users/${row.systemuser}/tasks/`
|
||||
const data = { action: 'test', assets: [this.object.id] }
|
||||
this.$axios.post(theUrl, data).then(resp => {
|
||||
openTaskPage(resp['task'])
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'Push',
|
||||
title: this.$t('common.Push'),
|
||||
can: vm.$hasPerm('assets.push_assetsystemuser'),
|
||||
type: 'primary',
|
||||
callback: ({ row }) => {
|
||||
const theUrl = `/api/v1/assets/system-users/${row.systemuser}/tasks/`
|
||||
const data = { action: 'push', assets: [this.object.id] }
|
||||
this.$axios.post(theUrl, data).then(resp => {
|
||||
openTaskPage(resp['task'])
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
title: this.$t('common.Delete'),
|
||||
type: 'danger',
|
||||
can: !this.$store.getters.currentOrgIsRoot && vm.$hasPerm('assets.delete_account'),
|
||||
callback: (val) => {
|
||||
this.$axios.delete(`/api/v1/assets/system-users-assets-relations/${val.row.id}/`).then(() => {
|
||||
this.$message.success(this.$t('common.deleteSuccessMsg'))
|
||||
this.$refs.ListTable.reloadTable()
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
headerActions: {
|
||||
hasBulkDelete: false,
|
||||
hasImport: false,
|
||||
hasCreate: false,
|
||||
extraMoreActions: [
|
||||
{
|
||||
title: this.$t('common.TestSelectedSystemUsersConnective'),
|
||||
name: 'TestSelected',
|
||||
can({ selectedRows }) {
|
||||
return selectedRows.length > 0 && vm.$hasPerm('assets.test_assetconnectivity')
|
||||
},
|
||||
callback: this.bulkTestCallback.bind(this)
|
||||
},
|
||||
{
|
||||
title: this.$t('common.PushSelectedSystemUsersToAsset'),
|
||||
name: 'PushSelected',
|
||||
can({ selectedRows }) {
|
||||
return selectedRows.length > 0 && vm.$hasPerm('assets.push_assetsystemuser')
|
||||
},
|
||||
callback: this.bulkPushCallback.bind(this)
|
||||
}
|
||||
]
|
||||
},
|
||||
quickActions: [
|
||||
{
|
||||
title: this.$t('assets.TestAllSystemUsersConnective'),
|
||||
attrs: {
|
||||
type: 'primary',
|
||||
label: this.$t('common.Test'),
|
||||
disabled: !vm.$hasPerm('assets.test_assetconnectivity')
|
||||
},
|
||||
callbacks: {
|
||||
click: function() {
|
||||
const theUrl = `/api/v1/assets/assets/${this.object.id}/tasks/`
|
||||
const data = { action: 'test_system_user' }
|
||||
this.$axios.post(theUrl, data).then(resp => {
|
||||
openTaskPage(resp['task'])
|
||||
})
|
||||
}.bind(this)
|
||||
}
|
||||
},
|
||||
{
|
||||
title: this.$t('assets.PushAllSystemUsersToAsset'),
|
||||
attrs: {
|
||||
type: 'primary',
|
||||
label: this.$t('common.Push'),
|
||||
disabled: !vm.$hasPerm('assets.push_assetsystemuser')
|
||||
},
|
||||
callbacks: {
|
||||
click: function({ row }) {
|
||||
const theUrl = `/api/v1/assets/assets/${this.object.id}/tasks/`
|
||||
const data = { action: 'push_system_user' }
|
||||
this.$axios.post(theUrl, data).then(resp => {
|
||||
openTaskPage(resp['task'])
|
||||
})
|
||||
}.bind(this)
|
||||
}
|
||||
}
|
||||
],
|
||||
systemUserRelationConfig: {
|
||||
disabled: !vm.$hasPerm('assets.add_account'),
|
||||
icon: 'fa-link',
|
||||
type: 'info',
|
||||
title: this.$t('assets.AssociateSystemUsers'),
|
||||
objectsAjax: {
|
||||
url: `/api/v1/assets/system-users/`
|
||||
},
|
||||
performAdd: (items, that) => {
|
||||
const relationUrl = `/api/v1/assets/system-users-assets-relations/`
|
||||
const data = items.map((i) => {
|
||||
return {
|
||||
'asset': this.object.id,
|
||||
'systemuser': i.value
|
||||
}
|
||||
})
|
||||
if (data.length === 0) {
|
||||
return this.$message.error(this.$tc('assets.UnselectedSystemUsers'))
|
||||
}
|
||||
return this.$axios.post(relationUrl, data)
|
||||
},
|
||||
onAddSuccess: (items, that) => {
|
||||
vm.$message.success(this.$t('common.updateSuccessMsg'))
|
||||
vm.$refs.ListTable.reloadTable()
|
||||
vm.$refs.systemUserRelation.$refs.select2.clearSelected()
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
bulkPushCallback({ selectedRows }) {
|
||||
const theUrl = `/api/v1/assets/assets/${this.object.id}/tasks/`
|
||||
const systemUsers = selectedRows.map((v) => {
|
||||
return v.systemuser
|
||||
})
|
||||
const data = { action: 'push_system_user', system_users: systemUsers }
|
||||
this.$axios.post(theUrl, data).then(resp => {
|
||||
openTaskPage(resp['task'])
|
||||
})
|
||||
},
|
||||
bulkTestCallback({ selectedRows }) {
|
||||
const theUrl = `/api/v1/assets/assets/${this.object.id}/tasks/`
|
||||
const systemUsers = selectedRows.map((v) => {
|
||||
return v.systemuser
|
||||
})
|
||||
const data = { action: 'test_system_user', system_users: systemUsers }
|
||||
this.$axios.post(theUrl, data).then(resp => {
|
||||
openTaskPage(resp['task'])
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang='less' scoped>
|
||||
|
||||
</style>
|
||||
@@ -15,7 +15,6 @@
|
||||
import { GenericDetailPage, TabPage } from '@/layout/components'
|
||||
import Detail from './Detail.vue'
|
||||
import Account from './Account.vue'
|
||||
import SystemUserList from './SystemUser.vue'
|
||||
import PermUserList from './PermUser.vue'
|
||||
|
||||
export default {
|
||||
@@ -25,7 +24,6 @@ export default {
|
||||
TabPage,
|
||||
Detail,
|
||||
Account,
|
||||
SystemUserList,
|
||||
PermUserList
|
||||
},
|
||||
data() {
|
||||
@@ -38,11 +36,6 @@ export default {
|
||||
title: this.$t('assets.AssetDetail'),
|
||||
name: 'Detail'
|
||||
},
|
||||
{
|
||||
title: this.$t('assets.SystemUser'),
|
||||
name: 'SystemUserList',
|
||||
hidden: () => !this.$hasPerm('assets.view_account')
|
||||
},
|
||||
{
|
||||
title: this.$t('assets.AccountList'),
|
||||
name: 'Account',
|
||||
|
||||
Reference in New Issue
Block a user