You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2020/06/25 11:43:09 UTC
[cloudstack-primate] branch master updated: iam: Fixing ldap form
(#444)
This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack-primate.git
The following commit(s) were added to refs/heads/master by this push:
new 93b9d33 iam: Fixing ldap form (#444)
93b9d33 is described below
commit 93b9d33a79d85569ccf73b8031d1f2c0eb5fdb1e
Author: davidjumani <dj...@gmail.com>
AuthorDate: Thu Jun 25 11:42:58 2020 +0000
iam: Fixing ldap form (#444)
Fixes #112
---
src/config/section/config.js | 2 +-
src/views/iam/AddLdapAccount.vue | 112 ++++++++++++++++++++++++++++-----------
2 files changed, 81 insertions(+), 33 deletions(-)
diff --git a/src/config/section/config.js b/src/config/section/config.js
index 1e6531b..8b77c65 100644
--- a/src/config/section/config.js
+++ b/src/config/section/config.js
@@ -42,7 +42,7 @@ export default {
label: 'label.configure.ldap',
listView: true,
args: [
- 'hostname', 'port'
+ 'hostname', 'port', 'domainid'
]
},
{
diff --git a/src/views/iam/AddLdapAccount.vue b/src/views/iam/AddLdapAccount.vue
index c80dc91..ce91f0c 100644
--- a/src/views/iam/AddLdapAccount.vue
+++ b/src/views/iam/AddLdapAccount.vue
@@ -48,8 +48,14 @@
<a-form
:form="form"
@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-select
showSearch
@@ -57,7 +63,8 @@
rules: [{ required: true, memessage: `${this.$t('message.error.select')}` }]
}]"
:placeholder="apiParams.domainid.description"
- :loading="domainLoading">
+ :loading="domainLoading"
+ @change="fetchListLdapUsers($event)" >
<a-select-option v-for="opt in listDomains" :key="opt.name">
{{ opt.name }}
</a-select-option>
@@ -99,7 +106,7 @@
:placeholder="apiParams.networkdomain.description"
/>
</a-form-item>
- <a-form-item :label="$t('label.group')">
+ <a-form-item :label="$t('label.ldap.group.name')">
<a-input
v-decorator="['group']"
:placeholder="apiParams.group.description"
@@ -119,6 +126,7 @@
<script>
import { api } from '@/api'
import { timeZone } from '@/utils/timezone'
+import store from '@/store'
export default {
name: 'AddLdapAccount',
@@ -131,6 +139,8 @@ export default {
listDomains: [],
listRoles: [],
timeZoneMap: [],
+ filters: [],
+ selectedFilter: '',
listLoading: false,
timeZoneLoading: false,
domainLoading: false,
@@ -175,32 +185,53 @@ export default {
title: this.$t('label.email'),
dataIndex: '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 () {
this.fetchData()
},
methods: {
async fetchData () {
- this.listLoading = true
this.timeZoneLoading = true
this.domainLoading = true
this.roleLoading = true
+ this.fetchListLdapUsers()
const [
listTimeZone,
- listLdapUsers,
listDomains,
listRoles
] = await Promise.all([
this.fetchTimeZone(),
- this.fetchListLdapUsers(),
this.fetchListDomains(),
this.fetchListRoles()
]).catch(error => {
this.$notifyError(error)
}).finally(() => {
- this.listLoading = false
this.timeZoneLoading = false
this.domainLoading = false
this.roleLoading = false
@@ -208,8 +239,6 @@ export default {
this.timeZoneMap = listTimeZone && listTimeZone.length > 0 ? listTimeZone : []
this.listDomains = listDomains && listDomains.length > 0 ? listDomains : []
this.listRoles = listRoles && listRoles.length > 0 ? listRoles : []
- this.dataSource = listLdapUsers
- this.oldDataSource = listLdapUsers
},
fetchTimeZone (value) {
return new Promise((resolve, reject) => {
@@ -220,22 +249,32 @@ export default {
})
})
},
- fetchListLdapUsers () {
- return new Promise((resolve, reject) => {
- const params = {}
- params.listtype = 'new'
- 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(' ')
- }
+ fetchListLdapUsers (domain) {
+ this.listLoading = true
+ const params = {}
+ params.listtype = 'new'
+ params.userfilter = this.selectedFilter
+ params.domainid = store.getters.userInfo.domainid
+ if (domain) {
+ const result = this.listDomains.filter(item => item.name === domain)
+ if (result) {
+ 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 => {
- reject(error)
- })
+ }
+ this.dataSource = listLdapUsers
+ this.oldDataSource = listLdapUsers
+ }).catch(error => {
+ this.$notifyError(error)
+ }).finally(() => {
+ this.listLoading = false
})
},
fetchListDomains () {
@@ -263,7 +302,7 @@ export default {
handleSubmit (e) {
e.preventDefault()
this.form.validateFields((err, values) => {
- if (err || this.selectedRowKeys.length === 0) {
+ if (err) {
return
}
let apiName = 'ldapCreateAccount'
@@ -273,14 +312,12 @@ export default {
const params = {}
params.domainid = domain[0].id
params.roleid = role[0].id
+ params.account = values.account
params.timezone = values.timezone
params.networkdomain = values.networkdomain
- params.group = values.group
- if (params.group && params.group.trim().length > 0) {
+ if (values.group && values.group.trim().length > 0) {
+ params.group = values.group
apiName = 'importLdapUsers'
- }
- this.selectedRowKeys.forEach(username => {
- params.username = username
promises.push(new Promise((resolve, reject) => {
api(apiName, params).then(json => {
resolve(json)
@@ -288,7 +325,18 @@ export default {
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
Promise.all(promises).then(response => {
for (let i = 0; i < response.length; i++) {