Merge pull request #978 from jumpserver/dev

v2.13.0 rc4
This commit is contained in:
Jiangjie.Bai
2021-08-18 19:46:06 +08:00
committed by GitHub
13 changed files with 94 additions and 39 deletions

View File

@@ -89,7 +89,7 @@ export default {
return return
} }
if (currentNode) { if (currentNode) {
currentNode.name = currentNode.meta.node.value currentNode.name = currentNode.meta.data.value
} }
this.zTree.editName(currentNode) this.zTree.editName(currentNode)
}, },
@@ -108,12 +108,12 @@ export default {
const query = Object.assign({}, this.$route.query) const query = Object.assign({}, this.$route.query)
if (treeNode.meta.type === 'node') { if (treeNode.meta.type === 'node') {
this.currentNode = treeNode this.currentNode = treeNode
this.currentNodeId = treeNode.meta.node.id this.currentNodeId = treeNode.meta.data.id
query['node'] = this.currentNodeId query['node'] = this.currentNodeId
url = `${this.setting.url}${combinator}node_id=${treeNode.meta.node.id}&show_current_asset=${show_current_asset}` url = `${this.setting.url}${combinator}node_id=${treeNode.meta.data.id}&show_current_asset=${show_current_asset}`
} else if (treeNode.meta.type === 'asset') { } else if (treeNode.meta.type === 'asset') {
query['asset'] = treeNode.meta.asset.id query['asset'] = treeNode.meta.data.id
url = `${this.setting.url}${combinator}asset_id=${treeNode.meta.asset.id}&show_current_asset=${show_current_asset}` url = `${this.setting.url}${combinator}asset_id=${treeNode.meta.data.id}&show_current_asset=${show_current_asset}`
} }
this.$router.push({ query }) this.$router.push({ query })
this.$emit('urlChange', url) this.$emit('urlChange', url)
@@ -125,7 +125,7 @@ export default {
return return
} }
this.$axios.delete( this.$axios.delete(
`${this.treeSetting.nodeUrl}${currentNode.meta.node.id}/` `${this.treeSetting.nodeUrl}${currentNode.meta.data.id}/`
).then(() => { ).then(() => {
this.$message.success(this.$t('common.deleteSuccessMsg')) this.$message.success(this.$t('common.deleteSuccessMsg'))
this.zTree.removeNode(currentNode) this.zTree.removeNode(currentNode)
@@ -143,7 +143,7 @@ export default {
url, url,
{ 'value': treeNode.name } { 'value': treeNode.name }
).then(res => { ).then(res => {
let assetsAmount = treeNode.meta.node.assetsAmount let assetsAmount = treeNode.meta.data.assetsAmount
if (!assetsAmount) { if (!assetsAmount) {
assetsAmount = 0 assetsAmount = 0
} }
@@ -208,9 +208,9 @@ export default {
onDrop: function(event, treeId, treeNodes, targetNode, moveType) { onDrop: function(event, treeId, treeNodes, targetNode, moveType) {
const treeNodesIds = [] const treeNodesIds = []
$.each(treeNodes, function(index, value) { $.each(treeNodes, function(index, value) {
treeNodesIds.push(value.meta.node.id) treeNodesIds.push(value.meta.data.id)
}) })
const theUrl = `${this.treeSetting.nodeUrl}${targetNode.meta.node.id}/children/add/` const theUrl = `${this.treeSetting.nodeUrl}${targetNode.meta.data.id}/children/add/`
this.$axios.put( this.$axios.put(
theUrl, { theUrl, {
nodes: treeNodesIds nodes: treeNodesIds
@@ -229,7 +229,7 @@ export default {
} }
this.zTree.expandNode(parentNode, true, false, true, false) 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.data.id}/children/`
this.$axios.post(url, {}).then(data => { this.$axios.post(url, {}).then(data => {
const newNode = { const newNode = {
id: data['key'], id: data['key'],
@@ -243,7 +243,7 @@ export default {
this.zTree.addNodes(parentNode, 0, newNode) this.zTree.addNodes(parentNode, 0, newNode)
// vm.$refs.dataztree.refresh() // vm.$refs.dataztree.refresh()
const node = this.zTree.getNodeByParam('id', newNode.id, parentNode) const node = this.zTree.getNodeByParam('id', newNode.id, parentNode)
this.currentNodeId = node.meta.node.id || newNode.id this.currentNodeId = node.meta.data.id || newNode.id
this.zTree.editName(node) this.zTree.editName(node)
this.$message.success(this.$t('common.createSuccessMsg')) this.$message.success(this.$t('common.createSuccessMsg'))
}).catch(error => { }).catch(error => {

View File

@@ -2,6 +2,7 @@
<el-select <el-select
ref="select" ref="select"
v-model="iValue" v-model="iValue"
v-loading="!initialized"
v-loadmore="loadMore" v-loadmore="loadMore"
:options="iOptions" :options="iOptions"
:remote="remote" :remote="remote"
@@ -97,7 +98,7 @@ export default {
return { return {
loading: false, loading: false,
initialized: false, initialized: false,
iValue: this.value ? this.value : [], iValue: this.multiple ? [] : '',
defaultParams: _.cloneDeep(defaultParams), defaultParams: _.cloneDeep(defaultParams),
params: _.cloneDeep(defaultParams), params: _.cloneDeep(defaultParams),
iOptions: this.options || [], iOptions: this.options || [],
@@ -161,11 +162,14 @@ export default {
this.iValue = iNew this.iValue = iNew
} }
}, },
mounted() { async mounted() {
// this.$log.debug('Select2 url is: ', this.iAjax.url) // this.$log.debug('Select2 url is: ', this.iAjax.url)
if (!this.initialized) { if (!this.initialized) {
this.initialSelect() await this.initialSelect()
this.initialized = true setTimeout(() => {
this.initialized = true
this.iValue = this.value
})
} }
this.$nextTick(() => { this.$nextTick(() => {
// 因为elform存在问题这个来清楚验证 // 因为elform存在问题这个来清楚验证
@@ -243,9 +247,13 @@ export default {
// this.$log.debug('Select ajax config', this.iAjax) // this.$log.debug('Select ajax config', this.iAjax)
if (this.iAjax.url) { if (this.iAjax.url) {
if (this.value && this.value.length !== 0) { if (this.value && this.value.length !== 0) {
this.$log.debug('Start init select2 value') this.$log.debug('Start init select2 value, ', this.value)
const data = await createSourceIdCache(this.value) let value = this.value
this.params.spm = data.spm if (!Array.isArray(value)) {
value = [value]
}
const data = await createSourceIdCache(value)
this.params.spm = data['spm']
await this.getInitialOptions() await this.getInitialOptions()
} }
await this.getOptions() await this.getOptions()

View File

@@ -27,7 +27,7 @@ export default {
vm.tableConfig.initialUrl = vm.tableConfig.url vm.tableConfig.initialUrl = vm.tableConfig.url
} }
const initialUrl = vm.tableConfig.initialUrl const initialUrl = vm.tableConfig.initialUrl
const nodeId = node.meta.node.id const nodeId = node.meta.data.id
const url = initialUrl.replace('/assets/', `/nodes/${nodeId}/assets/`) const url = initialUrl.replace('/assets/', `/nodes/${nodeId}/assets/`)
vm.tableConfig.url = url vm.tableConfig.url = url
} }

View File

@@ -24,7 +24,7 @@ export default {
refresh: () => {}, refresh: () => {},
onSelected: function(event, treeNode) { onSelected: function(event, treeNode) {
if (treeNode.meta.type === 'node') { if (treeNode.meta.type === 'node') {
const currentNodeId = treeNode.meta.node.id const currentNodeId = treeNode.meta.data.id
this.tableConfig.url = `/api/v1/perms/users/nodes/${currentNodeId}/assets/?cache_policy=1` this.tableConfig.url = `/api/v1/perms/users/nodes/${currentNodeId}/assets/?cache_policy=1`
} }
}.bind(this) }.bind(this)

View File

@@ -33,11 +33,11 @@ export default {
onSelected: function(event, treeNode) { onSelected: function(event, treeNode) {
let url = '/api/v1/assets/accounts/' let url = '/api/v1/assets/accounts/'
if (treeNode.meta.type === 'node') { if (treeNode.meta.type === 'node') {
const nodeId = treeNode.meta.node.id const nodeId = treeNode.meta.data.id
url = setUrlParam(url, 'asset', '') url = setUrlParam(url, 'asset', '')
url = setUrlParam(url, 'node', nodeId) url = setUrlParam(url, 'node', nodeId)
} else if (treeNode.meta.type === 'asset') { } else if (treeNode.meta.type === 'asset') {
const assetId = treeNode.meta.asset.id const assetId = treeNode.meta.data.id
url = setUrlParam(url, 'node', '') url = setUrlParam(url, 'node', '')
url = setUrlParam(url, 'asset', assetId) url = setUrlParam(url, 'asset', assetId)
} }

View File

@@ -37,7 +37,18 @@ export default {
} }
} }
}, },
url: `/api/v1/acls/login-acls/`, getUrl() {
const query = this.$route.query
const params = this.$route.params
let url = `/api/v1/acls/login-acls/`
if (params.id) {
url = `${url}${params.id}/`
}
if (query.user) {
url = `${url}?user=${query.user}`
}
return url
},
updateSuccessNextRoute: { name: 'UserDetail', params: { updateSuccessNextRoute: { name: 'UserDetail', params: {
id: this.$route.query.user id: this.$route.query.user
}}, }},
@@ -69,7 +80,6 @@ export default {
if (!Array.isArray(value.ip_group)) { if (!Array.isArray(value.ip_group)) {
value.ip_group = value.ip_group ? value.ip_group.split(',') : [] value.ip_group = value.ip_group ? value.ip_group.split(',') : []
} }
console.log('>>>>>>>>: ', value)
return value return value
} }
} }

View File

@@ -420,7 +420,7 @@ export default {
return return
} }
this.$axios.post( this.$axios.post(
`/api/v1/assets/nodes/${currentNode.meta.node.id}/tasks/`, `/api/v1/assets/nodes/${currentNode.meta.data.id}/tasks/`,
{ 'action': 'refresh' } { 'action': 'refresh' }
).then((res) => { ).then((res) => {
openTaskPage(res['task']) openTaskPage(res['task'])
@@ -435,7 +435,7 @@ export default {
return return
} }
this.$axios.post( this.$axios.post(
`/api/v1/assets/nodes/${currentNode.meta.node.id}/tasks/`, `/api/v1/assets/nodes/${currentNode.meta.data.id}/tasks/`,
{ 'action': 'test' } { 'action': 'test' }
).then((res) => { ).then((res) => {
openTaskPage(res['task']) openTaskPage(res['task'])
@@ -451,7 +451,7 @@ export default {
} }
this.$cookie.set('show_current_asset', '1', 1) this.$cookie.set('show_current_asset', '1', 1)
this.decorateRMenu() this.decorateRMenu()
const url = `${this.treeSetting.url}?node_id=${currentNode.meta.node.id}&show_current_asset=1` const url = `${this.treeSetting.url}?node_id=${currentNode.meta.data.id}&show_current_asset=1`
this.$refs.TreeList.$refs.TreeTable.handleUrlChange(url) this.$refs.TreeList.$refs.TreeTable.handleUrlChange(url)
}, },
rMenuShowAssetAllChildrenNode: function() { rMenuShowAssetAllChildrenNode: function() {
@@ -462,7 +462,7 @@ export default {
} }
this.$cookie.set('show_current_asset', '0', 1) this.$cookie.set('show_current_asset', '0', 1)
this.decorateRMenu() this.decorateRMenu()
const url = `${this.treeSetting.url}?node_id=${currentNode.meta.node.id}&show_current_asset=0` const url = `${this.treeSetting.url}?node_id=${currentNode.meta.data.id}&show_current_asset=0`
this.$refs.TreeList.$refs.TreeTable.handleUrlChange(url) this.$refs.TreeList.$refs.TreeTable.handleUrlChange(url)
}, },
rMenuShowNodeInfo: function() { rMenuShowNodeInfo: function() {
@@ -472,7 +472,7 @@ export default {
return return
} }
this.$axios.get( this.$axios.get(
`/api/v1/assets/nodes/${currentNode.meta.node.id}/` `/api/v1/assets/nodes/${currentNode.meta.data.id}/`
).then(res => { ).then(res => {
this.nodeInfoDialogSetting.dialogVisible = true this.nodeInfoDialogSetting.dialogVisible = true
this.nodeInfoDialogSetting.items = [ this.nodeInfoDialogSetting.items = [
@@ -512,9 +512,9 @@ export default {
if (!currentNode || assetsSelected.length === 0) { if (!currentNode || assetsSelected.length === 0) {
return return
} }
let url = `/api/v1/assets/nodes/${currentNode.meta.node.id}/assets/add/` let url = `/api/v1/assets/nodes/${currentNode.meta.data.id}/assets/add/`
if (this.assetTreeTableDialogSetting.action === 'move') { if (this.assetTreeTableDialogSetting.action === 'move') {
url = `/api/v1/assets/nodes/${currentNode.meta.node.id}/assets/replace/` url = `/api/v1/assets/nodes/${currentNode.meta.data.id}/assets/replace/`
} }
this.$axios.put( this.$axios.put(
url, { assets: assetsSelected } url, { assets: assetsSelected }

View File

@@ -142,7 +142,7 @@ export default {
}, },
onClick(event, treeId, treeNode, clickFlag) { onClick(event, treeId, treeNode, clickFlag) {
// if (treeNode.meta.type === 'asset') { // if (treeNode.meta.type === 'asset') {
// const protocolsStr = treeNode.meta.asset.protocols + '' // const protocolsStr = treeNode.meta.data.protocols + ''
// if (protocolsStr.indexOf('ssh/') === -1) { // if (protocolsStr.indexOf('ssh/') === -1) {
// // Don't Support SSH // // Don't Support SSH
// } // }
@@ -162,7 +162,7 @@ export default {
const assetsNode = [] const assetsNode = []
nodes.forEach(function(node) { nodes.forEach(function(node) {
if (node.meta.type === 'asset' && !node.isHidden) { if (node.meta.type === 'asset' && !node.isHidden) {
const protocolsStr = node.meta.asset.protocols + '' const protocolsStr = node.meta.data.protocols + ''
if (assetsNodeId.indexOf(node.id) === -1 && protocolsStr.indexOf('ssh') > -1) { if (assetsNodeId.indexOf(node.id) === -1 && protocolsStr.indexOf('ssh') > -1) {
assetsNodeId.push(node.id) assetsNodeId.push(node.id)
assetsNode.push(node) assetsNode.push(node)

View File

@@ -27,7 +27,7 @@ export default {
this.$t('common.Basic'), this.$t('common.Basic'),
[ [
'SECURITY_COMMAND_EXECUTION', 'SECURITY_SERVICE_ACCOUNT_REGISTRATION', 'SECURITY_COMMAND_EXECUTION', 'SECURITY_SERVICE_ACCOUNT_REGISTRATION',
'SECURITY_MAX_IDLE_TIME' 'SECURITY_MAX_IDLE_TIME', 'SECURITY_WATERMARK_ENABLED'
] ]
], ],
[ [

View File

@@ -15,6 +15,7 @@
<script> <script>
import Dialog from '@/components/Dialog' import Dialog from '@/components/Dialog'
import { krryPaging } from 'krry-transfer' import { krryPaging } from 'krry-transfer'
import { getUserList } from '@/api/users'
export default { export default {
name: 'ListSelect', name: 'ListSelect',
components: { components: {
@@ -39,8 +40,27 @@ export default {
getPageData: async function(pageIndex, pageSize) { getPageData: async function(pageIndex, pageSize) {
const limit = pageSize const limit = pageSize
const offset = (pageIndex - 1) * pageSize const offset = (pageIndex - 1) * pageSize
const url = `/api/v1/users/users/?limit=${limit}&offset=${offset}&oid=ROOT` const params = {
const data = await this.$axios.get(url) 'limit': limit,
'offset': offset,
'oid': 'ROOT'
}
const data = await getUserList(params)
const results = data['results'].map(item => {
return { id: item.id, label: `${item.name}(${item.username})` }
})
return results
},
getSearchData: async function(keyword, pageIndex, pageSize) {
const limit = pageSize
const offset = (pageIndex - 1) * pageSize
const params = {
'limit': limit,
'offset': offset,
'oid': 'ROOT',
'search': keyword
}
const data = await getUserList(params)
const results = data['results'].map(item => { const results = data['results'].map(item => {
return { id: item.id, label: `${item.name}(${item.username})` } return { id: item.id, label: `${item.name}(${item.username})` }
}) })

View File

@@ -33,7 +33,7 @@
<SelectDialog <SelectDialog
v-if="dialogVisible" v-if="dialogVisible"
:visible.sync="dialogVisible" :visible.sync="dialogVisible"
title="修改消息接受人" :title="$t('notifications.ChangeReceiver')"
:selected-users="dialogSelectedUsers" :selected-users="dialogSelectedUsers"
@submit="onDialogSelectSubmit" @submit="onDialogSelectSubmit"
@cancel="dialogVisible=false" @cancel="dialogVisible=false"

View File

@@ -134,6 +134,23 @@ export default {
value.ip_network_segment_group = value.ip_network_segment_group ? value.ip_network_segment_group.split(',') : [] value.ip_network_segment_group = value.ip_network_segment_group ? value.ip_network_segment_group.split(',') : []
} }
return value return value
},
onPerformError(error, method, vm) {
this.$emit('submitError', error)
const response = error.response
const data = response.data
if (response.status === 400) {
for (const key of Object.keys(data)) {
let value = data[key]
if (key === 'protocols') {
value = Object.values(data[key])
}
if (value instanceof Array) {
value = value.join(';')
}
this.$refs.form.setFieldError(key, value)
}
}
} }
} }
}, },

View File

@@ -62,11 +62,11 @@ export default {
onSelected: function(event, treeNode) { onSelected: function(event, treeNode) {
let url = vm.assetUserConfig.url let url = vm.assetUserConfig.url
if (treeNode.meta.type === 'node') { if (treeNode.meta.type === 'node') {
const nodeId = treeNode.meta.node.id const nodeId = treeNode.meta.data.id
url = setUrlParam(url, 'asset_id', '') url = setUrlParam(url, 'asset_id', '')
url = setUrlParam(url, 'node_id', nodeId) url = setUrlParam(url, 'node_id', nodeId)
} else if (treeNode.meta.type === 'asset') { } else if (treeNode.meta.type === 'asset') {
const assetId = treeNode.meta.asset.id const assetId = treeNode.meta.data.id
url = setUrlParam(url, 'node_id', '') url = setUrlParam(url, 'node_id', '')
url = setUrlParam(url, 'asset_id', assetId) url = setUrlParam(url, 'asset_id', assetId)
} }