bfg-common 1.5.568 → 1.5.569

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