Merge branch 'v3' of github.com:jumpserver/lina into v3

This commit is contained in:
ibuler
2022-10-27 19:06:04 +08:00
4 changed files with 27 additions and 13 deletions

View File

@@ -72,10 +72,11 @@ export default {
},
methods: {
async getPlatform() {
this.platform = await this.$axios.get(`/api/v1/assets/platforms/${this.asset?.platform?.id}/`)
const platformId = this.asset?.platform?.id || this.asset?.platform_id
this.platform = await this.$axios.get(`/api/v1/assets/platforms/${platformId}/`)
},
addAccount(form) {
const data = { asset: this.asset.id, ...form }
const data = { asset: this.asset?.id || '', ...form }
this.$axios.post(`/api/v1/assets/accounts/`, data).then(() => {
this.iVisible = false
this.$emit('add', true)

View File

@@ -68,7 +68,7 @@ export default {
},
asset: {
type: Object,
default: null
default: () => ({})
},
columns: {
type: Array,
@@ -179,6 +179,7 @@ export default {
can: this.$hasPerm('assets.change_account') && !this.$store.getters.currentOrgIsRoot,
callback: ({ row }) => {
vm.account = row
vm.$set(this.iAsset, 'platform_id', row.asset.platform_id)
vm.showAddDialog = false
setTimeout(() => {
vm.showAddDialog = true
@@ -235,7 +236,7 @@ export default {
this.$set(this.tableConfig, 'url', iNew)
this.$set(this.headerActions.exportOptions, 'url', iNew.replace('/accounts/', '/account-secrets/'))
},
'$route.query.assets': {
'$route.query.asset': {
immediate: true,
handler() {
this.hasAccountPermission()
@@ -252,8 +253,6 @@ export default {
actionColumn.formatterArgs.extraActions.push(item)
}
}
console.log('Has perm: ', this.$hasPerm('assets.change_account'))
},
methods: {
onUpdateAuthDone(account) {
@@ -262,11 +261,15 @@ export default {
addAccountSuccess() {
this.$refs.ListTable.reloadTable()
},
async getAssetDetail() {
const { query: { asset }} = this.$route
this.iAsset = await this.$axios.get(`/api/v1/assets/assets/${asset}/`)
},
hasAccountPermission() {
const { path, query } = this.$route
const { path, query: { asset }} = this.$route
if (!hasUUID(path)) {
const hasPerm = this.$hasPerm('assets.add_account') && !!query.assets
this.iAsset = { id: query.assets }
if (asset) this.getAssetDetail()
const hasPerm = this.$hasPerm('assets.add_account') && !!asset
this.$set(this.headerActions.extraActions[0], 'can', hasPerm)
}
}

View File

@@ -44,6 +44,8 @@ import AutoDataZTree from '../AutoDataZTree'
import Dialog from '@/components/Dialog'
import ListTable from '../ListTable'
import IBox from '../IBox'
import { setUrlParam } from '@/utils/common'
export default {
name: 'TreeTable',
components: {
@@ -88,8 +90,16 @@ export default {
},
mounted() {
// debug(this.treeSetting)
this.initSetTableUrl()
},
methods: {
initSetTableUrl() {
const { asset = '', node = '' } = this.$route.query || {}
let url = this.iTableConfig.url
url = setUrlParam(url, 'asset', asset)
url = setUrlParam(url, 'node', node)
this.$set(this.iTableConfig, 'url', url)
},
handleUrlChange(url) {
this.$set(this.iTableConfig, 'url', url)
this.$emit('urlChange', url)

View File

@@ -42,12 +42,12 @@ export default {
let url = '/api/v1/assets/accounts/'
if (treeNode.meta.type === 'node') {
const nodeId = treeNode.meta.data.id
url = setUrlParam(url, 'assets', '')
url = setUrlParam(url, 'nodes', nodeId)
url = setUrlParam(url, 'asset', '')
url = setUrlParam(url, 'node', nodeId)
} else if (treeNode.meta.type === 'asset') {
const assetId = treeNode.meta.data.id
url = setUrlParam(url, 'nodes', '')
url = setUrlParam(url, 'assets', assetId)
url = setUrlParam(url, 'node', '')
url = setUrlParam(url, 'asset', assetId)
}
this.$set(this.tableConfig, 'url', url)