164164 v-model:value =" form.isolatedpvlan"
165165 :placeholder =" apiParams.isolatedpvlan.description" />
166166 </a-form-item >
167- <a-form-item v-if = " accountVisible " name =" account" ref = " name " >
167+ <a-form-item ref = " account " name =" account" v-if = " accountVisible " >
168168 <template #label >
169169 <tooltip-label :title =" $t('label.account')" :tooltip =" apiParams.account.description" />
170170 </template >
171- <a-input
172- v-model:value =" form.account"
173- :placeholder =" apiParams.account.description" />
171+ <a-select
172+ v-model:value =" form.account"
173+ showSearch
174+ optionFilterProp =" label"
175+ :filterOption =" (input, option) => {
176+ return option.children[0].children.toLowerCase().indexOf(input.toLowerCase()) >= 0
177+ }"
178+ :loading =" accountLoading"
179+ :placeholder =" apiParams.account.description"
180+ @change =" val => { handleAccountChange(accounts[val]) }" >
181+ <a-select-option v-for =" (opt, optIndex) in accounts" :key =" optIndex" >
182+ {{ opt.name || opt.description }}
183+ </a-select-option >
184+ </a-select >
174185 </a-form-item >
175186 <div :span =" 24" class =" action-button" >
176187 <a-button
@@ -227,13 +238,16 @@ export default {
227238 domains: [],
228239 domainLoading: false ,
229240 selectedDomain: {},
241+ accountVisible: isAdminOrDomainAdmin (),
242+ accounts: [],
243+ accountLoading: false ,
244+ selectedAccount: {},
230245 zones: [],
231246 zoneLoading: false ,
232247 selectedZone: {},
233248 networkOfferings: [],
234249 networkOfferingLoading: false ,
235250 selectedNetworkOffering: {},
236- accountVisible: isAdminOrDomainAdmin (),
237251 isolatePvlanType: ' none'
238252 }
239253 },
@@ -336,8 +350,12 @@ export default {
336350 this .accountVisible = domain .id !== ' -1'
337351 if (isAdminOrDomainAdmin ()) {
338352 this .updateVPCCheckAndFetchNetworkOfferingData ()
353+ this .fetchAccounts ()
339354 }
340355 },
356+ handleAccountChange (account ) {
357+ this .selectedAccount = account
358+ },
341359 updateVPCCheckAndFetchNetworkOfferingData () {
342360 if (this .vpc !== null ) { // from VPC section
343361 this .fetchNetworkOfferingData (true )
@@ -390,6 +408,31 @@ export default {
390408 handleNetworkOfferingChange (networkOffering ) {
391409 this .selectedNetworkOffering = networkOffering
392410 },
411+ fetchAccounts () {
412+ this .accountLoading = true
413+ var params = {}
414+ if (isAdminOrDomainAdmin () && this .selectedDomain .id !== ' -1' ) { // domain is visible only for admins
415+ params .domainid = this .selectedDomain .id
416+ }
417+ this .accounts = [
418+ {
419+ id: ' -1' ,
420+ name: ' '
421+ }
422+ ]
423+ this .selectedAccount = {}
424+ api (' listAccounts' , params).then (json => {
425+ const listAccounts = json .listaccountsresponse .account
426+ this .accounts = this .accounts .concat (listAccounts)
427+ }).catch (error => {
428+ this .$notifyError (error)
429+ }).finally (() => {
430+ this .accountLoading = false
431+ if (this .arrayHasItems (this .accounts )) {
432+ this .form .accountid = 0
433+ }
434+ })
435+ },
393436 handleSubmit (e ) {
394437 if (this .actionLoading ) return
395438 this .formRef .value .validate ().then (() => {
@@ -411,7 +454,7 @@ export default {
411454 if (' domainid' in values && values .domainid > 0 ) {
412455 params .domainid = this .selectedDomain .id
413456 if (this .isValidTextValueForKey (values, ' account' )) {
414- params .account = values . account
457+ params .account = this . selectedAccount . name
415458 }
416459 }
417460 if (this .isValidValueForKey (values, ' isolatedpvlantype' ) && values .isolatedpvlantype !== ' none' ) {
0 commit comments