diff --git a/ui/src/components/view/ResourceView.vue b/ui/src/components/view/ResourceView.vue index f3f79e279f5..c7035a91237 100644 --- a/ui/src/components/view/ResourceView.vue +++ b/ui/src/components/view/ResourceView.vue @@ -43,7 +43,7 @@ v-for="tab in tabs" :tab="$t('label.' + tab.name)" :key="tab.name" - v-if="showHideTab(tab)"> + v-if="showTab(tab)"> @@ -97,8 +97,12 @@ export default { if (newItem.id === oldItem.id) return if (this.resource.associatednetworkid) { - api('listNetworks', { id: this.resource.associatednetworkid }).then(response => { - this.networkService = response.listnetworksresponse.network[0] + api('listNetworks', { id: this.resource.associatednetworkid, listall: true }).then(response => { + if (response && response.listnetworksresponse && response.listnetworksresponse.network) { + this.networkService = response.listnetworksresponse.network[0] + } else { + this.networkService = {} + } }) } } @@ -107,12 +111,15 @@ export default { onTabChange (key) { this.activeTab = key }, - showHideTab (tab) { + showTab (tab) { if ('networkServiceFilter' in tab) { - if (this.resource.virtualmachineid && tab.name !== 'Firewall') { + if (this.resource && this.resource.virtualmachineid && !this.resource.vpcid && tab.name !== 'firewall') { return false } - if (this.resource && this.resource.vpcid && tab.name !== 'Firewall') { + if (this.resource && this.resource.virtualmachineid && this.resource.vpcid) { + return false + } + if (this.resource && this.resource.vpcid && tab.name !== 'firewall') { return true } return this.networkService && this.networkService.service && diff --git a/ui/src/views/network/EnableStaticNat.vue b/ui/src/views/network/EnableStaticNat.vue index 3a7c35f75f8..c9e22b0ceab 100644 --- a/ui/src/views/network/EnableStaticNat.vue +++ b/ui/src/views/network/EnableStaticNat.vue @@ -172,7 +172,7 @@ export default { domainid: this.resource.domainid, keyword: this.searchQuery }).then(response => { - this.vmsList = response.listvirtualmachinesresponse.virtualmachine + this.vmsList = response.listvirtualmachinesresponse.virtualmachine || [] }).catch(error => { this.$notifyError(error) }).finally(() => { @@ -204,9 +204,9 @@ export default { this.loading = true api('listNics', { virtualmachineid: this.selectedVm, - networkid: this.resource.associatednetworkid + networkid: this.resource.associatednetworkid || this.selectedVpcTier }).then(response => { - this.nicsList = response.listnicsresponse.nic + this.nicsList = response.listnicsresponse.nic || [] let secondaryIps = this.nicsList.map(item => item.secondaryip) diff --git a/ui/src/views/network/LoadBalancing.vue b/ui/src/views/network/LoadBalancing.vue index b2586765c71..638da12b561 100644 --- a/ui/src/views/network/LoadBalancing.vue +++ b/ui/src/views/network/LoadBalancing.vue @@ -18,6 +18,21 @@ + + + + {{ $t('label.tiername') }} + + + {{ tier.displaytext }} + + + + + *{{ $t('label.name') }} @@ -63,7 +78,7 @@ - - - - - - {{ $t('label.name') }} - {{ $t('label.instancename') }} - {{ $t('label.displayname') }} - {{ $t('label.ip') }} - {{ $t('label.account') }} - {{ $t('label.zonenamelabel') }} - {{ $t('label.state') }} - {{ $t('label.select') }} - - - - - - - {{ vm.name }} - - - - - {{ nic }}{{ nicIndex === 0 ? ' (Primary)' : null }} - - + + + + + + {{ text }} - {{ vm.instancename }} - {{ vm.displayname }} - - {{ vm.account }} - {{ vm.zonename }} - {{ vm.state }} - fetchNics(e, index)" /> + + + + {{ nic }}{{ nicIndex === 0 ? ' (Primary)' : null }} + + - + + + + + + + fetchNics(e, index)" /> + + + @@ -423,7 +449,46 @@ export default { title: this.$t('label.action'), scopedSlots: { customRender: 'actions' } } - ] + ], + tiers: { + loading: false, + data: [] + }, + vmColumns: [ + { + title: this.$t('label.name'), + dataIndex: 'name', + scopedSlots: { customRender: 'name' }, + width: 220 + }, + { + title: this.$t('label.state'), + dataIndex: 'state', + scopedSlots: { customRender: 'state' } + }, + { + title: this.$t('label.displayname'), + dataIndex: 'displayname' + }, + { + title: this.$t('label.account'), + dataIndex: 'account' + }, + { + title: this.$t('label.zonename'), + dataIndex: 'zonename' + }, + { + title: this.$t('label.select'), + dataIndex: 'action', + scopedSlots: { customRender: 'action' }, + width: 80 + } + ], + vmPage: 1, + vmPageSize: 10, + vmCount: 0, + searchQuery: null } }, mounted () { @@ -446,9 +511,30 @@ export default { }, methods: { fetchData () { + this.fetchListTiers() + this.fetchLBRules() + }, + fetchListTiers () { + this.tiers.loading = true + + api('listNetworks', { + account: this.resource.account, + domainid: this.resource.domainid, + supportedservices: 'Lb', + vpcid: this.resource.vpcid + }).then(json => { + this.tiers.data = json.listnetworksresponse.network || [] + this.newRule.tier = this.tiers.data && this.tiers.data[0].id ? this.tiers.data[0].id : null + this.$forceUpdate() + }).catch(error => { + this.$notifyError(error) + }).finally(() => { this.tiers.loading = false }) + }, + fetchLBRules () { this.loading = true this.lbRules = [] this.stickinessPolicies = [] + api('listLoadBalancerRules', { listAll: true, publicipid: this.resource.id, @@ -882,26 +968,7 @@ export default { if (!this.newRule.name || !this.newRule.publicport || !this.newRule.privateport) return } this.addVmModalVisible = true - this.addVmModalLoading = true - api('listVirtualMachines', { - listAll: true, - page: 1, - pagesize: 500, - networkid: this.resource.associatednetworkid, - account: this.resource.account, - domainid: this.resource.domainid - }).then(response => { - this.vms = response.listvirtualmachinesresponse.virtualmachine - this.vms.forEach((vm, index) => { - this.newRule.virtualmachineid[index] = null - this.nics[index] = null - this.newRule.vmguestip[index] = null - }) - this.addVmModalLoading = false - }).catch(error => { - this.$notifyError(error) - this.closeModal() - }) + this.fetchVirtualMachines() }, fetchNics (e, index) { if (!e.target.checked) { @@ -917,7 +984,7 @@ export default { virtualmachineid: e.target.value, networkid: this.resource.associatednetworkid }).then(response => { - if (!response.listnicsresponse.nic[0]) return + if (!response || !response.listnicsresponse || !response.listnicsresponse.nic[0]) return const newItem = [] newItem.push(response.listnicsresponse.nic[0].ipaddress) if (response.listnicsresponse.nic[0].secondaryip) { @@ -931,6 +998,33 @@ export default { this.closeModal() }) }, + fetchVirtualMachines () { + this.vmCount = 0 + this.vms = [] + this.addVmModalLoading = true + const networkId = ('vpcid' in this.resource && !('associatednetworkid' in this.resource)) ? this.newRule.tier : this.resource.associatednetworkid + api('listVirtualMachines', { + listAll: true, + keyword: this.searchQuery, + page: this.vmPage, + pagesize: this.vmPageSize, + networkid: networkId, + account: this.resource.account, + domainid: this.resource.domainid + }).then(response => { + this.vmCount = response.listvirtualmachinesresponse.count || 0 + this.vms = response.listvirtualmachinesresponse.virtualmachine || [] + this.vms.forEach((vm, index) => { + this.newRule.virtualmachineid[index] = null + this.nics[index] = null + this.newRule.vmguestip[index] = null + }) + }).catch(error => { + this.$notifyError(error) + }).finally(() => { + this.addVmModalLoading = false + }) + }, handleAssignToLBRule (data) { const vmIDIpMap = {} @@ -991,9 +1085,10 @@ export default { return } + const networkId = ('vpcid' in this.resource && !('associatednetworkid' in this.resource)) ? this.newRule.tier : this.resource.associatednetworkid api('createLoadBalancerRule', { openfirewall: false, - networkid: this.resource.associatednetworkid, + networkid: networkId, publicipid: this.resource.id, algorithm: this.newRule.algorithm, name: this.newRule.name, @@ -1040,6 +1135,10 @@ export default { this.page = currentPage this.pageSize = pageSize this.fetchData() + }, + onSearch (value) { + this.searchQuery = value + this.fetchVirtualMachines() } } } @@ -1372,6 +1471,7 @@ export default { .pagination { margin-top: 20px; + text-align: right; } .actions { @@ -1381,4 +1481,22 @@ export default { } } } + + .list-view { + overflow-y: auto; + display: block; + width: 100%; + } + + .filter { + display: block; + width: 240px; + margin-bottom: 10px; + } + + .input-search { + margin-bottom: 10px; + width: 220px; + float: right; + } diff --git a/ui/src/views/network/PortForwarding.vue b/ui/src/views/network/PortForwarding.vue index f5bc4ac7f83..dabf6e3eeb0 100644 --- a/ui/src/views/network/PortForwarding.vue +++ b/ui/src/views/network/PortForwarding.vue @@ -18,6 +18,21 @@ + + + + {{ $t('label.tiername') }} + + + {{ tier.displaytext }} + + + + + {{ $t('label.privateport') }} @@ -159,57 +174,70 @@ {disabled: newRule.virtualmachineid === null } }" @cancel="closeModal" > - - - - - - {{ $t('label.name') }} - {{ $t('label.instancename') }} - {{ $t('label.displayname') }} - {{ $t('label.ip') }} - {{ $t('label.account') }} - {{ $t('label.zone') }} - {{ $t('label.state') }} - {{ $t('label.select') }} - - - - - - - - {{ vm.name }} - - - - - {{ nic }}{{ nicIndex === 0 ? ' (Primary)' : null }} - - + + + + + + {{ text }} - {{ vm.instancename }} - {{ vm.displayname }} - - {{ vm.account }} - {{ vm.zonename }} - {{ vm.state }} - + + + + {{ nic }}{{ nicIndex === 0 ? ' (Primary)' : null }} + + - + + + + + + + fetchNics(e)" /> + + + - -