Skip to content

Commit 9e7272c

Browse files
committed
UI: show 'VPN' tab if Public IP does not have rules
1 parent 05e9b79 commit 9e7272c

File tree

3 files changed

+21
-109
lines changed

3 files changed

+21
-109
lines changed

ui/src/config/section/network.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ export default {
794794
}, {
795795
name: 'vpn',
796796
component: shallowRef(defineAsyncComponent(() => import('@/views/network/VpnDetails.vue'))),
797-
show: (record) => { return record.issourcenat || record.virtualmachinetype === 'DomainRouter' }
797+
show: (record) => { return record.issourcenat || record.virtualmachinetype === 'DomainRouter' || !record.hasrules }
798798
},
799799
{
800800
name: 'events',

ui/src/views/network/EnableStaticNat.vue

Lines changed: 4 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,6 @@
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')"
@@ -117,7 +106,7 @@
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

ui/src/views/network/PublicIpResource.vue

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -134,24 +134,21 @@ export default {
134134
this.tabs = this.defaultTabs
135135
return
136136
}
137-
// VPC IPs with source nat have only VPN
138-
if (this.resource && this.resource.vpcid && this.resource.issourcenat) {
139-
this.tabs = this.defaultTabs.concat(this.$route.meta.tabs.filter(tab => tab.name === 'vpn'))
140-
return
141-
}
142-
// VPC IPs with vpnenabled have only VPN
143-
if (this.resource && this.resource.vpcid && this.resource.vpnenabled) {
144-
this.tabs = this.defaultTabs.concat(this.$route.meta.tabs.filter(tab => tab.name === 'vpn'))
145-
return
146-
}
147-
// VPC IPs with static nat have nothing
148-
if (this.resource && this.resource.vpcid && this.resource.isstaticnat) {
149-
if (this.resource.virtualmachinetype === 'DomainRouter') {
137+
if (this.resource && this.resource.vpcid) {
138+
// VPC IPs with source nat have only VPN
139+
if (this.resource.issourcenat) {
150140
this.tabs = this.defaultTabs.concat(this.$route.meta.tabs.filter(tab => tab.name === 'vpn'))
141+
return
151142
}
152-
return
153-
}
154-
if (this.resource && this.resource.vpcid) {
143+
144+
// VPC IPs with static nat have nothing
145+
if (this.resource.isstaticnat) {
146+
if (this.resource.virtualmachinetype === 'DomainRouter') {
147+
this.tabs = this.defaultTabs.concat(this.$route.meta.tabs.filter(tab => tab.name === 'vpn'))
148+
}
149+
return
150+
}
151+
155152
// VPC IPs don't have firewall
156153
let tabs = this.$route.meta.tabs.filter(tab => tab.name !== 'firewall')
157154
@@ -207,6 +204,9 @@ export default {
207204
this.actions = this.$route.meta.actions || []
208205
},
209206
fetchNetwork () {
207+
if (!this.resource.associatednetworkid) {
208+
return null
209+
}
210210
return new Promise((resolve, reject) => {
211211
api('listNetworks', {
212212
listAll: true,

0 commit comments

Comments
 (0)