Skip to content

Commit bcc64cc

Browse files
committed
ui fixes
Signed-off-by: Abhishek Kumar <[email protected]>
1 parent 3ad581e commit bcc64cc

File tree

6 files changed

+224
-155
lines changed

6 files changed

+224
-155
lines changed

ui/src/views/compute/CreateAutoScaleVmGroup.vue

Lines changed: 66 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
<os-based-image-selection
7373
v-if="isModernImageSelection"
7474
:imageTypeSelectionAllowed="false"
75+
:imagePreSelected="!!this.queryTemplateId"
76+
:guestOsCategoriesSelectionDisallowed="!this.queryGuestOsCategoryId && !!this.queryTemplateId"
7577
:guestOsCategories="options.guestOsCategories"
7678
:guestOsCategoriesLoading="loading.guestOsCategories"
7779
:selectedGuestOsCategoryId="form.guestoscategoryid"
@@ -88,7 +90,7 @@
8890
@update-disk-size="updateFieldValue" />
8991
<a-card
9092
v-else
91-
:tabList="imageTypeTabList"
93+
:tabList="imageTypeList"
9294
:activeTabKey="imageType">
9395
<div>
9496
{{ $t('message.template.desc') }}
@@ -1417,16 +1419,25 @@ export default {
14171419
templateConfigurationExists () {
14181420
return this.vm.templateid && this.templateConfigurations && this.templateConfigurations.length > 0
14191421
},
1422+
queryZoneId () {
1423+
return this.$route.query.zoneid || null
1424+
},
1425+
queryArchId () {
1426+
return this.$route.query.arch || null
1427+
},
14201428
queryTemplateId () {
14211429
return this.$route.query.templateid || null
14221430
},
14231431
queryNetworkId () {
14241432
return this.$route.query.networkid || null
14251433
},
1434+
queryGuestOsCategoryId () {
1435+
return this.$route.query.oscategoryid || null
1436+
},
14261437
queryLbRuleId () {
14271438
return this.$route.query.lbruleid || null
14281439
},
1429-
imageTypeTabList () {
1440+
imageTypeList () {
14301441
return [{
14311442
key: 'templateid',
14321443
tab: this.$t('label.templates')
@@ -1848,11 +1859,18 @@ export default {
18481859
let zones = []
18491860
let apiName = ''
18501861
const params = {}
1851-
if (this.queryTemplateId) {
1862+
if (this.queryZoneId) {
1863+
zones.push(this.queryZoneId)
1864+
if (this.queryTemplateId) {
1865+
this.dataPreFill.templateid = this.queryTemplateId
1866+
}
1867+
return resolve(zones)
1868+
} else if (this.queryTemplateId) {
18521869
apiName = 'listTemplates'
18531870
params.listall = true
18541871
params.templatefilter = this.isNormalAndDomainUser ? 'executable' : 'all'
18551872
params.id = this.queryTemplateId
1873+
this.dataPreFill.templateid = this.queryTemplateId
18561874
} else if (this.queryNetworkId) {
18571875
params.listall = true
18581876
params.id = this.queryNetworkId
@@ -1884,6 +1902,9 @@ export default {
18841902
},
18851903
async fetchData () {
18861904
this.architectureTypes.opts = this.$fetchCpuArchitectureTypes()
1905+
if (this.queryArchId) {
1906+
this.architectureTypes.opts = this.architectureTypes.opts.filter(o => o.id === this.queryArchId)
1907+
}
18871908
const zones = await this.fetchZoneByQuery()
18881909
if (zones && zones.length === 1) {
18891910
this.selectedZone = zones[0]
@@ -2033,21 +2054,15 @@ export default {
20332054
this.form.templateid = value
20342055
this.resetFromTemplateConfiguration()
20352056
let template = ''
2036-
for (const key in this.options.templates) {
2037-
var t = _.find(_.get(this.options.templates[key], 'template', []), (option) => option.id === value)
2038-
if (t) {
2039-
this.template = t
2040-
this.templateConfigurations = []
2041-
this.selectedTemplateConfiguration = {}
2042-
this.templateNics = []
2043-
this.templateLicenses = []
2044-
this.templateProperties = {}
2045-
this.updateTemplateParameters()
2046-
template = t
2057+
for (const entry of Object.values(this.options.templates)) {
2058+
template = entry?.template.find(option => option.id === value) || null
2059+
if (template) {
2060+
this.template = template
20472061
break
20482062
}
20492063
}
20502064
if (template) {
2065+
this.resetTemplateAssociatedResources()
20512066
var size = template.size / (1024 * 1024 * 1024) || 0 // bytes to GB
20522067
this.dataPreFill.minrootdisksize = Math.ceil(size)
20532068
this.updateTemplateLinkedUserData(this.template.userdataid)
@@ -2437,29 +2452,37 @@ export default {
24372452
},
24382453
fetchGuestOsCategories (skipFetchImages) {
24392454
const key = 'guestOsCategories'
2440-
const param = this.params[key]
2441-
return this.fetchOptions(param, key, ['zones'])
2455+
const params = this.params[key]
2456+
if (this.queryGuestOsCategoryId) {
2457+
params.options.id = this.queryGuestOsCategoryId
2458+
} else if (this.queryTemplateId) {
2459+
this.fetchAllTemplates()
2460+
return Promise.resolve()
2461+
}
2462+
return this.fetchOptions(params, key, ['zones'])
24422463
.then((res) => {
24432464
if (!this.options.guestOsCategories) {
24442465
this.options.guestOsCategories = []
24452466
}
2446-
if (this.showUserCategoryForModernImageSelection) {
2447-
const userCategory = {
2448-
id: '0',
2449-
name: this.$t('label.user')
2450-
}
2451-
if (this.$store.getters.avatar) {
2452-
userCategory.icon = {
2453-
base64image: this.$store.getters.avatar
2467+
if (!this.queryGuestOsCategoryId) {
2468+
if (this.showUserCategoryForModernImageSelection) {
2469+
const userCategory = {
2470+
id: '0',
2471+
name: this.$t('label.user')
2472+
}
2473+
if (this.$store.getters.avatar) {
2474+
userCategory.icon = {
2475+
base64image: this.$store.getters.avatar
2476+
}
24542477
}
2478+
this.options.guestOsCategories.push(userCategory)
2479+
}
2480+
if (this.showAllCategoryForModernImageSelection) {
2481+
this.options.guestOsCategories.push({
2482+
id: '-1',
2483+
name: this.$t('label.all')
2484+
})
24552485
}
2456-
this.options.guestOsCategories.push(userCategory)
2457-
}
2458-
if (this.showAllCategoryForModernImageSelection) {
2459-
this.options.guestOsCategories.push({
2460-
id: '-1',
2461-
name: this.$t('label.all')
2462-
})
24632486
}
24642487
this.form.guestoscategoryid = this.options.guestOsCategories[0].id
24652488
if (skipFetchImages) {
@@ -2960,6 +2983,8 @@ export default {
29602983
args.templatefilter = templateFilter
29612984
args.details = 'all'
29622985
args.showicon = 'true'
2986+
args.id = this.queryTemplateId
2987+
args.isvnf = false
29632988
29642989
delete args.category
29652990
delete args.public
@@ -3007,6 +3032,13 @@ export default {
30073032
})
30083033
this.options.templates = templates
30093034
},
3035+
resetTemplateAssociatedResources () {
3036+
this.templateConfigurations = []
3037+
this.selectedTemplateConfiguration = {}
3038+
this.templateNics = []
3039+
this.templateLicenses = []
3040+
this.templateProperties = {}
3041+
},
30103042
async fetchZoneOptions () {
30113043
let guestOsFetch = null
30123044
for (const [name, param] of Object.entries(this.params)) {
@@ -3038,7 +3070,9 @@ export default {
30383070
this.formModel = toRaw(this.form)
30393071
},
30403072
onSelectZoneId (value) {
3041-
this.dataPreFill = {}
3073+
if (this.dataPreFill.zoneid !== value) {
3074+
this.dataPreFill = {}
3075+
}
30423076
this.zoneId = value
30433077
this.zone = _.find(this.options.zones, (option) => option.id === value)
30443078
this.zoneSelected = true

ui/src/views/compute/DeployVM.vue

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@
151151
@change-iso-hypervisor="value => hypervisor = value" />
152152
<a-card
153153
v-else
154-
:tabList="imageTabList"
154+
:tabList="imageTypeList"
155155
:activeTabKey="imageType"
156156
@tabChange="key => changeImageType(key)">
157157
<div v-if="imageType === 'templateid'">
@@ -1353,30 +1353,26 @@ export default {
13531353
queryGuestOsCategoryId () {
13541354
return this.$route.query.oscategoryid || null
13551355
},
1356-
imageTabList () {
1357-
let imageTabList = []
1356+
imageTypeList () {
13581357
if (this.queryTemplateId) {
1359-
imageTabList = [{
1358+
return [{
13601359
key: 'templateid',
13611360
tab: this.$t('label.templates')
13621361
}]
13631362
} else if (this.queryIsoId) {
1364-
imageTabList = [{
1365-
key: 'isoid',
1366-
tab: this.$t('label.isos')
1367-
}]
1368-
} else {
1369-
imageTabList = [{
1370-
key: 'templateid',
1371-
tab: this.$t('label.templates')
1372-
},
1373-
{
1363+
return [{
13741364
key: 'isoid',
13751365
tab: this.$t('label.isos')
13761366
}]
13771367
}
1378-
1379-
return imageTabList
1368+
return [{
1369+
key: 'templateid',
1370+
tab: this.$t('label.templates')
1371+
},
1372+
{
1373+
key: 'isoid',
1374+
tab: this.$t('label.isos')
1375+
}]
13801376
},
13811377
userdataTabList () {
13821378
let tabList = []

0 commit comments

Comments
 (0)