|
40 | 40 | :showIcon="true" |
41 | 41 | :message="$t('message.import.running.instance.warning')" |
42 | 42 | /> |
| 43 | + <div v-if="!isNormalUserOrProject"> |
| 44 | + <ownership-selection @fetch-owner="fetchOwnerOptions" /> |
| 45 | + </div> |
43 | 46 | <a-form-item name="displayname" ref="displayname"> |
44 | 47 | <template #label> |
45 | 48 | <tooltip-label :title="$t('label.displayname')" :tooltip="apiParams.displayname.description"/> |
|
58 | 61 | v-model:value="form.hostname" |
59 | 62 | :placeholder="apiParams.hostname.description" /> |
60 | 63 | </a-form-item> |
61 | | - <a-form-item name="domainid" ref="domainid"> |
62 | | - <template #label> |
63 | | - <tooltip-label :title="$t('label.domainid')" :tooltip="apiParams.domainid.description"/> |
64 | | - </template> |
65 | | - <a-select |
66 | | - v-model:value="form.domainid" |
67 | | - showSearch |
68 | | - optionFilterProp="label" |
69 | | - :filterOption="(input, option) => { |
70 | | - return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0 |
71 | | - }" |
72 | | - :loading="optionsLoading.domains" |
73 | | - :placeholder="apiParams.domainid.description" |
74 | | - @change="val => { this.selectedDomainId = val }"> |
75 | | - <a-select-option v-for="dom in domainSelectOptions" :key="dom.value" :label="dom.label"> |
76 | | - <span> |
77 | | - <resource-icon v-if="dom.icon" :image="dom.icon" size="1x" style="margin-right: 5px"/> |
78 | | - <block-outlined v-else-if="dom.value !== null" style="margin-right: 5px" /> |
79 | | - {{ dom.label }} |
80 | | - </span> |
81 | | - </a-select-option> |
82 | | - </a-select> |
83 | | - </a-form-item> |
84 | | - <a-form-item name="account" ref="account" v-if="selectedDomainId"> |
85 | | - <template #label> |
86 | | - <tooltip-label :title="$t('label.account')" :tooltip="apiParams.account.description"/> |
87 | | - </template> |
88 | | - <a-input |
89 | | - v-model:value="form.account" |
90 | | - :placeholder="apiParams.account.description"/> |
91 | | - </a-form-item> |
92 | | - <a-form-item name="projectid" ref="projectid"> |
93 | | - <template #label> |
94 | | - <tooltip-label :title="$t('label.project')" :tooltip="apiParams.projectid.description"/> |
95 | | - </template> |
96 | | - <a-select |
97 | | - v-model:value="form.projectid" |
98 | | - showSearch |
99 | | - optionFilterProp="label" |
100 | | - :filterOption="(input, option) => { |
101 | | - return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0 |
102 | | - }" |
103 | | - :loading="optionsLoading.projects" |
104 | | - :placeholder="apiParams.projectid.description"> |
105 | | - <a-select-option v-for="proj in projectSelectOptions" :key="proj.value" :label="proj.label"> |
106 | | - <span> |
107 | | - <resource-icon v-if="proj.icon" :image="proj.icon" size="1x" style="margin-right: 5px"/> |
108 | | - <project-outlined v-else-if="proj.value !== null" style="margin-right: 5px" /> |
109 | | - {{ proj.label }} |
110 | | - </span> |
111 | | - </a-select-option> |
112 | | - </a-select> |
113 | | - </a-form-item> |
114 | 64 | <a-form-item name="templateid" ref="templateid" v-if="cluster.hypervisortype === 'VMware' || (cluster.hypervisortype === 'KVM' && !selectedVmwareVcenter && !isDiskImport && !isExternalImport)"> |
115 | 65 | <template #label> |
116 | 66 | <tooltip-label :title="$t('label.templatename')" :tooltip="apiParams.templateid.description + '. ' + $t('message.template.import.vm.temporary')"/> |
|
315 | 265 | <multi-network-selection |
316 | 266 | :items="nics" |
317 | 267 | :zoneId="cluster.zoneid" |
318 | | - :domainid="form.domainid" |
319 | | - :account="form.account" |
| 268 | + :domainid="this.owner.domainid" |
| 269 | + :accountid="this.owner.account" |
320 | 270 | :selectionEnabled="false" |
321 | 271 | :filterUnimplementedNetworks="true" |
322 | 272 | :hypervisor="this.cluster.hypervisortype" |
@@ -391,17 +341,20 @@ import { api } from '@/api' |
391 | 341 | import _ from 'lodash' |
392 | 342 | import InfoCard from '@/components/view/InfoCard' |
393 | 343 | import TooltipLabel from '@/components/widgets/TooltipLabel' |
| 344 | +import OwnershipSelection from '@/views/compute/wizard/OwnershipSelection.vue' |
394 | 345 | import ComputeOfferingSelection from '@views/compute/wizard/ComputeOfferingSelection' |
395 | 346 | import ComputeSelection from '@views/compute/wizard/ComputeSelection' |
396 | 347 | import MultiDiskSelection from '@views/compute/wizard/MultiDiskSelection' |
397 | 348 | import MultiNetworkSelection from '@views/compute/wizard/MultiNetworkSelection' |
398 | 349 | import OsLogo from '@/components/widgets/OsLogo' |
399 | 350 | import ResourceIcon from '@/components/view/ResourceIcon' |
400 | 351 | import CheckBoxSelectPair from '@/components/CheckBoxSelectPair' |
| 352 | +import store from '@/store' |
401 | 353 |
|
402 | 354 | export default { |
403 | 355 | name: 'ImportUnmanagedInstances', |
404 | 356 | components: { |
| 357 | + OwnershipSelection, |
405 | 358 | InfoCard, |
406 | 359 | TooltipLabel, |
407 | 360 | ComputeOfferingSelection, |
@@ -472,22 +425,20 @@ export default { |
472 | 425 | }, |
473 | 426 | data () { |
474 | 427 | return { |
| 428 | + owner: { |
| 429 | + projectid: store.getters.project?.id, |
| 430 | + domainid: store.getters.project?.id ? null : store.getters.userInfo.domainid, |
| 431 | + account: store.getters.project?.id ? null : store.getters.userInfo.account |
| 432 | + }, |
475 | 433 | options: { |
476 | | - domains: [], |
477 | | - projects: [], |
478 | 434 | networks: [], |
479 | 435 | templates: [] |
480 | 436 | }, |
481 | 437 | rowCount: {}, |
482 | 438 | optionsLoading: { |
483 | | - domains: false, |
484 | | - projects: false, |
485 | 439 | networks: false, |
486 | 440 | templates: false |
487 | 441 | }, |
488 | | - domains: [], |
489 | | - domainLoading: false, |
490 | | - selectedDomainId: null, |
491 | 442 | templates: [], |
492 | 443 | templateLoading: false, |
493 | 444 | templateType: this.defaultTemplateType(), |
@@ -588,9 +539,20 @@ export default { |
588 | 539 | showicon: true |
589 | 540 | }, |
590 | 541 | field: 'templateid' |
| 542 | + }, |
| 543 | + accounts: { |
| 544 | + list: 'listAccounts', |
| 545 | + isLoad: true, |
| 546 | + options: { |
| 547 | + domainid: this.domainid |
| 548 | + }, |
| 549 | + field: 'accountid' |
591 | 550 | } |
592 | 551 | } |
593 | 552 | }, |
| 553 | + isNormalUserOrProject () { |
| 554 | + return ['User'].includes(this.$store.getters.userInfo.roletype) || store.getters.project?.id |
| 555 | + }, |
594 | 556 | isVmRunning () { |
595 | 557 | if (this.resource && this.resource.powerstate === 'PowerOn') { |
596 | 558 | return true |
@@ -724,14 +686,30 @@ export default { |
724 | 686 | forced: this.switches.forced, |
725 | 687 | forcemstoimportvmfiles: this.switches.forceMsToImportVmFiles, |
726 | 688 | domainid: null, |
727 | | - account: null |
| 689 | + accountid: null |
728 | 690 | }) |
729 | 691 | this.rules = reactive({ |
730 | 692 | displayname: [{ required: true, message: this.$t('message.error.input.value') }], |
731 | 693 | templateid: [{ required: this.templateType !== 'auto', message: this.$t('message.error.input.value') }], |
732 | 694 | rootdiskid: [{ required: this.templateType !== 'auto', message: this.$t('message.error.input.value') }] |
733 | 695 | }) |
734 | 696 | }, |
| 697 | + fetchOwnerOptions (OwnerOptions) { |
| 698 | + this.owner = {} |
| 699 | + if (OwnerOptions.selectedAccountType === 'Account') { |
| 700 | + if (!OwnerOptions.selectedAccount) { |
| 701 | + return |
| 702 | + } |
| 703 | + this.owner.account = OwnerOptions.selectedAccount |
| 704 | + this.owner.domainid = OwnerOptions.selectedDomain |
| 705 | + } else if (OwnerOptions.selectedAccountType === 'Project') { |
| 706 | + if (!OwnerOptions.selectedProject) { |
| 707 | + return |
| 708 | + } |
| 709 | + this.owner.projectid = OwnerOptions.selectedProject |
| 710 | + } |
| 711 | + this.fetchData() |
| 712 | + }, |
735 | 713 | fetchData () { |
736 | 714 | _.each(this.params, (param, name) => { |
737 | 715 | if (param.isLoad) { |
@@ -1068,6 +1046,12 @@ export default { |
1068 | 1046 | diskpath: this.diskpath, |
1069 | 1047 | temppath: this.tmppath |
1070 | 1048 | } |
| 1049 | + values.domainid = this.owner.domainid |
| 1050 | + if (this.owner.projectid) { |
| 1051 | + values.projectid = this.owner.projectid |
| 1052 | + } else { |
| 1053 | + values.account = this.owner.account |
| 1054 | + } |
1071 | 1055 | var importapi = 'importUnmanagedInstance' |
1072 | 1056 | if (this.isExternalImport || this.isDiskImport || this.selectedVmwareVcenter) { |
1073 | 1057 | importapi = 'importVm' |
|
0 commit comments