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
99105 :placeholder =" apiParams.networkdomain.description"
100106 />
101107 </a-form-item >
102- <a-form-item :label =" $t('label.group')" >
108+ <a-form-item :label =" $t('label.ldap. group.name ')" >
103109 <a-input
104110 v-decorator =" ['group']"
105111 :placeholder =" apiParams.group.description"
119125<script >
120126import { api } from ' @/api'
121127import { timeZone } from ' @/utils/timezone'
128+ import store from ' @/store'
122129
123130export default {
124131 name: ' AddLdapAccount' ,
@@ -131,6 +138,8 @@ export default {
131138 listDomains: [],
132139 listRoles: [],
133140 timeZoneMap: [],
141+ filters: [],
142+ selectedFilter: ' ' ,
134143 listLoading: false ,
135144 timeZoneLoading: false ,
136145 domainLoading: false ,
@@ -175,41 +184,60 @@ export default {
175184 title: this .$t (' label.email' ),
176185 dataIndex: ' email' ,
177186 scopedSlots: { customRender: ' email' }
187+ },
188+ {
189+ title: this .$t (' Conflict' ),
190+ dataIndex: ' conflictingusersource' ,
191+ scopedSlots: { customRender: ' conflictingusersource' }
178192 }
179193 ]
194+ this .filters = [
195+ {
196+ id: ' NoFilter' ,
197+ name: ' No filter'
198+ },
199+ {
200+ id: ' LocalDomain' ,
201+ name: ' Local domain'
202+ },
203+ {
204+ id: ' AnyDomain' ,
205+ name: ' Any domain'
206+ },
207+ {
208+ id: ' PotentialImport' ,
209+ name: ' Potential import'
210+ }
211+ ]
212+ this .selectedFilter = this .filters [0 ].id
180213 },
181214 mounted () {
182215 this .fetchData ()
183216 },
184217 methods: {
185218 async fetchData () {
186- this .listLoading = true
187219 this .timeZoneLoading = true
188220 this .domainLoading = true
189221 this .roleLoading = true
222+ this .fetchListLdapUsers ()
190223 const [
191224 listTimeZone,
192- listLdapUsers,
193225 listDomains,
194226 listRoles
195227 ] = await Promise .all ([
196228 this .fetchTimeZone (),
197- this .fetchListLdapUsers (),
198229 this .fetchListDomains (),
199230 this .fetchListRoles ()
200231 ]).catch (error => {
201232 this .$notifyError (error)
202233 }).finally (() => {
203- this .listLoading = false
204234 this .timeZoneLoading = false
205235 this .domainLoading = false
206236 this .roleLoading = false
207237 })
208238 this .timeZoneMap = listTimeZone && listTimeZone .length > 0 ? listTimeZone : []
209239 this .listDomains = listDomains && listDomains .length > 0 ? listDomains : []
210240 this .listRoles = listRoles && listRoles .length > 0 ? listRoles : []
211- this .dataSource = listLdapUsers
212- this .oldDataSource = listLdapUsers
213241 },
214242 fetchTimeZone (value ) {
215243 return new Promise ((resolve , reject ) => {
@@ -221,21 +249,25 @@ export default {
221249 })
222250 },
223251 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+ this .listLoading = true
253+ const params = {}
254+ params .listtype = ' new'
255+ params .userfilter = this .selectedFilter
256+ params .domainid = store .getters .userInfo .domainid
257+ api (' listLdapUsers' , params).then (json => {
258+ const listLdapUsers = json .ldapuserresponse .LdapUser
259+ if (listLdapUsers) {
260+ const ldapUserLength = listLdapUsers .length
261+ for (let i = 0 ; i < ldapUserLength; i++ ) {
262+ listLdapUsers[i].name = [listLdapUsers[i].firstname , listLdapUsers[i].lastname ].join (' ' )
234263 }
235- resolve (listLdapUsers)
236- }).catch (error => {
237- reject (error)
238- })
264+ }
265+ this .dataSource = listLdapUsers
266+ this .oldDataSource = listLdapUsers
267+ }).catch (error => {
268+ this .$notifyError (error)
269+ }).finally (() => {
270+ this .listLoading = false
239271 })
240272 },
241273 fetchListDomains () {
@@ -263,7 +295,7 @@ export default {
263295 handleSubmit (e ) {
264296 e .preventDefault ()
265297 this .form .validateFields ((err , values ) => {
266- if (err || this . selectedRowKeys . length === 0 ) {
298+ if (err) {
267299 return
268300 }
269301 let apiName = ' ldapCreateAccount'
@@ -273,22 +305,31 @@ export default {
273305 const params = {}
274306 params .domainid = domain[0 ].id
275307 params .roleid = role[0 ].id
308+ params .account = values .account
276309 params .timezone = values .timezone
277310 params .networkdomain = values .networkdomain
278- params .group = values .group
279- if ( params .group && params .group . trim (). length > 0 ) {
311+ if ( values .group && values .group . trim (). length > 0 ) {
312+ params .group = values .group
280313 apiName = ' importLdapUsers'
281- }
282- this .selectedRowKeys .forEach (username => {
283- params .username = username
284314 promises .push (new Promise ((resolve , reject ) => {
285315 api (apiName, params).then (json => {
286316 resolve (json)
287317 }).catch (error => {
288318 reject (error)
289319 })
290320 }))
291- })
321+ } else {
322+ this .selectedRowKeys .forEach (username => {
323+ params .username = username
324+ promises .push (new Promise ((resolve , reject ) => {
325+ api (apiName, params).then (json => {
326+ resolve (json)
327+ }).catch (error => {
328+ reject (error)
329+ })
330+ }))
331+ })
332+ }
292333 this .loading = true
293334 Promise .all (promises).then (response => {
294335 for (let i = 0 ; i < response .length ; i++ ) {
0 commit comments