1616// under the License.
1717
1818<template >
19- <div class =" form-layout" >
20- <a-tabs defaultActiveKey =" 1" :animated =" false" >
21- <a-tab-pane :tab =" $t('label.isolated')" key =" 1" v-if =" this. isAdvancedZoneWithoutSGAvailable() " >
19+ <a-spin :spinning = " loading " class =" form-layout" >
20+ <a-tabs defaultActiveKey =" 1" :animated =" false" v-if = " !loading " >
21+ <a-tab-pane :tab =" $t('label.isolated')" key =" 1" v-if =" isAdvancedZoneWithoutSGAvailable" >
2222 <CreateIsolatedNetworkForm
2323 :loading =" loading"
2424 :resource =" resource"
4343 @refresh =" handleRefresh" />
4444 </a-tab-pane >
4545 </a-tabs >
46- </div >
46+ </a-spin >
4747</template >
4848
4949<script >
@@ -67,6 +67,7 @@ export default {
6767 },
6868 data () {
6969 return {
70+ isAdvancedZoneWithoutSGAvailable: true ,
7071 defaultNetworkTypeTabKey: ' 1' ,
7172 loading: false ,
7273 actionZones: [],
@@ -78,40 +79,39 @@ export default {
7879 this .fetchData ()
7980 }
8081 },
81- mounted () {
82- this .fetchData ()
82+ created () {
83+ const promises = []
84+ promises .push (this .fetchActionZoneData ())
85+ Promise .all (promises).then (() => {
86+ for (const i in this .actionZones ) {
87+ const zone = this .actionZones [i]
88+ if (zone .networktype === ' Advanced' && zone .securitygroupsenabled !== true ) {
89+ this .isAdvancedZoneWithoutSGAvailable = true
90+ return
91+ }
92+ }
93+ this .isAdvancedZoneWithoutSGAvailable = false
94+ })
8395 },
8496 methods: {
85- fetchData () {
86- this .loading = true
87- this .fetchActionZoneData ()
88- },
8997 isAdmin () {
9098 return [' Admin' ].includes (this .$store .getters .userInfo .roletype )
9199 },
92100 fetchActionZoneData () {
101+ this .loading = true
93102 const params = {}
94103 if (this .resource && this .resource .zoneid ) {
95104 params .id = this .resource .zoneid
96105 }
97106 params .listAll = true
98107 this .actionZonesLoading = true
99- api (' listZones' , params).then (json => {
108+ return api (' listZones' , params).then (json => {
100109 this .actionZones = json .listzonesresponse .zone
101110 }).finally (() => {
102111 this .actionZoneLoading = false
103112 this .loading = false
104113 })
105114 },
106- isAdvancedZoneWithoutSGAvailable () {
107- for (const i in this .actionZones ) {
108- const zone = this .actionZones [i]
109- if (zone .networktype === ' Advanced' && zone .securitygroupsenabled !== true ) {
110- return true
111- }
112- }
113- return false
114- },
115115 handleRefresh () {
116116 this .fetchData ()
117117 },
0 commit comments