54
54
:ref =" field.name"
55
55
:name =" field.name"
56
56
: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)" >
59
58
<a-select
60
59
allowClear
61
60
v-if =" field.type==='list'"
@@ -242,6 +241,19 @@ export default {
242
241
if (! this .visibleFilter ) return
243
242
this .initFormFieldData ()
244
243
},
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
+ },
245
257
async initFormFieldData () {
246
258
const arrayField = []
247
259
this .fields = []
@@ -260,7 +272,10 @@ export default {
260
272
if (item === ' clusterid' && ! (' listClusters' in this .$store .getters .apis )) {
261
273
return true
262
274
}
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)) {
264
279
type = ' list'
265
280
} else if (item === ' tags' ) {
266
281
type = ' tag'
@@ -282,6 +297,7 @@ export default {
282
297
let domainIndex = - 1
283
298
let podIndex = - 1
284
299
let clusterIndex = - 1
300
+ let groupIndex = - 1
285
301
286
302
if (arrayField .includes (' type' )) {
287
303
if (this .$route .path === ' /guestnetwork' || this .$route .path .includes (' /guestnetwork/' )) {
@@ -330,6 +346,12 @@ export default {
330
346
promises .push (await this .fetchClusters ())
331
347
}
332
348
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
+
333
355
if (arrayField .includes (' entitytype' )) {
334
356
const entityTypeIndex = this .fields .findIndex (item => item .name === ' entitytype' )
335
357
this .fields [entityTypeIndex].loading = true
@@ -378,6 +400,12 @@ export default {
378
400
this .fields [clusterIndex].opts = this .sortArray (cluster[0 ].data )
379
401
}
380
402
}
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
+ }
381
409
}).finally (() => {
382
410
if (zoneIndex > - 1 ) {
383
411
this .fields [zoneIndex].loading = false
@@ -391,6 +419,9 @@ export default {
391
419
if (clusterIndex > - 1 ) {
392
420
this .fields [clusterIndex].loading = false
393
421
}
422
+ if (groupIndex > - 1 ) {
423
+ this .fields [groupIndex].loading = false
424
+ }
394
425
this .fillFormFieldValues ()
395
426
})
396
427
},
@@ -468,6 +499,19 @@ export default {
468
499
})
469
500
})
470
501
},
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
+ },
471
515
fetchGuestNetworkTypes () {
472
516
const types = []
473
517
if (this .apiName .indexOf (' listNetworks' ) > - 1 ) {
0 commit comments