Skip to content

Commit b7590ba

Browse files
committed
update Template selection + minor fixes
1 parent 4d2e444 commit b7590ba

File tree

4 files changed

+225
-46
lines changed

4 files changed

+225
-46
lines changed

ui/src/components/view/DeployVMFromBackup.vue

Lines changed: 192 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,108 @@
4545
</div>
4646
</template>
4747
</a-step>
48+
<a-step :title="$t('label.select.deployment.infrastructure')" status="process">
49+
<template #description>
50+
<div style="margin-top: 15px">
51+
<a-form-item
52+
v-if="!isNormalAndDomainUser"
53+
:label="$t('label.podid')"
54+
name="podid"
55+
ref="podid">
56+
<a-select
57+
v-model:value="form.podid"
58+
showSearch
59+
optionFilterProp="label"
60+
:filterOption="filterOption"
61+
:options="podSelectOptions"
62+
:loading="loading.pods"
63+
@change="onSelectPodId"
64+
></a-select>
65+
</a-form-item>
66+
<a-form-item
67+
v-if="!isNormalAndDomainUser"
68+
:label="$t('label.clusterid')"
69+
name="clusterid"
70+
ref="clusterid">
71+
<a-select
72+
v-model:value="form.clusterid"
73+
showSearch
74+
optionFilterProp="label"
75+
:filterOption="filterOption"
76+
:options="clusterSelectOptions"
77+
:loading="loading.clusters"
78+
@change="onSelectClusterId"
79+
></a-select>
80+
</a-form-item>
81+
<a-form-item
82+
v-if="!isNormalAndDomainUser"
83+
:label="$t('label.hostid')"
84+
name="hostid"
85+
ref="hostid">
86+
<a-select
87+
v-model:value="form.hostid"
88+
showSearch
89+
optionFilterProp="label"
90+
:filterOption="filterOption"
91+
:options="hostSelectOptions"
92+
:loading="loading.hosts"
93+
@change="onSelectHostId"
94+
></a-select>
95+
</a-form-item>
96+
</div>
97+
</template>
98+
</a-step>
4899
<a-step
49100
:title="$t('label.template')"
50101
:status="zoneSelected ? 'process' : 'wait'">
51102
<template #description>
52-
<div style="margin-top: 15px">
53-
<a-select
54-
style="width: 100%"
55-
:options="templateSelectOptions"
56-
v-model:value="form.templateid"
57-
showSearch
58-
optionFilterProp="label"
59-
:filterOption="filterOption"
60-
:loading="loading.templates">
61-
<a-select-option v-for="temp in templateSelectOptions" :key="temp.value" :label="temp.label">
62-
<span>
63-
<resource-icon v-if="temp.icon" :image="temp.icon" size="1x" style="margin-right: 5px"/>
64-
<os-logo v-else-if="temp.value !== null" :osId="temp.ostypeid" :osName="temp.ostypename" size="lg" style="margin-left: -1px" />
65-
{{ temp.label }}
66-
</span>
67-
</a-select-option>
68-
</a-select>
103+
<div v-if="zoneSelected" style="margin-top: 15px">
104+
<a-card>
105+
{{ $t('message.template.desc') }}
106+
<div v-if="isZoneSelectedMultiArch" style="width: 100%; margin-top: 5px">
107+
{{ $t('message.template.arch') }}
108+
<a-select
109+
style="width: 100%"
110+
v-model:value="selectedArchitecture"
111+
:defaultValue="architectureTypes.opts[0].id"
112+
@change="arch => changeArchitecture(arch, true)">
113+
<a-select-option v-for="opt in architectureTypes.opts" :key="opt.id">
114+
{{ opt.name || opt.description }}
115+
</a-select-option>
116+
</a-select>
117+
</div>
118+
<template-iso-selection
119+
input-decorator="templateid"
120+
:items="options.templates"
121+
:loading="loading.templates"
122+
:preFillContent="dataPreFill"
123+
:key="templateKey"
124+
@handle-search-filter="($event) => fetchAllTemplates($event)"
125+
@update-template-iso="updateFieldValue" />
126+
<div>
127+
{{ $t('label.override.rootdisk.size') }}
128+
<a-switch
129+
v-model:checked="form.rootdisksizeitem"
130+
:disabled="rootDiskSizeFixed > 0 || template.deployasis || showOverrideDiskOfferingOption"
131+
@change="val => { showRootDiskSizeChanger = val }"
132+
style="margin-left: 10px;"/>
133+
<div v-if="template.deployasis"> {{ $t('message.deployasis') }} </div>
134+
</div>
135+
<disk-size-selection
136+
v-if="showRootDiskSizeChanger"
137+
input-decorator="rootdisksize"
138+
:preFillContent="dataPreFill"
139+
:isCustomized="true"
140+
:minDiskSize="dataPreFill.minrootdisksize"
141+
@update-disk-size="updateFieldValue"
142+
style="margin-top: 10px;"/>
143+
</a-card>
144+
<a-form-item class="form-item-hidden">
145+
<a-input v-model:value="form.templateid" />
146+
</a-form-item>
147+
<a-form-item class="form-item-hidden">
148+
<a-input v-model:value="form.rootdisksize" />
149+
</a-form-item>
69150
</div>
70151
</template>
71152
</a-step>
@@ -567,6 +648,7 @@ import DiskOfferingSelection from '@views/compute/wizard/DiskOfferingSelection'
567648
import DiskSizeSelection from '@views/compute/wizard/DiskSizeSelection'
568649
import VolumeDiskOfferingSelectView from '@views/compute/wizard/VolumeDiskOfferingSelectView'
569650
import MultiDiskSelection from '@views/compute/wizard/MultiDiskSelection'
651+
import TemplateIsoSelection from '@views/compute/wizard/TemplateIsoSelection'
570652
import AffinityGroupSelection from '@views/compute/wizard/AffinityGroupSelection'
571653
import NetworkSelection from '@views/compute/wizard/NetworkSelection'
572654
import NetworkConfiguration from '@views/compute/wizard/NetworkConfiguration'
@@ -586,6 +668,7 @@ export default {
586668
NetworkSelection,
587669
AffinityGroupSelection,
588670
DiskSizeSelection,
671+
TemplateIsoSelection,
589672
MultiDiskSelection,
590673
VolumeDiskOfferingSelectView,
591674
DiskOfferingSelection,
@@ -611,6 +694,8 @@ export default {
611694
data () {
612695
return {
613696
zoneId: '',
697+
podId: null,
698+
clusterId: null,
614699
zoneSelected: false,
615700
isZoneSelectedMultiArch: false,
616701
dynamicscalingenabled: true,
@@ -639,7 +724,6 @@ export default {
639724
},
640725
options: {
641726
templates: {},
642-
templates2: [],
643727
hypervisors: [],
644728
serviceOfferings: [],
645729
diskOfferings: [],
@@ -648,6 +732,9 @@ export default {
648732
networks: [],
649733
sshKeyPairs: [],
650734
UserDatas: [],
735+
pods: [],
736+
clusters: [],
737+
hosts: [],
651738
groups: [],
652739
keyboards: [],
653740
bootTypes: [],
@@ -666,6 +753,9 @@ export default {
666753
networks: false,
667754
sshKeyPairs: false,
668755
zones: false,
756+
pods: false,
757+
clusters: false,
758+
hosts: false,
669759
groups: false
670760
},
671761
owner: {
@@ -738,7 +828,7 @@ export default {
738828
return this.showRootDiskSizeChanger && this.rootDiskSizeFixed > 0
739829
},
740830
templateSelectOptions () {
741-
return this.options.templates2.map((template) => {
831+
return this.options.templates.map((template) => {
742832
return {
743833
label: template.name,
744834
value: template.id,
@@ -856,15 +946,34 @@ export default {
856946
showIcon: true
857947
}
858948
},
859-
templates2: {
860-
list: 'listTemplates',
861-
isLoad: true,
949+
pods: {
950+
list: 'listPods',
951+
isLoad: !this.isNormalAndDomainUser,
862952
options: {
863-
templatefilter: 'all',
864-
hypervisor: this.hypervisor,
865-
showicon: true
953+
zoneid: _.get(this.zone, 'id')
954+
},
955+
field: 'podid'
956+
},
957+
clusters: {
958+
list: 'listClusters',
959+
isLoad: !this.isNormalAndDomainUser,
960+
options: {
961+
zoneid: _.get(this.zone, 'id'),
962+
podid: this.podId
866963
},
867-
field: 'templateid'
964+
field: 'clusterid'
965+
},
966+
hosts: {
967+
list: 'listHosts',
968+
isLoad: !this.isNormalAndDomainUser,
969+
options: {
970+
zoneid: _.get(this.zone, 'id'),
971+
podid: this.podId,
972+
clusterid: this.clusterId,
973+
state: 'Up',
974+
type: 'Routing'
975+
},
976+
field: 'hostid'
868977
},
869978
dynamicScalingVmConfig: {
870979
list: 'listConfigurations',
@@ -886,13 +995,44 @@ export default {
886995
}
887996
})
888997
},
889-
hypervisorSelectOptions () {
890-
return this.options.hypervisors.map((hypervisor) => {
998+
podSelectOptions () {
999+
const options = this.options.pods.map((pod) => {
8911000
return {
892-
label: hypervisor.name,
893-
value: hypervisor.name
1001+
label: pod.name,
1002+
value: pod.id
8941003
}
8951004
})
1005+
options.unshift({
1006+
label: this.$t('label.default'),
1007+
value: null
1008+
})
1009+
return options
1010+
},
1011+
clusterSelectOptions () {
1012+
const options = this.options.clusters.map((cluster) => {
1013+
return {
1014+
label: cluster.name,
1015+
value: cluster.id
1016+
}
1017+
})
1018+
options.unshift({
1019+
label: this.$t('label.default'),
1020+
value: null
1021+
})
1022+
return options
1023+
},
1024+
hostSelectOptions () {
1025+
const options = this.options.hosts.map((host) => {
1026+
return {
1027+
label: host.name,
1028+
value: host.id
1029+
}
1030+
})
1031+
options.unshift({
1032+
label: this.$t('label.default'),
1033+
value: null
1034+
})
1035+
return options
8961036
},
8971037
keyboardSelectOptions () {
8981038
const keyboardOpts = this.$config.keyboardOptions || {}
@@ -941,11 +1081,6 @@ export default {
9411081
}
9421082
},
9431083
watch: {
944-
'$route' (to, from) {
945-
if (to.name === 'deployVirtualMachine') {
946-
this.resetData()
947-
}
948-
},
9491084
formModel: {
9501085
deep: true,
9511086
handler (instanceConfig) {
@@ -1847,8 +1982,28 @@ export default {
18471982
this.params[name].options = { ...this.params[name].options, ...options }
18481983
this.fetchOptions(this.params[name], name)
18491984
},
1850-
onTabChange (key, type) {
1851-
this[type] = key
1985+
onSelectPodId (value) {
1986+
this.podId = value
1987+
if (this.podId === null) {
1988+
this.form.podid = undefined
1989+
}
1990+
1991+
this.fetchOptions(this.params.clusters, 'clusters')
1992+
this.fetchOptions(this.params.hosts, 'hosts')
1993+
},
1994+
onSelectClusterId (value) {
1995+
this.clusterId = value
1996+
if (this.clusterId === null) {
1997+
this.form.clusterid = undefined
1998+
}
1999+
2000+
this.fetchOptions(this.params.hosts, 'hosts')
2001+
},
2002+
onSelectHostId (value) {
2003+
this.hostId = value
2004+
if (this.hostId === null) {
2005+
this.form.hostid = undefined
2006+
}
18522007
},
18532008
fetchTemplateNics (template) {
18542009
var nics = []

ui/src/views/compute/wizard/TemplateIsoSelection.vue

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<a-spin :spinning="loading">
2626
<a-tabs
2727
:animated="false"
28-
:defaultActiveKey="filterOpts[0].id"
28+
:activeKey="filterType"
2929
v-model="filterType"
3030
tabPosition="top"
3131
@change="changeFilterType">
@@ -103,13 +103,25 @@ export default {
103103
deep: true,
104104
handler (items) {
105105
const key = this.inputDecorator.slice(0, -2)
106-
for (const filter of this.filterOpts) {
107-
if (items[filter.id] && items[filter.id][key] && items[filter.id][key].length > 0) {
108-
if (!this.pagination) {
109-
this.filterType = filter.id
106+
if (!this.pagination) {
107+
let i = 0
108+
for (i < this.filterOpts.length; i++;) {
109+
const filter = this.filterOpts[i]
110+
if (items[filter.id]?.[key]?.length > 0) {
111+
this.filterType = this.filter.id
110112
this.checkedValue = items[filter.id][key][0].id
113+
break
114+
}
115+
}
116+
if (this.preFillContent.templateid) {
117+
for (i < this.filterOpts.length; i++;) {
118+
const filter = this.filterOpts[i]
119+
if (items[filter.id]?.[key]?.some(item => item.id === this.preFillContent.templateid)) {
120+
this.filterType = filter.id
121+
this.checkedValue = items[filter.id][key][0].id
122+
break
123+
}
111124
}
112-
break
113125
}
114126
}
115127
}

0 commit comments

Comments
 (0)