bfg-common 1.5.577 → 1.5.578

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/components/common/vm/actions/add/Add.vue +886 -960
  2. package/components/common/vm/actions/add/New.vue +16 -54
  3. package/components/common/vm/actions/add/Old.vue +16 -55
  4. package/components/common/vm/actions/add/lib/config/steps.ts +347 -347
  5. package/components/common/vm/actions/clone/Clone.vue +744 -816
  6. package/components/common/vm/actions/clone/new/New.vue +14 -50
  7. package/components/common/vm/actions/clone/old/Old.vue +16 -52
  8. package/components/common/vm/actions/common/customizeHardware/CustomizeHardware.vue +14 -81
  9. package/components/common/vm/actions/common/customizeHardware/CustomizeHardwareNew.vue +7 -56
  10. package/components/common/vm/actions/common/customizeHardware/CustomizeHardwareOld.vue +8 -56
  11. package/components/common/vm/actions/common/customizeHardware/virtualHardware/VirtualHardware.vue +211 -206
  12. package/components/common/vm/actions/common/customizeHardware/virtualHardware/VirtualHardwareNew.vue +225 -120
  13. package/components/common/vm/actions/common/customizeHardware/virtualHardware/VirtualHardwareOld.vue +220 -118
  14. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/CdDvdDrive.vue +66 -53
  15. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/Cpu.vue +139 -159
  16. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/CpuNew.vue +8 -15
  17. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/CpuOld.vue +8 -13
  18. package/components/common/vm/actions/common/customizeHardware/virtualHardware/memory/Memory.vue +62 -75
  19. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/NewHardDisk.vue +241 -149
  20. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/NewHardDiskNew.vue +3 -4
  21. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/NewHardDiskOld.vue +2 -3
  22. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/NewNetwork.vue +62 -100
  23. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newUsbController/NewUsbController.vue +6 -17
  24. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newUsbController/NewUsbControllerNew.vue +6 -3
  25. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newUsbController/NewUsbControllerOld.vue +6 -3
  26. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/VideoCard.vue +17 -39
  27. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/VideoCardNew.vue +6 -5
  28. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/VideoCardOld.vue +6 -5
  29. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/lib/config/options.ts +4 -4
  30. package/components/common/vm/actions/common/customizeHardware/vmoptions/Vmoptions.vue +6 -93
  31. package/components/common/vm/actions/common/customizeHardware/vmoptions/VmoptionsNew.vue +8 -60
  32. package/components/common/vm/actions/common/customizeHardware/vmoptions/VmoptionsOld.vue +8 -58
  33. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/BootOptions.vue +5 -69
  34. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/BootOptionsNew.vue +12 -32
  35. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/BootOptionsOld.vue +12 -33
  36. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/Order.vue +114 -132
  37. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/OrderNew.vue +41 -6
  38. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/OrderOld.vue +44 -6
  39. package/components/common/vm/actions/common/customizeHardware/vmoptions/generalOptions/GeneralOptions.vue +8 -23
  40. package/components/common/vm/actions/common/customizeHardware/vmoptions/generalOptions/GeneralOptionsNew.vue +21 -31
  41. package/components/common/vm/actions/common/customizeHardware/vmoptions/generalOptions/GeneralOptionsOld.vue +26 -34
  42. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/New.vue +28 -34
  43. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/Old.vue +24 -30
  44. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/RemoteConsoleOptions.vue +8 -112
  45. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/keymap/Keymap.vue +3 -3
  46. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/keymap/{KeymapNew.vue → New.vue} +6 -6
  47. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/keymap/{KeymapOld.vue → Old.vue} +5 -5
  48. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/password/Password.vue +6 -7
  49. package/components/common/vm/actions/common/customizeHardware/vmoptions/tools/Tools.vue +9 -27
  50. package/components/common/vm/actions/common/lib/models/interfaces.ts +58 -25
  51. package/components/common/vm/actions/common/select/options/New.vue +258 -258
  52. package/components/common/vm/actions/common/select/options/Old.vue +103 -103
  53. package/components/common/vm/actions/common/select/options/Options.vue +54 -54
  54. package/components/common/vm/actions/editSettings/EditSettings.vue +32 -90
  55. package/components/common/vm/actions/editSettings/EditSettingsOld.vue +14 -41
  56. package/components/common/vm/actions/editSettings/new/New.vue +14 -41
  57. package/components/common/vm/actions/lib/models/interfaces.ts +4 -29
  58. package/components/common/vm/actions/lib/utils.ts +64 -36
  59. package/package.json +1 -1
  60. /package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/password/{PasswordNew.vue → New.vue} +0 -0
  61. /package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/password/{PasswordOld.vue → Old.vue} +0 -0
@@ -1,960 +1,886 @@
1
- <template>
2
- <common-vm-actions-add-new
3
- v-if="isNewView"
4
- v-model:vm-form="vmForm"
5
- v-model:selected-create-type="selectedCreateType"
6
- v-model:is-power-on-by-default="isPowerOnByDefault"
7
- :project="props.project"
8
- :is-vmt="props.isVmt"
9
- :nodes="props.nodes"
10
- :files="props.files"
11
- :networks-table="props.networksTable"
12
- :datastore="props.datastore"
13
- :is-datastore-loading="props.isDatastoreLoading"
14
- :error-validation-fields="props.errorValidationFields"
15
- :ready-complete-table-info="props.readyCompleteTableInfo"
16
- :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
17
- :import-from-v-m-warev-sphere="props.importFromVMWarevSphere"
18
- :get-datastore-table-func="props.getDatastoreTableFunc"
19
- :passthrough-devices="props.passthroughDevices"
20
- :mediated-devices="props.mediatedDevices"
21
- :templates-tree="props.templatesTree"
22
- :wizard="wizard"
23
- :selected-scheme="selectedScheme"
24
- :template-submit="templateSubmit"
25
- :name-form-submit="nameFormSubmit"
26
- :storage-submit="storageSubmit"
27
- :customize-hardware-submit="customizeHardwareSubmit"
28
- :customize-hardware-for-template-submit="customizeHardwareForTemplateSubmit"
29
- :is-sphere="isSphere"
30
- :compatibility="compatibility"
31
- :guestOsFamilies="guestOsFamilies"
32
- :guestOsVersions="guestOsVersions"
33
- :machineTypes="machineTypes"
34
- :virtual-hardware-hard-disks-local="virtualHardwareHardDisksLocal"
35
- :virtual-hardware-cd-dvd-drives-local="virtualHardwareCdDvdDrivesLocal"
36
- :virtual-hardware-networks-local="virtualHardwareNetworksLocal"
37
- :max-cpus="maxCpus"
38
- :max-memory="maxMemory"
39
- :cpu-models="cpuModels"
40
- :selected-nav-item="selectedNavItem"
41
- :compatibility-info="compatibilityInfo"
42
- :is-show-power-on="isShowPowerOn"
43
- :is-show-select-template="isShowSelectTemplate"
44
- :data-center="props.dataCenter"
45
- :compute-resource="props.computeResource"
46
- :compute-resource-tree="props.computeResourceTree"
47
- :location-nodes="props.locationNodes"
48
- :allowed-location-kinds="allowedLocationKinds"
49
- :location-description="locationDescription"
50
- :vmt-settings="props.vmtSettings"
51
- :is-loading="isLoading"
52
- :selected-template-id="props.selectedTemplateId"
53
- :validate-empty-name="props.validateEmptyName"
54
- :title="title"
55
- :name-request-url="props.nameRequestUrl"
56
- :validation-description="validationDescription"
57
- :name-exist-validation="nameExistValidation"
58
- :name-test-ids="nameTestIds"
59
- :is-loading-compute-tree="isLoadingComputeTree"
60
- :compute-resource-alert="computeResourceAlert"
61
- :compatibility-text="compatibilityText"
62
- @get-storage="emits('get-storage', $event)"
63
- @get-folders-or-files="emits('get-folders-or-files', $event)"
64
- @get-active-device-child="emits('get-active-device-child', $event)"
65
- @show-datastore-child="emits('show-datastore-child', $event)"
66
- @remove-error-by-title="emits('remove-error-by-title', $event)"
67
- @get-networks-table="emits('get-networks-table', $event)"
68
- @get-pci-devices="emits('get-pci-devices')"
69
- @change-steps="onChangeSteps"
70
- @change-template="onChangeTemplate"
71
- @change-name="onChangeName(...$event)"
72
- @change-storage="onChangeStorage"
73
- @change-select-options="onChangeSelectOptions"
74
- @change-clone-count="cloneCount = $event"
75
- @change-compatibility="onChangeCompatibility"
76
- @change-boot-order="onChangeBootOrder"
77
- @change-customize-hardware="onChangeCustomizeHardware"
78
- @finish="onFinish"
79
- @hide="onHideModal"
80
- />
81
- <common-vm-actions-add-old
82
- v-else
83
- v-model:vm-form="vmForm"
84
- v-model:selected-create-type="selectedCreateType"
85
- v-model:is-power-on-by-default="isPowerOnByDefault"
86
- :project="props.project"
87
- :is-vmt="props.isVmt"
88
- :nodes="props.nodes"
89
- :files="props.files"
90
- :networks-table="props.networksTable"
91
- :datastore="props.datastore"
92
- :is-datastore-loading="props.isDatastoreLoading"
93
- :error-validation-fields="props.errorValidationFields"
94
- :ready-complete-table-info="props.readyCompleteTableInfo"
95
- :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
96
- :import-from-v-m-warev-sphere="props.importFromVMWarevSphere"
97
- :get-datastore-table-func="props.getDatastoreTableFunc"
98
- :passthrough-devices="props.passthroughDevices"
99
- :mediated-devices="props.mediatedDevices"
100
- :templates-tree="props.templatesTree"
101
- :wizard="wizard"
102
- :selected-scheme="selectedScheme"
103
- :template-submit="templateSubmit"
104
- :name-form-submit="nameFormSubmit"
105
- :storage-submit="storageSubmit"
106
- :customize-hardware-submit="customizeHardwareSubmit"
107
- :customize-hardware-for-template-submit="customizeHardwareForTemplateSubmit"
108
- :is-sphere="isSphere"
109
- :compatibility="compatibility"
110
- :guestOsFamilies="guestOsFamilies"
111
- :guestOsVersions="guestOsVersions"
112
- :machineTypes="machineTypes"
113
- :virtual-hardware-hard-disks-local="virtualHardwareHardDisksLocal"
114
- :virtual-hardware-cd-dvd-drives-local="virtualHardwareCdDvdDrivesLocal"
115
- :virtual-hardware-networks-local="virtualHardwareNetworksLocal"
116
- :max-cpus="maxCpus"
117
- :max-memory="maxMemory"
118
- :cpu-models="cpuModels"
119
- :selected-nav-item="selectedNavItem"
120
- :compatibility-info="compatibilityInfo"
121
- :is-show-power-on="isShowPowerOn"
122
- :data-center="props.dataCenter"
123
- :compute-resource="props.computeResource"
124
- :compute-resource-tree="props.computeResourceTree"
125
- :location-nodes="props.locationNodes"
126
- :allowed-location-kinds="allowedLocationKinds"
127
- :location-description="locationDescription"
128
- :vmt-settings="props.vmtSettings"
129
- :is-loading="isLoading"
130
- :validate-empty-name="props.validateEmptyName"
131
- :title="title"
132
- :name-request-url="props.nameRequestUrl"
133
- :validation-description="validationDescription"
134
- :name-exist-validation="nameExistValidation"
135
- :name-test-ids="nameTestIds"
136
- :is-loading-compute-tree="isLoadingComputeTree"
137
- :compute-resource-alert="computeResourceAlert"
138
- :compatibility-text="compatibilityText"
139
- @get-storage="emits('get-storage', $event)"
140
- @get-folders-or-files="emits('get-folders-or-files', $event)"
141
- @get-active-device-child="emits('get-active-device-child', $event)"
142
- @show-datastore-child="emits('show-datastore-child', $event)"
143
- @remove-error-by-title="emits('remove-error-by-title', $event)"
144
- @get-networks-table="emits('get-networks-table', $event)"
145
- @get-pci-devices="emits('get-pci-devices')"
146
- @change-steps="onChangeSteps"
147
- @change-template="onChangeTemplate"
148
- @change-name="onChangeName(...$event)"
149
- @change-storage="onChangeStorage"
150
- @change-select-options="onChangeSelectOptions"
151
- @change-clone-count="cloneCount = $event"
152
- @change-compatibility="onChangeCompatibility"
153
- @change-boot-order="onChangeBootOrder"
154
- @change-customize-hardware="onChangeCustomizeHardware"
155
- @finish="onFinish"
156
- @hide="onHideModal"
157
- />
158
- </template>
159
-
160
- <script setup lang="ts">
161
- import type {
162
- UI_I_ValidationReturn,
163
- UI_I_WizardStep,
164
- } from '~/node_modules/bfg-uikit/components/ui/wizard/lib/models/interfaces'
165
- import Wizard from '~/node_modules/bfg-uikit/components/ui/wizard/lib/utils/utils'
166
- import type {
167
- UI_I_Localization,
168
- UI_I_ArbitraryObject,
169
- } from '~/lib/models/interfaces'
170
- import type { UI_T_Project } from '~/lib/models/types'
171
- import type { UI_I_FileTreeNode } from '~/components/lib/models/interfaces'
172
- import type { UI_I_NetworkTableItem } from '~/lib/models/store/network/interfaces'
173
- import type {
174
- UI_I_DatastoreTableItem,
175
- UI_I_FolderOrFileTreePayload,
176
- } from '~/lib/models/store/storage/interfaces'
177
- import type {
178
- // API_UI_I_Error,
179
- UI_I_ErrorValidationField,
180
- } from '~/lib/models/store/interfaces'
181
- import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
182
- import type { UI_I_TableInfoItem } from '~/components/atoms/table/info/lib/models/interfaces'
183
- import type {
184
- UI_T_AddVmFinishFunc,
185
- UI_T_SelectedNavItem,
186
- } from '~/components/common/vm/actions/common/lib/models/types'
187
- import type { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
188
- import type {
189
- UI_I_Capabilities,
190
- UI_I_VmForm,
191
- UI_I_VmFormCash,
192
- } from '~/components/common/vm/actions/common/lib/models/interfaces'
193
- import type { UI_I_SendDataCustomizeHardware } from '~/components/common/vm/actions/common/customizeHardware/lib/models/interfaces'
194
- import type {
195
- UI_I_SendDataCpu,
196
- UI_I_SendDataMemory,
197
- UI_I_SendDataNewCdDvdDrive,
198
- UI_I_SendDataNewHardDisk,
199
- UI_I_SendDataNewNetwork,
200
- } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
201
- import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
202
- import type { UI_T_ChangeBootOrder } from '~/components/common/vm/actions/lib/models/types'
203
- import type {
204
- UI_I_MediatedDevice,
205
- UI_I_PciDevice,
206
- UI_I_VmSettings,
207
- } from '~/lib/models/store/vm/interfaces'
208
- import type { UI_I_NameTestIds } from '~/components/common/wizards/common/steps/name/lib/models/interfaces'
209
- import type { UI_T_CompatibilityStatus } from '~/components/common/wizards/common/compatibility/lib/models/types'
210
- import { capabilities } from '~/components/common/vm/actions/common/lib/config/capabilities'
211
- import {
212
- stepsSchemeInitial,
213
- stepsFunc,
214
- dynamicSteps,
215
- } from '~/components/common/vm/actions/add/lib/config/steps'
216
- import { mapCapabilities } from '~/components/common/vm/actions/common/lib/utils/capabilities'
217
-
218
- const props = withDefaults(
219
- defineProps<{
220
- project: UI_T_Project
221
- nodes: UI_I_FileTreeNode[]
222
- files: UI_I_FileTreeNode[]
223
- networksTable: UI_I_NetworkTableItem[]
224
- datastore: UI_I_DatastoreTableItem[]
225
- isDatastoreLoading: boolean
226
- errorValidationFields: UI_I_ErrorValidationField[]
227
- readyCompleteTableInfo: UI_I_TableInfoItem[]
228
- vmCpuHelpTextSecond: string
229
- importFromVMWarevSphere: string
230
- finishFunc: UI_T_AddVmFinishFunc
231
- getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
232
- validateSendDataFunc: UI_T_AddVmFinishFunc<
233
- [UI_T_SelectedNavItem, null | number] | null
234
- >
235
- passthroughDevices: UI_I_PciDevice[]
236
- mediatedDevices: UI_I_MediatedDevice[]
237
- vmNameInWizard: string
238
- nameRequestUrl: string
239
- templatesTree?: UI_I_TreeNode[]
240
- capabilities?: UI_I_Capabilities
241
- vmtSettings?: UI_I_VmSettings | null
242
- validateEmptyName?: boolean
243
- dataCenter?: UI_I_TreeNode // для сферы
244
- computeResource?: UI_I_TreeNode // для сферы
245
- computeResourceTree?: UI_I_TreeNode[] // для сферы
246
- locationNodes?: UI_I_TreeNode[] // для сферы
247
- selectedTemplateId?: string // для сферы
248
- isVmt?: boolean // для сферы
249
- }>(),
250
- {
251
- templatesTree: [],
252
- capabilities: undefined,
253
- vmtSettings: undefined,
254
- validateEmptyName: false,
255
- dataCenter: null,
256
- computeResource: null,
257
- computeResourceTree: undefined,
258
- locationNodes: undefined,
259
- selectedTemplateId: '',
260
- isVmt: false,
261
- }
262
- )
263
-
264
- const emits = defineEmits<{
265
- (event: 'get-storage', value: UI_I_TablePayload): void
266
- (event: 'get-folders-or-files', value: UI_I_FolderOrFileTreePayload): void
267
- (event: 'get-active-device-child', value: UI_I_FileTreeNode): void
268
- (event: 'show-datastore-child', value: UI_I_FileTreeNode): void
269
- (event: 'remove-error-by-title', value: string): void
270
- (event: 'get-networks-table', value: UI_I_TablePayload): void
271
- (event: 'get-pci-devices'): void
272
- (event: 'get-pci-devices'): void
273
- (event: 'hide'): void
274
- (event: 'select-template', value: string): void
275
- (
276
- event: 'get-compute-resource-tree',
277
- value: { id: string | number; cb: () => void }
278
- ): void // для сферы
279
- (event: 'select-compute-resource-tree', value: UI_I_TreeNode): void // для сферы
280
- }>()
281
-
282
- const { $store, $recursion }: any = useNuxtApp()
283
- const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
284
-
285
- const localization = computed<UI_I_Localization>(() => useLocal())
286
-
287
- const isSphere = computed<boolean>(() => props.project === 'sphere')
288
-
289
- const title = computed<string>(() =>
290
- props.isVmt
291
- ? localization.value.vmt.newTemplate
292
- : localization.value.common.newVirtualMachine2
293
- )
294
-
295
- watch(
296
- () => props.capabilities,
297
- () => {
298
- if (props.capabilities) mapCapabilities(props.capabilities)
299
- },
300
- { deep: true, immediate: true }
301
- )
302
-
303
- const selectedCreateType = ref<string>('0')
304
- if (props.isVmt) selectedCreateType.value = '-1'
305
-
306
- const wizard: Wizard = new Wizard(
307
- stepsFunc(localization.value, props.isVmt, isSphere.value),
308
- stepsSchemeInitial
309
- )
310
- watch(
311
- selectedCreateType,
312
- (newValue) => {
313
- switch (newValue) {
314
- case '0':
315
- wizard.changeScheme(isSphere.value ? 1 : 0)
316
- break
317
- case '1':
318
- wizard.changeScheme(isSphere.value ? 6 : 2)
319
- break
320
- case '-1':
321
- wizard.changeScheme(isSphere.value ? 11 : 10)
322
- break
323
- }
324
- },
325
- { immediate: true }
326
- )
327
-
328
- // if (isSphere.value) wizard.changeScheme(1)
329
- const selectedScheme = computed<number[]>(() => wizard.selectedScheme.value)
330
- // const alertMessages = computed<string[][]>(() => wizard.alertMessages.value)
331
-
332
- const allowedLocationKinds = [3, 7] // TODO use from config
333
- const locationDescription = computed<string>(() =>
334
- props.isVmt
335
- ? localization.value.vmt.selectLocationTemplate
336
- : localization.value.common.selectLocationVirtualMachine
337
- )
338
-
339
- const nameTestIds: UI_I_NameTestIds = {
340
- name: 'virtual-machine-name',
341
- helpIcon: 'show-vm-name-help-icon',
342
- }
343
- const validationDescription =
344
- localization.value.common.enterValidLocationVirtualMachine
345
- const nameExistValidation =
346
- localization.value.common.vmNameExistInSelectedLocation
347
-
348
- const isShowSelectTemplate = computed<boolean>(
349
- () =>
350
- wizard.selectedStepId === dynamicSteps.selectTemplate &&
351
- selectedCreateType.value === '1'
352
- )
353
-
354
- const isShowPowerOn = computed<boolean>(
355
- () =>
356
- wizard.selectedStepId > dynamicSteps.customizeHardware &&
357
- selectedCreateType.value !== '1' &&
358
- !props.isVmt
359
- )
360
-
361
- const onChangeSteps = async (value: UI_I_WizardStep[]): Promise<void> => {
362
- wizard.changeSteps(value, validationFunc, validateSendData)
363
- }
364
- const validationFunc = async (
365
- value: UI_I_WizardStep[],
366
- currentStep: UI_I_WizardStep,
367
- nextStep: UI_I_WizardStep
368
- ): Promise<UI_I_ValidationReturn> => {
369
- let stepHasError = false
370
- let stepShouldStop = {
371
- ifOnCurrentStep: false,
372
- ifFromAnyStep: false,
373
- stoppageStepId: -1,
374
- }
375
-
376
- wizard.setLoader(true)
377
- if (
378
- wizard.isValidateForStep(
379
- dynamicSteps.selectTemplate,
380
- currentStep.id,
381
- nextStep.id
382
- )
383
- ) {
384
- const templateValidation = await checkTemplate(value)
385
-
386
- value = templateValidation.newValue
387
- stepHasError = stepHasError || templateValidation.stepHasError
388
- } else if (
389
- wizard.isValidateForStep(
390
- isSphere.value ? dynamicSteps.selectNameFolder : dynamicSteps.selectName,
391
- currentStep.id,
392
- nextStep.id
393
- )
394
- ) {
395
- const nameValidation = await onCheckName(value)
396
-
397
- value = nameValidation.newValue
398
- stepHasError = stepHasError || nameValidation.stepHasError
399
- } else if (
400
- isSphere.value &&
401
- wizard.isValidateForStep(
402
- dynamicSteps.selectComputeResource,
403
- currentStep.id,
404
- nextStep.id
405
- )
406
- ) {
407
- const computeResourceValidation = await checkComputeResource(value)
408
-
409
- value = computeResourceValidation.newValue
410
- stepHasError = stepHasError || computeResourceValidation.stepHasError
411
- } else if (
412
- wizard.isValidateForStep(
413
- dynamicSteps.selectStorage,
414
- currentStep.id,
415
- nextStep.id
416
- )
417
- ) {
418
- const storageValidation = await checkStorage(value)
419
-
420
- value = storageValidation.newValue
421
-
422
- stepHasError = stepHasError || storageValidation.stepHasError
423
- } else if (
424
- wizard.isValidateForStep(
425
- dynamicSteps.customizeHardware,
426
- currentStep.id,
427
- nextStep.id
428
- )
429
- ) {
430
- const validation = await checkCustomizeHardware(value)
431
-
432
- value = validation.newValue
433
-
434
- stepHasError = stepHasError || validation.stepHasError
435
- } else if (
436
- wizard.isValidateForStep(
437
- dynamicSteps.customizeHardwareTemplate,
438
- currentStep.id,
439
- nextStep.id
440
- )
441
- ) {
442
- const validation = await checkCustomizeHardwareForTemplate(value)
443
-
444
- value = validation.newValue
445
-
446
- stepHasError = stepHasError || validation.stepHasError
447
- }
448
- wizard.setLoader(false)
449
-
450
- return {
451
- newValue: value,
452
- stepHasError,
453
- stepShouldStop,
454
- }
455
- }
456
-
457
- const checkTemplate = async (
458
- value: UI_I_WizardStep[]
459
- ): Promise<UI_I_ValidationReturn> => {
460
- let stepHasError = false
461
-
462
- return new Promise((resolve) => {
463
- templateSubmit.value = (isValid: boolean) => {
464
- if (!isValid) {
465
- stepHasError = wizard.setValidation(
466
- dynamicSteps.selectTemplate,
467
- 'template',
468
- {
469
- fieldMessage: 'aaa',
470
- alertMessage: 'aaa',
471
- }
472
- )
473
- } else if (wizard.hasMessage(dynamicSteps.selectTemplate, 'template')) {
474
- value = wizard.removeValidation(
475
- dynamicSteps.selectTemplate,
476
- 'template',
477
- value
478
- )
479
- }
480
-
481
- resolve({
482
- stepHasError,
483
- newValue: value,
484
- })
485
- templateSubmit.value = null
486
- }
487
- })
488
- }
489
- const onCheckName = async (
490
- value: UI_I_WizardStep[]
491
- ): Promise<UI_I_ValidationReturn> => {
492
- let stepHasError = false
493
-
494
- return new Promise((resolve) => {
495
- const step = isSphere.value
496
- ? dynamicSteps.selectNameFolder
497
- : dynamicSteps.selectName
498
- nameFormSubmit.value = (isValid: boolean) => {
499
- if (!isValid) {
500
- stepHasError = wizard.setValidation(step, 'name', {
501
- fieldMessage: 'aaa',
502
- alertMessage: 'aaa',
503
- })
504
- } else if (wizard.hasMessage(step, 'name')) {
505
- value = wizard.removeValidation(step, 'name', value)
506
- }
507
-
508
- resolve({
509
- stepHasError,
510
- newValue: value,
511
- })
512
- nameFormSubmit.value = null
513
- }
514
- })
515
- }
516
- const compatibilityText = computed<[UI_T_CompatibilityStatus, string]>(() => {
517
- const { computeResource } = vmForm.value
518
-
519
- if (!computeResource)
520
- return [
521
- 'none',
522
- localization.value.vmWizard.noDestinationComputeResourceSelected,
523
- ]
524
-
525
- let res: [UI_T_CompatibilityStatus, string] = [
526
- 'success',
527
- localization.value.common.compatibilityChecksSucceeded,
528
- ]
529
-
530
- if (!['cluster', 'host', 'resource_pool'].includes(computeResource?.type)) {
531
- res = [
532
- 'error',
533
- localization.value.common.selectValidClusterOrHostDestination,
534
- ]
535
- }
536
- if (computeResource?.type === 'cluster') {
537
- const hasHost = !!computeResource.nodes.length
538
- if (!hasHost) {
539
- res = ['error', localization.value.common.clusterNotContainAnyHosts]
540
- }
541
- }
542
-
543
- if (computeResource?.type === 'host') {
544
- if (computeResource.state === 'Error') {
545
- // TODO check Maintenance Mode
546
- res = [
547
- 'error',
548
- localization.value.common.selectedHostDisconnectedMaintenanceMode,
549
- ]
550
- }
551
- }
552
-
553
- return res
554
- })
555
- const computeResourceAlert = ref<string[]>([])
556
- const checkComputeResource = (
557
- value: UI_I_WizardStep[]
558
- ): UI_I_ValidationReturn => {
559
- let stepHasError = false
560
-
561
- const { computeResource } = vmForm.value
562
-
563
- if (
564
- !computeResource ||
565
- // compatibilityText.value[0] !== 1 ||
566
- computeResource.type === 'datacenter' ||
567
- computeResource.type === 'folder' ||
568
- (computeResource.type === 'cluster' && !computeResource.nodes.length)
569
- ) {
570
- computeResourceAlert.value = [
571
- localization.value.common.specifyValidClusterOrHostDestination,
572
- ]
573
- stepHasError = wizard.setValidation(
574
- dynamicSteps.selectComputeResource,
575
- 'computeResource',
576
- {
577
- fieldMessage: 'aaa',
578
- alertMessage: 'aaa',
579
- }
580
- )
581
- } else {
582
- computeResourceAlert.value = []
583
- if (
584
- wizard.hasMessage(dynamicSteps.selectComputeResource, 'computeResource')
585
- ) {
586
- value = wizard.removeValidation(
587
- dynamicSteps.selectComputeResource,
588
- 'computeResource',
589
- value
590
- )
591
- }
592
- }
593
-
594
- return {
595
- stepHasError,
596
- newValue: value,
597
- }
598
- }
599
- const checkStorage = async (
600
- value: UI_I_WizardStep[]
601
- ): Promise<UI_I_ValidationReturn> => {
602
- let stepHasError = false
603
-
604
- return new Promise((resolve) => {
605
- storageSubmit.value = (isValid: boolean) => {
606
- if (!isValid) {
607
- stepHasError = wizard.setValidation(
608
- dynamicSteps.selectStorage,
609
- 'storage',
610
- {
611
- fieldMessage: 'aaa',
612
- alertMessage: 'aaa',
613
- }
614
- )
615
- } else if (wizard.hasMessage(dynamicSteps.selectStorage, 'storage')) {
616
- value = wizard.removeValidation(
617
- dynamicSteps.selectStorage,
618
- 'storage',
619
- value
620
- )
621
- }
622
-
623
- resolve({
624
- stepHasError,
625
- newValue: value,
626
- })
627
- storageSubmit.value = null
628
- }
629
- })
630
- }
631
- const checkCustomizeHardware = async (
632
- value: UI_I_WizardStep[]
633
- ): Promise<UI_I_ValidationReturn> => {
634
- let stepHasError = false
635
- isLoading.value = true
636
-
637
- return new Promise((resolve) => {
638
- customizeHardwareSubmit.value = (isValid: boolean) => {
639
- if (!isValid) {
640
- stepHasError = wizard.setValidation(
641
- dynamicSteps.customizeHardware,
642
- 'customizeHardware',
643
- {
644
- fieldMessage: 'aaa',
645
- alertMessage: 'aaa',
646
- }
647
- )
648
- } else if (
649
- wizard.hasMessage(dynamicSteps.customizeHardware, 'customizeHardware')
650
- ) {
651
- wizard.removeValidationLocal(
652
- dynamicSteps.customizeHardware,
653
- 'customizeHardware'
654
- )
655
- value = wizard.removeValidation(
656
- dynamicSteps.customizeHardware,
657
- 'customizeHardware',
658
- value
659
- )
660
- }
661
-
662
- resolve({
663
- stepHasError,
664
- newValue: value,
665
- })
666
- storageSubmit.value = null
667
- isLoading.value = false
668
- }
669
- })
670
- }
671
- const checkCustomizeHardwareForTemplate = async (
672
- value: UI_I_WizardStep[]
673
- ): Promise<UI_I_ValidationReturn> => {
674
- let stepHasError = false
675
-
676
- return new Promise((resolve) => {
677
- customizeHardwareForTemplateSubmit.value = (isValid: boolean) => {
678
- if (!isValid) {
679
- stepHasError = wizard.setValidation(
680
- dynamicSteps.customizeHardwareTemplate,
681
- 'customizeHardwareForTemplate',
682
- {
683
- fieldMessage: 'aaa',
684
- alertMessage: 'aaa',
685
- }
686
- )
687
- } else if (
688
- wizard.hasMessage(
689
- dynamicSteps.customizeHardwareTemplate,
690
- 'customizeHardwareForTemplate'
691
- )
692
- ) {
693
- value = wizard.removeValidation(
694
- dynamicSteps.customizeHardwareTemplate,
695
- 'customizeHardwareForTemplate',
696
- value
697
- )
698
- }
699
-
700
- resolve({
701
- stepHasError,
702
- newValue: value,
703
- })
704
- storageSubmit.value = null
705
- }
706
- })
707
- }
708
-
709
- const storageIdCash = ref<string | null>(null)
710
- const vmForm = ref<UI_I_VmForm>({
711
- name: '',
712
- compatibility: '',
713
- guestMachineType: null,
714
- guestOsFamily: null,
715
- guestOsVersion: null,
716
- computeResource: props.computeResource,
717
- storage: null,
718
- locationPath: '',
719
- dataCenter: null,
720
- })
721
-
722
- const isLoadingComputeTree = ref<boolean>(false)
723
- const onChangeName = (name: string, node: UI_I_TreeNode | null): void => {
724
- vmForm.value.name = name // TODO уже нету смысла
725
- if (isSphere.value) {
726
- vmForm.value.locationPath = node.id
727
- vmForm.value.dataCenter = $recursion.findParentByValue(
728
- node,
729
- 'datacenter',
730
- 'type',
731
- 'parent'
732
- )
733
- isLoadingComputeTree.value = true
734
- emits('get-compute-resource-tree', {
735
- id: node.id,
736
- cb: () => {
737
- isLoadingComputeTree.value = false
738
- },
739
- })
740
- }
741
- }
742
- // Для сферы
743
- const computeResourcePath = ref<string>('')
744
- const onSelectComputeResourceTree = (node: UI_I_TreeNode): void => {
745
- emits('select-compute-resource-tree', node)
746
- computeResourcePath.value = node.id
747
- }
748
- watch(
749
- () => vmForm.value.computeResource,
750
- (newValue, oldValue) => {
751
- if (newValue && newValue.id !== oldValue?.id) {
752
- onSelectComputeResourceTree(newValue)
753
- }
754
- },
755
- { deep: true, immediate: true }
756
- )
757
-
758
- const onChangeStorage = (storage: UI_I_DatastoreTableItem | null): void => {
759
- if (!storage) return
760
-
761
- vmForm.value.storage = storage
762
- storageIdCash.value = storage.id
763
- }
764
- const compatibilityInfo = ref<string>('')
765
- const onChangeCompatibility = (compatibility: UI_I_OptionItem): void => {
766
- vmForm.value.compatibility = compatibility.value
767
-
768
- const version = compatibility.value.split('-')[1]
769
- compatibilityInfo.value = `${localization.value.common.compatibility}: ${compatibility.text} (${localization.value.common.vmVersion} ${version})`
770
- }
771
- const customizeHardware = ref<UI_I_SendDataCustomizeHardware | null>(null)
772
- const onChangeCustomizeHardware = (
773
- data: UI_I_SendDataCustomizeHardware
774
- ): void => {
775
- customizeHardware.value = data
776
- }
777
-
778
- const virtualHardwareHardDisksLocal = computed<
779
- UI_I_SendDataNewHardDisk[] | null
780
- >(() => customizeHardware.value?.virtualHardware?.hardDisks || null)
781
- const virtualHardwareNetworksLocal = computed<UI_I_SendDataNewNetwork[] | null>(
782
- () => customizeHardware.value?.virtualHardware?.networks || null
783
- )
784
- const virtualHardwareCdDvdDrivesLocal = computed<
785
- UI_I_SendDataNewCdDvdDrive[] | null
786
- >(() => customizeHardware.value?.virtualHardware?.cdDvdDrives || null)
787
-
788
- const virtualHardwareCpu = computed<UI_I_SendDataCpu | null>(
789
- () => customizeHardware.value?.virtualHardware?.cpu || null
790
- )
791
- const virtualHardwareMemory = computed<UI_I_SendDataMemory | null>(
792
- () => customizeHardware.value?.virtualHardware?.memory || null
793
- )
794
- const virtualHardwareHardDisks = ref<UI_I_SendDataNewHardDisk[] | null>(null)
795
- const virtualHardwareCdDvdDrives = ref<UI_I_SendDataNewCdDvdDrive[] | null>(
796
- null
797
- )
798
- const virtualHardwareNetworks = ref<UI_I_SendDataNewNetwork[] | null>(null)
799
- const onChangeBootOrder = (data: UI_T_ChangeBootOrder): void => {
800
- virtualHardwareHardDisks.value = data[0]
801
- virtualHardwareCdDvdDrives.value = data[1]
802
- virtualHardwareNetworks.value = data[2]
803
- }
804
-
805
- const isPowerOnByDefault = ref<boolean>(true)
806
- const isCreateLinkedClone = ref<boolean>(false)
807
-
808
- watch(
809
- () => props.vmNameInWizard,
810
- (newValue) => {
811
- vmForm.value.name = newValue
812
- }
813
- )
814
-
815
- const validateSendData = async (
816
- value: UI_I_WizardStep[]
817
- ): Promise<UI_I_ValidationReturn> => {
818
- wizard.setLoader(true)
819
- let stepHasError = false
820
- isLoading.value = true
821
-
822
- const data = await props.validateSendDataFunc(
823
- vmForm.value,
824
- virtualHardwareCpu.value,
825
- virtualHardwareMemory.value,
826
- customizeHardware.value,
827
- virtualHardwareNetworks.value,
828
- virtualHardwareHardDisks.value,
829
- virtualHardwareCdDvdDrives.value,
830
- isPowerOnByDefault.value,
831
- localization.value,
832
- vmForm.value.locationPath, // для сферы
833
- computeResourcePath.value, // для сферы
834
- selectedCreateType.value
835
- )
836
-
837
- isLoading.value = false
838
- wizard.setLoader(false)
839
- if (data) {
840
- stepHasError = true
841
- selectedNavItem.value = data[0]
842
- data[1] !== null && wizard.selectStepHard(data[1])
843
- }
844
-
845
- return {
846
- stepHasError,
847
- newValue: value,
848
- }
849
- }
850
-
851
- const isLoading = ref<boolean>(false)
852
- const onFinish = (): void => {
853
- isLoading.value = true
854
- wizard.setLoader(false)
855
- props
856
- .finishFunc(
857
- vmForm.value,
858
- virtualHardwareCpu.value,
859
- virtualHardwareMemory.value,
860
- customizeHardware.value,
861
- virtualHardwareNetworks.value,
862
- virtualHardwareHardDisks.value,
863
- virtualHardwareCdDvdDrives.value,
864
- isPowerOnByDefault.value,
865
- localization.value,
866
- vmForm.value.locationPath, // для сферы
867
- computeResourcePath.value, // для сферы
868
- false,
869
- selectedTemplate.value,
870
- selectedCreateType.value,
871
- isCreateLinkedClone.value, // для шаблонов
872
- cloneCount.value // для шаблонов
873
- )
874
- .then(() => {
875
- onHideModal()
876
- wizard.setLoader(false)
877
- isLoading.value = false
878
- })
879
- }
880
-
881
- const selectedNavItem = ref<UI_T_SelectedNavItem>(0)
882
-
883
- const nameFormSubmit = ref<null | Function>(null)
884
- const templateSubmit = ref<null | Function>(null)
885
- const storageSubmit = ref<null | Function>(null)
886
- const customizeHardwareSubmit = ref<null | Function>(null)
887
- const customizeHardwareForTemplateSubmit = ref<null | Function>(null)
888
- const compatibility = ref<UI_I_OptionItem[]>(capabilities.value.compatibility)
889
- const guestOsFamilies = ref<UI_I_OptionItem[]>(
890
- capabilities.value.guestOsFamilies
891
- )
892
- const guestOsVersions = ref<UI_I_ArbitraryObject<UI_I_OptionItem[]>>(
893
- capabilities.value.guestOsVersions
894
- )
895
- const machineTypes = ref<UI_I_OptionItem[]>(capabilities.value.machineTypes)
896
- const cpuModels = ref<UI_I_OptionItem[]>(capabilities.value.cpuModels)
897
- const maxCpus = ref<number>(capabilities.value.maxCpus)
898
- const maxMemory = ref<number>(capabilities.value.maxMemory)
899
-
900
- const selectedTemplate = ref<string>('')
901
- const onChangeTemplate = (node: UI_I_TreeNode): void => {
902
- selectedTemplate.value = node.id.toString()
903
- emits('select-template', node.id.toString())
904
- }
905
- const selectedOptions = ref<string[]>([])
906
- const onChangeSelectOptions = (options: string[]) => {
907
- selectedOptions.value = options
908
- if (
909
- options.includes('customize-os') &&
910
- options.includes('customize-hardware')
911
- ) {
912
- wizard.changeScheme(isSphere.value ? 9 : 5)
913
- } else if (options.includes('customize-os')) {
914
- wizard.changeScheme(isSphere.value ? 7 : 3)
915
- } else if (options.includes('customize-hardware')) {
916
- wizard.changeScheme(isSphere.value ? 8 : 4)
917
- } else {
918
- wizard.changeScheme(isSphere.value ? 6 : 2)
919
- }
920
-
921
- isPowerOnByDefault.value = options.includes('power-on')
922
- isCreateLinkedClone.value = options.includes('create-inked-clone')
923
- }
924
- const cloneCount = ref<number>(1)
925
-
926
- const onHideModal = (): void => {
927
- emits('hide')
928
- }
929
-
930
- watch(
931
- () => props.vmtSettings,
932
- (newValue) => {
933
- if (newValue) {
934
- vmForm.value.name = newValue.name
935
- vmForm.value.compatibility =
936
- newValue.compatibility || vmForm.value.compatibility
937
- vmForm.value.storage = newValue.storage
938
- if (customizeHardware.value?.virtualHardware) {
939
- customizeHardware.value.virtualHardware.cdDvdDrives =
940
- newValue.cdDvdDrives
941
- customizeHardware.value.virtualHardware.hardDisks = newValue.hardDisks
942
- customizeHardware.value.virtualHardware.networks = newValue.networks
943
- customizeHardware.value.virtualHardware.cpu = newValue.cpu
944
- customizeHardware.value.virtualHardware.memory = newValue.memory
945
- customizeHardware.value.virtualHardware.videoCard = newValue.videoCard
946
- customizeHardware.value.virtualHardware.usbController =
947
- newValue.usbController
948
- customizeHardware.value.virtualHardware.pciDevices = newValue.pciDevices
949
- customizeHardware.value.vmOptions = newValue.options
950
- }
951
- maxCpus.value = newValue.cpu.max_vcpus
952
- // cpuModels.value = newValue.cpu.model
953
- isPowerOnByDefault.value = false
954
- isCreateLinkedClone.value = false
955
- }
956
- }
957
- )
958
- </script>
959
-
960
- <style scoped lang="scss"></style>
1
+ <template>
2
+ <common-vm-actions-add-new
3
+ v-if="isNewView"
4
+ v-model="model"
5
+ v-model:computed-resource="computeResource"
6
+ v-model:selected-create-type="selectedCreateType"
7
+ v-model:is-power-on-by-default="isPowerOnByDefault"
8
+ :project="props.project"
9
+ :is-vmt="props.isVmt"
10
+ :nodes="props.nodes"
11
+ :files="props.files"
12
+ :networks-table="props.networksTable"
13
+ :datastore="props.datastore"
14
+ :is-datastore-loading="props.isDatastoreLoading"
15
+ :error-validation-fields="props.errorValidationFields"
16
+ :ready-complete-table-info="props.readyCompleteTableInfo"
17
+ :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
18
+ :import-from-v-m-warev-sphere="props.importFromVMWarevSphere"
19
+ :get-datastore-table-func="props.getDatastoreTableFunc"
20
+ :passthrough-devices="props.passthroughDevices"
21
+ :mediated-devices="props.mediatedDevices"
22
+ :templates-tree="props.templatesTree"
23
+ :wizard="wizard"
24
+ :selected-scheme="selectedScheme"
25
+ :template-submit="templateSubmit"
26
+ :name-form-submit="nameFormSubmit"
27
+ :storage-submit="storageSubmit"
28
+ :customize-hardware-submit="customizeHardwareSubmit"
29
+ :customize-hardware-for-template-submit="customizeHardwareForTemplateSubmit"
30
+ :is-sphere="isSphere"
31
+ :compatibility="compatibility"
32
+ :guestOsFamilies="guestOsFamilies"
33
+ :guestOsVersions="guestOsVersions"
34
+ :machineTypes="machineTypes"
35
+ :max-memory="maxMemory"
36
+ :cpu-models="cpuModels"
37
+ :selected-nav-item="selectedNavItem"
38
+ :compatibility-info="compatibilityInfo"
39
+ :is-show-power-on="isShowPowerOn"
40
+ :is-show-select-template="isShowSelectTemplate"
41
+ :data-center="props.dataCenter"
42
+ :compute-resource="props.computeResource"
43
+ :compute-resource-tree="props.computeResourceTree"
44
+ :location-nodes="props.locationNodes"
45
+ :allowed-location-kinds="allowedLocationKinds"
46
+ :location-description="locationDescription"
47
+ :vmt-settings="props.vmtSettings"
48
+ :is-loading="isLoading"
49
+ :selected-template-id="props.selectedTemplateId"
50
+ :validate-empty-name="props.validateEmptyName"
51
+ :title="title"
52
+ :name-request-url="props.nameRequestUrl"
53
+ :validation-description="validationDescription"
54
+ :name-exist-validation="nameExistValidation"
55
+ :name-test-ids="nameTestIds"
56
+ :is-loading-compute-tree="isLoadingComputeTree"
57
+ :compute-resource-alert="computeResourceAlert"
58
+ :compatibility-text="compatibilityText"
59
+ @get-storage="emits('get-storage', $event)"
60
+ @get-folders-or-files="emits('get-folders-or-files', $event)"
61
+ @get-active-device-child="emits('get-active-device-child', $event)"
62
+ @show-datastore-child="emits('show-datastore-child', $event)"
63
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
64
+ @get-networks-table="emits('get-networks-table', $event)"
65
+ @get-pci-devices="emits('get-pci-devices')"
66
+ @change-steps="onChangeSteps"
67
+ @change-template="onChangeTemplate"
68
+ @change-name="onChangeName(...$event)"
69
+ @change-storage="onChangeStorage"
70
+ @change-select-options="onChangeSelectOptions"
71
+ @change-clone-count="cloneCount = $event"
72
+ @change-compatibility="onChangeCompatibility"
73
+ @finish="onFinish"
74
+ @hide="onHideModal"
75
+ />
76
+ <common-vm-actions-add-old
77
+ v-else
78
+ v-model="model"
79
+ v-model:compute-resource="computeResource"
80
+ v-model:selected-create-type="selectedCreateType"
81
+ v-model:is-power-on-by-default="isPowerOnByDefault"
82
+ :project="props.project"
83
+ :is-vmt="props.isVmt"
84
+ :nodes="props.nodes"
85
+ :files="props.files"
86
+ :networks-table="props.networksTable"
87
+ :datastore="props.datastore"
88
+ :is-datastore-loading="props.isDatastoreLoading"
89
+ :error-validation-fields="props.errorValidationFields"
90
+ :ready-complete-table-info="props.readyCompleteTableInfo"
91
+ :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
92
+ :import-from-v-m-warev-sphere="props.importFromVMWarevSphere"
93
+ :get-datastore-table-func="props.getDatastoreTableFunc"
94
+ :passthrough-devices="props.passthroughDevices"
95
+ :mediated-devices="props.mediatedDevices"
96
+ :templates-tree="props.templatesTree"
97
+ :wizard="wizard"
98
+ :selected-scheme="selectedScheme"
99
+ :template-submit="templateSubmit"
100
+ :name-form-submit="nameFormSubmit"
101
+ :storage-submit="storageSubmit"
102
+ :customize-hardware-submit="customizeHardwareSubmit"
103
+ :customize-hardware-for-template-submit="customizeHardwareForTemplateSubmit"
104
+ :is-sphere="isSphere"
105
+ :compatibility="compatibility"
106
+ :guestOsFamilies="guestOsFamilies"
107
+ :guestOsVersions="guestOsVersions"
108
+ :machineTypes="machineTypes"
109
+ :max-memory="maxMemory"
110
+ :cpu-models="cpuModels"
111
+ :selected-nav-item="selectedNavItem"
112
+ :compatibility-info="compatibilityInfo"
113
+ :is-show-power-on="isShowPowerOn"
114
+ :data-center="props.dataCenter"
115
+ :compute-resource="props.computeResource"
116
+ :compute-resource-tree="props.computeResourceTree"
117
+ :location-nodes="props.locationNodes"
118
+ :allowed-location-kinds="allowedLocationKinds"
119
+ :location-description="locationDescription"
120
+ :vmt-settings="props.vmtSettings"
121
+ :is-loading="isLoading"
122
+ :validate-empty-name="props.validateEmptyName"
123
+ :title="title"
124
+ :name-request-url="props.nameRequestUrl"
125
+ :validation-description="validationDescription"
126
+ :name-exist-validation="nameExistValidation"
127
+ :name-test-ids="nameTestIds"
128
+ :is-loading-compute-tree="isLoadingComputeTree"
129
+ :compute-resource-alert="computeResourceAlert"
130
+ :compatibility-text="compatibilityText"
131
+ @get-storage="emits('get-storage', $event)"
132
+ @get-folders-or-files="emits('get-folders-or-files', $event)"
133
+ @get-active-device-child="emits('get-active-device-child', $event)"
134
+ @show-datastore-child="emits('show-datastore-child', $event)"
135
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
136
+ @get-networks-table="emits('get-networks-table', $event)"
137
+ @get-pci-devices="emits('get-pci-devices')"
138
+ @change-steps="onChangeSteps"
139
+ @change-template="onChangeTemplate"
140
+ @change-name="onChangeName(...$event)"
141
+ @change-storage="onChangeStorage"
142
+ @change-select-options="onChangeSelectOptions"
143
+ @change-clone-count="cloneCount = $event"
144
+ @change-compatibility="onChangeCompatibility"
145
+ @finish="onFinish"
146
+ @hide="onHideModal"
147
+ />
148
+ </template>
149
+
150
+ <script setup lang="ts">
151
+ import type {
152
+ UI_I_ValidationReturn,
153
+ UI_I_WizardStep,
154
+ } from '~/node_modules/bfg-uikit/components/ui/wizard/lib/models/interfaces'
155
+ import Wizard from '~/node_modules/bfg-uikit/components/ui/wizard/lib/utils/utils'
156
+ import type {
157
+ UI_I_Localization,
158
+ UI_I_ArbitraryObject,
159
+ } from '~/lib/models/interfaces'
160
+ import type { UI_T_Project } from '~/lib/models/types'
161
+ import type { UI_I_FileTreeNode } from '~/components/lib/models/interfaces'
162
+ import type { UI_I_NetworkTableItem } from '~/lib/models/store/network/interfaces'
163
+ import type {
164
+ UI_I_DatastoreTableItem,
165
+ UI_I_FolderOrFileTreePayload,
166
+ } from '~/lib/models/store/storage/interfaces'
167
+ import type {
168
+ // API_UI_I_Error,
169
+ UI_I_ErrorValidationField,
170
+ } from '~/lib/models/store/interfaces'
171
+ import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
172
+ import type { UI_I_TableInfoItem } from '~/components/atoms/table/info/lib/models/interfaces'
173
+ import type {
174
+ UI_T_AddVmFinishFunc,
175
+ UI_T_SelectedNavItem,
176
+ } from '~/components/common/vm/actions/common/lib/models/types'
177
+ import type { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
178
+ import type {
179
+ UI_I_Capabilities,
180
+ UI_I_CreateVmData,
181
+ UI_I_VmForm,
182
+ // UI_I_VmFormCash,
183
+ } from '~/components/common/vm/actions/common/lib/models/interfaces'
184
+ import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
185
+ import type {
186
+ UI_I_MediatedDevice,
187
+ UI_I_PciDevice,
188
+ UI_I_VmSettings,
189
+ } from '~/lib/models/store/vm/interfaces'
190
+ import type { UI_I_NameTestIds } from '~/components/common/wizards/common/steps/name/lib/models/interfaces'
191
+ import type { UI_T_CompatibilityStatus } from '~/components/common/wizards/common/compatibility/lib/models/types'
192
+ import { capabilities } from '~/components/common/vm/actions/common/lib/config/capabilities'
193
+ import {
194
+ stepsSchemeInitial,
195
+ stepsFunc,
196
+ dynamicSteps,
197
+ } from '~/components/common/vm/actions/add/lib/config/steps'
198
+ import { mapCapabilities } from '~/components/common/vm/actions/common/lib/utils/capabilities'
199
+
200
+ const model = defineModel<UI_I_CreateVmData>({ required: true })
201
+
202
+ const props = withDefaults(
203
+ defineProps<{
204
+ project: UI_T_Project
205
+ nodes: UI_I_FileTreeNode[]
206
+ files: UI_I_FileTreeNode[]
207
+ networksTable: UI_I_NetworkTableItem[]
208
+ datastore: UI_I_DatastoreTableItem[]
209
+ isDatastoreLoading: boolean
210
+ errorValidationFields: UI_I_ErrorValidationField[]
211
+ readyCompleteTableInfo: UI_I_TableInfoItem[]
212
+ vmCpuHelpTextSecond: string
213
+ importFromVMWarevSphere: string
214
+ finishFunc: UI_T_AddVmFinishFunc
215
+ getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
216
+ validateSendDataFunc: UI_T_AddVmFinishFunc<
217
+ [UI_T_SelectedNavItem, null | number] | null
218
+ >
219
+ passthroughDevices: UI_I_PciDevice[]
220
+ mediatedDevices: UI_I_MediatedDevice[]
221
+ vmNameInWizard: string
222
+ nameRequestUrl: string
223
+ templatesTree?: UI_I_TreeNode[]
224
+ capabilities?: UI_I_Capabilities
225
+ vmtSettings?: UI_I_VmSettings | null
226
+ validateEmptyName?: boolean
227
+ dataCenter?: UI_I_TreeNode // для сферы
228
+ computeResource?: UI_I_TreeNode // для сферы
229
+ computeResourceTree?: UI_I_TreeNode[] // для сферы
230
+ locationNodes?: UI_I_TreeNode[] // для сферы
231
+ selectedTemplateId?: string // для сферы
232
+ isVmt?: boolean // для сферы
233
+ }>(),
234
+ {
235
+ templatesTree: [],
236
+ capabilities: undefined,
237
+ vmtSettings: undefined,
238
+ validateEmptyName: false,
239
+ dataCenter: null,
240
+ computeResource: null,
241
+ computeResourceTree: undefined,
242
+ locationNodes: undefined,
243
+ selectedTemplateId: '',
244
+ isVmt: false,
245
+ }
246
+ )
247
+
248
+ const emits = defineEmits<{
249
+ (event: 'get-storage', value: UI_I_TablePayload): void
250
+ (event: 'get-folders-or-files', value: UI_I_FolderOrFileTreePayload): void
251
+ (event: 'get-active-device-child', value: UI_I_FileTreeNode): void
252
+ (event: 'show-datastore-child', value: UI_I_FileTreeNode): void
253
+ (event: 'remove-error-by-title', value: string): void
254
+ (event: 'get-networks-table', value: UI_I_TablePayload): void
255
+ (event: 'get-pci-devices'): void
256
+ (event: 'hide'): void
257
+ (event: 'select-template', value: string): void
258
+ (
259
+ event: 'get-compute-resource-tree',
260
+ value: { id: string | number; cb: () => void }
261
+ ): void // для сферы
262
+ (event: 'select-compute-resource-tree', value: UI_I_TreeNode): void // для сферы
263
+ }>()
264
+
265
+ const { $store, $recursion }: any = useNuxtApp()
266
+ const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
267
+
268
+ const localization = computed<UI_I_Localization>(() => useLocal())
269
+
270
+ const isSphere = computed<boolean>(() => props.project === 'sphere')
271
+
272
+ const title = computed<string>(() =>
273
+ props.isVmt
274
+ ? localization.value.vmt.newTemplate
275
+ : localization.value.common.newVirtualMachine2
276
+ )
277
+
278
+ watch(
279
+ () => props.capabilities,
280
+ () => {
281
+ if (props.capabilities) mapCapabilities(props.capabilities)
282
+ },
283
+ { deep: true, immediate: true }
284
+ )
285
+
286
+ const selectedCreateType = ref<string>('0')
287
+ if (props.isVmt) selectedCreateType.value = '-1'
288
+
289
+ const wizard: Wizard = new Wizard(
290
+ stepsFunc(localization.value, props.isVmt, isSphere.value),
291
+ stepsSchemeInitial
292
+ )
293
+ watch(
294
+ selectedCreateType,
295
+ (newValue) => {
296
+ switch (newValue) {
297
+ case '0':
298
+ wizard.changeScheme(isSphere.value ? 1 : 0)
299
+ break
300
+ case '1':
301
+ wizard.changeScheme(isSphere.value ? 6 : 2)
302
+ break
303
+ case '-1':
304
+ wizard.changeScheme(isSphere.value ? 11 : 10)
305
+ break
306
+ }
307
+ },
308
+ { immediate: true }
309
+ )
310
+
311
+ // if (isSphere.value) wizard.changeScheme(1)
312
+ const selectedScheme = computed<number[]>(() => wizard.selectedScheme.value)
313
+ // const alertMessages = computed<string[][]>(() => wizard.alertMessages.value)
314
+
315
+ const allowedLocationKinds = [3, 7] // TODO use from config
316
+ const locationDescription = computed<string>(() =>
317
+ props.isVmt
318
+ ? localization.value.vmt.selectLocationTemplate
319
+ : localization.value.common.selectLocationVirtualMachine
320
+ )
321
+
322
+ const nameTestIds: UI_I_NameTestIds = {
323
+ name: 'virtual-machine-name',
324
+ helpIcon: 'show-vm-name-help-icon',
325
+ }
326
+ const validationDescription =
327
+ localization.value.common.enterValidLocationVirtualMachine
328
+ const nameExistValidation =
329
+ localization.value.common.vmNameExistInSelectedLocation
330
+
331
+ const isShowSelectTemplate = computed<boolean>(
332
+ () =>
333
+ wizard.selectedStepId === dynamicSteps.selectTemplate &&
334
+ selectedCreateType.value === '1'
335
+ )
336
+
337
+ const isShowPowerOn = computed<boolean>(
338
+ () =>
339
+ wizard.selectedStepId > dynamicSteps.customizeHardware &&
340
+ selectedCreateType.value !== '1' &&
341
+ !props.isVmt
342
+ )
343
+
344
+ const onChangeSteps = async (value: UI_I_WizardStep[]): Promise<void> => {
345
+ wizard.changeSteps(value, validationFunc, validateSendData)
346
+ }
347
+ const validationFunc = async (
348
+ value: UI_I_WizardStep[],
349
+ currentStep: UI_I_WizardStep,
350
+ nextStep: UI_I_WizardStep
351
+ ): Promise<UI_I_ValidationReturn> => {
352
+ let stepHasError = false
353
+ let stepShouldStop = {
354
+ ifOnCurrentStep: false,
355
+ ifFromAnyStep: false,
356
+ stoppageStepId: -1,
357
+ }
358
+
359
+ wizard.setLoader(true)
360
+ if (
361
+ wizard.isValidateForStep(
362
+ dynamicSteps.selectTemplate,
363
+ currentStep.id,
364
+ nextStep.id
365
+ )
366
+ ) {
367
+ const templateValidation = await checkTemplate(value)
368
+
369
+ value = templateValidation.newValue
370
+ stepHasError = stepHasError || templateValidation.stepHasError
371
+ } else if (
372
+ wizard.isValidateForStep(
373
+ isSphere.value ? dynamicSteps.selectNameFolder : dynamicSteps.selectName,
374
+ currentStep.id,
375
+ nextStep.id
376
+ )
377
+ ) {
378
+ const nameValidation = await onCheckName(value)
379
+
380
+ value = nameValidation.newValue
381
+ stepHasError = stepHasError || nameValidation.stepHasError
382
+ } else if (
383
+ isSphere.value &&
384
+ wizard.isValidateForStep(
385
+ dynamicSteps.selectComputeResource,
386
+ currentStep.id,
387
+ nextStep.id
388
+ )
389
+ ) {
390
+ const computeResourceValidation = await checkComputeResource(value)
391
+
392
+ value = computeResourceValidation.newValue
393
+ stepHasError = stepHasError || computeResourceValidation.stepHasError
394
+ } else if (
395
+ wizard.isValidateForStep(
396
+ dynamicSteps.selectStorage,
397
+ currentStep.id,
398
+ nextStep.id
399
+ )
400
+ ) {
401
+ const storageValidation = await checkStorage(value)
402
+
403
+ value = storageValidation.newValue
404
+
405
+ stepHasError = stepHasError || storageValidation.stepHasError
406
+ } else if (
407
+ wizard.isValidateForStep(
408
+ dynamicSteps.customizeHardware,
409
+ currentStep.id,
410
+ nextStep.id
411
+ )
412
+ ) {
413
+ const validation = await checkCustomizeHardware(value)
414
+
415
+ value = validation.newValue
416
+
417
+ stepHasError = stepHasError || validation.stepHasError
418
+ } else if (
419
+ wizard.isValidateForStep(
420
+ dynamicSteps.customizeHardwareTemplate,
421
+ currentStep.id,
422
+ nextStep.id
423
+ )
424
+ ) {
425
+ const validation = await checkCustomizeHardwareForTemplate(value)
426
+
427
+ value = validation.newValue
428
+
429
+ stepHasError = stepHasError || validation.stepHasError
430
+ }
431
+ wizard.setLoader(false)
432
+
433
+ return {
434
+ newValue: value,
435
+ stepHasError,
436
+ stepShouldStop,
437
+ }
438
+ }
439
+
440
+ const checkTemplate = async (
441
+ value: UI_I_WizardStep[]
442
+ ): Promise<UI_I_ValidationReturn> => {
443
+ let stepHasError = false
444
+
445
+ return new Promise((resolve) => {
446
+ templateSubmit.value = (isValid: boolean) => {
447
+ if (!isValid) {
448
+ stepHasError = wizard.setValidation(
449
+ dynamicSteps.selectTemplate,
450
+ 'template',
451
+ {
452
+ fieldMessage: 'aaa',
453
+ alertMessage: 'aaa',
454
+ }
455
+ )
456
+ } else if (wizard.hasMessage(dynamicSteps.selectTemplate, 'template')) {
457
+ value = wizard.removeValidation(
458
+ dynamicSteps.selectTemplate,
459
+ 'template',
460
+ value
461
+ )
462
+ }
463
+
464
+ resolve({
465
+ stepHasError,
466
+ newValue: value,
467
+ })
468
+ templateSubmit.value = null
469
+ }
470
+ })
471
+ }
472
+ const onCheckName = async (
473
+ value: UI_I_WizardStep[]
474
+ ): Promise<UI_I_ValidationReturn> => {
475
+ let stepHasError = false
476
+
477
+ return new Promise((resolve) => {
478
+ const step = isSphere.value
479
+ ? dynamicSteps.selectNameFolder
480
+ : dynamicSteps.selectName
481
+ nameFormSubmit.value = (isValid: boolean) => {
482
+ if (!isValid) {
483
+ stepHasError = wizard.setValidation(step, 'name', {
484
+ fieldMessage: 'aaa',
485
+ alertMessage: 'aaa',
486
+ })
487
+ } else if (wizard.hasMessage(step, 'name')) {
488
+ value = wizard.removeValidation(step, 'name', value)
489
+ }
490
+
491
+ resolve({
492
+ stepHasError,
493
+ newValue: value,
494
+ })
495
+ nameFormSubmit.value = null
496
+ }
497
+ })
498
+ }
499
+ const compatibilityText = computed<[UI_T_CompatibilityStatus, string]>(() => {
500
+ if (!computeResource.value)
501
+ return [
502
+ 'none',
503
+ localization.value.vmWizard.noDestinationComputeResourceSelected,
504
+ ]
505
+
506
+ let res: [UI_T_CompatibilityStatus, string] = [
507
+ 'success',
508
+ localization.value.common.compatibilityChecksSucceeded,
509
+ ]
510
+
511
+ if (
512
+ !['cluster', 'host', 'resource_pool'].includes(computeResource.value?.type)
513
+ ) {
514
+ res = [
515
+ 'error',
516
+ localization.value.common.selectValidClusterOrHostDestination,
517
+ ]
518
+ }
519
+ if (computeResource.value?.type === 'cluster') {
520
+ const hasHost = !!computeResource.value.nodes.length
521
+ if (!hasHost) {
522
+ res = ['error', localization.value.common.clusterNotContainAnyHosts]
523
+ }
524
+ }
525
+
526
+ if (computeResource.value?.type === 'host') {
527
+ if (computeResource.value.state === 'Error') {
528
+ // TODO check Maintenance Mode
529
+ res = [
530
+ 'error',
531
+ localization.value.common.selectedHostDisconnectedMaintenanceMode,
532
+ ]
533
+ }
534
+ }
535
+
536
+ return res
537
+ })
538
+ const computeResourceAlert = ref<string[]>([])
539
+ const checkComputeResource = (
540
+ value: UI_I_WizardStep[]
541
+ ): UI_I_ValidationReturn => {
542
+ let stepHasError = false
543
+
544
+ if (
545
+ !computeResource.value ||
546
+ // compatibilityText.value[0] !== 1 ||
547
+ computeResource.value.type === 'datacenter' ||
548
+ computeResource.value.type === 'folder' ||
549
+ (computeResource.value.type === 'cluster' &&
550
+ !computeResource.value.nodes.length)
551
+ ) {
552
+ computeResourceAlert.value = [
553
+ localization.value.common.specifyValidClusterOrHostDestination,
554
+ ]
555
+ stepHasError = wizard.setValidation(
556
+ dynamicSteps.selectComputeResource,
557
+ 'computeResource',
558
+ {
559
+ fieldMessage: 'aaa',
560
+ alertMessage: 'aaa',
561
+ }
562
+ )
563
+ } else {
564
+ computeResourceAlert.value = []
565
+ if (
566
+ wizard.hasMessage(dynamicSteps.selectComputeResource, 'computeResource')
567
+ ) {
568
+ value = wizard.removeValidation(
569
+ dynamicSteps.selectComputeResource,
570
+ 'computeResource',
571
+ value
572
+ )
573
+ }
574
+ }
575
+
576
+ return {
577
+ stepHasError,
578
+ newValue: value,
579
+ }
580
+ }
581
+ const checkStorage = async (
582
+ value: UI_I_WizardStep[]
583
+ ): Promise<UI_I_ValidationReturn> => {
584
+ let stepHasError = false
585
+
586
+ return new Promise((resolve) => {
587
+ storageSubmit.value = (isValid: boolean) => {
588
+ if (!isValid) {
589
+ stepHasError = wizard.setValidation(
590
+ dynamicSteps.selectStorage,
591
+ 'storage',
592
+ {
593
+ fieldMessage: 'aaa',
594
+ alertMessage: 'aaa',
595
+ }
596
+ )
597
+ } else if (wizard.hasMessage(dynamicSteps.selectStorage, 'storage')) {
598
+ value = wizard.removeValidation(
599
+ dynamicSteps.selectStorage,
600
+ 'storage',
601
+ value
602
+ )
603
+ }
604
+
605
+ resolve({
606
+ stepHasError,
607
+ newValue: value,
608
+ })
609
+ storageSubmit.value = null
610
+ }
611
+ })
612
+ }
613
+ const checkCustomizeHardware = async (
614
+ value: UI_I_WizardStep[]
615
+ ): Promise<UI_I_ValidationReturn> => {
616
+ let stepHasError = false
617
+ isLoading.value = true
618
+
619
+ return new Promise((resolve) => {
620
+ customizeHardwareSubmit.value = (isValid: boolean) => {
621
+ if (!isValid) {
622
+ stepHasError = wizard.setValidation(
623
+ dynamicSteps.customizeHardware,
624
+ 'customizeHardware',
625
+ {
626
+ fieldMessage: 'aaa',
627
+ alertMessage: 'aaa',
628
+ }
629
+ )
630
+ } else if (
631
+ wizard.hasMessage(dynamicSteps.customizeHardware, 'customizeHardware')
632
+ ) {
633
+ wizard.removeValidationLocal(
634
+ dynamicSteps.customizeHardware,
635
+ 'customizeHardware'
636
+ )
637
+ value = wizard.removeValidation(
638
+ dynamicSteps.customizeHardware,
639
+ 'customizeHardware',
640
+ value
641
+ )
642
+ }
643
+
644
+ resolve({
645
+ stepHasError,
646
+ newValue: value,
647
+ })
648
+ storageSubmit.value = null
649
+ isLoading.value = false
650
+ }
651
+ })
652
+ }
653
+ const checkCustomizeHardwareForTemplate = async (
654
+ value: UI_I_WizardStep[]
655
+ ): Promise<UI_I_ValidationReturn> => {
656
+ let stepHasError = false
657
+
658
+ return new Promise((resolve) => {
659
+ customizeHardwareForTemplateSubmit.value = (isValid: boolean) => {
660
+ if (!isValid) {
661
+ stepHasError = wizard.setValidation(
662
+ dynamicSteps.customizeHardwareTemplate,
663
+ 'customizeHardwareForTemplate',
664
+ {
665
+ fieldMessage: 'aaa',
666
+ alertMessage: 'aaa',
667
+ }
668
+ )
669
+ } else if (
670
+ wizard.hasMessage(
671
+ dynamicSteps.customizeHardwareTemplate,
672
+ 'customizeHardwareForTemplate'
673
+ )
674
+ ) {
675
+ value = wizard.removeValidation(
676
+ dynamicSteps.customizeHardwareTemplate,
677
+ 'customizeHardwareForTemplate',
678
+ value
679
+ )
680
+ }
681
+
682
+ resolve({
683
+ stepHasError,
684
+ newValue: value,
685
+ })
686
+ storageSubmit.value = null
687
+ }
688
+ })
689
+ }
690
+
691
+ const computeResource = ref<UI_I_TreeNode | null>(props.computeResource)
692
+ const vmForm = ref<UI_I_VmForm>({
693
+ locationPath: '',
694
+ dataCenter: null,
695
+ })
696
+
697
+ const isLoadingComputeTree = ref<boolean>(false)
698
+ const onChangeName = (_name: string, node: UI_I_TreeNode | null): void => {
699
+ // vmForm.value.name = name // TODO уже нету смысла
700
+ if (isSphere.value) {
701
+ vmForm.value.locationPath = node.id
702
+ vmForm.value.dataCenter = $recursion.findParentByValue(
703
+ node,
704
+ 'datacenter',
705
+ 'type',
706
+ 'parent'
707
+ )
708
+ isLoadingComputeTree.value = true
709
+ emits('get-compute-resource-tree', {
710
+ id: node.id,
711
+ cb: () => {
712
+ isLoadingComputeTree.value = false
713
+ },
714
+ })
715
+ }
716
+ }
717
+ // Для сферы
718
+ const computeResourcePath = ref<string>('')
719
+ const onSelectComputeResourceTree = (node: UI_I_TreeNode): void => {
720
+ emits('select-compute-resource-tree', node)
721
+ computeResourcePath.value = node.id
722
+ }
723
+ watch(
724
+ computeResource,
725
+ (newValue, oldValue) => {
726
+ if (newValue && newValue.id !== oldValue?.id) {
727
+ onSelectComputeResourceTree(newValue)
728
+ }
729
+ },
730
+ { deep: true, immediate: true }
731
+ )
732
+
733
+ const onChangeStorage = (storage: UI_I_DatastoreTableItem | null): void => {
734
+ if (!storage) return
735
+
736
+ // vmForm.value.storage = storage
737
+ model.value.storage = storage
738
+ }
739
+ const compatibilityInfo = ref<string>('')
740
+ const onChangeCompatibility = (compatibility: UI_I_OptionItem): void => {
741
+ // vmForm.value.compatibility = compatibility.value
742
+ model.value.compatibility = compatibility.value
743
+
744
+ const version = compatibility.value.split('-')[1]
745
+ compatibilityInfo.value = `${localization.value.common.compatibility}: ${compatibility.text} (${localization.value.common.vmVersion} ${version})`
746
+ }
747
+
748
+ const isPowerOnByDefault = ref<boolean>(true)
749
+ const isCreateLinkedClone = ref<boolean>(false)
750
+
751
+ watch(
752
+ () => props.vmNameInWizard,
753
+ (newValue) => {
754
+ // vmForm.value.name = newValue
755
+ model.value.name = newValue
756
+ }
757
+ )
758
+
759
+ const validateSendData = async (
760
+ value: UI_I_WizardStep[]
761
+ ): Promise<UI_I_ValidationReturn> => {
762
+ wizard.setLoader(true)
763
+ let stepHasError = false
764
+ isLoading.value = true
765
+
766
+ const data = await props.validateSendDataFunc(
767
+ model.value,
768
+ isPowerOnByDefault.value,
769
+ localization.value,
770
+ vmForm.value.locationPath, // для сферы
771
+ computeResourcePath.value, // для сферы
772
+ selectedCreateType.value
773
+ )
774
+
775
+ isLoading.value = false
776
+ wizard.setLoader(false)
777
+ if (data) {
778
+ stepHasError = true
779
+ selectedNavItem.value = data[0]
780
+ data[1] !== null && wizard.selectStepHard(data[1])
781
+ }
782
+
783
+ return {
784
+ stepHasError,
785
+ newValue: value,
786
+ }
787
+ }
788
+
789
+ const isLoading = ref<boolean>(false)
790
+ const onFinish = (): void => {
791
+ isLoading.value = true
792
+ wizard.setLoader(false)
793
+ props
794
+ .finishFunc(
795
+ model.value,
796
+ isPowerOnByDefault.value,
797
+ localization.value,
798
+ vmForm.value.locationPath, // для сферы
799
+ computeResourcePath.value, // для сферы
800
+ false,
801
+ selectedTemplate.value,
802
+ selectedCreateType.value,
803
+ isCreateLinkedClone.value, // для шаблонов
804
+ cloneCount.value // для шаблонов
805
+ )
806
+ .then(() => {
807
+ onHideModal()
808
+ wizard.setLoader(false)
809
+ isLoading.value = false
810
+ })
811
+ }
812
+
813
+ const selectedNavItem = ref<UI_T_SelectedNavItem>(0)
814
+
815
+ const nameFormSubmit = ref<null | Function>(null)
816
+ const templateSubmit = ref<null | Function>(null)
817
+ const storageSubmit = ref<null | Function>(null)
818
+ const customizeHardwareSubmit = ref<null | Function>(null)
819
+ const customizeHardwareForTemplateSubmit = ref<null | Function>(null)
820
+ const compatibility = ref<UI_I_OptionItem[]>(capabilities.value.compatibility)
821
+ const guestOsFamilies = ref<UI_I_OptionItem[]>(
822
+ capabilities.value.guestOsFamilies
823
+ )
824
+ const guestOsVersions = ref<UI_I_ArbitraryObject<UI_I_OptionItem[]>>(
825
+ capabilities.value.guestOsVersions
826
+ )
827
+ const machineTypes = ref<UI_I_OptionItem[]>(capabilities.value.machineTypes)
828
+ const cpuModels = ref<UI_I_OptionItem[]>(capabilities.value.cpuModels)
829
+ model.value.cpu.max_vcpus = capabilities.value.maxCpus
830
+ const maxMemory = ref<number>(capabilities.value.maxMemory)
831
+
832
+ const selectedTemplate = ref<string>('')
833
+ const onChangeTemplate = (node: UI_I_TreeNode): void => {
834
+ selectedTemplate.value = node.id.toString()
835
+ emits('select-template', node.id.toString())
836
+ }
837
+ const selectedOptions = ref<string[]>([])
838
+ const onChangeSelectOptions = (options: string[]) => {
839
+ selectedOptions.value = options
840
+ if (
841
+ options.includes('customize-os') &&
842
+ options.includes('customize-hardware')
843
+ ) {
844
+ wizard.changeScheme(isSphere.value ? 9 : 5)
845
+ } else if (options.includes('customize-os')) {
846
+ wizard.changeScheme(isSphere.value ? 7 : 3)
847
+ } else if (options.includes('customize-hardware')) {
848
+ wizard.changeScheme(isSphere.value ? 8 : 4)
849
+ } else {
850
+ wizard.changeScheme(isSphere.value ? 6 : 2)
851
+ }
852
+
853
+ isPowerOnByDefault.value = options.includes('power-on')
854
+ isCreateLinkedClone.value = options.includes('create-inked-clone')
855
+ }
856
+ const cloneCount = ref<number>(1)
857
+
858
+ const onHideModal = (): void => {
859
+ emits('hide')
860
+ }
861
+
862
+ watch(
863
+ () => props.vmtSettings,
864
+ (newValue) => {
865
+ if (newValue) {
866
+ // vmForm.value.name = newValue.name
867
+ // vmForm.value.compatibility =
868
+ // newValue.compatibility || vmForm.value.compatibility
869
+ // vmForm.value.storage = newValue.storage
870
+ // TODO remove
871
+ model.value.name = newValue.name
872
+ model.value.compatibility =
873
+ newValue.compatibility || model.value.compatibility
874
+ model.value.storage = newValue.storage
875
+ // TODO remove end
876
+
877
+ capabilities.value.maxCpus = newValue.cpu.max_vcpus
878
+ // cpuModels.value = newValue.cpu.model
879
+ isPowerOnByDefault.value = false
880
+ isCreateLinkedClone.value = false
881
+ }
882
+ }
883
+ )
884
+ </script>
885
+
886
+ <style scoped lang="scss"></style>