5454 :ref =" field.name"
5555 :name =" field.name"
5656 :key =" index"
57- :label =" field.name==='keyword' ?
58- ('listAnnotations' in $store.getters.apis ? $t('label.annotation') : $t('label.name')) : $t('label.' + field.name)" >
57+ :label =" retrieveFieldLabel(field.name)" >
5958 <a-select
6059 allowClear
6160 v-if =" field.type==='list'"
@@ -242,6 +241,19 @@ export default {
242241 if (! this .visibleFilter ) return
243242 this .initFormFieldData ()
244243 },
244+ retrieveFieldLabel (fieldName ) {
245+ if (fieldName === ' groupid' ) {
246+ fieldName = ' group'
247+ }
248+ if (fieldName === ' keyword' ) {
249+ if (' listAnnotations' in this .$store .getters .apis ) {
250+ return this .$t (' label.annotation' )
251+ } else {
252+ return this .$t (' label.name' )
253+ }
254+ }
255+ return this .$t (' label.' + fieldName)
256+ },
245257 async initFormFieldData () {
246258 const arrayField = []
247259 this .fields = []
@@ -260,7 +272,10 @@ export default {
260272 if (item === ' clusterid' && ! (' listClusters' in this .$store .getters .apis )) {
261273 return true
262274 }
263- if ([' zoneid' , ' domainid' , ' state' , ' level' , ' clusterid' , ' podid' , ' entitytype' , ' type' ].includes (item)) {
275+ if (item === ' groupid' && ! (' listInstanceGroups' in this .$store .getters .apis )) {
276+ return true
277+ }
278+ if ([' zoneid' , ' domainid' , ' state' , ' level' , ' clusterid' , ' podid' , ' groupid' , ' entitytype' , ' type' ].includes (item)) {
264279 type = ' list'
265280 } else if (item === ' tags' ) {
266281 type = ' tag'
@@ -282,6 +297,7 @@ export default {
282297 let domainIndex = - 1
283298 let podIndex = - 1
284299 let clusterIndex = - 1
300+ let groupIndex = - 1
285301
286302 if (arrayField .includes (' type' )) {
287303 if (this .$route .path === ' /guestnetwork' || this .$route .path .includes (' /guestnetwork/' )) {
@@ -330,6 +346,12 @@ export default {
330346 promises .push (await this .fetchClusters ())
331347 }
332348
349+ if (arrayField .includes (' groupid' )) {
350+ groupIndex = this .fields .findIndex (item => item .name === ' groupid' )
351+ this .fields [groupIndex].loading = true
352+ promises .push (await this .fetchInstanceGroups ())
353+ }
354+
333355 if (arrayField .includes (' entitytype' )) {
334356 const entityTypeIndex = this .fields .findIndex (item => item .name === ' entitytype' )
335357 this .fields [entityTypeIndex].loading = true
@@ -378,6 +400,12 @@ export default {
378400 this .fields [clusterIndex].opts = this .sortArray (cluster[0 ].data )
379401 }
380402 }
403+ if (groupIndex > - 1 ) {
404+ const groups = response .filter (item => item .type === ' groupid' )
405+ if (groups && groups .length > 0 ) {
406+ this .fields [groupIndex].opts = this .sortArray (groups[0 ].data )
407+ }
408+ }
381409 }).finally (() => {
382410 if (zoneIndex > - 1 ) {
383411 this .fields [zoneIndex].loading = false
@@ -391,6 +419,9 @@ export default {
391419 if (clusterIndex > - 1 ) {
392420 this .fields [clusterIndex].loading = false
393421 }
422+ if (groupIndex > - 1 ) {
423+ this .fields [groupIndex].loading = false
424+ }
394425 this .fillFormFieldValues ()
395426 })
396427 },
@@ -468,6 +499,19 @@ export default {
468499 })
469500 })
470501 },
502+ fetchInstanceGroups () {
503+ return new Promise ((resolve , reject ) => {
504+ api (' listInstanceGroups' , { listAll: true }).then (json => {
505+ const instancegroups = json .listinstancegroupsresponse .instancegroup
506+ resolve ({
507+ type: ' groupid' ,
508+ data: instancegroups
509+ })
510+ }).catch (error => {
511+ reject (error .response .headers [' x-description' ])
512+ })
513+ })
514+ },
471515 fetchGuestNetworkTypes () {
472516 const types = []
473517 if (this .apiName .indexOf (' listNetworks' ) > - 1 ) {
0 commit comments