|
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')"/> |
|
303 | 253 | <multi-network-selection |
304 | 254 | :items="nics" |
305 | 255 | :zoneId="cluster.zoneid" |
306 | | - :domainid="form.domainid" |
307 | | - :account="form.account" |
| 256 | + :domainid="this.owner.domainid" |
| 257 | + :accountid="this.owner.account" |
308 | 258 | :selectionEnabled="false" |
309 | 259 | :filterUnimplementedNetworks="true" |
310 | 260 | :hypervisor="this.cluster.hypervisortype" |
@@ -379,17 +329,20 @@ import { api } from '@/api' |
379 | 329 | import _ from 'lodash' |
380 | 330 | import InfoCard from '@/components/view/InfoCard' |
381 | 331 | import TooltipLabel from '@/components/widgets/TooltipLabel' |
| 332 | +import OwnershipSelection from '@/views/compute/wizard/OwnershipSelection.vue' |
382 | 333 | import ComputeOfferingSelection from '@views/compute/wizard/ComputeOfferingSelection' |
383 | 334 | import ComputeSelection from '@views/compute/wizard/ComputeSelection' |
384 | 335 | import MultiDiskSelection from '@views/compute/wizard/MultiDiskSelection' |
385 | 336 | import MultiNetworkSelection from '@views/compute/wizard/MultiNetworkSelection' |
386 | 337 | import OsLogo from '@/components/widgets/OsLogo' |
387 | 338 | import ResourceIcon from '@/components/view/ResourceIcon' |
388 | 339 | import CheckBoxSelectPair from '@/components/CheckBoxSelectPair' |
| 340 | +import store from '@/store' |
389 | 341 |
|
390 | 342 | export default { |
391 | 343 | name: 'ImportUnmanagedInstances', |
392 | 344 | components: { |
| 345 | + OwnershipSelection, |
393 | 346 | InfoCard, |
394 | 347 | TooltipLabel, |
395 | 348 | ComputeOfferingSelection, |
@@ -460,22 +413,20 @@ export default { |
460 | 413 | }, |
461 | 414 | data () { |
462 | 415 | return { |
| 416 | + owner: { |
| 417 | + projectid: store.getters.project?.id, |
| 418 | + domainid: store.getters.project?.id ? null : store.getters.userInfo.domainid, |
| 419 | + account: store.getters.project?.id ? null : store.getters.userInfo.account |
| 420 | + }, |
463 | 421 | options: { |
464 | | - domains: [], |
465 | | - projects: [], |
466 | 422 | networks: [], |
467 | 423 | templates: [] |
468 | 424 | }, |
469 | 425 | rowCount: {}, |
470 | 426 | optionsLoading: { |
471 | | - domains: false, |
472 | | - projects: false, |
473 | 427 | networks: false, |
474 | 428 | templates: false |
475 | 429 | }, |
476 | | - domains: [], |
477 | | - domainLoading: false, |
478 | | - selectedDomainId: null, |
479 | 430 | templates: [], |
480 | 431 | templateLoading: false, |
481 | 432 | templateType: this.defaultTemplateType(), |
@@ -574,9 +525,20 @@ export default { |
574 | 525 | showicon: true |
575 | 526 | }, |
576 | 527 | field: 'templateid' |
| 528 | + }, |
| 529 | + accounts: { |
| 530 | + list: 'listAccounts', |
| 531 | + isLoad: true, |
| 532 | + options: { |
| 533 | + domainid: this.domainid |
| 534 | + }, |
| 535 | + field: 'accountid' |
577 | 536 | } |
578 | 537 | } |
579 | 538 | }, |
| 539 | + isNormalUserOrProject () { |
| 540 | + return ['User'].includes(this.$store.getters.userInfo.roletype) || store.getters.project?.id |
| 541 | + }, |
580 | 542 | isVmRunning () { |
581 | 543 | if (this.resource && this.resource.powerstate === 'PowerOn') { |
582 | 544 | return true |
@@ -710,14 +672,30 @@ export default { |
710 | 672 | forced: this.switches.forced, |
711 | 673 | forcemstoimportvmfiles: this.switches.forceMsToImportVmFiles, |
712 | 674 | domainid: null, |
713 | | - account: null |
| 675 | + accountid: null |
714 | 676 | }) |
715 | 677 | this.rules = reactive({ |
716 | 678 | displayname: [{ required: true, message: this.$t('message.error.input.value') }], |
717 | 679 | templateid: [{ required: this.templateType !== 'auto', message: this.$t('message.error.input.value') }], |
718 | 680 | rootdiskid: [{ required: this.templateType !== 'auto', message: this.$t('message.error.input.value') }] |
719 | 681 | }) |
720 | 682 | }, |
| 683 | + fetchOwnerOptions (OwnerOptions) { |
| 684 | + this.owner = {} |
| 685 | + if (OwnerOptions.selectedAccountType === 'Account') { |
| 686 | + if (!OwnerOptions.selectedAccount) { |
| 687 | + return |
| 688 | + } |
| 689 | + this.owner.account = OwnerOptions.selectedAccount |
| 690 | + this.owner.domainid = OwnerOptions.selectedDomain |
| 691 | + } else if (OwnerOptions.selectedAccountType === 'Project') { |
| 692 | + if (!OwnerOptions.selectedProject) { |
| 693 | + return |
| 694 | + } |
| 695 | + this.owner.projectid = OwnerOptions.selectedProject |
| 696 | + } |
| 697 | + this.fetchData() |
| 698 | + }, |
721 | 699 | fetchData () { |
722 | 700 | _.each(this.params, (param, name) => { |
723 | 701 | if (param.isLoad) { |
@@ -1018,6 +996,12 @@ export default { |
1018 | 996 | diskpath: this.diskpath, |
1019 | 997 | temppath: this.tmppath |
1020 | 998 | } |
| 999 | + values.domainid = this.owner.domainid |
| 1000 | + if (this.owner.projectid) { |
| 1001 | + values.projectid = this.owner.projectid |
| 1002 | + } else { |
| 1003 | + values.account = this.owner.account |
| 1004 | + } |
1021 | 1005 | var importapi = 'importUnmanagedInstance' |
1022 | 1006 | if (this.isExternalImport || this.isDiskImport || this.selectedVmwareVcenter) { |
1023 | 1007 | importapi = 'importVm' |
|
0 commit comments