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

This commit is contained in:
ibuler
2020-06-15 17:02:29 +08:00
7 changed files with 48 additions and 32 deletions

View File

@@ -209,6 +209,7 @@ export default {
if (!parentNode) { if (!parentNode) {
return return
} }
this.zTree.expandNode(parentNode, true, false, true, false)
// http://localhost/api/v1/assets/nodes/85aa4ee2-0bd9-41db-9079-aa3646448d0c/children/ // http://localhost/api/v1/assets/nodes/85aa4ee2-0bd9-41db-9079-aa3646448d0c/children/
const url = `${this.treeSetting.nodeUrl}${parentNode.meta.node.id}/children/` const url = `${this.treeSetting.nodeUrl}${parentNode.meta.node.id}/children/`
this.$axios.post(url, {}).then(data => { this.$axios.post(url, {}).then(data => {

View File

@@ -16,7 +16,7 @@ export default {
} }
}, },
methods: { methods: {
onDelete(col, row, cellValue, reload) { defaultOnDelete(col, row, cellValue, reload) {
const url = col.deleteUrl + cellValue const url = col.deleteUrl + cellValue
this.$axios.delete(url).then(res => { this.$axios.delete(url).then(res => {
this.$message.success(this.$t('common.deleteSuccessMsg')) this.$message.success(this.$t('common.deleteSuccessMsg'))
@@ -25,6 +25,13 @@ export default {
this.$message.error(this.$t('common.deleteErrorMsg' + ' ' + error)) this.$message.error(this.$t('common.deleteErrorMsg' + ' ' + error))
}) })
}, },
onDelete(col, row, cellValue, reload) {
if (col.onDelete && typeof col.onDelete === 'function') {
col.onDelete(col, row, cellValue, reload)
} else {
this.defaultOnDelete(col, row, cellValue, reload)
}
},
iCanDelete() { iCanDelete() {
return this.col.objects.indexOf(this.cellValue) === -1 return this.col.objects.indexOf(this.cellValue) === -1
} }

View File

@@ -130,11 +130,7 @@ export default {
items.map(v => { items.map(v => {
newData.push(v.value) newData.push(v.value)
}) })
return this.$axios.patch(relationUrl, { nodes: newData }).then(res => { return this.$axios.patch(relationUrl, { nodes: newData })
this.$message.success(this.$t('common.updateSuccessMsg'))
}).catch(err => {
this.$message.error(this.$t('common.updateErrorMsg' + ' ' + err))
})
}, },
performDelete: (item) => { performDelete: (item) => {
const itemId = item.value const itemId = item.value
@@ -146,11 +142,7 @@ export default {
} }
}) })
const relationUrl = `/api/v1/assets/assets/${this.object.id}/` const relationUrl = `/api/v1/assets/assets/${this.object.id}/`
return this.$axios.patch(relationUrl, { nodes: newData }).then(res => { return this.$axios.patch(relationUrl, { nodes: newData })
this.$message.success(this.$t('common.updateSuccessMsg'))
}).catch(err => {
this.$message.error(this.$t('common.updateErrorMsg' + ' ' + err))
})
} }
}, },
labelConfig: { labelConfig: {

View File

@@ -55,11 +55,7 @@ export default {
items.map(v => { items.map(v => {
newData.push(v.value) newData.push(v.value)
}) })
return this.$axios.patch(relationUrl, { system_users: newData }).then(res => { return this.$axios.patch(relationUrl, { system_users: newData })
this.$message.success(this.$t('common.updateSuccessMsg'))
}).catch(err => {
this.$message.error(this.$t('common.updateErrorMsg' + ' ' + err))
})
}, },
performDelete: (item) => { performDelete: (item) => {
const itemId = item.value const itemId = item.value
@@ -71,11 +67,7 @@ export default {
} }
}) })
const relationUrl = `/api/v1/assets/cmd-filters/${this.object.id}/` const relationUrl = `/api/v1/assets/cmd-filters/${this.object.id}/`
return this.$axios.patch(relationUrl, { system_users: newData }).then(res => { return this.$axios.patch(relationUrl, { system_users: newData })
this.$message.success(this.$t('common.deleteSuccessMsg'))
}).catch(err => {
this.$message.error(this.$t('common.deleteErrorMsg' + ' ' + err))
})
} }
} }
} }

View File

@@ -127,21 +127,13 @@ export default {
node: v.value node: v.value
} }
}) })
return this.$axios.post(relationUrl, data).then(res => { return this.$axios.post(relationUrl, data)
this.$message.success(this.$t('common.updateSuccessMsg'))
}).catch(err => {
this.$message.error(this.$t('common.updateErrorMsg' + ' ' + err))
})
}, },
performDelete: (item) => { performDelete: (item) => {
const itemId = item.value const itemId = item.value
const objectId = this.object.id const objectId = this.object.id
const relationUrl = `/api/v1/assets/system-users-nodes-relations/?systemuser=${objectId}&node=${itemId}` const relationUrl = `/api/v1/assets/system-users-nodes-relations/?systemuser=${objectId}&node=${itemId}`
return this.$axios.delete(relationUrl).then(res => { return this.$axios.delete(relationUrl)
this.$message.success(this.$t('common.updateSuccessMsg'))
}).catch(err => {
this.$message.error(this.$t('common.updateErrorMsg' + ' ' + err))
})
} }
} }
} }

View File

@@ -14,6 +14,7 @@
import ListTable from '@/components/ListTable/index' import ListTable from '@/components/ListTable/index'
import RelationCard from '@/components/RelationCard/index' import RelationCard from '@/components/RelationCard/index'
import AssetRelationCard from '@/components/AssetRelationCard' import AssetRelationCard from '@/components/AssetRelationCard'
import { DeleteActionFormatter } from '@/components/ListTable/formatters'
export default { export default {
name: 'ChangeAuthPlanAsset', name: 'ChangeAuthPlanAsset',
@@ -32,8 +33,29 @@ export default {
tableConfig: { tableConfig: {
url: `/api/v1/xpack/change-auth-plan/plan/${this.object.id}/assets/`, url: `/api/v1/xpack/change-auth-plan/plan/${this.object.id}/assets/`,
columns: [ columns: [
'hostname', 'ip' 'hostname', 'ip', 'delete_action'
], ],
columnsMeta: {
delete_action: {
prop: 'id',
label: this.$t('common.Actions'),
align: 'center',
width: 150,
objects: this.object.assets,
formatter: DeleteActionFormatter,
onDelete: function(col, row, cellValue, reload) {
this.$axios.patch(
`/api/v1/xpack/change-auth-plan/plan/${this.object.id}/asset/remove/`,
{ assets: [row.id] }
).then(res => {
this.$message.success(this.$t('common.deleteSuccessMsg'))
reload()
}).catch(error => {
this.$message.error(this.$t('common.deleteErrorMsg' + ' ' + error))
})
}.bind(this)
}
},
tableAttrs: { tableAttrs: {
border: false border: false
} }

View File

@@ -20,6 +20,16 @@ export default {
], ],
url: '/api/v1/xpack/cloud/accounts/', url: '/api/v1/xpack/cloud/accounts/',
fieldsMeta: { fieldsMeta: {
access_key_id: {
rules: [
{ required: this.$route.meta.action === 'create', message: this.$t('common.fieldRequiredError') }
]
},
access_key_secret: {
rules: [
{ required: this.$route.meta.action === 'create', message: this.$t('common.fieldRequiredError') }
]
}
}, },
updateSuccessNextRoute: { name: 'CloudCenter' }, updateSuccessNextRoute: { name: 'CloudCenter' },
createSuccessNextRoute: { name: 'CloudCenter' } createSuccessNextRoute: { name: 'CloudCenter' }