|
72 | 72 | <os-based-image-selection |
73 | 73 | v-if="isModernImageSelection" |
74 | 74 | :imageTypeSelectionAllowed="false" |
| 75 | + :imagePreSelected="!!this.queryTemplateId" |
| 76 | + :guestOsCategoriesSelectionDisallowed="!this.queryGuestOsCategoryId && !!this.queryTemplateId" |
75 | 77 | :guestOsCategories="options.guestOsCategories" |
76 | 78 | :guestOsCategoriesLoading="loading.guestOsCategories" |
77 | 79 | :selectedGuestOsCategoryId="form.guestoscategoryid" |
|
88 | 90 | @update-disk-size="updateFieldValue" /> |
89 | 91 | <a-card |
90 | 92 | v-else |
91 | | - :tabList="imageTypeTabList" |
| 93 | + :tabList="imageTypeList" |
92 | 94 | :activeTabKey="imageType"> |
93 | 95 | <div> |
94 | 96 | {{ $t('message.template.desc') }} |
@@ -1417,16 +1419,25 @@ export default { |
1417 | 1419 | templateConfigurationExists () { |
1418 | 1420 | return this.vm.templateid && this.templateConfigurations && this.templateConfigurations.length > 0 |
1419 | 1421 | }, |
| 1422 | + queryZoneId () { |
| 1423 | + return this.$route.query.zoneid || null |
| 1424 | + }, |
| 1425 | + queryArchId () { |
| 1426 | + return this.$route.query.arch || null |
| 1427 | + }, |
1420 | 1428 | queryTemplateId () { |
1421 | 1429 | return this.$route.query.templateid || null |
1422 | 1430 | }, |
1423 | 1431 | queryNetworkId () { |
1424 | 1432 | return this.$route.query.networkid || null |
1425 | 1433 | }, |
| 1434 | + queryGuestOsCategoryId () { |
| 1435 | + return this.$route.query.oscategoryid || null |
| 1436 | + }, |
1426 | 1437 | queryLbRuleId () { |
1427 | 1438 | return this.$route.query.lbruleid || null |
1428 | 1439 | }, |
1429 | | - imageTypeTabList () { |
| 1440 | + imageTypeList () { |
1430 | 1441 | return [{ |
1431 | 1442 | key: 'templateid', |
1432 | 1443 | tab: this.$t('label.templates') |
@@ -1848,11 +1859,18 @@ export default { |
1848 | 1859 | let zones = [] |
1849 | 1860 | let apiName = '' |
1850 | 1861 | 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) { |
1852 | 1869 | apiName = 'listTemplates' |
1853 | 1870 | params.listall = true |
1854 | 1871 | params.templatefilter = this.isNormalAndDomainUser ? 'executable' : 'all' |
1855 | 1872 | params.id = this.queryTemplateId |
| 1873 | + this.dataPreFill.templateid = this.queryTemplateId |
1856 | 1874 | } else if (this.queryNetworkId) { |
1857 | 1875 | params.listall = true |
1858 | 1876 | params.id = this.queryNetworkId |
@@ -1884,6 +1902,9 @@ export default { |
1884 | 1902 | }, |
1885 | 1903 | async fetchData () { |
1886 | 1904 | this.architectureTypes.opts = this.$fetchCpuArchitectureTypes() |
| 1905 | + if (this.queryArchId) { |
| 1906 | + this.architectureTypes.opts = this.architectureTypes.opts.filter(o => o.id === this.queryArchId) |
| 1907 | + } |
1887 | 1908 | const zones = await this.fetchZoneByQuery() |
1888 | 1909 | if (zones && zones.length === 1) { |
1889 | 1910 | this.selectedZone = zones[0] |
@@ -2033,21 +2054,15 @@ export default { |
2033 | 2054 | this.form.templateid = value |
2034 | 2055 | this.resetFromTemplateConfiguration() |
2035 | 2056 | 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 |
2047 | 2061 | break |
2048 | 2062 | } |
2049 | 2063 | } |
2050 | 2064 | if (template) { |
| 2065 | + this.resetTemplateAssociatedResources() |
2051 | 2066 | var size = template.size / (1024 * 1024 * 1024) || 0 // bytes to GB |
2052 | 2067 | this.dataPreFill.minrootdisksize = Math.ceil(size) |
2053 | 2068 | this.updateTemplateLinkedUserData(this.template.userdataid) |
@@ -2437,29 +2452,37 @@ export default { |
2437 | 2452 | }, |
2438 | 2453 | fetchGuestOsCategories (skipFetchImages) { |
2439 | 2454 | 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']) |
2442 | 2463 | .then((res) => { |
2443 | 2464 | if (!this.options.guestOsCategories) { |
2444 | 2465 | this.options.guestOsCategories = [] |
2445 | 2466 | } |
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 | + } |
2454 | 2477 | } |
| 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 | + }) |
2455 | 2485 | } |
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 | | - }) |
2463 | 2486 | } |
2464 | 2487 | this.form.guestoscategoryid = this.options.guestOsCategories[0].id |
2465 | 2488 | if (skipFetchImages) { |
@@ -2960,6 +2983,8 @@ export default { |
2960 | 2983 | args.templatefilter = templateFilter |
2961 | 2984 | args.details = 'all' |
2962 | 2985 | args.showicon = 'true' |
| 2986 | + args.id = this.queryTemplateId |
| 2987 | + args.isvnf = false |
2963 | 2988 |
|
2964 | 2989 | delete args.category |
2965 | 2990 | delete args.public |
@@ -3007,6 +3032,13 @@ export default { |
3007 | 3032 | }) |
3008 | 3033 | this.options.templates = templates |
3009 | 3034 | }, |
| 3035 | + resetTemplateAssociatedResources () { |
| 3036 | + this.templateConfigurations = [] |
| 3037 | + this.selectedTemplateConfiguration = {} |
| 3038 | + this.templateNics = [] |
| 3039 | + this.templateLicenses = [] |
| 3040 | + this.templateProperties = {} |
| 3041 | + }, |
3010 | 3042 | async fetchZoneOptions () { |
3011 | 3043 | let guestOsFetch = null |
3012 | 3044 | for (const [name, param] of Object.entries(this.params)) { |
@@ -3038,7 +3070,9 @@ export default { |
3038 | 3070 | this.formModel = toRaw(this.form) |
3039 | 3071 | }, |
3040 | 3072 | onSelectZoneId (value) { |
3041 | | - this.dataPreFill = {} |
| 3073 | + if (this.dataPreFill.zoneid !== value) { |
| 3074 | + this.dataPreFill = {} |
| 3075 | + } |
3042 | 3076 | this.zoneId = value |
3043 | 3077 | this.zone = _.find(this.options.zones, (option) => option.id === value) |
3044 | 3078 | this.zoneSelected = true |
|
0 commit comments