8585 </a-select-option >
8686 </a-select >
8787 </a-form-item >
88+ <a-form-item ref =" account" name =" account" v-if =" accountVisible" >
89+ <template #label >
90+ <tooltip-label :title =" $t('label.account')" :tooltip =" apiParams.account.description" />
91+ </template >
92+ <a-select
93+ v-model:value =" form.account"
94+ showSearch
95+ optionFilterProp =" label"
96+ :filterOption =" (input, option) => {
97+ return option.children[0].children.toLowerCase().indexOf(input.toLowerCase()) >= 0
98+ }"
99+ :loading =" accountLoading"
100+ :placeholder =" apiParams.account.description"
101+ @change =" val => { handleAccountChange(accounts[val]) }" >
102+ <a-select-option v-for =" (opt, optIndex) in accounts" :key =" optIndex" >
103+ {{ opt.name || opt.description }}
104+ </a-select-option >
105+ </a-select >
106+ </a-form-item >
107+ <a-form-item
108+ ref =" networkdomain"
109+ name =" networkdomain"
110+ v-if =" !isObjectEmpty(selectedNetworkOffering) && !selectedNetworkOffering.forvpc" >
111+ <template #label >
112+ <tooltip-label :title =" $t('label.networkdomain')" :tooltip =" apiParams.networkdomain.description" />
113+ </template >
114+ <a-input
115+ v-model:value =" form.networkdomain"
116+ :placeholder =" apiParams.networkdomain.description" />
117+ </a-form-item >
88118 <a-form-item ref =" networkofferingid" name =" networkofferingid" >
89119 <template #label >
90120 <tooltip-label :title =" $t('label.networkofferingid')" :tooltip =" apiParams.networkofferingid.description" />
261291 </a-col >
262292 </a-row >
263293 </div >
264- <a-form-item
265- ref =" networkdomain"
266- name =" networkdomain"
267- v-if =" !isObjectEmpty(selectedNetworkOffering) && !selectedNetworkOffering.forvpc" >
268- <template #label >
269- <tooltip-label :title =" $t('label.networkdomain')" :tooltip =" apiParams.networkdomain.description" />
270- </template >
271- <a-input
272- v-model:value =" form.networkdomain"
273- :placeholder =" apiParams.networkdomain.description" />
274- </a-form-item >
275- <a-form-item
276- ref =" account"
277- name =" account"
278- v-if =" accountVisible" >
279- <template #label >
280- <tooltip-label :title =" $t('label.account')" :tooltip =" apiParams.account.description" />
281- </template >
282- <a-input
283- v-model:value =" form.account"
284- :placeholder =" apiParams.account.description" />
285- </a-form-item >
286294 <div :span =" 24" class =" action-button" >
287295 <a-button
288296 :loading =" actionLoading"
@@ -339,6 +347,10 @@ export default {
339347 domains: [],
340348 domainLoading: false ,
341349 selectedDomain: {},
350+ accountVisible: isAdminOrDomainAdmin (),
351+ accounts: [],
352+ accountLoading: false ,
353+ selectedAccount: {},
342354 zones: [],
343355 zoneLoading: false ,
344356 selectedZone: {},
@@ -348,7 +360,6 @@ export default {
348360 vpcs: [],
349361 vpcLoading: false ,
350362 selectedVpc: {},
351- accountVisible: isAdminOrDomainAdmin (),
352363 privateMtuMax: 1500 ,
353364 publicMtuMax: 1500 ,
354365 minMTU: 68 ,
@@ -466,8 +477,12 @@ export default {
466477 this .accountVisible = domain .id !== ' -1'
467478 if (isAdminOrDomainAdmin ()) {
468479 this .updateVPCCheckAndFetchNetworkOfferingData ()
480+ this .fetchAccounts ()
469481 }
470482 },
483+ handleAccountChange (account ) {
484+ this .selectedAccount = account
485+ },
471486 updateVPCCheckAndFetchNetworkOfferingData () {
472487 if (this .vpc !== null ) { // from VPC section
473488 this .fetchNetworkOfferingData (true )
@@ -544,6 +559,31 @@ export default {
544559 }
545560 })
546561 },
562+ fetchAccounts () {
563+ this .accountLoading = true
564+ var params = {}
565+ if (isAdminOrDomainAdmin () && this .selectedDomain .id !== ' -1' ) { // domain is visible only for admins
566+ params .domainid = this .selectedDomain .id
567+ }
568+ this .accounts = [
569+ {
570+ id: ' -1' ,
571+ name: ' '
572+ }
573+ ]
574+ this .selectedAccount = {}
575+ api (' listAccounts' , params).then (json => {
576+ const listAccounts = json .listaccountsresponse .account || []
577+ this .accounts = this .accounts .concat (listAccounts)
578+ }).catch (error => {
579+ this .$notifyError (error)
580+ }).finally (() => {
581+ this .accountLoading = false
582+ if (this .arrayHasItems (this .accounts )) {
583+ this .form .account = null
584+ }
585+ })
586+ },
547587 handleSubmit () {
548588 if (this .actionLoading ) return
549589 this .formRef .value .validate ().then (() => {
@@ -570,8 +610,8 @@ export default {
570610 }
571611 if (' domainid' in values && values .domainid > 0 ) {
572612 params .domainid = this .selectedDomain .id
573- if (this .isValidTextValueForKey (values, ' account' )) {
574- params .account = values . account
613+ if (this .isValidTextValueForKey (values, ' account' ) && this . selectedAccount . id !== ' -1 ' ) {
614+ params .account = this . selectedAccount . name
575615 }
576616 }
577617 api (' createNetwork' , params).then (json => {
0 commit comments