3535 </a-select >
3636 </div >
3737
38- <div class =" list__header__col" v-if =" vmTypeSelector" >
39- <a-select
40- v-focus =" true"
41- @change =" handleVmTypeSelect"
42- v-model:value =" selectedVmType"
43- :placeholder =" $t('label.vm.type')" >
44- <a-select-option value =" UserVm" >{{ $t('label.vms') }}</a-select-option >
45- <a-select-option value =" DomainRouter" >{{ $t('label.domain.router') }}</a-select-option >
46- </a-select >
47- </div >
48-
4938 <div class =" list__header__col list__header__col--full" >
5039 <a-input-search
5140 :placeholder =" $t('label.search')"
117106
118107 <div class =" list__footer" >
119108 <a-button @click =" handleClose" >{{ $t('label.cancel') }}</a-button >
120- <a-button @click =" handleSubmit" type =" primary" :disabled =" !selectedVm || (this.selectedVmType === 'UserVm' && !selectedNic) " >{{ $t('label.ok') }}</a-button >
109+ <a-button @click =" handleSubmit" type =" primary" :disabled =" !selectedVm || !selectedNic" >{{ $t('label.ok') }}</a-button >
121110 </div >
122111 </div >
123112
@@ -180,47 +169,15 @@ export default {
180169 networksList: [],
181170 vpcTiers: [],
182171 selectedVpcTier: null ,
183- vmTypeSelector: false ,
184- selectedVmType: ' UserVm' ,
185172 page: 1 ,
186173 pageSize: 10 ,
187174 vmCount: 0
188175 }
189176 },
190177 created () {
191- this .fetchVmTypeSelector ()
192178 this .fetchData ()
193179 },
194180 methods: {
195- fetchVmTypeSelector () {
196- if (this .resource .vpcid ) {
197- api (' listVPCs' , {
198- listAll: true ,
199- id: this .resource .vpcid
200- }).then (json => {
201- const vpc = json .listvpcsresponse .vpc ? .[0 ] || null
202- if (vpc) {
203- const isVRSourceNat = vpc .service .filter (s => (s .name === ' SourceNat' ) && (s .provider .filter (c => c .name === ' VpcVirtualRouter' ).length > 0 )).length > 0 || false
204- if (! isVRSourceNat) {
205- this .vmTypeSelector = true
206- }
207- }
208- })
209- } else {
210- api (' listNetworks' , {
211- listAll: true ,
212- id: this .resource .associatednetworkid
213- }).then (json => {
214- const network = json .listnetworksresponse .vpc ? .[0 ] || null
215- if (network) {
216- const isVRSourceNat = network .service .filter (s => (s .name === ' SourceNat' ) && (s .provider .filter (c => c .name === ' VirtualRouter' ).length > 0 )).length > 0 || false
217- if (! isVRSourceNat) {
218- this .vmTypeSelector = true
219- }
220- }
221- })
222- }
223- },
224181 fetchData () {
225182 if (this .resource .vpcid ) {
226183 this .handleTiers ()
@@ -229,23 +186,6 @@ export default {
229186 }
230187
231188 this .loading = true
232- if (this .selectedVmType === ' DomainRouter' ) {
233- api (' listRouters' , {
234- page: this .page ,
235- pageSize: this .pageSize ,
236- listAll: true ,
237- networkid: this .resource .associatednetworkid ,
238- keyword: this .searchQuery
239- }).then (response => {
240- this .vmCount = response .listroutersresponse .count
241- this .vmsList = response .listroutersresponse .router || []
242- }).catch (error => {
243- this .$notifyError (error)
244- }).finally (() => {
245- this .loading = false
246- })
247- return
248- }
249189 api (' listVirtualMachines' , {
250190 page: this .page ,
251191 pageSize: this .pageSize ,
@@ -263,24 +203,6 @@ export default {
263203 },
264204 fetchDataTiers (e ) {
265205 this .loading = true
266- if (this .selectedVmType === ' DomainRouter' ) {
267- api (' listRouters' , {
268- page: this .page ,
269- pageSize: this .pageSize ,
270- listAll: true ,
271- networkid: e,
272- vpcid: this .resource .vpcid ,
273- keyword: this .searchQuery
274- }).then (response => {
275- this .vmCount = response .listroutersresponse .count
276- this .vmsList = response .listroutersresponse .router || []
277- }).catch (error => {
278- this .$notifyError (error)
279- }).finally (() => {
280- this .loading = false
281- })
282- return
283- }
284206 api (' listVirtualMachines' , {
285207 page: this .page ,
286208 pageSize: this .pageSize ,
@@ -298,10 +220,6 @@ export default {
298220 },
299221 fetchNics (e ) {
300222 this .selectedVm = e .target .value
301- if (this .selectedVmType === ' DomainRouter' ) {
302- this .nicsList = []
303- return
304- }
305223 this .nicsList = []
306224 this .loading = true
307225 api (' listNics' , {
@@ -340,15 +258,12 @@ export default {
340258 },
341259 handleSubmit () {
342260 this .loading = true
343- const params = {
261+ api ( ' enableStaticNat ' , {
344262 ipaddressid: this .resource .id ,
345263 virtualmachineid: this .selectedVm ,
264+ vmguestip: this .selectedNic .ipaddress ,
346265 networkid: this .selectedVpcTier
347- }
348- if (this .selectedNic && this .selectedNic .ipaddress ) {
349- params .vmguestip = this .selectedNic .ipaddress
350- }
351- api (' enableStaticNat' , params).then (() => {
266+ }).then (() => {
352267 this .parentFetchData ()
353268 this .handleClose ()
354269 }).catch (error => {
@@ -368,9 +283,6 @@ export default {
368283 this .selectedVpcTier = tier
369284 this .fetchDataTiers (tier)
370285 },
371- handleVmTypeSelect () {
372- this .fetchData ()
373- },
374286 changePage (page , pageSize ) {
375287 this .page = page
376288 this .pageSize = pageSize
0 commit comments