mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
iam: Fixing ldap form (#444)
Fixes #112 Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
68989bd939
commit
0e933a2a84
@ -42,7 +42,7 @@ export default {
|
|||||||
label: 'label.configure.ldap',
|
label: 'label.configure.ldap',
|
||||||
listView: true,
|
listView: true,
|
||||||
args: [
|
args: [
|
||||||
'hostname', 'port'
|
'hostname', 'port', 'domainid'
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -48,8 +48,14 @@
|
|||||||
<a-form
|
<a-form
|
||||||
:form="form"
|
:form="form"
|
||||||
@submit="handleSubmit"
|
@submit="handleSubmit"
|
||||||
layout="vertical"
|
layout="vertical" >
|
||||||
>
|
<a-form-item :label="$t('label.filterby')">
|
||||||
|
<a-select @change="fetchListLdapUsers" v-model="selectedFilter" >
|
||||||
|
<a-select-option v-for="opt in filters" :key="opt.id" >
|
||||||
|
{{ opt.name }}
|
||||||
|
</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
<a-form-item :label="$t('label.domain')">
|
<a-form-item :label="$t('label.domain')">
|
||||||
<a-select
|
<a-select
|
||||||
showSearch
|
showSearch
|
||||||
@ -57,7 +63,8 @@
|
|||||||
rules: [{ required: true, memessage: `${this.$t('message.error.select')}` }]
|
rules: [{ required: true, memessage: `${this.$t('message.error.select')}` }]
|
||||||
}]"
|
}]"
|
||||||
:placeholder="apiParams.domainid.description"
|
:placeholder="apiParams.domainid.description"
|
||||||
:loading="domainLoading">
|
:loading="domainLoading"
|
||||||
|
@change="fetchListLdapUsers($event)" >
|
||||||
<a-select-option v-for="opt in listDomains" :key="opt.name">
|
<a-select-option v-for="opt in listDomains" :key="opt.name">
|
||||||
{{ opt.name }}
|
{{ opt.name }}
|
||||||
</a-select-option>
|
</a-select-option>
|
||||||
@ -99,7 +106,7 @@
|
|||||||
:placeholder="apiParams.networkdomain.description"
|
:placeholder="apiParams.networkdomain.description"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item :label="$t('label.group')">
|
<a-form-item :label="$t('label.ldap.group.name')">
|
||||||
<a-input
|
<a-input
|
||||||
v-decorator="['group']"
|
v-decorator="['group']"
|
||||||
:placeholder="apiParams.group.description"
|
:placeholder="apiParams.group.description"
|
||||||
@ -119,6 +126,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { api } from '@/api'
|
import { api } from '@/api'
|
||||||
import { timeZone } from '@/utils/timezone'
|
import { timeZone } from '@/utils/timezone'
|
||||||
|
import store from '@/store'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'AddLdapAccount',
|
name: 'AddLdapAccount',
|
||||||
@ -131,6 +139,8 @@ export default {
|
|||||||
listDomains: [],
|
listDomains: [],
|
||||||
listRoles: [],
|
listRoles: [],
|
||||||
timeZoneMap: [],
|
timeZoneMap: [],
|
||||||
|
filters: [],
|
||||||
|
selectedFilter: '',
|
||||||
listLoading: false,
|
listLoading: false,
|
||||||
timeZoneLoading: false,
|
timeZoneLoading: false,
|
||||||
domainLoading: false,
|
domainLoading: false,
|
||||||
@ -175,32 +185,53 @@ export default {
|
|||||||
title: this.$t('label.email'),
|
title: this.$t('label.email'),
|
||||||
dataIndex: 'email',
|
dataIndex: 'email',
|
||||||
scopedSlots: { customRender: 'email' }
|
scopedSlots: { customRender: 'email' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: this.$t('Conflict'),
|
||||||
|
dataIndex: 'conflictingusersource',
|
||||||
|
scopedSlots: { customRender: 'conflictingusersource' }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
this.filters = [
|
||||||
|
{
|
||||||
|
id: 'NoFilter',
|
||||||
|
name: 'No filter'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'LocalDomain',
|
||||||
|
name: 'Local domain'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'AnyDomain',
|
||||||
|
name: 'Any domain'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'PotentialImport',
|
||||||
|
name: 'Potential import'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
this.selectedFilter = this.filters[0].id
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
this.fetchData()
|
this.fetchData()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async fetchData () {
|
async fetchData () {
|
||||||
this.listLoading = true
|
|
||||||
this.timeZoneLoading = true
|
this.timeZoneLoading = true
|
||||||
this.domainLoading = true
|
this.domainLoading = true
|
||||||
this.roleLoading = true
|
this.roleLoading = true
|
||||||
|
this.fetchListLdapUsers()
|
||||||
const [
|
const [
|
||||||
listTimeZone,
|
listTimeZone,
|
||||||
listLdapUsers,
|
|
||||||
listDomains,
|
listDomains,
|
||||||
listRoles
|
listRoles
|
||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
this.fetchTimeZone(),
|
this.fetchTimeZone(),
|
||||||
this.fetchListLdapUsers(),
|
|
||||||
this.fetchListDomains(),
|
this.fetchListDomains(),
|
||||||
this.fetchListRoles()
|
this.fetchListRoles()
|
||||||
]).catch(error => {
|
]).catch(error => {
|
||||||
this.$notifyError(error)
|
this.$notifyError(error)
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.listLoading = false
|
|
||||||
this.timeZoneLoading = false
|
this.timeZoneLoading = false
|
||||||
this.domainLoading = false
|
this.domainLoading = false
|
||||||
this.roleLoading = false
|
this.roleLoading = false
|
||||||
@ -208,8 +239,6 @@ export default {
|
|||||||
this.timeZoneMap = listTimeZone && listTimeZone.length > 0 ? listTimeZone : []
|
this.timeZoneMap = listTimeZone && listTimeZone.length > 0 ? listTimeZone : []
|
||||||
this.listDomains = listDomains && listDomains.length > 0 ? listDomains : []
|
this.listDomains = listDomains && listDomains.length > 0 ? listDomains : []
|
||||||
this.listRoles = listRoles && listRoles.length > 0 ? listRoles : []
|
this.listRoles = listRoles && listRoles.length > 0 ? listRoles : []
|
||||||
this.dataSource = listLdapUsers
|
|
||||||
this.oldDataSource = listLdapUsers
|
|
||||||
},
|
},
|
||||||
fetchTimeZone (value) {
|
fetchTimeZone (value) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -220,22 +249,32 @@ export default {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
fetchListLdapUsers () {
|
fetchListLdapUsers (domain) {
|
||||||
return new Promise((resolve, reject) => {
|
this.listLoading = true
|
||||||
const params = {}
|
const params = {}
|
||||||
params.listtype = 'new'
|
params.listtype = 'new'
|
||||||
api('listLdapUsers', params).then(json => {
|
params.userfilter = this.selectedFilter
|
||||||
const listLdapUsers = json.ldapuserresponse.LdapUser
|
params.domainid = store.getters.userInfo.domainid
|
||||||
if (listLdapUsers) {
|
if (domain) {
|
||||||
const ldapUserLength = listLdapUsers.length
|
const result = this.listDomains.filter(item => item.name === domain)
|
||||||
for (let i = 0; i < ldapUserLength; i++) {
|
if (result) {
|
||||||
listLdapUsers[i].name = [listLdapUsers[i].firstname, listLdapUsers[i].lastname].join(' ')
|
params.domainid = result[0].id
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
api('listLdapUsers', params).then(json => {
|
||||||
|
const listLdapUsers = json.ldapuserresponse.LdapUser
|
||||||
|
if (listLdapUsers) {
|
||||||
|
const ldapUserLength = listLdapUsers.length
|
||||||
|
for (let i = 0; i < ldapUserLength; i++) {
|
||||||
|
listLdapUsers[i].name = [listLdapUsers[i].firstname, listLdapUsers[i].lastname].join(' ')
|
||||||
}
|
}
|
||||||
resolve(listLdapUsers)
|
}
|
||||||
}).catch(error => {
|
this.dataSource = listLdapUsers
|
||||||
reject(error)
|
this.oldDataSource = listLdapUsers
|
||||||
})
|
}).catch(error => {
|
||||||
|
this.$notifyError(error)
|
||||||
|
}).finally(() => {
|
||||||
|
this.listLoading = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
fetchListDomains () {
|
fetchListDomains () {
|
||||||
@ -263,7 +302,7 @@ export default {
|
|||||||
handleSubmit (e) {
|
handleSubmit (e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
this.form.validateFields((err, values) => {
|
this.form.validateFields((err, values) => {
|
||||||
if (err || this.selectedRowKeys.length === 0) {
|
if (err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let apiName = 'ldapCreateAccount'
|
let apiName = 'ldapCreateAccount'
|
||||||
@ -273,14 +312,12 @@ export default {
|
|||||||
const params = {}
|
const params = {}
|
||||||
params.domainid = domain[0].id
|
params.domainid = domain[0].id
|
||||||
params.roleid = role[0].id
|
params.roleid = role[0].id
|
||||||
|
params.account = values.account
|
||||||
params.timezone = values.timezone
|
params.timezone = values.timezone
|
||||||
params.networkdomain = values.networkdomain
|
params.networkdomain = values.networkdomain
|
||||||
params.group = values.group
|
if (values.group && values.group.trim().length > 0) {
|
||||||
if (params.group && params.group.trim().length > 0) {
|
params.group = values.group
|
||||||
apiName = 'importLdapUsers'
|
apiName = 'importLdapUsers'
|
||||||
}
|
|
||||||
this.selectedRowKeys.forEach(username => {
|
|
||||||
params.username = username
|
|
||||||
promises.push(new Promise((resolve, reject) => {
|
promises.push(new Promise((resolve, reject) => {
|
||||||
api(apiName, params).then(json => {
|
api(apiName, params).then(json => {
|
||||||
resolve(json)
|
resolve(json)
|
||||||
@ -288,7 +325,18 @@ export default {
|
|||||||
reject(error)
|
reject(error)
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
})
|
} else {
|
||||||
|
this.selectedRowKeys.forEach(username => {
|
||||||
|
params.username = username
|
||||||
|
promises.push(new Promise((resolve, reject) => {
|
||||||
|
api(apiName, params).then(json => {
|
||||||
|
resolve(json)
|
||||||
|
}).catch(error => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
}
|
||||||
this.loading = true
|
this.loading = true
|
||||||
Promise.all(promises).then(response => {
|
Promise.all(promises).then(response => {
|
||||||
for (let i = 0; i < response.length; i++) {
|
for (let i = 0; i < response.length; i++) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user