Skip to content
This repository was archived by the owner on Jan 20, 2021. It is now read-only.

Commit 862b033

Browse files
committed
Fixing ldap form
1 parent 7c0d6aa commit 862b033

2 files changed

Lines changed: 81 additions & 33 deletions

File tree

src/config/section/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default {
4242
label: 'label.configure.ldap',
4343
listView: true,
4444
args: [
45-
'hostname', 'port'
45+
'hostname', 'port', 'domainid'
4646
]
4747
},
4848
{

src/views/iam/AddLdapAccount.vue

Lines changed: 80 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,23 @@
4848
<a-form
4949
:form="form"
5050
@submit="handleSubmit"
51-
layout="vertical"
52-
>
51+
layout="vertical" >
52+
<a-form-item :label="$t('label.filterby')">
53+
<a-select @change="fetchListLdapUsers" v-model="selectedFilter" >
54+
<a-select-option v-for="opt in filters" :key="opt.id" >
55+
{{ opt.name }}
56+
</a-select-option>
57+
</a-select>
58+
</a-form-item>
5359
<a-form-item :label="$t('label.domain')">
5460
<a-select
5561
showSearch
5662
v-decorator="['domainid', {
5763
rules: [{ required: true, memessage: `${this.$t('message.error.select')}` }]
5864
}]"
5965
:placeholder="apiParams.domainid.description"
60-
:loading="domainLoading">
66+
:loading="domainLoading"
67+
@change="fetchListLdapUsers($event)" >
6168
<a-select-option v-for="opt in listDomains" :key="opt.name">
6269
{{ opt.name }}
6370
</a-select-option>
@@ -99,7 +106,7 @@
99106
:placeholder="apiParams.networkdomain.description"
100107
/>
101108
</a-form-item>
102-
<a-form-item :label="$t('label.group')">
109+
<a-form-item :label="$t('label.ldap.group.name')">
103110
<a-input
104111
v-decorator="['group']"
105112
:placeholder="apiParams.group.description"
@@ -119,6 +126,7 @@
119126
<script>
120127
import { api } from '@/api'
121128
import { timeZone } from '@/utils/timezone'
129+
import store from '@/store'
122130
123131
export default {
124132
name: 'AddLdapAccount',
@@ -131,6 +139,8 @@ export default {
131139
listDomains: [],
132140
listRoles: [],
133141
timeZoneMap: [],
142+
filters: [],
143+
selectedFilter: '',
134144
listLoading: false,
135145
timeZoneLoading: false,
136146
domainLoading: false,
@@ -175,41 +185,60 @@ export default {
175185
title: this.$t('label.email'),
176186
dataIndex: 'email',
177187
scopedSlots: { customRender: 'email' }
188+
},
189+
{
190+
title: this.$t('Conflict'),
191+
dataIndex: 'conflictingusersource',
192+
scopedSlots: { customRender: 'conflictingusersource' }
193+
}
194+
]
195+
this.filters = [
196+
{
197+
id: 'NoFilter',
198+
name: 'No filter'
199+
},
200+
{
201+
id: 'LocalDomain',
202+
name: 'Local domain'
203+
},
204+
{
205+
id: 'AnyDomain',
206+
name: 'Any domain'
207+
},
208+
{
209+
id: 'PotentialImport',
210+
name: 'Potential import'
178211
}
179212
]
213+
this.selectedFilter = this.filters[0].id
180214
},
181215
mounted () {
182216
this.fetchData()
183217
},
184218
methods: {
185219
async fetchData () {
186-
this.listLoading = true
187220
this.timeZoneLoading = true
188221
this.domainLoading = true
189222
this.roleLoading = true
223+
this.fetchListLdapUsers()
190224
const [
191225
listTimeZone,
192-
listLdapUsers,
193226
listDomains,
194227
listRoles
195228
] = await Promise.all([
196229
this.fetchTimeZone(),
197-
this.fetchListLdapUsers(),
198230
this.fetchListDomains(),
199231
this.fetchListRoles()
200232
]).catch(error => {
201233
this.$notifyError(error)
202234
}).finally(() => {
203-
this.listLoading = false
204235
this.timeZoneLoading = false
205236
this.domainLoading = false
206237
this.roleLoading = false
207238
})
208239
this.timeZoneMap = listTimeZone && listTimeZone.length > 0 ? listTimeZone : []
209240
this.listDomains = listDomains && listDomains.length > 0 ? listDomains : []
210241
this.listRoles = listRoles && listRoles.length > 0 ? listRoles : []
211-
this.dataSource = listLdapUsers
212-
this.oldDataSource = listLdapUsers
213242
},
214243
fetchTimeZone (value) {
215244
return new Promise((resolve, reject) => {
@@ -220,22 +249,32 @@ export default {
220249
})
221250
})
222251
},
223-
fetchListLdapUsers () {
224-
return new Promise((resolve, reject) => {
225-
const params = {}
226-
params.listtype = 'new'
227-
api('listLdapUsers', params).then(json => {
228-
const listLdapUsers = json.ldapuserresponse.LdapUser
229-
if (listLdapUsers) {
230-
const ldapUserLength = listLdapUsers.length
231-
for (let i = 0; i < ldapUserLength; i++) {
232-
listLdapUsers[i].name = [listLdapUsers[i].firstname, listLdapUsers[i].lastname].join(' ')
233-
}
252+
fetchListLdapUsers (domain) {
253+
this.listLoading = true
254+
const params = {}
255+
params.listtype = 'new'
256+
params.userfilter = this.selectedFilter
257+
params.domainid = store.getters.userInfo.domainid
258+
if (domain) {
259+
const result = this.listDomains.filter(item => item.name === domain)
260+
if (result) {
261+
params.domainid = result[0].id
262+
}
263+
}
264+
api('listLdapUsers', params).then(json => {
265+
const listLdapUsers = json.ldapuserresponse.LdapUser
266+
if (listLdapUsers) {
267+
const ldapUserLength = listLdapUsers.length
268+
for (let i = 0; i < ldapUserLength; i++) {
269+
listLdapUsers[i].name = [listLdapUsers[i].firstname, listLdapUsers[i].lastname].join(' ')
234270
}
235-
resolve(listLdapUsers)
236-
}).catch(error => {
237-
reject(error)
238-
})
271+
}
272+
this.dataSource = listLdapUsers
273+
this.oldDataSource = listLdapUsers
274+
}).catch(error => {
275+
this.$notifyError(error)
276+
}).finally(() => {
277+
this.listLoading = false
239278
})
240279
},
241280
fetchListDomains () {
@@ -263,7 +302,7 @@ export default {
263302
handleSubmit (e) {
264303
e.preventDefault()
265304
this.form.validateFields((err, values) => {
266-
if (err || this.selectedRowKeys.length === 0) {
305+
if (err) {
267306
return
268307
}
269308
let apiName = 'ldapCreateAccount'
@@ -273,22 +312,31 @@ export default {
273312
const params = {}
274313
params.domainid = domain[0].id
275314
params.roleid = role[0].id
315+
params.account = values.account
276316
params.timezone = values.timezone
277317
params.networkdomain = values.networkdomain
278-
params.group = values.group
279-
if (params.group && params.group.trim().length > 0) {
318+
if (values.group && values.group.trim().length > 0) {
319+
params.group = values.group
280320
apiName = 'importLdapUsers'
281-
}
282-
this.selectedRowKeys.forEach(username => {
283-
params.username = username
284321
promises.push(new Promise((resolve, reject) => {
285322
api(apiName, params).then(json => {
286323
resolve(json)
287324
}).catch(error => {
288325
reject(error)
289326
})
290327
}))
291-
})
328+
} else {
329+
this.selectedRowKeys.forEach(username => {
330+
params.username = username
331+
promises.push(new Promise((resolve, reject) => {
332+
api(apiName, params).then(json => {
333+
resolve(json)
334+
}).catch(error => {
335+
reject(error)
336+
})
337+
}))
338+
})
339+
}
292340
this.loading = true
293341
Promise.all(promises).then(response => {
294342
for (let i = 0; i < response.length; i++) {

0 commit comments

Comments
 (0)