bfg-common 1.5.136 → 1.5.138

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 (22) hide show
  1. package/assets/img/icons/icons-sprite-dark-3.svg +227 -227
  2. package/assets/img/icons/icons-sprite-dark-5.svg +488 -488
  3. package/assets/img/icons/icons-sprite-light-3.svg +227 -227
  4. package/assets/img/icons/icons-sprite-light-5.svg +488 -488
  5. package/assets/localization/local_be.json +3093 -3093
  6. package/assets/localization/local_en.json +3097 -3097
  7. package/assets/localization/local_hy.json +3097 -3097
  8. package/assets/localization/local_kk.json +3096 -3096
  9. package/assets/localization/local_ru.json +3098 -3098
  10. package/assets/localization/local_zh.json +3094 -3094
  11. package/components/atoms/table/compact/Compact.vue +4 -1
  12. package/components/atoms/table/dataGrid/DataGrid.vue +1 -1
  13. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/lib/config/utils.ts +1040 -1040
  14. package/components/common/vm/actions/add/Add.vue +785 -785
  15. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/VideoCard.vue +8 -3
  16. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/model/Model.vue +8 -3
  17. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/model/lib/config/options.ts +11 -8
  18. package/components/common/vm/actions/common/lib/config/capabilities.ts +363 -362
  19. package/components/common/vm/actions/common/select/compatibility/Compatibility.vue +1 -4
  20. package/components/common/wizards/vm/migrate/select/storage/configure/batch/Batch.vue +1 -1
  21. package/components/common/wizards/vm/migrate/select/storage/configure/batch/config/virtualDiskFormat.ts +6 -5
  22. package/package.json +1 -1
@@ -1,785 +1,785 @@
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
- :nodes="props.nodes"
9
- :files="props.files"
10
- :networks-table="props.networksTable"
11
- :datastore="props.datastore"
12
- :error-validation-fields="props.errorValidationFields"
13
- :ready-complete-table-info="props.readyCompleteTableInfo"
14
- :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
15
- :import-from-v-m-warev-sphere="props.importFromVMWarevSphere"
16
- :get-datastore-table-func="props.getDatastoreTableFunc"
17
- :passthrough-devices="props.passthroughDevices"
18
- :mediated-devices="props.mediatedDevices"
19
- :templates-tree="props.templatesTree"
20
- :wizard="wizard"
21
- :selected-scheme="selectedScheme"
22
- :template-submit="templateSubmit"
23
- :name-form-submit="nameFormSubmit"
24
- :storage-submit="storageSubmit"
25
- :customize-hardware-submit="customizeHardwareSubmit"
26
- :is-sphere="isSphere"
27
- :compatibility="compatibility"
28
- :guestOsFamilies="guestOsFamilies"
29
- :guestOsVersions="guestOsVersions"
30
- :machineTypes="machineTypes"
31
- :virtual-hardware-hard-disks-local="virtualHardwareHardDisksLocal"
32
- :virtual-hardware-cd-dvd-drives-local="virtualHardwareCdDvdDrivesLocal"
33
- :virtual-hardware-networks-local="virtualHardwareNetworksLocal"
34
- :max-cpus="maxCpus"
35
- :max-memory="maxMemory"
36
- :cpu-models="cpuModels"
37
- :selected-nav-item="selectedNavItem"
38
- :compatibility-info="compatibilityInfo"
39
- :is-show-power-on="isShowPowerOn"
40
- :compute-resource-submit="computeResourceSubmit"
41
- :data-center="props.dataCenter"
42
- :compute-resource="props.computeResource"
43
- :compute-resource-tree="props.computeResourceTree"
44
- :vmt-settings="props.vmtSettings"
45
- @check-name="emits('check-name', $event)"
46
- @get-storage="emits('get-storage', $event)"
47
- @get-folders-or-files="emits('get-folders-or-files', $event)"
48
- @get-active-device-child="emits('get-active-device-child', $event)"
49
- @show-datastore-child="emits('show-datastore-child', $event)"
50
- @remove-error-by-title="emits('remove-error-by-title', $event)"
51
- @get-networks-table="emits('get-networks-table', $event)"
52
- @get-pci-devices="emits('get-pci-devices')"
53
- @change-steps="onChangeSteps"
54
- @change-template="onChangeTemplate"
55
- @change-name="onChangeName(...$event)"
56
- @change-storage="onChangeStorage"
57
- @change-select-options="onChangeSelectOptions"
58
- @change-compatibility="onChangeCompatibility"
59
- @change-boot-order="onChangeBootOrder"
60
- @change-customize-hardware="onChangeCustomizeHardware"
61
- @clear-compute-resource-tree="emits('clear-compute-resource-tree')"
62
- @change-compute-resource="onChangeComputeResource"
63
- @select-compute-resource-tree="onSelectComputeResourceTree"
64
- @get-compute-resource-tree="emits('get-compute-resource-tree', $event)"
65
- @show-compute-resource-tree="emits('show-compute-resource-tree', $event)"
66
- @finish="onFinish"
67
- @hide="onHideModal"
68
- />
69
- <common-vm-actions-add-old
70
- v-else
71
- v-model:vm-form="vmForm"
72
- v-model:selected-create-type="selectedCreateType"
73
- v-model:is-power-on-by-default="isPowerOnByDefault"
74
- :project="props.project"
75
- :nodes="props.nodes"
76
- :files="props.files"
77
- :networks-table="props.networksTable"
78
- :datastore="props.datastore"
79
- :error-validation-fields="props.errorValidationFields"
80
- :ready-complete-table-info="props.readyCompleteTableInfo"
81
- :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
82
- :import-from-v-m-warev-sphere="props.importFromVMWarevSphere"
83
- :get-datastore-table-func="props.getDatastoreTableFunc"
84
- :passthrough-devices="props.passthroughDevices"
85
- :mediated-devices="props.mediatedDevices"
86
- :templates-tree="props.templatesTree"
87
- :wizard="wizard"
88
- :selected-scheme="selectedScheme"
89
- :template-submit="templateSubmit"
90
- :name-form-submit="nameFormSubmit"
91
- :storage-submit="storageSubmit"
92
- :customize-hardware-submit="customizeHardwareSubmit"
93
- :is-sphere="isSphere"
94
- :compatibility="compatibility"
95
- :guestOsFamilies="guestOsFamilies"
96
- :guestOsVersions="guestOsVersions"
97
- :machineTypes="machineTypes"
98
- :virtual-hardware-hard-disks-local="virtualHardwareHardDisksLocal"
99
- :virtual-hardware-cd-dvd-drives-local="virtualHardwareCdDvdDrivesLocal"
100
- :virtual-hardware-networks-local="virtualHardwareNetworksLocal"
101
- :max-cpus="maxCpus"
102
- :max-memory="maxMemory"
103
- :cpu-models="cpuModels"
104
- :selected-nav-item="selectedNavItem"
105
- :compatibility-info="compatibilityInfo"
106
- :is-show-power-on="isShowPowerOn"
107
- :compute-resource-submit="computeResourceSubmit"
108
- :data-center="props.dataCenter"
109
- :compute-resource="props.computeResource"
110
- :compute-resource-tree="props.computeResourceTree"
111
- :vmt-settings="props.vmtSettings"
112
- @check-name="emits('check-name', $event)"
113
- @get-storage="emits('get-storage', $event)"
114
- @get-folders-or-files="emits('get-folders-or-files', $event)"
115
- @get-active-device-child="emits('get-active-device-child', $event)"
116
- @show-datastore-child="emits('show-datastore-child', $event)"
117
- @remove-error-by-title="emits('remove-error-by-title', $event)"
118
- @get-networks-table="emits('get-networks-table', $event)"
119
- @get-pci-devices="emits('get-pci-devices')"
120
- @change-steps="onChangeSteps"
121
- @change-template="onChangeTemplate"
122
- @change-name="onChangeName(...$event)"
123
- @change-storage="onChangeStorage"
124
- @change-select-options="onChangeSelectOptions"
125
- @change-compatibility="onChangeCompatibility"
126
- @change-boot-order="onChangeBootOrder"
127
- @change-customize-hardware="onChangeCustomizeHardware"
128
- @clear-compute-resource-tree="emits('clear-compute-resource-tree')"
129
- @change-compute-resource="onChangeComputeResource"
130
- @select-compute-resource-tree="onSelectComputeResourceTree"
131
- @get-compute-resource-tree="emits('get-compute-resource-tree', $event)"
132
- @show-compute-resource-tree="emits('show-compute-resource-tree', $event)"
133
- @finish="onFinish"
134
- @hide="onHideModal"
135
- />
136
- </template>
137
-
138
- <script setup lang="ts">
139
- import type {
140
- UI_I_Localization,
141
- UI_I_ArbitraryObject,
142
- } from '~/lib/models/interfaces'
143
- import type { UI_T_Project } from '~/lib/models/types'
144
- import type { UI_I_FileTreeNode } from '~/components/lib/models/interfaces'
145
- import type { UI_I_NetworkTableItem } from '~/lib/models/store/network/interfaces'
146
- import type {
147
- UI_I_DatastoreTableItem,
148
- UI_I_FolderOrFileTreePayload,
149
- } from '~/lib/models/store/storage/interfaces'
150
- import type {
151
- API_UI_I_Error,
152
- UI_I_ErrorValidationField,
153
- } from '~/lib/models/store/interfaces'
154
- import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
155
- import type { UI_I_TableInfoItem } from '~/components/atoms/table/info/lib/models/interfaces'
156
- import type {
157
- UI_T_AddVmFinishFunc,
158
- UI_T_SelectedNavItem,
159
- } from '~/components/common/vm/actions/common/lib/models/types'
160
- import type { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
161
- import type {
162
- UI_I_ValidationReturn,
163
- UI_I_WizardStep,
164
- } from '~/components/atoms/wizard/lib/models/interfaces'
165
- import type {
166
- UI_I_Capabilities,
167
- UI_I_VmForm,
168
- UI_I_VmFormCash,
169
- } from '~/components/common/vm/actions/common/lib/models/interfaces'
170
- import type { UI_I_SendDataCustomizeHardware } from '~/components/common/vm/actions/common/customizeHardware/lib/models/interfaces'
171
- import type {
172
- UI_I_SendDataCpu,
173
- UI_I_SendDataMemory,
174
- UI_I_SendDataNewCdDvdDrive,
175
- UI_I_SendDataNewHardDisk,
176
- UI_I_SendDataNewNetwork,
177
- } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
178
- import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
179
- import type { UI_T_ChangeBootOrder } from '~/components/common/vm/actions/lib/models/types'
180
- import type {
181
- UI_I_MediatedDevice,
182
- UI_I_PciDevice,
183
- UI_I_VmSettings,
184
- } from '~/lib/models/store/vm/interfaces'
185
- import { capabilities } from '~/components/common/vm/actions/common/lib/config/capabilities'
186
- import {
187
- stepsSchemeInitial,
188
- stepsFunc,
189
- dynamicSteps,
190
- } from '~/components/common/vm/actions/add/lib/config/steps'
191
- import Wizard from '~/components/atoms/wizard/lib/utils/utils'
192
- import { mapCapabilities } from '~/components/common/vm/actions/common/lib/utils/capabilities'
193
-
194
- const props = defineProps<{
195
- project: UI_T_Project
196
- nodes: UI_I_FileTreeNode[]
197
- files: UI_I_FileTreeNode[]
198
- networksTable: UI_I_NetworkTableItem[]
199
- datastore: UI_I_DatastoreTableItem[]
200
- errorValidationFields: UI_I_ErrorValidationField[]
201
- readyCompleteTableInfo: UI_I_TableInfoItem[]
202
- vmCpuHelpTextSecond: string
203
- importFromVMWarevSphere: string
204
- finishFunc: UI_T_AddVmFinishFunc
205
- getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
206
- validateSendDataFunc: UI_T_AddVmFinishFunc<
207
- [UI_T_SelectedNavItem, null | number] | null
208
- >
209
- passthroughDevices: UI_I_PciDevice[]
210
- mediatedDevices: UI_I_MediatedDevice[]
211
- vmNameInWizard: string
212
- templatesTree: UI_I_TreeNode[]
213
- capabilities?: UI_I_Capabilities
214
- vmtSettings?: UI_I_VmSettings | null
215
- dataCenter?: UI_I_TreeNode // для сферы
216
- computeResource?: UI_I_TreeNode // для сферы
217
- computeResourceTree?: UI_I_TreeNode[] // для сферы
218
- }>()
219
-
220
- const emits = defineEmits<{
221
- (event: 'check-name', value: [string, (error: API_UI_I_Error) => void]): void
222
- (event: 'get-storage', value: UI_I_TablePayload): void
223
- (event: 'get-folders-or-files', value: UI_I_FolderOrFileTreePayload): void
224
- (event: 'get-active-device-child', value: UI_I_FileTreeNode): void
225
- (event: 'show-datastore-child', value: UI_I_FileTreeNode): void
226
- (event: 'remove-error-by-title', value: string): void
227
- (event: 'get-networks-table', value: UI_I_TablePayload): void
228
- (event: 'get-pci-devices'): void
229
- (event: 'get-pci-devices'): void
230
- (event: 'hide'): void
231
- (event: 'select-template', value: string): void
232
- (
233
- event: 'get-compute-resource-tree',
234
- value: { id: string | number; cb: () => void }
235
- ): void // для сферы
236
- (event: 'show-compute-resource-tree', value: UI_I_TreeNode): void // для сферы
237
- (event: 'select-compute-resource-tree', value: UI_I_TreeNode): void // для сферы
238
- (event: 'clear-compute-resource-tree'): void // для сферы
239
- }>()
240
-
241
- const { $store, $recursion }: any = useNuxtApp()
242
- const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
243
-
244
- const localization = computed<UI_I_Localization>(() => useLocal())
245
-
246
- const isSphere = computed<boolean>(() => props.project === 'sphere')
247
-
248
- watch(
249
- () => props.capabilities,
250
- () => {
251
- if (props.capabilities) mapCapabilities(props.capabilities)
252
- },
253
- { deep: true, immediate: true }
254
- )
255
-
256
- const selectedCreateType = ref<string>('0')
257
-
258
- const wizard: Wizard = new Wizard(
259
- stepsFunc(localization.value),
260
- stepsSchemeInitial
261
- )
262
- watch(
263
- selectedCreateType,
264
- (newValue) => {
265
- switch (newValue) {
266
- case '0':
267
- wizard.changeScheme(isSphere.value ? 1 : 0)
268
- break
269
- case '1':
270
- wizard.changeScheme(2)
271
- }
272
- },
273
- { immediate: true }
274
- )
275
- // if (isSphere.value) wizard.changeScheme(1)
276
- const selectedScheme = computed<number[]>(() => wizard.selectedScheme.value)
277
- // const alertMessages = computed<string[][]>(() => wizard.alertMessages.value)
278
-
279
- const isShowPowerOn = computed<boolean>(
280
- () => wizard.selectedStepId > dynamicSteps.customizeHardware
281
- )
282
-
283
- const onChangeSteps = async (value: UI_I_WizardStep[]): Promise<void> => {
284
- wizard.changeSteps(value, validationFunc, validateSendData)
285
- }
286
- const validationFunc = async (
287
- value: UI_I_WizardStep[],
288
- currentStep: UI_I_WizardStep,
289
- nextStep: UI_I_WizardStep
290
- ): Promise<UI_I_ValidationReturn> => {
291
- let stepHasError = false
292
- let stepShouldStop = {
293
- ifOnCurrentStep: false,
294
- ifFromAnyStep: false,
295
- stoppageStepId: -1,
296
- }
297
-
298
- wizard.setLoader(true)
299
- if (
300
- wizard.isValidateForStep(
301
- dynamicSteps.selectTemplate,
302
- currentStep.id,
303
- nextStep.id
304
- )
305
- ) {
306
- const templateValidation = await checkTemplate(value)
307
-
308
- value = templateValidation.newValue
309
- stepHasError = stepHasError || templateValidation.stepHasError
310
- } else if (
311
- wizard.isValidateForStep(
312
- isSphere.value ? dynamicSteps.selectNameFolder : dynamicSteps.selectName,
313
- currentStep.id,
314
- nextStep.id
315
- )
316
- ) {
317
- const nameValidation = await onCheckName(value)
318
-
319
- value = nameValidation.newValue
320
- stepHasError = stepHasError || nameValidation.stepHasError
321
- } else if (
322
- isSphere.value &&
323
- wizard.isValidateForStep(
324
- dynamicSteps.selectComputeResource,
325
- currentStep.id,
326
- nextStep.id
327
- )
328
- ) {
329
- const computeResourceValidation = await checkComputeResource(value)
330
-
331
- value = computeResourceValidation.newValue
332
- stepHasError = stepHasError || computeResourceValidation.stepHasError
333
- } else if (
334
- wizard.isValidateForStep(
335
- dynamicSteps.selectStorage,
336
- currentStep.id,
337
- nextStep.id
338
- )
339
- ) {
340
- const storageValidation = await checkStorage(value)
341
-
342
- value = storageValidation.newValue
343
-
344
- stepHasError = stepHasError || storageValidation.stepHasError
345
- } else if (
346
- wizard.isValidateForStep(
347
- dynamicSteps.customizeHardware,
348
- currentStep.id,
349
- nextStep.id
350
- )
351
- ) {
352
- const validation = await checkCustomizeHardware(value)
353
-
354
- value = validation.newValue
355
-
356
- stepHasError = stepHasError || validation.stepHasError
357
- } else if (
358
- wizard.isValidateForStep(
359
- dynamicSteps.customizeHardwareTemplate,
360
- currentStep.id,
361
- nextStep.id
362
- )
363
- ) {
364
- const validation = await checkCustomizeHardware(value, true)
365
-
366
- value = validation.newValue
367
-
368
- stepHasError = stepHasError || validation.stepHasError
369
- }
370
- wizard.setLoader(false)
371
-
372
- return {
373
- newValue: value,
374
- stepHasError,
375
- stepShouldStop,
376
- }
377
- }
378
-
379
- const checkTemplate = async (
380
- value: UI_I_WizardStep[]
381
- ): Promise<UI_I_ValidationReturn> => {
382
- let stepHasError = false
383
-
384
- return new Promise((resolve) => {
385
- templateSubmit.value = (isValid: boolean) => {
386
- if (!isValid) {
387
- stepHasError = wizard.setValidation(
388
- dynamicSteps.selectTemplate,
389
- 'template',
390
- {
391
- fieldMessage: 'aaa',
392
- alertMessage: 'aaa',
393
- }
394
- )
395
- } else if (wizard.hasMessage(dynamicSteps.selectTemplate, 'template')) {
396
- value = wizard.removeValidation(
397
- dynamicSteps.selectTemplate,
398
- 'template',
399
- value
400
- )
401
- }
402
-
403
- resolve({
404
- stepHasError,
405
- newValue: value,
406
- })
407
- templateSubmit.value = null
408
- }
409
- })
410
- }
411
- const onCheckName = async (
412
- value: UI_I_WizardStep[]
413
- ): Promise<UI_I_ValidationReturn> => {
414
- let stepHasError = false
415
-
416
- return new Promise((resolve) => {
417
- const step = isSphere.value
418
- ? dynamicSteps.selectNameFolder
419
- : dynamicSteps.selectName
420
- nameFormSubmit.value = (isValid: boolean) => {
421
- if (!isValid) {
422
- stepHasError = wizard.setValidation(step, 'name', {
423
- fieldMessage: 'aaa',
424
- alertMessage: 'aaa',
425
- })
426
- } else if (wizard.hasMessage(step, 'name')) {
427
- value = wizard.removeValidation(step, 'name', value)
428
- }
429
-
430
- resolve({
431
- stepHasError,
432
- newValue: value,
433
- })
434
- nameFormSubmit.value = null
435
- }
436
- })
437
- }
438
- const checkComputeResource = async (
439
- value: UI_I_WizardStep[]
440
- ): Promise<UI_I_ValidationReturn> => {
441
- let stepHasError = false
442
-
443
- return new Promise((resolve) => {
444
- computeResourceSubmit.value = (isValid: boolean) => {
445
- if (!isValid) {
446
- stepHasError = wizard.setValidation(
447
- dynamicSteps.selectComputeResource,
448
- 'computeResource',
449
- {
450
- fieldMessage: 'aaa',
451
- alertMessage: 'aaa',
452
- }
453
- )
454
- } else if (
455
- wizard.hasMessage(dynamicSteps.selectComputeResource, 'computeResource')
456
- ) {
457
- value = wizard.removeValidation(
458
- dynamicSteps.selectComputeResource,
459
- 'computeResource',
460
- value
461
- )
462
- }
463
-
464
- resolve({
465
- stepHasError,
466
- newValue: value,
467
- })
468
- computeResourceSubmit.value = null
469
- }
470
- })
471
- }
472
- const checkStorage = async (
473
- value: UI_I_WizardStep[]
474
- ): Promise<UI_I_ValidationReturn> => {
475
- let stepHasError = false
476
-
477
- return new Promise((resolve) => {
478
- storageSubmit.value = (isValid: boolean) => {
479
- if (!isValid) {
480
- stepHasError = wizard.setValidation(
481
- dynamicSteps.selectStorage,
482
- 'storage',
483
- {
484
- fieldMessage: 'aaa',
485
- alertMessage: 'aaa',
486
- }
487
- )
488
- } else if (wizard.hasMessage(dynamicSteps.selectStorage, 'storage')) {
489
- value = wizard.removeValidation(
490
- dynamicSteps.selectStorage,
491
- 'storage',
492
- value
493
- )
494
- }
495
-
496
- resolve({
497
- stepHasError,
498
- newValue: value,
499
- })
500
- storageSubmit.value = null
501
- }
502
- })
503
- }
504
- const checkCustomizeHardware = async (
505
- value: UI_I_WizardStep[],
506
- forTemplate = false
507
- ): Promise<UI_I_ValidationReturn> => {
508
- let stepHasError = false
509
-
510
- return new Promise((resolve) => {
511
- customizeHardwareSubmit.value = (isValid: boolean) => {
512
- if (!isValid) {
513
- stepHasError = wizard.setValidation(
514
- forTemplate
515
- ? dynamicSteps.customizeHardwareTemplate
516
- : dynamicSteps.customizeHardware,
517
- 'customizeHardware',
518
- {
519
- fieldMessage: 'aaa',
520
- alertMessage: 'aaa',
521
- }
522
- )
523
- } else if (
524
- wizard.hasMessage(
525
- forTemplate
526
- ? dynamicSteps.customizeHardwareTemplate
527
- : dynamicSteps.customizeHardware,
528
- 'customizeHardware'
529
- )
530
- ) {
531
- value = wizard.removeValidation(
532
- forTemplate
533
- ? dynamicSteps.customizeHardwareTemplate
534
- : dynamicSteps.customizeHardware,
535
- 'customizeHardware',
536
- value
537
- )
538
- }
539
-
540
- resolve({
541
- stepHasError,
542
- newValue: value,
543
- })
544
- storageSubmit.value = null
545
- }
546
- })
547
- }
548
-
549
- const storageIdCash = ref<string | null>(null)
550
- const vmForm = ref<UI_I_VmForm>({
551
- name: '',
552
- compatibility: '',
553
- guestMachineType: null,
554
- guestOsFamily: null,
555
- guestOsVersion: null,
556
- computeResource: null,
557
- storage: null,
558
- locationPath: '',
559
- dataCenter: null,
560
- })
561
-
562
- // TODO remove (not used)
563
- const vmFormCash = ref<UI_I_VmFormCash>({
564
- dataCenterId: null,
565
- computeResourceTypeAndId: null,
566
- })
567
-
568
- const onChangeName = (name: string, node: UI_I_TreeNode | null): void => {
569
- vmForm.value.name = name
570
- if (isSphere.value) {
571
- vmForm.value.locationPath = node.id
572
- vmForm.value.dataCenter = $recursion.findParentByValue(
573
- node,
574
- 'datacenter',
575
- 'type',
576
- 'parent'
577
- )
578
- vmFormCash.value.dataCenterId = vmForm.value.dataCenter?.id || null
579
- }
580
- }
581
- // // Для сферы
582
- const computeResourcePath = ref<string>('')
583
- const onSelectComputeResourceTree = (node: UI_I_TreeNode): void => {
584
- emits('select-compute-resource-tree', node)
585
- computeResourcePath.value = node.id
586
- }
587
- const onChangeComputeResource = (node: UI_I_TreeNode): void => {
588
- vmForm.value.computeResource = node
589
- // const type = node.type.toUpperCase()
590
- // schedRequirementsTemplate.value = `sched_requirements="(${type}_ID=${node.id})"\\`
591
- vmFormCash.value.computeResourceTypeAndId = `${node.type}${node.id}` || null
592
- }
593
- const onChangeStorage = (storage: UI_I_DatastoreTableItem | null): void => {
594
- if (!storage) return
595
-
596
- vmForm.value.storage = storage
597
- storageIdCash.value = storage.id
598
- }
599
- const compatibilityInfo = ref<string>('')
600
- const onChangeCompatibility = (compatibility: UI_I_OptionItem): void => {
601
- vmForm.value.compatibility = compatibility.value
602
-
603
- const version = compatibility.value.split('-')[1]
604
- compatibilityInfo.value = `${localization.value.common.compatibility}: ${compatibility.text} (${localization.value.common.vmVersion} ${version})`
605
- }
606
- const customizeHardware = ref<UI_I_SendDataCustomizeHardware | null>(null)
607
- const onChangeCustomizeHardware = (
608
- data: UI_I_SendDataCustomizeHardware
609
- ): void => {
610
- customizeHardware.value = data
611
- }
612
-
613
- const virtualHardwareHardDisksLocal = computed<
614
- UI_I_SendDataNewHardDisk[] | null
615
- >(() => customizeHardware.value?.virtualHardware?.hardDisks || null)
616
- const virtualHardwareNetworksLocal = computed<UI_I_SendDataNewNetwork[] | null>(
617
- () => customizeHardware.value?.virtualHardware?.networks || null
618
- )
619
- const virtualHardwareCdDvdDrivesLocal = computed<
620
- UI_I_SendDataNewCdDvdDrive[] | null
621
- >(() => customizeHardware.value?.virtualHardware?.cdDvdDrives || null)
622
-
623
- const virtualHardwareCpu = computed<UI_I_SendDataCpu | null>(
624
- () => customizeHardware.value?.virtualHardware?.cpu || null
625
- )
626
- const virtualHardwareMemory = computed<UI_I_SendDataMemory | null>(
627
- () => customizeHardware.value?.virtualHardware?.memory || null
628
- )
629
- const virtualHardwareHardDisks = ref<UI_I_SendDataNewHardDisk[] | null>(null)
630
- const virtualHardwareCdDvdDrives = ref<UI_I_SendDataNewCdDvdDrive[] | null>(
631
- null
632
- )
633
- const virtualHardwareNetworks = ref<UI_I_SendDataNewNetwork[] | null>(null)
634
- const onChangeBootOrder = (data: UI_T_ChangeBootOrder): void => {
635
- virtualHardwareHardDisks.value = data[0]
636
- virtualHardwareCdDvdDrives.value = data[1]
637
- virtualHardwareNetworks.value = data[2]
638
- }
639
-
640
- const isPowerOnByDefault = ref<boolean>(true)
641
-
642
- watch(
643
- () => props.vmNameInWizard,
644
- (newValue) => {
645
- vmForm.value.name = newValue
646
- }
647
- )
648
-
649
- const validateSendData = async (
650
- value: UI_I_WizardStep[]
651
- ): Promise<UI_I_ValidationReturn> => {
652
- wizard.setLoader(true)
653
- let stepHasError = false
654
-
655
- const data = await props.validateSendDataFunc(
656
- vmForm.value,
657
- virtualHardwareCpu.value,
658
- virtualHardwareMemory.value,
659
- customizeHardware.value,
660
- virtualHardwareNetworks.value,
661
- virtualHardwareHardDisks.value,
662
- virtualHardwareCdDvdDrives.value,
663
- isPowerOnByDefault.value,
664
- localization.value,
665
- vmForm.value.locationPath, // для сферы
666
- computeResourcePath.value // для сферы
667
- )
668
-
669
- wizard.setLoader(false)
670
- if (data) {
671
- stepHasError = true
672
- selectedNavItem.value = data[0]
673
- data[1] !== null && wizard.selectStepHard(data[1])
674
- }
675
-
676
- return {
677
- stepHasError,
678
- newValue: value,
679
- }
680
- }
681
- const onFinish = (): void => {
682
- wizard.setLoader(false)
683
- props
684
- .finishFunc(
685
- vmForm.value,
686
- virtualHardwareCpu.value,
687
- virtualHardwareMemory.value,
688
- customizeHardware.value,
689
- virtualHardwareNetworks.value,
690
- virtualHardwareHardDisks.value,
691
- virtualHardwareCdDvdDrives.value,
692
- isPowerOnByDefault.value,
693
- localization.value,
694
- vmForm.value.locationPath, // для сферы
695
- computeResourcePath.value, // для сферы
696
- false
697
- )
698
- .then(() => {
699
- onHideModal()
700
- wizard.setLoader(false)
701
- })
702
- }
703
-
704
- const selectedNavItem = ref<UI_T_SelectedNavItem>(0)
705
-
706
- const nameFormSubmit = ref<null | Function>(null)
707
- const templateSubmit = ref<null | Function>(null)
708
- const computeResourceSubmit = ref<null | Function>(null)
709
- const storageSubmit = ref<null | Function>(null)
710
- const customizeHardwareSubmit = ref<null | Function>(null)
711
- const compatibility = ref<UI_I_OptionItem[]>(
712
- capabilities.compatibility.filter((camp) => {
713
- let result = true
714
- // if (isDev && camp.value === 'pvm-2') result = false
715
- if (camp.value === 'pvm-2') result = false
716
- return result
717
- })
718
- )
719
- const guestOsFamilies = ref<UI_I_OptionItem[]>(capabilities.guestOsFamilies)
720
- const guestOsVersions = ref<UI_I_ArbitraryObject<UI_I_OptionItem[]>>(
721
- capabilities.guestOsVersions
722
- )
723
- const machineTypes = ref<UI_I_OptionItem[]>(capabilities.machineTypes)
724
- const cpuModels = ref<UI_I_OptionItem[]>(capabilities.cpuModels)
725
- const maxCpus = ref<number>(capabilities.maxCpus)
726
- const maxMemory = ref<number>(capabilities.maxMemory)
727
-
728
- const selectedTemplate = ref<string>('')
729
- const onChangeTemplate = (node: UI_I_TreeNode): void => {
730
- selectedTemplate.value = node.id.toString()
731
- emits('select-template', node.id.toString())
732
- }
733
- const selectedOptions = ref<string[]>([])
734
- const onChangeSelectOptions = (options: string[]) => {
735
- selectedOptions.value = options
736
- if (
737
- options.includes('customize-os') &&
738
- options.includes('customize-hardware')
739
- ) {
740
- wizard.changeScheme(5)
741
- } else if (options.includes('customize-os')) {
742
- wizard.changeScheme(3)
743
- } else if (options.includes('customize-hardware')) {
744
- wizard.changeScheme(4)
745
- } else {
746
- wizard.changeScheme(2)
747
- }
748
-
749
- isPowerOnByDefault.value = options.includes('power-on')
750
- }
751
-
752
- const onHideModal = (): void => {
753
- emits('hide')
754
- }
755
-
756
- watch(
757
- () => props.vmtSettings,
758
- (newValue) => {
759
- if (newValue) {
760
- vmForm.value.name = newValue.name
761
- vmForm.value.compatibility =
762
- newValue.compatibility || vmForm.value.compatibility
763
- vmForm.value.storage = newValue.storage
764
- if (customizeHardware.value?.virtualHardware) {
765
- customizeHardware.value.virtualHardware.cdDvdDrives =
766
- newValue.cdDvdDrives
767
- customizeHardware.value.virtualHardware.hardDisks = newValue.hardDisks
768
- customizeHardware.value.virtualHardware.networks = newValue.networks
769
- customizeHardware.value.virtualHardware.cpu = newValue.cpu
770
- customizeHardware.value.virtualHardware.memory = newValue.memory
771
- customizeHardware.value.virtualHardware.videoCard = newValue.videoCard
772
- customizeHardware.value.virtualHardware.usbController =
773
- newValue.usbController
774
- customizeHardware.value.virtualHardware.pciDevices = newValue.pciDevices
775
- customizeHardware.value.vmOptions = newValue.options
776
- }
777
- maxCpus.value = newValue.cpu.max_vcpus
778
- cpuModels.value = newValue.cpu.model
779
- isPowerOnByDefault.value = false
780
- }
781
- }
782
- )
783
- </script>
784
-
785
- <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
+ :nodes="props.nodes"
9
+ :files="props.files"
10
+ :networks-table="props.networksTable"
11
+ :datastore="props.datastore"
12
+ :error-validation-fields="props.errorValidationFields"
13
+ :ready-complete-table-info="props.readyCompleteTableInfo"
14
+ :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
15
+ :import-from-v-m-warev-sphere="props.importFromVMWarevSphere"
16
+ :get-datastore-table-func="props.getDatastoreTableFunc"
17
+ :passthrough-devices="props.passthroughDevices"
18
+ :mediated-devices="props.mediatedDevices"
19
+ :templates-tree="props.templatesTree"
20
+ :wizard="wizard"
21
+ :selected-scheme="selectedScheme"
22
+ :template-submit="templateSubmit"
23
+ :name-form-submit="nameFormSubmit"
24
+ :storage-submit="storageSubmit"
25
+ :customize-hardware-submit="customizeHardwareSubmit"
26
+ :is-sphere="isSphere"
27
+ :compatibility="compatibility"
28
+ :guestOsFamilies="guestOsFamilies"
29
+ :guestOsVersions="guestOsVersions"
30
+ :machineTypes="machineTypes"
31
+ :virtual-hardware-hard-disks-local="virtualHardwareHardDisksLocal"
32
+ :virtual-hardware-cd-dvd-drives-local="virtualHardwareCdDvdDrivesLocal"
33
+ :virtual-hardware-networks-local="virtualHardwareNetworksLocal"
34
+ :max-cpus="maxCpus"
35
+ :max-memory="maxMemory"
36
+ :cpu-models="cpuModels"
37
+ :selected-nav-item="selectedNavItem"
38
+ :compatibility-info="compatibilityInfo"
39
+ :is-show-power-on="isShowPowerOn"
40
+ :compute-resource-submit="computeResourceSubmit"
41
+ :data-center="props.dataCenter"
42
+ :compute-resource="props.computeResource"
43
+ :compute-resource-tree="props.computeResourceTree"
44
+ :vmt-settings="props.vmtSettings"
45
+ @check-name="emits('check-name', $event)"
46
+ @get-storage="emits('get-storage', $event)"
47
+ @get-folders-or-files="emits('get-folders-or-files', $event)"
48
+ @get-active-device-child="emits('get-active-device-child', $event)"
49
+ @show-datastore-child="emits('show-datastore-child', $event)"
50
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
51
+ @get-networks-table="emits('get-networks-table', $event)"
52
+ @get-pci-devices="emits('get-pci-devices')"
53
+ @change-steps="onChangeSteps"
54
+ @change-template="onChangeTemplate"
55
+ @change-name="onChangeName(...$event)"
56
+ @change-storage="onChangeStorage"
57
+ @change-select-options="onChangeSelectOptions"
58
+ @change-compatibility="onChangeCompatibility"
59
+ @change-boot-order="onChangeBootOrder"
60
+ @change-customize-hardware="onChangeCustomizeHardware"
61
+ @clear-compute-resource-tree="emits('clear-compute-resource-tree')"
62
+ @change-compute-resource="onChangeComputeResource"
63
+ @select-compute-resource-tree="onSelectComputeResourceTree"
64
+ @get-compute-resource-tree="emits('get-compute-resource-tree', $event)"
65
+ @show-compute-resource-tree="emits('show-compute-resource-tree', $event)"
66
+ @finish="onFinish"
67
+ @hide="onHideModal"
68
+ />
69
+ <common-vm-actions-add-old
70
+ v-else
71
+ v-model:vm-form="vmForm"
72
+ v-model:selected-create-type="selectedCreateType"
73
+ v-model:is-power-on-by-default="isPowerOnByDefault"
74
+ :project="props.project"
75
+ :nodes="props.nodes"
76
+ :files="props.files"
77
+ :networks-table="props.networksTable"
78
+ :datastore="props.datastore"
79
+ :error-validation-fields="props.errorValidationFields"
80
+ :ready-complete-table-info="props.readyCompleteTableInfo"
81
+ :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
82
+ :import-from-v-m-warev-sphere="props.importFromVMWarevSphere"
83
+ :get-datastore-table-func="props.getDatastoreTableFunc"
84
+ :passthrough-devices="props.passthroughDevices"
85
+ :mediated-devices="props.mediatedDevices"
86
+ :templates-tree="props.templatesTree"
87
+ :wizard="wizard"
88
+ :selected-scheme="selectedScheme"
89
+ :template-submit="templateSubmit"
90
+ :name-form-submit="nameFormSubmit"
91
+ :storage-submit="storageSubmit"
92
+ :customize-hardware-submit="customizeHardwareSubmit"
93
+ :is-sphere="isSphere"
94
+ :compatibility="compatibility"
95
+ :guestOsFamilies="guestOsFamilies"
96
+ :guestOsVersions="guestOsVersions"
97
+ :machineTypes="machineTypes"
98
+ :virtual-hardware-hard-disks-local="virtualHardwareHardDisksLocal"
99
+ :virtual-hardware-cd-dvd-drives-local="virtualHardwareCdDvdDrivesLocal"
100
+ :virtual-hardware-networks-local="virtualHardwareNetworksLocal"
101
+ :max-cpus="maxCpus"
102
+ :max-memory="maxMemory"
103
+ :cpu-models="cpuModels"
104
+ :selected-nav-item="selectedNavItem"
105
+ :compatibility-info="compatibilityInfo"
106
+ :is-show-power-on="isShowPowerOn"
107
+ :compute-resource-submit="computeResourceSubmit"
108
+ :data-center="props.dataCenter"
109
+ :compute-resource="props.computeResource"
110
+ :compute-resource-tree="props.computeResourceTree"
111
+ :vmt-settings="props.vmtSettings"
112
+ @check-name="emits('check-name', $event)"
113
+ @get-storage="emits('get-storage', $event)"
114
+ @get-folders-or-files="emits('get-folders-or-files', $event)"
115
+ @get-active-device-child="emits('get-active-device-child', $event)"
116
+ @show-datastore-child="emits('show-datastore-child', $event)"
117
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
118
+ @get-networks-table="emits('get-networks-table', $event)"
119
+ @get-pci-devices="emits('get-pci-devices')"
120
+ @change-steps="onChangeSteps"
121
+ @change-template="onChangeTemplate"
122
+ @change-name="onChangeName(...$event)"
123
+ @change-storage="onChangeStorage"
124
+ @change-select-options="onChangeSelectOptions"
125
+ @change-compatibility="onChangeCompatibility"
126
+ @change-boot-order="onChangeBootOrder"
127
+ @change-customize-hardware="onChangeCustomizeHardware"
128
+ @clear-compute-resource-tree="emits('clear-compute-resource-tree')"
129
+ @change-compute-resource="onChangeComputeResource"
130
+ @select-compute-resource-tree="onSelectComputeResourceTree"
131
+ @get-compute-resource-tree="emits('get-compute-resource-tree', $event)"
132
+ @show-compute-resource-tree="emits('show-compute-resource-tree', $event)"
133
+ @finish="onFinish"
134
+ @hide="onHideModal"
135
+ />
136
+ </template>
137
+
138
+ <script setup lang="ts">
139
+ import type {
140
+ UI_I_Localization,
141
+ UI_I_ArbitraryObject,
142
+ } from '~/lib/models/interfaces'
143
+ import type { UI_T_Project } from '~/lib/models/types'
144
+ import type { UI_I_FileTreeNode } from '~/components/lib/models/interfaces'
145
+ import type { UI_I_NetworkTableItem } from '~/lib/models/store/network/interfaces'
146
+ import type {
147
+ UI_I_DatastoreTableItem,
148
+ UI_I_FolderOrFileTreePayload,
149
+ } from '~/lib/models/store/storage/interfaces'
150
+ import type {
151
+ API_UI_I_Error,
152
+ UI_I_ErrorValidationField,
153
+ } from '~/lib/models/store/interfaces'
154
+ import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
155
+ import type { UI_I_TableInfoItem } from '~/components/atoms/table/info/lib/models/interfaces'
156
+ import type {
157
+ UI_T_AddVmFinishFunc,
158
+ UI_T_SelectedNavItem,
159
+ } from '~/components/common/vm/actions/common/lib/models/types'
160
+ import type { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
161
+ import type {
162
+ UI_I_ValidationReturn,
163
+ UI_I_WizardStep,
164
+ } from '~/components/atoms/wizard/lib/models/interfaces'
165
+ import type {
166
+ UI_I_Capabilities,
167
+ UI_I_VmForm,
168
+ UI_I_VmFormCash,
169
+ } from '~/components/common/vm/actions/common/lib/models/interfaces'
170
+ import type { UI_I_SendDataCustomizeHardware } from '~/components/common/vm/actions/common/customizeHardware/lib/models/interfaces'
171
+ import type {
172
+ UI_I_SendDataCpu,
173
+ UI_I_SendDataMemory,
174
+ UI_I_SendDataNewCdDvdDrive,
175
+ UI_I_SendDataNewHardDisk,
176
+ UI_I_SendDataNewNetwork,
177
+ } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
178
+ import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
179
+ import type { UI_T_ChangeBootOrder } from '~/components/common/vm/actions/lib/models/types'
180
+ import type {
181
+ UI_I_MediatedDevice,
182
+ UI_I_PciDevice,
183
+ UI_I_VmSettings,
184
+ } from '~/lib/models/store/vm/interfaces'
185
+ import { capabilities } from '~/components/common/vm/actions/common/lib/config/capabilities'
186
+ import {
187
+ stepsSchemeInitial,
188
+ stepsFunc,
189
+ dynamicSteps,
190
+ } from '~/components/common/vm/actions/add/lib/config/steps'
191
+ import Wizard from '~/components/atoms/wizard/lib/utils/utils'
192
+ import { mapCapabilities } from '~/components/common/vm/actions/common/lib/utils/capabilities'
193
+
194
+ const props = defineProps<{
195
+ project: UI_T_Project
196
+ nodes: UI_I_FileTreeNode[]
197
+ files: UI_I_FileTreeNode[]
198
+ networksTable: UI_I_NetworkTableItem[]
199
+ datastore: UI_I_DatastoreTableItem[]
200
+ errorValidationFields: UI_I_ErrorValidationField[]
201
+ readyCompleteTableInfo: UI_I_TableInfoItem[]
202
+ vmCpuHelpTextSecond: string
203
+ importFromVMWarevSphere: string
204
+ finishFunc: UI_T_AddVmFinishFunc
205
+ getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
206
+ validateSendDataFunc: UI_T_AddVmFinishFunc<
207
+ [UI_T_SelectedNavItem, null | number] | null
208
+ >
209
+ passthroughDevices: UI_I_PciDevice[]
210
+ mediatedDevices: UI_I_MediatedDevice[]
211
+ vmNameInWizard: string
212
+ templatesTree: UI_I_TreeNode[]
213
+ capabilities?: UI_I_Capabilities
214
+ vmtSettings?: UI_I_VmSettings | null
215
+ dataCenter?: UI_I_TreeNode // для сферы
216
+ computeResource?: UI_I_TreeNode // для сферы
217
+ computeResourceTree?: UI_I_TreeNode[] // для сферы
218
+ }>()
219
+
220
+ const emits = defineEmits<{
221
+ (event: 'check-name', value: [string, (error: API_UI_I_Error) => void]): void
222
+ (event: 'get-storage', value: UI_I_TablePayload): void
223
+ (event: 'get-folders-or-files', value: UI_I_FolderOrFileTreePayload): void
224
+ (event: 'get-active-device-child', value: UI_I_FileTreeNode): void
225
+ (event: 'show-datastore-child', value: UI_I_FileTreeNode): void
226
+ (event: 'remove-error-by-title', value: string): void
227
+ (event: 'get-networks-table', value: UI_I_TablePayload): void
228
+ (event: 'get-pci-devices'): void
229
+ (event: 'get-pci-devices'): void
230
+ (event: 'hide'): void
231
+ (event: 'select-template', value: string): void
232
+ (
233
+ event: 'get-compute-resource-tree',
234
+ value: { id: string | number; cb: () => void }
235
+ ): void // для сферы
236
+ (event: 'show-compute-resource-tree', value: UI_I_TreeNode): void // для сферы
237
+ (event: 'select-compute-resource-tree', value: UI_I_TreeNode): void // для сферы
238
+ (event: 'clear-compute-resource-tree'): void // для сферы
239
+ }>()
240
+
241
+ const { $store, $recursion }: any = useNuxtApp()
242
+ const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
243
+
244
+ const localization = computed<UI_I_Localization>(() => useLocal())
245
+
246
+ const isSphere = computed<boolean>(() => props.project === 'sphere')
247
+
248
+ watch(
249
+ () => props.capabilities,
250
+ () => {
251
+ if (props.capabilities) mapCapabilities(props.capabilities)
252
+ },
253
+ { deep: true, immediate: true }
254
+ )
255
+
256
+ const selectedCreateType = ref<string>('0')
257
+
258
+ const wizard: Wizard = new Wizard(
259
+ stepsFunc(localization.value),
260
+ stepsSchemeInitial
261
+ )
262
+ watch(
263
+ selectedCreateType,
264
+ (newValue) => {
265
+ switch (newValue) {
266
+ case '0':
267
+ wizard.changeScheme(isSphere.value ? 1 : 0)
268
+ break
269
+ case '1':
270
+ wizard.changeScheme(2)
271
+ }
272
+ },
273
+ { immediate: true }
274
+ )
275
+ // if (isSphere.value) wizard.changeScheme(1)
276
+ const selectedScheme = computed<number[]>(() => wizard.selectedScheme.value)
277
+ // const alertMessages = computed<string[][]>(() => wizard.alertMessages.value)
278
+
279
+ const isShowPowerOn = computed<boolean>(
280
+ () => wizard.selectedStepId > dynamicSteps.customizeHardware
281
+ )
282
+
283
+ const onChangeSteps = async (value: UI_I_WizardStep[]): Promise<void> => {
284
+ wizard.changeSteps(value, validationFunc, validateSendData)
285
+ }
286
+ const validationFunc = async (
287
+ value: UI_I_WizardStep[],
288
+ currentStep: UI_I_WizardStep,
289
+ nextStep: UI_I_WizardStep
290
+ ): Promise<UI_I_ValidationReturn> => {
291
+ let stepHasError = false
292
+ let stepShouldStop = {
293
+ ifOnCurrentStep: false,
294
+ ifFromAnyStep: false,
295
+ stoppageStepId: -1,
296
+ }
297
+
298
+ wizard.setLoader(true)
299
+ if (
300
+ wizard.isValidateForStep(
301
+ dynamicSteps.selectTemplate,
302
+ currentStep.id,
303
+ nextStep.id
304
+ )
305
+ ) {
306
+ const templateValidation = await checkTemplate(value)
307
+
308
+ value = templateValidation.newValue
309
+ stepHasError = stepHasError || templateValidation.stepHasError
310
+ } else if (
311
+ wizard.isValidateForStep(
312
+ isSphere.value ? dynamicSteps.selectNameFolder : dynamicSteps.selectName,
313
+ currentStep.id,
314
+ nextStep.id
315
+ )
316
+ ) {
317
+ const nameValidation = await onCheckName(value)
318
+
319
+ value = nameValidation.newValue
320
+ stepHasError = stepHasError || nameValidation.stepHasError
321
+ } else if (
322
+ isSphere.value &&
323
+ wizard.isValidateForStep(
324
+ dynamicSteps.selectComputeResource,
325
+ currentStep.id,
326
+ nextStep.id
327
+ )
328
+ ) {
329
+ const computeResourceValidation = await checkComputeResource(value)
330
+
331
+ value = computeResourceValidation.newValue
332
+ stepHasError = stepHasError || computeResourceValidation.stepHasError
333
+ } else if (
334
+ wizard.isValidateForStep(
335
+ dynamicSteps.selectStorage,
336
+ currentStep.id,
337
+ nextStep.id
338
+ )
339
+ ) {
340
+ const storageValidation = await checkStorage(value)
341
+
342
+ value = storageValidation.newValue
343
+
344
+ stepHasError = stepHasError || storageValidation.stepHasError
345
+ } else if (
346
+ wizard.isValidateForStep(
347
+ dynamicSteps.customizeHardware,
348
+ currentStep.id,
349
+ nextStep.id
350
+ )
351
+ ) {
352
+ const validation = await checkCustomizeHardware(value)
353
+
354
+ value = validation.newValue
355
+
356
+ stepHasError = stepHasError || validation.stepHasError
357
+ } else if (
358
+ wizard.isValidateForStep(
359
+ dynamicSteps.customizeHardwareTemplate,
360
+ currentStep.id,
361
+ nextStep.id
362
+ )
363
+ ) {
364
+ const validation = await checkCustomizeHardware(value, true)
365
+
366
+ value = validation.newValue
367
+
368
+ stepHasError = stepHasError || validation.stepHasError
369
+ }
370
+ wizard.setLoader(false)
371
+
372
+ return {
373
+ newValue: value,
374
+ stepHasError,
375
+ stepShouldStop,
376
+ }
377
+ }
378
+
379
+ const checkTemplate = async (
380
+ value: UI_I_WizardStep[]
381
+ ): Promise<UI_I_ValidationReturn> => {
382
+ let stepHasError = false
383
+
384
+ return new Promise((resolve) => {
385
+ templateSubmit.value = (isValid: boolean) => {
386
+ if (!isValid) {
387
+ stepHasError = wizard.setValidation(
388
+ dynamicSteps.selectTemplate,
389
+ 'template',
390
+ {
391
+ fieldMessage: 'aaa',
392
+ alertMessage: 'aaa',
393
+ }
394
+ )
395
+ } else if (wizard.hasMessage(dynamicSteps.selectTemplate, 'template')) {
396
+ value = wizard.removeValidation(
397
+ dynamicSteps.selectTemplate,
398
+ 'template',
399
+ value
400
+ )
401
+ }
402
+
403
+ resolve({
404
+ stepHasError,
405
+ newValue: value,
406
+ })
407
+ templateSubmit.value = null
408
+ }
409
+ })
410
+ }
411
+ const onCheckName = async (
412
+ value: UI_I_WizardStep[]
413
+ ): Promise<UI_I_ValidationReturn> => {
414
+ let stepHasError = false
415
+
416
+ return new Promise((resolve) => {
417
+ const step = isSphere.value
418
+ ? dynamicSteps.selectNameFolder
419
+ : dynamicSteps.selectName
420
+ nameFormSubmit.value = (isValid: boolean) => {
421
+ if (!isValid) {
422
+ stepHasError = wizard.setValidation(step, 'name', {
423
+ fieldMessage: 'aaa',
424
+ alertMessage: 'aaa',
425
+ })
426
+ } else if (wizard.hasMessage(step, 'name')) {
427
+ value = wizard.removeValidation(step, 'name', value)
428
+ }
429
+
430
+ resolve({
431
+ stepHasError,
432
+ newValue: value,
433
+ })
434
+ nameFormSubmit.value = null
435
+ }
436
+ })
437
+ }
438
+ const checkComputeResource = async (
439
+ value: UI_I_WizardStep[]
440
+ ): Promise<UI_I_ValidationReturn> => {
441
+ let stepHasError = false
442
+
443
+ return new Promise((resolve) => {
444
+ computeResourceSubmit.value = (isValid: boolean) => {
445
+ if (!isValid) {
446
+ stepHasError = wizard.setValidation(
447
+ dynamicSteps.selectComputeResource,
448
+ 'computeResource',
449
+ {
450
+ fieldMessage: 'aaa',
451
+ alertMessage: 'aaa',
452
+ }
453
+ )
454
+ } else if (
455
+ wizard.hasMessage(dynamicSteps.selectComputeResource, 'computeResource')
456
+ ) {
457
+ value = wizard.removeValidation(
458
+ dynamicSteps.selectComputeResource,
459
+ 'computeResource',
460
+ value
461
+ )
462
+ }
463
+
464
+ resolve({
465
+ stepHasError,
466
+ newValue: value,
467
+ })
468
+ computeResourceSubmit.value = null
469
+ }
470
+ })
471
+ }
472
+ const checkStorage = async (
473
+ value: UI_I_WizardStep[]
474
+ ): Promise<UI_I_ValidationReturn> => {
475
+ let stepHasError = false
476
+
477
+ return new Promise((resolve) => {
478
+ storageSubmit.value = (isValid: boolean) => {
479
+ if (!isValid) {
480
+ stepHasError = wizard.setValidation(
481
+ dynamicSteps.selectStorage,
482
+ 'storage',
483
+ {
484
+ fieldMessage: 'aaa',
485
+ alertMessage: 'aaa',
486
+ }
487
+ )
488
+ } else if (wizard.hasMessage(dynamicSteps.selectStorage, 'storage')) {
489
+ value = wizard.removeValidation(
490
+ dynamicSteps.selectStorage,
491
+ 'storage',
492
+ value
493
+ )
494
+ }
495
+
496
+ resolve({
497
+ stepHasError,
498
+ newValue: value,
499
+ })
500
+ storageSubmit.value = null
501
+ }
502
+ })
503
+ }
504
+ const checkCustomizeHardware = async (
505
+ value: UI_I_WizardStep[],
506
+ forTemplate = false
507
+ ): Promise<UI_I_ValidationReturn> => {
508
+ let stepHasError = false
509
+
510
+ return new Promise((resolve) => {
511
+ customizeHardwareSubmit.value = (isValid: boolean) => {
512
+ if (!isValid) {
513
+ stepHasError = wizard.setValidation(
514
+ forTemplate
515
+ ? dynamicSteps.customizeHardwareTemplate
516
+ : dynamicSteps.customizeHardware,
517
+ 'customizeHardware',
518
+ {
519
+ fieldMessage: 'aaa',
520
+ alertMessage: 'aaa',
521
+ }
522
+ )
523
+ } else if (
524
+ wizard.hasMessage(
525
+ forTemplate
526
+ ? dynamicSteps.customizeHardwareTemplate
527
+ : dynamicSteps.customizeHardware,
528
+ 'customizeHardware'
529
+ )
530
+ ) {
531
+ value = wizard.removeValidation(
532
+ forTemplate
533
+ ? dynamicSteps.customizeHardwareTemplate
534
+ : dynamicSteps.customizeHardware,
535
+ 'customizeHardware',
536
+ value
537
+ )
538
+ }
539
+
540
+ resolve({
541
+ stepHasError,
542
+ newValue: value,
543
+ })
544
+ storageSubmit.value = null
545
+ }
546
+ })
547
+ }
548
+
549
+ const storageIdCash = ref<string | null>(null)
550
+ const vmForm = ref<UI_I_VmForm>({
551
+ name: '',
552
+ compatibility: '',
553
+ guestMachineType: null,
554
+ guestOsFamily: null,
555
+ guestOsVersion: null,
556
+ computeResource: null,
557
+ storage: null,
558
+ locationPath: '',
559
+ dataCenter: null,
560
+ })
561
+
562
+ // TODO remove (not used)
563
+ const vmFormCash = ref<UI_I_VmFormCash>({
564
+ dataCenterId: null,
565
+ computeResourceTypeAndId: null,
566
+ })
567
+
568
+ const onChangeName = (name: string, node: UI_I_TreeNode | null): void => {
569
+ vmForm.value.name = name
570
+ if (isSphere.value) {
571
+ vmForm.value.locationPath = node.id
572
+ vmForm.value.dataCenter = $recursion.findParentByValue(
573
+ node,
574
+ 'datacenter',
575
+ 'type',
576
+ 'parent'
577
+ )
578
+ vmFormCash.value.dataCenterId = vmForm.value.dataCenter?.id || null
579
+ }
580
+ }
581
+ // // Для сферы
582
+ const computeResourcePath = ref<string>('')
583
+ const onSelectComputeResourceTree = (node: UI_I_TreeNode): void => {
584
+ emits('select-compute-resource-tree', node)
585
+ computeResourcePath.value = node.id
586
+ }
587
+ const onChangeComputeResource = (node: UI_I_TreeNode): void => {
588
+ vmForm.value.computeResource = node
589
+ // const type = node.type.toUpperCase()
590
+ // schedRequirementsTemplate.value = `sched_requirements="(${type}_ID=${node.id})"\\`
591
+ vmFormCash.value.computeResourceTypeAndId = `${node.type}${node.id}` || null
592
+ }
593
+ const onChangeStorage = (storage: UI_I_DatastoreTableItem | null): void => {
594
+ if (!storage) return
595
+
596
+ vmForm.value.storage = storage
597
+ storageIdCash.value = storage.id
598
+ }
599
+ const compatibilityInfo = ref<string>('')
600
+ const onChangeCompatibility = (compatibility: UI_I_OptionItem): void => {
601
+ vmForm.value.compatibility = compatibility.value
602
+
603
+ const version = compatibility.value.split('-')[1]
604
+ compatibilityInfo.value = `${localization.value.common.compatibility}: ${compatibility.text} (${localization.value.common.vmVersion} ${version})`
605
+ }
606
+ const customizeHardware = ref<UI_I_SendDataCustomizeHardware | null>(null)
607
+ const onChangeCustomizeHardware = (
608
+ data: UI_I_SendDataCustomizeHardware
609
+ ): void => {
610
+ customizeHardware.value = data
611
+ }
612
+
613
+ const virtualHardwareHardDisksLocal = computed<
614
+ UI_I_SendDataNewHardDisk[] | null
615
+ >(() => customizeHardware.value?.virtualHardware?.hardDisks || null)
616
+ const virtualHardwareNetworksLocal = computed<UI_I_SendDataNewNetwork[] | null>(
617
+ () => customizeHardware.value?.virtualHardware?.networks || null
618
+ )
619
+ const virtualHardwareCdDvdDrivesLocal = computed<
620
+ UI_I_SendDataNewCdDvdDrive[] | null
621
+ >(() => customizeHardware.value?.virtualHardware?.cdDvdDrives || null)
622
+
623
+ const virtualHardwareCpu = computed<UI_I_SendDataCpu | null>(
624
+ () => customizeHardware.value?.virtualHardware?.cpu || null
625
+ )
626
+ const virtualHardwareMemory = computed<UI_I_SendDataMemory | null>(
627
+ () => customizeHardware.value?.virtualHardware?.memory || null
628
+ )
629
+ const virtualHardwareHardDisks = ref<UI_I_SendDataNewHardDisk[] | null>(null)
630
+ const virtualHardwareCdDvdDrives = ref<UI_I_SendDataNewCdDvdDrive[] | null>(
631
+ null
632
+ )
633
+ const virtualHardwareNetworks = ref<UI_I_SendDataNewNetwork[] | null>(null)
634
+ const onChangeBootOrder = (data: UI_T_ChangeBootOrder): void => {
635
+ virtualHardwareHardDisks.value = data[0]
636
+ virtualHardwareCdDvdDrives.value = data[1]
637
+ virtualHardwareNetworks.value = data[2]
638
+ }
639
+
640
+ const isPowerOnByDefault = ref<boolean>(true)
641
+
642
+ watch(
643
+ () => props.vmNameInWizard,
644
+ (newValue) => {
645
+ vmForm.value.name = newValue
646
+ }
647
+ )
648
+
649
+ const validateSendData = async (
650
+ value: UI_I_WizardStep[]
651
+ ): Promise<UI_I_ValidationReturn> => {
652
+ wizard.setLoader(true)
653
+ let stepHasError = false
654
+
655
+ const data = await props.validateSendDataFunc(
656
+ vmForm.value,
657
+ virtualHardwareCpu.value,
658
+ virtualHardwareMemory.value,
659
+ customizeHardware.value,
660
+ virtualHardwareNetworks.value,
661
+ virtualHardwareHardDisks.value,
662
+ virtualHardwareCdDvdDrives.value,
663
+ isPowerOnByDefault.value,
664
+ localization.value,
665
+ vmForm.value.locationPath, // для сферы
666
+ computeResourcePath.value // для сферы
667
+ )
668
+
669
+ wizard.setLoader(false)
670
+ if (data) {
671
+ stepHasError = true
672
+ selectedNavItem.value = data[0]
673
+ data[1] !== null && wizard.selectStepHard(data[1])
674
+ }
675
+
676
+ return {
677
+ stepHasError,
678
+ newValue: value,
679
+ }
680
+ }
681
+ const onFinish = (): void => {
682
+ wizard.setLoader(false)
683
+ props
684
+ .finishFunc(
685
+ vmForm.value,
686
+ virtualHardwareCpu.value,
687
+ virtualHardwareMemory.value,
688
+ customizeHardware.value,
689
+ virtualHardwareNetworks.value,
690
+ virtualHardwareHardDisks.value,
691
+ virtualHardwareCdDvdDrives.value,
692
+ isPowerOnByDefault.value,
693
+ localization.value,
694
+ vmForm.value.locationPath, // для сферы
695
+ computeResourcePath.value, // для сферы
696
+ false
697
+ )
698
+ .then(() => {
699
+ onHideModal()
700
+ wizard.setLoader(false)
701
+ })
702
+ }
703
+
704
+ const selectedNavItem = ref<UI_T_SelectedNavItem>(0)
705
+
706
+ const nameFormSubmit = ref<null | Function>(null)
707
+ const templateSubmit = ref<null | Function>(null)
708
+ const computeResourceSubmit = ref<null | Function>(null)
709
+ const storageSubmit = ref<null | Function>(null)
710
+ const customizeHardwareSubmit = ref<null | Function>(null)
711
+ const compatibility = ref<UI_I_OptionItem[]>(
712
+ capabilities.compatibility.filter((camp) => {
713
+ let result = true
714
+ // if (isDev && camp.value === 'pvm-2') result = false
715
+ if (camp.value === 'pvm-2') result = false
716
+ return result
717
+ })
718
+ )
719
+ const guestOsFamilies = ref<UI_I_OptionItem[]>(capabilities.guestOsFamilies)
720
+ const guestOsVersions = ref<UI_I_ArbitraryObject<UI_I_OptionItem[]>>(
721
+ capabilities.guestOsVersions
722
+ )
723
+ const machineTypes = ref<UI_I_OptionItem[]>(capabilities.machineTypes)
724
+ const cpuModels = ref<UI_I_OptionItem[]>(capabilities.cpuModels)
725
+ const maxCpus = ref<number>(capabilities.maxCpus)
726
+ const maxMemory = ref<number>(capabilities.maxMemory)
727
+
728
+ const selectedTemplate = ref<string>('')
729
+ const onChangeTemplate = (node: UI_I_TreeNode): void => {
730
+ selectedTemplate.value = node.id.toString()
731
+ emits('select-template', node.id.toString())
732
+ }
733
+ const selectedOptions = ref<string[]>([])
734
+ const onChangeSelectOptions = (options: string[]) => {
735
+ selectedOptions.value = options
736
+ if (
737
+ options.includes('customize-os') &&
738
+ options.includes('customize-hardware')
739
+ ) {
740
+ wizard.changeScheme(5)
741
+ } else if (options.includes('customize-os')) {
742
+ wizard.changeScheme(3)
743
+ } else if (options.includes('customize-hardware')) {
744
+ wizard.changeScheme(4)
745
+ } else {
746
+ wizard.changeScheme(2)
747
+ }
748
+
749
+ isPowerOnByDefault.value = options.includes('power-on')
750
+ }
751
+
752
+ const onHideModal = (): void => {
753
+ emits('hide')
754
+ }
755
+
756
+ watch(
757
+ () => props.vmtSettings,
758
+ (newValue) => {
759
+ if (newValue) {
760
+ vmForm.value.name = newValue.name
761
+ vmForm.value.compatibility =
762
+ newValue.compatibility || vmForm.value.compatibility
763
+ vmForm.value.storage = newValue.storage
764
+ if (customizeHardware.value?.virtualHardware) {
765
+ customizeHardware.value.virtualHardware.cdDvdDrives =
766
+ newValue.cdDvdDrives
767
+ customizeHardware.value.virtualHardware.hardDisks = newValue.hardDisks
768
+ customizeHardware.value.virtualHardware.networks = newValue.networks
769
+ customizeHardware.value.virtualHardware.cpu = newValue.cpu
770
+ customizeHardware.value.virtualHardware.memory = newValue.memory
771
+ customizeHardware.value.virtualHardware.videoCard = newValue.videoCard
772
+ customizeHardware.value.virtualHardware.usbController =
773
+ newValue.usbController
774
+ customizeHardware.value.virtualHardware.pciDevices = newValue.pciDevices
775
+ customizeHardware.value.vmOptions = newValue.options
776
+ }
777
+ maxCpus.value = newValue.cpu.max_vcpus
778
+ cpuModels.value = newValue.cpu.model
779
+ isPowerOnByDefault.value = false
780
+ }
781
+ }
782
+ )
783
+ </script>
784
+
785
+ <style scoped lang="scss"></style>