You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2020/10/05 11:49:38 UTC
[cloudstack-primate] branch master updated: Not relying on
erroneous count returned by findHostsForMigration (#774)
This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack-primate.git
The following commit(s) were added to refs/heads/master by this push:
new c662440 Not relying on erroneous count returned by findHostsForMigration (#774)
c662440 is described below
commit c6624403556df286f1b61e9d34f948a089af8326
Author: davidjumani <dj...@gmail.com>
AuthorDate: Mon Oct 5 17:19:25 2020 +0530
Not relying on erroneous count returned by findHostsForMigration (#774)
---
src/views/compute/MigrateWizard.vue | 66 +++++++++++++++++++++++++------------
1 file changed, 45 insertions(+), 21 deletions(-)
diff --git a/src/views/compute/MigrateWizard.vue b/src/views/compute/MigrateWizard.vue
index af305ae..b45a20b 100644
--- a/src/views/compute/MigrateWizard.vue
+++ b/src/views/compute/MigrateWizard.vue
@@ -21,13 +21,13 @@
:placeholder="$t('label.search')"
v-model="searchQuery"
style="margin-bottom: 10px;"
- @search="fetchData" />
+ @search="handleSearch" />
<a-table
size="small"
style="overflow-y: auto"
:loading="loading"
:columns="columns"
- :dataSource="hosts"
+ :dataSource="items"
:pagination="false"
:rowKey="record => record.id">
<div slot="suitability" slot-scope="record">
@@ -95,6 +95,7 @@ export default {
return {
loading: true,
hosts: [],
+ items: [],
selectedHost: {},
searchQuery: '',
totalCount: 0,
@@ -129,23 +130,34 @@ export default {
},
methods: {
fetchData () {
- this.loading = true
- api('findHostsForMigration', {
- virtualmachineid: this.resource.id,
- keyword: this.searchQuery,
- page: this.page,
- pagesize: this.pageSize
- }).then(response => {
- this.hosts = response.findhostsformigrationresponse.host
- this.totalCount = response.findhostsformigrationresponse.count
- if (this.totalCount > 0) {
- this.totalCount -= 1
- }
- }).catch(error => {
- this.$message.error(`${this.$t('message.load.host.failed')}: ${error}`)
- }).finally(() => {
- this.loading = false
- })
+ var page = 1
+ const hosts = []
+ const getNextPage = () => {
+ this.loading = true
+ api('findHostsForMigration', {
+ virtualmachineid: this.resource.id,
+ listAll: true,
+ details: 'min',
+ page: page,
+ pageSize: 500
+ }).then(response => {
+ if (response && response.findhostsformigrationresponse && response.findhostsformigrationresponse.host) {
+ hosts.push(...response.findhostsformigrationresponse.host)
+ }
+ if (response.findhostsformigrationresponse.host) {
+ page++
+ getNextPage()
+ }
+ }).catch(error => {
+ this.$message.error(`${this.$t('message.load.host.failed')}: ${error}`)
+ }).finally(() => {
+ this.hosts = hosts
+ this.totalCount = this.hosts.length
+ this.items = this.hosts.slice(0, Math.min(this.totalCount, this.pageSize))
+ this.loading = false
+ })
+ }
+ getNextPage()
},
submitForm () {
this.loading = true
@@ -181,15 +193,27 @@ export default {
this.$message.error(`${this.$t('message.migrating.vm.to.host.failed')} ${this.selectedHost.name}`)
})
},
+ handleSearch () {
+ this.loading = true
+ this.page = 1
+ this.items = this.hosts.filter(x => x.name.toLowerCase().includes(this.searchQuery))
+ this.totalCount = this.items.length
+ this.items = this.items.slice((this.page - 1) * this.pageSize, Math.min(this.totalCount, this.page * this.pageSize))
+ this.loading = false
+ },
handleChangePage (page, pageSize) {
+ this.loading = true
this.page = page
this.pageSize = pageSize
- this.fetchData()
+ this.items = this.hosts.slice((this.page - 1) * this.pageSize, Math.min(this.totalCount, this.page * this.pageSize))
+ this.loading = false
},
handleChangePageSize (currentPage, pageSize) {
+ this.loading = true
this.page = currentPage
this.pageSize = pageSize
- this.fetchData()
+ this.items = this.hosts.slice((this.page - 1) * this.pageSize, Math.min(this.totalCount, this.page * this.pageSize))
+ this.loading = false
}
},
filters: {