ui: select newly created network in deploy vm (#5423)

Form tries to find newly created network which belongs to the same account, created in last 30s and was not present in the networks list before opening create network dialog.

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
Abhishek Kumar 2021-09-14 09:04:10 +05:30 committed by GitHub
parent 470ceb4351
commit 6e50e10470
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 33 additions and 2 deletions

View File

@ -22,7 +22,7 @@
:placeholder="$t('label.search')"
v-model="filter"
@search="handleSearch" />
<a-button type="primary" @click="showCreateForm = true" style="float: right; margin-right: 5px; z-index: 8">
<a-button type="primary" @click="onCreateNetworkClick" style="float: right; margin-right: 5px; z-index: 8">
{{ $t('label.create.network') }}
</a-button>
<a-table
@ -139,7 +139,8 @@ export default {
page: 1,
pageSize: 10,
keyword: null
}
},
networksBeforeCreate: null
}
},
computed: {
@ -222,6 +223,32 @@ export default {
}
}
}
},
items () {
if (this.items && this.items.length > 0 &&
this.networksBeforeCreate) {
var user = this.$store.getters.userInfo
for (var network of this.items) {
if (user.account !== network.account ||
user.domainid !== network.domainid ||
(new Date()).getTime() - Date.parse(network.created) > 30000) {
continue
}
var networkFoundInNewList = false
for (var oldNetwork of this.networksBeforeCreate) {
if (oldNetwork.id === network.id) {
networkFoundInNewList = true
break
}
}
if (!networkFoundInNewList) {
this.selectedRowKeys.push(network.id)
this.$emit('select-network-item', this.selectedRowKeys)
break
}
}
this.networksBeforeCreate = null
}
}
},
beforeCreate () {
@ -289,6 +316,10 @@ export default {
resolve(error)
})
})
},
onCreateNetworkClick () {
this.networksBeforeCreate = this.items
this.showCreateForm = true
}
}
}