bfg-common 1.3.373 → 1.3.374

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 (58) hide show
  1. package/components/atoms/loader/Loader.vue +30 -30
  2. package/components/atoms/loader/PreLoader.vue +38 -38
  3. package/components/atoms/switch/Switch.vue +111 -111
  4. package/components/atoms/table/compact/Compact.vue +526 -526
  5. package/components/common/adapterManager/ui/table/Header.vue +93 -93
  6. package/components/common/adapterManager/ui/table/Table.vue +162 -162
  7. package/components/common/context/Context.vue +99 -99
  8. package/components/common/lib/config/states.ts +126 -126
  9. package/components/common/resource/progressBlock/ProgressBlock.vue +142 -142
  10. package/components/common/shortcuts/lib/models/interfaces.ts +1 -1
  11. package/components/common/vm/actions/add/Add.vue +602 -602
  12. package/components/common/vm/actions/clone/Clone.vue +518 -518
  13. package/components/common/vm/actions/common/customizeHardware/CustomizeHardware.vue +273 -273
  14. package/components/common/vm/actions/common/customizeHardware/virtualHardware/VirtualHardware.vue +697 -697
  15. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/CdDvdDrive.vue +256 -256
  16. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/NewHardDisk.vue +458 -458
  17. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/NewNetwork.vue +304 -304
  18. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/NewPciDevice.vue +167 -167
  19. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newUsbController/NewUsbController.vue +82 -82
  20. package/components/common/vm/actions/common/customizeHardware/virtualHardware/other/Other.vue +32 -32
  21. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/VideoCard.vue +182 -182
  22. package/components/common/vm/actions/common/select/computeResource/ComputeResource.vue +164 -164
  23. package/components/common/vm/actions/common/select/name/Name.vue +235 -235
  24. package/components/common/vm/actions/common/select/storage/Storage.vue +198 -198
  25. package/components/common/vm/actions/editSettings/EditSettings.vue +316 -316
  26. package/components/common/weekSelect/lib/config/options.ts +10 -10
  27. package/components/common/wizards/datastore/add/Add.vue +436 -436
  28. package/components/common/wizards/datastore/add/lib/config/stepItems.ts +191 -191
  29. package/components/common/wizards/datastore/add/lib/models/interfaces.ts +38 -38
  30. package/components/common/wizards/datastore/add/lib/utils.ts +70 -70
  31. package/components/common/wizards/datastore/add/local/createName/CreateName.vue +160 -160
  32. package/components/common/wizards/datastore/add/nfs/Nfs.vue +112 -112
  33. package/components/common/wizards/datastore/add/nfs/accessibility/Accessibility.vue +104 -104
  34. package/components/common/wizards/datastore/add/nfs/accessibility/tablesView/lib/config/compatibleTable.ts +62 -62
  35. package/components/common/wizards/datastore/add/nfs/accessibility/tablesView/lib/config/hostsTableItems.ts +53 -53
  36. package/components/common/wizards/datastore/add/readyComplete/ReadyComplete.vue +86 -86
  37. package/components/common/wizards/datastore/add/readyComplete/lib/config/propertiesDetails.ts +184 -184
  38. package/components/common/wizards/datastore/add/sharedStorm/deviceSelection/DeviceSelection.vue +459 -459
  39. package/components/common/wizards/datastore/add/types/Types.vue +80 -80
  40. package/components/common/wizards/datastore/add/types/lib/config/typeOptions.ts +49 -49
  41. package/composables/useAppVersion.ts +21 -21
  42. package/composables/useEnvLanguage.ts +20 -20
  43. package/lib/utils/sendTask.ts +72 -72
  44. package/minify.js +146 -146
  45. package/package.json +1 -1
  46. package/plugins/spice-console/spice.console.ts +147 -18
  47. package/public/spice-console/application/codec.js +257 -257
  48. package/public/spice-console/application/inputmanager.js +1 -1
  49. package/public/spice-console/lib/rasterEngine.js +907 -907
  50. package/public/spice-console/network/spicechannel.js +375 -369
  51. package/public/spice-console/process/mainprocess.js +2 -2
  52. package/public/spice-console-minify/run.min.js +1 -1
  53. package/store/main/lib/interfaces.ts +9 -9
  54. package/store/tasks/actions.ts +133 -133
  55. package/store/tasks/getters.ts +25 -25
  56. package/store/tasks/lib/models/interfaces.ts +18 -18
  57. package/store/tasks/mutations.ts +58 -58
  58. package/store/tasks/state.ts +16 -16
@@ -1,602 +1,602 @@
1
- <template>
2
- <div class="add-vm">
3
- <atoms-wizard
4
- show
5
- :steps="wizard.steps"
6
- :selected-scheme="selectedScheme"
7
- :is-loading="wizard.wizardLoader.status"
8
- :loader-messages="wizard.wizardLoader.messages"
9
- :title="localization.newVirtualMachine2"
10
- :was-completed="wasCompleted"
11
- :localization="localization"
12
- test-id="new-virtual-machine-wizard"
13
- @change-steps="onChangeSteps"
14
- @hide="onHideModal"
15
- @submit="onFinish"
16
- >
17
- <template #modalBody="{ selectedStep }">
18
- <div class="add-vm-content">
19
- <common-vm-actions-common-select-create-type
20
- v-show="selectedStep.id === 0"
21
- :import-from-v-m-warev-sphere="props.importFromVMWarevSphere"
22
- />
23
- <common-vm-actions-common-select-name
24
- v-show="selectedStep.id === 1 || selectedStep.id === 2"
25
- :show="selectedStep.id === 1 || selectedStep.id === 2"
26
- :name-form-submit="nameFormSubmit"
27
- :project="props.project"
28
- :data-center="props.dataCenter"
29
- @submit="onChangeName(...$event)"
30
- @check-name="emits('check-name', $event)"
31
- />
32
- <common-vm-actions-common-select-compute-resource
33
- v-if="isSphere"
34
- v-show="selectedStep.id === 3"
35
- v-model="vmForm.computeResource"
36
- :compute-resource-submit="computeResourceSubmit"
37
- :data-center="vmForm.dataCenter"
38
- :compute-resource="props.computeResource"
39
- :compute-resource-tree="props.computeResourceTree"
40
- @submit="onChangeComputeResource"
41
- @select-compute-resource-tree="onSelectComputeResourceTree"
42
- @get-compute-resource-tree="
43
- emits('get-compute-resource-tree', $event)
44
- "
45
- @show-compute-resource-tree="
46
- emits('show-compute-resource-tree', $event)
47
- "
48
- @clear-compute-resource-tree="
49
- emits('clear-compute-resource-tree', $event)
50
- "
51
- />
52
- <common-vm-actions-common-select-storage
53
- v-show="selectedStep.id === 4"
54
- :storage-submit="storageSubmit"
55
- :datastore="props.datastore"
56
- :get-datastore-table-func="props.getDatastoreTableFunc"
57
- @submit="onChangeStorage"
58
- />
59
- <common-vm-actions-common-select-compatibility
60
- v-show="selectedStep.id === 5"
61
- :options="compatibility"
62
- :error-validation-fields="props.errorValidationFields"
63
- @change="onChangeCompatibility"
64
- @remove-error-by-title="emits('remove-error-by-title', $event)"
65
- />
66
- <common-vm-actions-common-select-os
67
- v-show="selectedStep.id === 6 || selectedStep.id === 7"
68
- :families-options="guestOsFamilies"
69
- :versions-options="guestOsVersions"
70
- :machine-types-options="machineTypes"
71
- :error-validation-fields="props.errorValidationFields"
72
- @change="onChangeOs"
73
- @remove-error-by-title="emits('remove-error-by-title', $event)"
74
- />
75
- <common-vm-actions-common-customize-hardware
76
- v-show="selectedStep.id === 8"
77
- :project="props.project"
78
- :vm-name="vmForm.name"
79
- :guest-machine-type="vmForm.guestMachineType"
80
- :guest-os-family="vmForm.guestOsFamily"
81
- :guest-os-version="vmForm.guestOsVersion"
82
- :storage="vmForm.storage"
83
- :hard-disks-for-boot-options="virtualHardwareHardDisksLocal"
84
- :cd-dvd-drives-for-boot-options="virtualHardwareCdDvdDrivesLocal"
85
- :networks-for-boot-options="virtualHardwareNetworksLocal"
86
- :cd-dvd-drives="virtualHardwareCdDvdDrivesLocal"
87
- :customize-hardware-submit="customizeHardwareSubmit"
88
- :max-cpus="maxCpus"
89
- :max-memory="maxMemory"
90
- :cpu-models="cpuModels"
91
- :selected-nav-item="selectedNavItem"
92
- :nodes="props.nodes"
93
- :files="props.files"
94
- :networks-table="props.networksTable"
95
- :error-validation-fields="props.errorValidationFields"
96
- :get-datastore-table-func="props.getDatastoreTableFunc"
97
- :datastore="props.datastore"
98
- :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
99
- :passthrough-devices="props.passthroughDevices"
100
- @change-boot-order="onChangeBootOrder"
101
- @send-data="onChangeCustomizeHardware"
102
- @get-storage="emits('get-storage', $event)"
103
- @get-folders-or-files="emits('get-folders-or-files', $event)"
104
- @get-active-device-child="emits('get-active-device-child', $event)"
105
- @show-datastore-child="emits('show-datastore-child', $event)"
106
- @remove-error-by-title="emits('remove-error-by-title', $event)"
107
- @get-networks-table="emits('get-networks-table', $event)"
108
- @get-pci-devices="emits('get-pci-devices')"
109
- />
110
- <common-vm-actions-common-ready-to-complete
111
- v-if="selectedStep.id === 9"
112
- :ready-complete-table-info="props.readyCompleteTableInfo"
113
- />
114
- <span v-if="selectedStep.id > 5" class="vm-hardware-version">{{
115
- compatibilityInfo
116
- }}</span>
117
- </div>
118
- </template>
119
-
120
- <template #modalFooterContent>
121
- <div v-if="isShowPowerOn" class="power-on-by-default-wrap">
122
- <input
123
- id="power-on-by-default"
124
- v-model="isPowerOnByDefault"
125
- data-id="power-on-by-default"
126
- type="checkbox"
127
- />
128
- <label for="power-on-by-default" class="label-text-normal">{{
129
- localization.powerOnByDefault
130
- }}</label>
131
- </div>
132
- </template>
133
- </atoms-wizard>
134
- </div>
135
- </template>
136
-
137
- <script setup lang="ts">
138
- import type {
139
- UI_I_Localization,
140
- UI_I_ArbitraryObject,
141
- } from '~/lib/models/interfaces'
142
- import type { UI_T_Project } from '~/lib/models/types'
143
- import type { UI_I_FileTreeNode } from '~/components/lib/models/interfaces'
144
- import type { UI_I_NetworkTableItem } from '~/lib/models/store/network/interfaces'
145
- import type {
146
- UI_I_DatastoreTableItem,
147
- UI_I_FolderOrFileTreePayload,
148
- } from '~/lib/models/store/storage/interfaces'
149
- import type {
150
- API_UI_I_Error,
151
- UI_I_ErrorValidationField,
152
- } from '~/lib/models/store/interfaces'
153
- import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
154
- import type { UI_I_TableInfoItem } from '~/components/atoms/table/info/lib/models/interfaces'
155
- import type {
156
- UI_T_AddVmFinishFunc,
157
- UI_T_SelectedNavItem,
158
- } from '~/components/common/vm/actions/common/lib/models/types'
159
- import type { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
160
- import type {
161
- UI_I_ValidationReturn,
162
- UI_I_WizardStep,
163
- } from '~/components/atoms/wizard/lib/models/interfaces'
164
- import type {
165
- UI_I_VmForm,
166
- UI_I_VmFormCash,
167
- } from '~/components/common/vm/actions/common/lib/models/interfaces'
168
- import type { UI_I_SendDataCustomizeHardware } from '~/components/common/vm/actions/common/customizeHardware/lib/models/interfaces'
169
- import type { UI_I_OsChange } from '~/components/common/vm/actions/common/select/lib/models/interfaces'
170
- import type {
171
- UI_I_SendDataCpu,
172
- UI_I_SendDataMemory,
173
- UI_I_SendDataNewCdDvdDrive,
174
- UI_I_SendDataNewHardDisk,
175
- UI_I_SendDataNewNetwork,
176
- } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
177
- import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
178
- import type { UI_T_ChangeBootOrder } from '~/components/common/vm/actions/lib/models/types'
179
- import type { UI_I_PciDevice } from '~/lib/models/store/vm/interfaces'
180
- import { capabilities } from '~/components/common/vm/actions/common/lib/config/capabilities'
181
- import {
182
- stepsSchemeInitial,
183
- stepsFunc,
184
- } from '~/components/common/vm/actions/add/lib/config/steps'
185
- import Wizard from '~/components/atoms/wizard/lib/utils/utils'
186
-
187
- const props = defineProps<{
188
- project: UI_T_Project
189
- nodes: UI_I_FileTreeNode[]
190
- files: UI_I_FileTreeNode[]
191
- networksTable: UI_I_NetworkTableItem[]
192
- datastore: UI_I_DatastoreTableItem[]
193
- errorValidationFields: UI_I_ErrorValidationField[]
194
- readyCompleteTableInfo: UI_I_TableInfoItem[]
195
- vmCpuHelpTextSecond: string
196
- importFromVMWarevSphere: string
197
- finishFunc: UI_T_AddVmFinishFunc
198
- getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
199
- validateSendDataFunc: UI_T_AddVmFinishFunc<
200
- [UI_T_SelectedNavItem, null | number] | null
201
- >
202
- passthroughDevices: UI_I_PciDevice[]
203
- vmNameInWizard: string
204
- dataCenter?: UI_I_TreeNode // для сферы
205
- computeResource?: UI_I_TreeNode // для сферы
206
- computeResourceTree?: UI_I_TreeNode[] // для сферы
207
- }>()
208
-
209
- const emits = defineEmits<{
210
- (event: 'check-name', value: [string, (error: API_UI_I_Error) => void]): void
211
- (event: 'get-storage', value: UI_I_TablePayload): void
212
- (event: 'get-folders-or-files', value: UI_I_FolderOrFileTreePayload): void
213
- (event: 'get-active-device-child', value: UI_I_FileTreeNode): void
214
- (event: 'show-datastore-child', value: UI_I_FileTreeNode): void
215
- (event: 'remove-error-by-title', value: string): void
216
- (event: 'get-networks-table', value: UI_I_TablePayload): void
217
- (event: 'get-pci-devices'): void
218
- (event: 'get-pci-devices'): void
219
- (event: 'hide'): void
220
- (
221
- event: 'get-compute-resource-tree',
222
- value: { id: string | number; cb: () => void }
223
- ): void // для сферы
224
- (event: 'show-compute-resource-tree', value: UI_I_TreeNode): void // для сферы
225
- (event: 'select-compute-resource-tree', value: UI_I_TreeNode): void // для сферы
226
- (event: 'clear-compute-resource-tree'): void // для сферы
227
- }>()
228
-
229
- const isSphere = computed<boolean>(() => props.project === 'sphere')
230
-
231
- const { $recursion } = useNuxtApp()
232
-
233
- const localization = computed<UI_I_Localization>(() => useLocal())
234
-
235
- const wizard: Wizard = new Wizard(
236
- stepsFunc(localization.value),
237
- stepsSchemeInitial
238
- )
239
- if (isSphere.value) wizard.changeScheme(1)
240
- const wasCompleted = computed<boolean>(() => wizard.wasCompleted())
241
- const selectedScheme = computed<number[]>(() => wizard.selectedScheme.value)
242
- const alertMessages = computed<string[][]>(() => wizard.alertMessages.value)
243
-
244
- const isShowPowerOn = computed<boolean>(() => wizard.selectedStepId > 8)
245
-
246
- const onChangeSteps = async (value: UI_I_WizardStep[]): Promise<void> => {
247
- wizard.changeSteps(value, validationFunc, validateSendData)
248
- }
249
- const validationFunc = async (
250
- value: UI_I_WizardStep[],
251
- currentStep: UI_I_WizardStep,
252
- nextStep: UI_I_WizardStep
253
- ): Promise<UI_I_ValidationReturn> => {
254
- let stepHasError = false
255
- let stepShouldStop = {
256
- ifOnCurrentStep: false,
257
- ifFromAnyStep: false,
258
- stoppageStepId: -1,
259
- }
260
-
261
- wizard.setLoader(true)
262
- if (
263
- wizard.isValidateForStep(
264
- isSphere.value ? 2 : 1,
265
- currentStep.id,
266
- nextStep.id
267
- )
268
- ) {
269
- const nameValidation = await checkName(value)
270
-
271
- value = nameValidation.newValue
272
- stepHasError = stepHasError || nameValidation.stepHasError
273
- } else if (
274
- isSphere.value &&
275
- wizard.isValidateForStep(3, currentStep.id, nextStep.id)
276
- ) {
277
- const computeResourceValidation = await checkComputeResource(value)
278
-
279
- value = computeResourceValidation.newValue
280
- stepHasError = stepHasError || computeResourceValidation.stepHasError
281
- } else if (wizard.isValidateForStep(4, currentStep.id, nextStep.id)) {
282
- const storageValidation = await checkStorage(value)
283
-
284
- value = storageValidation.newValue
285
-
286
- stepHasError = stepHasError || storageValidation.stepHasError
287
- } else if (wizard.isValidateForStep(8, currentStep.id, nextStep.id)) {
288
- const storageValidation = await checkCustomizeHardware(value)
289
-
290
- value = storageValidation.newValue
291
-
292
- stepHasError = stepHasError || storageValidation.stepHasError
293
- }
294
- wizard.setLoader(false)
295
-
296
- return {
297
- newValue: value,
298
- stepHasError,
299
- stepShouldStop,
300
- }
301
- }
302
- const checkName = async (
303
- value: UI_I_WizardStep[]
304
- ): Promise<UI_I_ValidationReturn> => {
305
- let stepHasError = false
306
-
307
- return new Promise((resolve) => {
308
- const step = isSphere.value ? 2 : 1
309
- nameFormSubmit.value = (isValid: boolean) => {
310
- if (!isValid) {
311
- stepHasError = wizard.setValidation(step, 'name', {
312
- fieldMessage: 'aaa',
313
- alertMessage: 'aaa',
314
- })
315
- } else if (wizard.hasMessage(step, 'name')) {
316
- value = wizard.removeValidation(step, 'name', value)
317
- }
318
-
319
- resolve({
320
- stepHasError,
321
- newValue: value,
322
- })
323
- nameFormSubmit.value = null
324
- }
325
- })
326
- }
327
- const checkComputeResource = async (
328
- value: UI_I_WizardStep[]
329
- ): Promise<UI_I_ValidationReturn> => {
330
- let stepHasError = false
331
-
332
- return new Promise((resolve) => {
333
- computeResourceSubmit.value = (isValid: boolean) => {
334
- if (!isValid) {
335
- stepHasError = wizard.setValidation(3, 'computeResource', {
336
- fieldMessage: 'aaa',
337
- alertMessage: 'aaa',
338
- })
339
- } else if (wizard.hasMessage(3, 'computeResource')) {
340
- value = wizard.removeValidation(3, 'computeResource', value)
341
- }
342
-
343
- resolve({
344
- stepHasError,
345
- newValue: value,
346
- })
347
- computeResourceSubmit.value = null
348
- }
349
- })
350
- }
351
- const checkStorage = async (
352
- value: UI_I_WizardStep[]
353
- ): Promise<UI_I_ValidationReturn> => {
354
- let stepHasError = false
355
-
356
- return new Promise((resolve) => {
357
- storageSubmit.value = (isValid: boolean) => {
358
- if (!isValid) {
359
- stepHasError = wizard.setValidation(4, 'storage', {
360
- fieldMessage: 'aaa',
361
- alertMessage: 'aaa',
362
- })
363
- } else if (wizard.hasMessage(4, 'storage')) {
364
- value = wizard.removeValidation(4, 'storage', value)
365
- }
366
-
367
- resolve({
368
- stepHasError,
369
- newValue: value,
370
- })
371
- storageSubmit.value = null
372
- }
373
- })
374
- }
375
- const checkCustomizeHardware = async (
376
- value: UI_I_WizardStep[]
377
- ): Promise<UI_I_ValidationReturn> => {
378
- let stepHasError = false
379
-
380
- return new Promise((resolve) => {
381
- customizeHardwareSubmit.value = (isValid: boolean) => {
382
- if (!isValid) {
383
- stepHasError = wizard.setValidation(8, 'customizeHardware', {
384
- fieldMessage: 'aaa',
385
- alertMessage: 'aaa',
386
- })
387
- } else if (wizard.hasMessage(8, 'customizeHardware')) {
388
- value = wizard.removeValidation(8, 'customizeHardware', value)
389
- }
390
-
391
- resolve({
392
- stepHasError,
393
- newValue: value,
394
- })
395
- storageSubmit.value = null
396
- }
397
- })
398
- }
399
-
400
- const storageIdCash = ref<string | null>(null)
401
- const vmForm = ref<UI_I_VmForm>({
402
- name: '',
403
- compatibility: '',
404
- guestMachineType: null,
405
- guestOsFamily: null,
406
- guestOsVersion: null,
407
- computeResource: null,
408
- storage: null,
409
- locationPath: '',
410
- dataCenter: null,
411
- })
412
- const vmFormCash = ref<UI_I_VmFormCash>({
413
- dataCenterId: null,
414
- computeResourceTypeAndId: null,
415
- })
416
-
417
- const onChangeName = (name: string, node: UI_I_TreeNode): void => {
418
- vmForm.value.name = name
419
- if (isSphere.value) {
420
- vmForm.value.locationPath = node.id
421
- vmForm.value.dataCenter = $recursion.findParentByValue(
422
- node,
423
- 'datacenter',
424
- 'type',
425
- 'parent'
426
- )
427
- vmFormCash.value.dataCenterId = vmForm.value.dataCenter?.id || null
428
- }
429
- }
430
- // // Для сферы
431
- const computeResourcePath = ref<string>('')
432
- const onSelectComputeResourceTree = (node: UI_I_TreeNode): void => {
433
- emits('select-compute-resource-tree', node)
434
- computeResourcePath.value = node.id
435
- }
436
- const onChangeComputeResource = (node: UI_I_TreeNode): void => {
437
- vmForm.value.computeResource = node
438
- // const type = node.type.toUpperCase()
439
- // schedRequirementsTemplate.value = `sched_requirements="(${type}_ID=${node.id})"\\`
440
- vmFormCash.value.computeResourceTypeAndId = `${node.type}${node.id}` || null
441
- }
442
- const onChangeStorage = (storage: UI_I_DatastoreTableItem | null): void => {
443
- if (!storage) return
444
-
445
- vmForm.value.storage = storage
446
- storageIdCash.value = storage.id
447
- }
448
- const compatibilityInfo = ref<string>('')
449
- const onChangeCompatibility = (compatibility: UI_I_OptionItem): void => {
450
- vmForm.value.compatibility = compatibility.value
451
-
452
- const version = compatibility.value.split('-')[1]
453
- compatibilityInfo.value = `${localization.value.compatibility}: ${compatibility.text} (${localization.value.vmVersion} ${version})`
454
- }
455
- const onChangeOs = (data: UI_I_OsChange): void => {
456
- vmForm.value.guestMachineType = data.selectedMachineType
457
- vmForm.value.guestOsFamily = data.selectedOS
458
- vmForm.value.guestOsVersion = data.selectedVersion
459
- }
460
- const customizeHardware = ref<UI_I_SendDataCustomizeHardware | null>(null)
461
- const onChangeCustomizeHardware = (
462
- data: UI_I_SendDataCustomizeHardware
463
- ): void => {
464
- customizeHardware.value = data
465
- }
466
-
467
- const virtualHardwareHardDisksLocal = computed<
468
- UI_I_SendDataNewHardDisk[] | null
469
- >(() => customizeHardware.value?.virtualHardware?.hardDisks || null)
470
- const virtualHardwareNetworksLocal = computed<UI_I_SendDataNewNetwork[] | null>(
471
- () => customizeHardware.value?.virtualHardware?.networks || null
472
- )
473
- const virtualHardwareCdDvdDrivesLocal = computed<
474
- UI_I_SendDataNewCdDvdDrive[] | null
475
- >(() => customizeHardware.value?.virtualHardware?.cdDvdDrives || null)
476
-
477
- const virtualHardwareCpu = computed<UI_I_SendDataCpu | null>(
478
- () => customizeHardware.value?.virtualHardware?.cpu || null
479
- )
480
- const virtualHardwareMemory = computed<UI_I_SendDataMemory | null>(
481
- () => customizeHardware.value?.virtualHardware?.memory || null
482
- )
483
- const virtualHardwareHardDisks = ref<UI_I_SendDataNewHardDisk[] | null>(null)
484
- const virtualHardwareCdDvdDrives = ref<UI_I_SendDataNewCdDvdDrive[] | null>(
485
- null
486
- )
487
- const virtualHardwareNetworks = ref<UI_I_SendDataNewNetwork[] | null>(null)
488
- const onChangeBootOrder = (data: UI_T_ChangeBootOrder): void => {
489
- virtualHardwareHardDisks.value = data[0]
490
- virtualHardwareCdDvdDrives.value = data[1]
491
- virtualHardwareNetworks.value = data[2]
492
- }
493
-
494
- const isPowerOnByDefault = ref<boolean>(true)
495
-
496
- watch(
497
- () => props.vmNameInWizard,
498
- (newValue) => {
499
- vmForm.value.name = newValue
500
- }
501
- )
502
-
503
- const validateSendData = async (
504
- value: UI_I_WizardStep[]
505
- ): Promise<UI_I_ValidationReturn> => {
506
- wizard.setLoader(true)
507
- let stepHasError = false
508
-
509
- const data = await props.validateSendDataFunc(
510
- vmForm.value,
511
- virtualHardwareCpu.value,
512
- virtualHardwareMemory.value,
513
- customizeHardware.value,
514
- virtualHardwareNetworks.value,
515
- virtualHardwareHardDisks.value,
516
- virtualHardwareCdDvdDrives.value,
517
- isPowerOnByDefault.value,
518
- localization.value,
519
- vmForm.value.locationPath, // для сферы
520
- computeResourcePath.value // для сферы
521
- )
522
-
523
- wizard.setLoader(false)
524
- if (data) {
525
- stepHasError = true
526
- selectedNavItem.value = data[0]
527
- data[1] !== null && wizard.selectStepHard(data[1])
528
- }
529
-
530
- return {
531
- stepHasError,
532
- newValue: value,
533
- }
534
- }
535
- const onFinish = (): void => {
536
- wizard.setLoader(false)
537
- props
538
- .finishFunc(
539
- vmForm.value,
540
- virtualHardwareCpu.value,
541
- virtualHardwareMemory.value,
542
- customizeHardware.value,
543
- virtualHardwareNetworks.value,
544
- virtualHardwareHardDisks.value,
545
- virtualHardwareCdDvdDrives.value,
546
- isPowerOnByDefault.value,
547
- localization.value,
548
- vmForm.value.locationPath, // для сферы
549
- computeResourcePath.value, // для сферы
550
- false
551
- )
552
- .then(() => {
553
- onHideModal()
554
- wizard.setLoader(false)
555
- })
556
- }
557
-
558
- const selectedNavItem = ref<UI_T_SelectedNavItem>(0)
559
-
560
- const nameFormSubmit = ref<null | Function>(null)
561
- const computeResourceSubmit = ref<null | Function>(null)
562
- const storageSubmit = ref<null | Function>(null)
563
- const customizeHardwareSubmit = ref<null | Function>(null)
564
- const compatibility = ref<UI_I_OptionItem[]>(capabilities.compatibility)
565
- const guestOsFamilies = ref<UI_I_OptionItem[]>(capabilities.guestOsFamilies)
566
- const guestOsVersions = ref<UI_I_ArbitraryObject<UI_I_OptionItem[]>>(
567
- capabilities.guestOsVersions
568
- )
569
- const machineTypes = ref<UI_I_OptionItem[]>(capabilities.machineTypes)
570
- const cpuModels = ref<UI_I_OptionItem[]>(capabilities.cpuModels)
571
- const maxCpus = ref<number>(capabilities.maxCpus)
572
- const maxMemory = ref<number>(capabilities.maxMemory)
573
-
574
- const onHideModal = (): void => {
575
- emits('hide')
576
- }
577
- </script>
578
-
579
- <style scoped lang="scss">
580
- :deep(.modal-body) {
581
- display: flex;
582
- flex-direction: column;
583
- }
584
- .add-vm-content {
585
- display: flex;
586
- flex-direction: column;
587
- flex: 1;
588
- }
589
- .vm-hardware-version {
590
- align-self: flex-end;
591
- margin-top: auto;
592
- }
593
- .power-on-by-default-wrap {
594
- display: flex;
595
- align-items: center;
596
- margin-right: auto;
597
-
598
- input {
599
- margin-right: 6px;
600
- }
601
- }
602
- </style>
1
+ <template>
2
+ <div class="add-vm">
3
+ <atoms-wizard
4
+ show
5
+ :steps="wizard.steps"
6
+ :selected-scheme="selectedScheme"
7
+ :is-loading="wizard.wizardLoader.status"
8
+ :loader-messages="wizard.wizardLoader.messages"
9
+ :title="localization.newVirtualMachine2"
10
+ :was-completed="wasCompleted"
11
+ :localization="localization"
12
+ test-id="new-virtual-machine-wizard"
13
+ @change-steps="onChangeSteps"
14
+ @hide="onHideModal"
15
+ @submit="onFinish"
16
+ >
17
+ <template #modalBody="{ selectedStep }">
18
+ <div class="add-vm-content">
19
+ <common-vm-actions-common-select-create-type
20
+ v-show="selectedStep.id === 0"
21
+ :import-from-v-m-warev-sphere="props.importFromVMWarevSphere"
22
+ />
23
+ <common-vm-actions-common-select-name
24
+ v-show="selectedStep.id === 1 || selectedStep.id === 2"
25
+ :show="selectedStep.id === 1 || selectedStep.id === 2"
26
+ :name-form-submit="nameFormSubmit"
27
+ :project="props.project"
28
+ :data-center="props.dataCenter"
29
+ @submit="onChangeName(...$event)"
30
+ @check-name="emits('check-name', $event)"
31
+ />
32
+ <common-vm-actions-common-select-compute-resource
33
+ v-if="isSphere"
34
+ v-show="selectedStep.id === 3"
35
+ v-model="vmForm.computeResource"
36
+ :compute-resource-submit="computeResourceSubmit"
37
+ :data-center="vmForm.dataCenter"
38
+ :compute-resource="props.computeResource"
39
+ :compute-resource-tree="props.computeResourceTree"
40
+ @submit="onChangeComputeResource"
41
+ @select-compute-resource-tree="onSelectComputeResourceTree"
42
+ @get-compute-resource-tree="
43
+ emits('get-compute-resource-tree', $event)
44
+ "
45
+ @show-compute-resource-tree="
46
+ emits('show-compute-resource-tree', $event)
47
+ "
48
+ @clear-compute-resource-tree="
49
+ emits('clear-compute-resource-tree', $event)
50
+ "
51
+ />
52
+ <common-vm-actions-common-select-storage
53
+ v-show="selectedStep.id === 4"
54
+ :storage-submit="storageSubmit"
55
+ :datastore="props.datastore"
56
+ :get-datastore-table-func="props.getDatastoreTableFunc"
57
+ @submit="onChangeStorage"
58
+ />
59
+ <common-vm-actions-common-select-compatibility
60
+ v-show="selectedStep.id === 5"
61
+ :options="compatibility"
62
+ :error-validation-fields="props.errorValidationFields"
63
+ @change="onChangeCompatibility"
64
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
65
+ />
66
+ <common-vm-actions-common-select-os
67
+ v-show="selectedStep.id === 6 || selectedStep.id === 7"
68
+ :families-options="guestOsFamilies"
69
+ :versions-options="guestOsVersions"
70
+ :machine-types-options="machineTypes"
71
+ :error-validation-fields="props.errorValidationFields"
72
+ @change="onChangeOs"
73
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
74
+ />
75
+ <common-vm-actions-common-customize-hardware
76
+ v-show="selectedStep.id === 8"
77
+ :project="props.project"
78
+ :vm-name="vmForm.name"
79
+ :guest-machine-type="vmForm.guestMachineType"
80
+ :guest-os-family="vmForm.guestOsFamily"
81
+ :guest-os-version="vmForm.guestOsVersion"
82
+ :storage="vmForm.storage"
83
+ :hard-disks-for-boot-options="virtualHardwareHardDisksLocal"
84
+ :cd-dvd-drives-for-boot-options="virtualHardwareCdDvdDrivesLocal"
85
+ :networks-for-boot-options="virtualHardwareNetworksLocal"
86
+ :cd-dvd-drives="virtualHardwareCdDvdDrivesLocal"
87
+ :customize-hardware-submit="customizeHardwareSubmit"
88
+ :max-cpus="maxCpus"
89
+ :max-memory="maxMemory"
90
+ :cpu-models="cpuModels"
91
+ :selected-nav-item="selectedNavItem"
92
+ :nodes="props.nodes"
93
+ :files="props.files"
94
+ :networks-table="props.networksTable"
95
+ :error-validation-fields="props.errorValidationFields"
96
+ :get-datastore-table-func="props.getDatastoreTableFunc"
97
+ :datastore="props.datastore"
98
+ :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
99
+ :passthrough-devices="props.passthroughDevices"
100
+ @change-boot-order="onChangeBootOrder"
101
+ @send-data="onChangeCustomizeHardware"
102
+ @get-storage="emits('get-storage', $event)"
103
+ @get-folders-or-files="emits('get-folders-or-files', $event)"
104
+ @get-active-device-child="emits('get-active-device-child', $event)"
105
+ @show-datastore-child="emits('show-datastore-child', $event)"
106
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
107
+ @get-networks-table="emits('get-networks-table', $event)"
108
+ @get-pci-devices="emits('get-pci-devices')"
109
+ />
110
+ <common-vm-actions-common-ready-to-complete
111
+ v-if="selectedStep.id === 9"
112
+ :ready-complete-table-info="props.readyCompleteTableInfo"
113
+ />
114
+ <span v-if="selectedStep.id > 5" class="vm-hardware-version">{{
115
+ compatibilityInfo
116
+ }}</span>
117
+ </div>
118
+ </template>
119
+
120
+ <template #modalFooterContent>
121
+ <div v-if="isShowPowerOn" class="power-on-by-default-wrap">
122
+ <input
123
+ id="power-on-by-default"
124
+ v-model="isPowerOnByDefault"
125
+ data-id="power-on-by-default"
126
+ type="checkbox"
127
+ />
128
+ <label for="power-on-by-default" class="label-text-normal">{{
129
+ localization.powerOnByDefault
130
+ }}</label>
131
+ </div>
132
+ </template>
133
+ </atoms-wizard>
134
+ </div>
135
+ </template>
136
+
137
+ <script setup lang="ts">
138
+ import type {
139
+ UI_I_Localization,
140
+ UI_I_ArbitraryObject,
141
+ } from '~/lib/models/interfaces'
142
+ import type { UI_T_Project } from '~/lib/models/types'
143
+ import type { UI_I_FileTreeNode } from '~/components/lib/models/interfaces'
144
+ import type { UI_I_NetworkTableItem } from '~/lib/models/store/network/interfaces'
145
+ import type {
146
+ UI_I_DatastoreTableItem,
147
+ UI_I_FolderOrFileTreePayload,
148
+ } from '~/lib/models/store/storage/interfaces'
149
+ import type {
150
+ API_UI_I_Error,
151
+ UI_I_ErrorValidationField,
152
+ } from '~/lib/models/store/interfaces'
153
+ import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
154
+ import type { UI_I_TableInfoItem } from '~/components/atoms/table/info/lib/models/interfaces'
155
+ import type {
156
+ UI_T_AddVmFinishFunc,
157
+ UI_T_SelectedNavItem,
158
+ } from '~/components/common/vm/actions/common/lib/models/types'
159
+ import type { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
160
+ import type {
161
+ UI_I_ValidationReturn,
162
+ UI_I_WizardStep,
163
+ } from '~/components/atoms/wizard/lib/models/interfaces'
164
+ import type {
165
+ UI_I_VmForm,
166
+ UI_I_VmFormCash,
167
+ } from '~/components/common/vm/actions/common/lib/models/interfaces'
168
+ import type { UI_I_SendDataCustomizeHardware } from '~/components/common/vm/actions/common/customizeHardware/lib/models/interfaces'
169
+ import type { UI_I_OsChange } from '~/components/common/vm/actions/common/select/lib/models/interfaces'
170
+ import type {
171
+ UI_I_SendDataCpu,
172
+ UI_I_SendDataMemory,
173
+ UI_I_SendDataNewCdDvdDrive,
174
+ UI_I_SendDataNewHardDisk,
175
+ UI_I_SendDataNewNetwork,
176
+ } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
177
+ import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
178
+ import type { UI_T_ChangeBootOrder } from '~/components/common/vm/actions/lib/models/types'
179
+ import type { UI_I_PciDevice } from '~/lib/models/store/vm/interfaces'
180
+ import { capabilities } from '~/components/common/vm/actions/common/lib/config/capabilities'
181
+ import {
182
+ stepsSchemeInitial,
183
+ stepsFunc,
184
+ } from '~/components/common/vm/actions/add/lib/config/steps'
185
+ import Wizard from '~/components/atoms/wizard/lib/utils/utils'
186
+
187
+ const props = defineProps<{
188
+ project: UI_T_Project
189
+ nodes: UI_I_FileTreeNode[]
190
+ files: UI_I_FileTreeNode[]
191
+ networksTable: UI_I_NetworkTableItem[]
192
+ datastore: UI_I_DatastoreTableItem[]
193
+ errorValidationFields: UI_I_ErrorValidationField[]
194
+ readyCompleteTableInfo: UI_I_TableInfoItem[]
195
+ vmCpuHelpTextSecond: string
196
+ importFromVMWarevSphere: string
197
+ finishFunc: UI_T_AddVmFinishFunc
198
+ getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
199
+ validateSendDataFunc: UI_T_AddVmFinishFunc<
200
+ [UI_T_SelectedNavItem, null | number] | null
201
+ >
202
+ passthroughDevices: UI_I_PciDevice[]
203
+ vmNameInWizard: string
204
+ dataCenter?: UI_I_TreeNode // для сферы
205
+ computeResource?: UI_I_TreeNode // для сферы
206
+ computeResourceTree?: UI_I_TreeNode[] // для сферы
207
+ }>()
208
+
209
+ const emits = defineEmits<{
210
+ (event: 'check-name', value: [string, (error: API_UI_I_Error) => void]): void
211
+ (event: 'get-storage', value: UI_I_TablePayload): void
212
+ (event: 'get-folders-or-files', value: UI_I_FolderOrFileTreePayload): void
213
+ (event: 'get-active-device-child', value: UI_I_FileTreeNode): void
214
+ (event: 'show-datastore-child', value: UI_I_FileTreeNode): void
215
+ (event: 'remove-error-by-title', value: string): void
216
+ (event: 'get-networks-table', value: UI_I_TablePayload): void
217
+ (event: 'get-pci-devices'): void
218
+ (event: 'get-pci-devices'): void
219
+ (event: 'hide'): void
220
+ (
221
+ event: 'get-compute-resource-tree',
222
+ value: { id: string | number; cb: () => void }
223
+ ): void // для сферы
224
+ (event: 'show-compute-resource-tree', value: UI_I_TreeNode): void // для сферы
225
+ (event: 'select-compute-resource-tree', value: UI_I_TreeNode): void // для сферы
226
+ (event: 'clear-compute-resource-tree'): void // для сферы
227
+ }>()
228
+
229
+ const isSphere = computed<boolean>(() => props.project === 'sphere')
230
+
231
+ const { $recursion } = useNuxtApp()
232
+
233
+ const localization = computed<UI_I_Localization>(() => useLocal())
234
+
235
+ const wizard: Wizard = new Wizard(
236
+ stepsFunc(localization.value),
237
+ stepsSchemeInitial
238
+ )
239
+ if (isSphere.value) wizard.changeScheme(1)
240
+ const wasCompleted = computed<boolean>(() => wizard.wasCompleted())
241
+ const selectedScheme = computed<number[]>(() => wizard.selectedScheme.value)
242
+ const alertMessages = computed<string[][]>(() => wizard.alertMessages.value)
243
+
244
+ const isShowPowerOn = computed<boolean>(() => wizard.selectedStepId > 8)
245
+
246
+ const onChangeSteps = async (value: UI_I_WizardStep[]): Promise<void> => {
247
+ wizard.changeSteps(value, validationFunc, validateSendData)
248
+ }
249
+ const validationFunc = async (
250
+ value: UI_I_WizardStep[],
251
+ currentStep: UI_I_WizardStep,
252
+ nextStep: UI_I_WizardStep
253
+ ): Promise<UI_I_ValidationReturn> => {
254
+ let stepHasError = false
255
+ let stepShouldStop = {
256
+ ifOnCurrentStep: false,
257
+ ifFromAnyStep: false,
258
+ stoppageStepId: -1,
259
+ }
260
+
261
+ wizard.setLoader(true)
262
+ if (
263
+ wizard.isValidateForStep(
264
+ isSphere.value ? 2 : 1,
265
+ currentStep.id,
266
+ nextStep.id
267
+ )
268
+ ) {
269
+ const nameValidation = await checkName(value)
270
+
271
+ value = nameValidation.newValue
272
+ stepHasError = stepHasError || nameValidation.stepHasError
273
+ } else if (
274
+ isSphere.value &&
275
+ wizard.isValidateForStep(3, currentStep.id, nextStep.id)
276
+ ) {
277
+ const computeResourceValidation = await checkComputeResource(value)
278
+
279
+ value = computeResourceValidation.newValue
280
+ stepHasError = stepHasError || computeResourceValidation.stepHasError
281
+ } else if (wizard.isValidateForStep(4, currentStep.id, nextStep.id)) {
282
+ const storageValidation = await checkStorage(value)
283
+
284
+ value = storageValidation.newValue
285
+
286
+ stepHasError = stepHasError || storageValidation.stepHasError
287
+ } else if (wizard.isValidateForStep(8, currentStep.id, nextStep.id)) {
288
+ const storageValidation = await checkCustomizeHardware(value)
289
+
290
+ value = storageValidation.newValue
291
+
292
+ stepHasError = stepHasError || storageValidation.stepHasError
293
+ }
294
+ wizard.setLoader(false)
295
+
296
+ return {
297
+ newValue: value,
298
+ stepHasError,
299
+ stepShouldStop,
300
+ }
301
+ }
302
+ const checkName = async (
303
+ value: UI_I_WizardStep[]
304
+ ): Promise<UI_I_ValidationReturn> => {
305
+ let stepHasError = false
306
+
307
+ return new Promise((resolve) => {
308
+ const step = isSphere.value ? 2 : 1
309
+ nameFormSubmit.value = (isValid: boolean) => {
310
+ if (!isValid) {
311
+ stepHasError = wizard.setValidation(step, 'name', {
312
+ fieldMessage: 'aaa',
313
+ alertMessage: 'aaa',
314
+ })
315
+ } else if (wizard.hasMessage(step, 'name')) {
316
+ value = wizard.removeValidation(step, 'name', value)
317
+ }
318
+
319
+ resolve({
320
+ stepHasError,
321
+ newValue: value,
322
+ })
323
+ nameFormSubmit.value = null
324
+ }
325
+ })
326
+ }
327
+ const checkComputeResource = async (
328
+ value: UI_I_WizardStep[]
329
+ ): Promise<UI_I_ValidationReturn> => {
330
+ let stepHasError = false
331
+
332
+ return new Promise((resolve) => {
333
+ computeResourceSubmit.value = (isValid: boolean) => {
334
+ if (!isValid) {
335
+ stepHasError = wizard.setValidation(3, 'computeResource', {
336
+ fieldMessage: 'aaa',
337
+ alertMessage: 'aaa',
338
+ })
339
+ } else if (wizard.hasMessage(3, 'computeResource')) {
340
+ value = wizard.removeValidation(3, 'computeResource', value)
341
+ }
342
+
343
+ resolve({
344
+ stepHasError,
345
+ newValue: value,
346
+ })
347
+ computeResourceSubmit.value = null
348
+ }
349
+ })
350
+ }
351
+ const checkStorage = async (
352
+ value: UI_I_WizardStep[]
353
+ ): Promise<UI_I_ValidationReturn> => {
354
+ let stepHasError = false
355
+
356
+ return new Promise((resolve) => {
357
+ storageSubmit.value = (isValid: boolean) => {
358
+ if (!isValid) {
359
+ stepHasError = wizard.setValidation(4, 'storage', {
360
+ fieldMessage: 'aaa',
361
+ alertMessage: 'aaa',
362
+ })
363
+ } else if (wizard.hasMessage(4, 'storage')) {
364
+ value = wizard.removeValidation(4, 'storage', value)
365
+ }
366
+
367
+ resolve({
368
+ stepHasError,
369
+ newValue: value,
370
+ })
371
+ storageSubmit.value = null
372
+ }
373
+ })
374
+ }
375
+ const checkCustomizeHardware = async (
376
+ value: UI_I_WizardStep[]
377
+ ): Promise<UI_I_ValidationReturn> => {
378
+ let stepHasError = false
379
+
380
+ return new Promise((resolve) => {
381
+ customizeHardwareSubmit.value = (isValid: boolean) => {
382
+ if (!isValid) {
383
+ stepHasError = wizard.setValidation(8, 'customizeHardware', {
384
+ fieldMessage: 'aaa',
385
+ alertMessage: 'aaa',
386
+ })
387
+ } else if (wizard.hasMessage(8, 'customizeHardware')) {
388
+ value = wizard.removeValidation(8, 'customizeHardware', value)
389
+ }
390
+
391
+ resolve({
392
+ stepHasError,
393
+ newValue: value,
394
+ })
395
+ storageSubmit.value = null
396
+ }
397
+ })
398
+ }
399
+
400
+ const storageIdCash = ref<string | null>(null)
401
+ const vmForm = ref<UI_I_VmForm>({
402
+ name: '',
403
+ compatibility: '',
404
+ guestMachineType: null,
405
+ guestOsFamily: null,
406
+ guestOsVersion: null,
407
+ computeResource: null,
408
+ storage: null,
409
+ locationPath: '',
410
+ dataCenter: null,
411
+ })
412
+ const vmFormCash = ref<UI_I_VmFormCash>({
413
+ dataCenterId: null,
414
+ computeResourceTypeAndId: null,
415
+ })
416
+
417
+ const onChangeName = (name: string, node: UI_I_TreeNode): void => {
418
+ vmForm.value.name = name
419
+ if (isSphere.value) {
420
+ vmForm.value.locationPath = node.id
421
+ vmForm.value.dataCenter = $recursion.findParentByValue(
422
+ node,
423
+ 'datacenter',
424
+ 'type',
425
+ 'parent'
426
+ )
427
+ vmFormCash.value.dataCenterId = vmForm.value.dataCenter?.id || null
428
+ }
429
+ }
430
+ // // Для сферы
431
+ const computeResourcePath = ref<string>('')
432
+ const onSelectComputeResourceTree = (node: UI_I_TreeNode): void => {
433
+ emits('select-compute-resource-tree', node)
434
+ computeResourcePath.value = node.id
435
+ }
436
+ const onChangeComputeResource = (node: UI_I_TreeNode): void => {
437
+ vmForm.value.computeResource = node
438
+ // const type = node.type.toUpperCase()
439
+ // schedRequirementsTemplate.value = `sched_requirements="(${type}_ID=${node.id})"\\`
440
+ vmFormCash.value.computeResourceTypeAndId = `${node.type}${node.id}` || null
441
+ }
442
+ const onChangeStorage = (storage: UI_I_DatastoreTableItem | null): void => {
443
+ if (!storage) return
444
+
445
+ vmForm.value.storage = storage
446
+ storageIdCash.value = storage.id
447
+ }
448
+ const compatibilityInfo = ref<string>('')
449
+ const onChangeCompatibility = (compatibility: UI_I_OptionItem): void => {
450
+ vmForm.value.compatibility = compatibility.value
451
+
452
+ const version = compatibility.value.split('-')[1]
453
+ compatibilityInfo.value = `${localization.value.compatibility}: ${compatibility.text} (${localization.value.vmVersion} ${version})`
454
+ }
455
+ const onChangeOs = (data: UI_I_OsChange): void => {
456
+ vmForm.value.guestMachineType = data.selectedMachineType
457
+ vmForm.value.guestOsFamily = data.selectedOS
458
+ vmForm.value.guestOsVersion = data.selectedVersion
459
+ }
460
+ const customizeHardware = ref<UI_I_SendDataCustomizeHardware | null>(null)
461
+ const onChangeCustomizeHardware = (
462
+ data: UI_I_SendDataCustomizeHardware
463
+ ): void => {
464
+ customizeHardware.value = data
465
+ }
466
+
467
+ const virtualHardwareHardDisksLocal = computed<
468
+ UI_I_SendDataNewHardDisk[] | null
469
+ >(() => customizeHardware.value?.virtualHardware?.hardDisks || null)
470
+ const virtualHardwareNetworksLocal = computed<UI_I_SendDataNewNetwork[] | null>(
471
+ () => customizeHardware.value?.virtualHardware?.networks || null
472
+ )
473
+ const virtualHardwareCdDvdDrivesLocal = computed<
474
+ UI_I_SendDataNewCdDvdDrive[] | null
475
+ >(() => customizeHardware.value?.virtualHardware?.cdDvdDrives || null)
476
+
477
+ const virtualHardwareCpu = computed<UI_I_SendDataCpu | null>(
478
+ () => customizeHardware.value?.virtualHardware?.cpu || null
479
+ )
480
+ const virtualHardwareMemory = computed<UI_I_SendDataMemory | null>(
481
+ () => customizeHardware.value?.virtualHardware?.memory || null
482
+ )
483
+ const virtualHardwareHardDisks = ref<UI_I_SendDataNewHardDisk[] | null>(null)
484
+ const virtualHardwareCdDvdDrives = ref<UI_I_SendDataNewCdDvdDrive[] | null>(
485
+ null
486
+ )
487
+ const virtualHardwareNetworks = ref<UI_I_SendDataNewNetwork[] | null>(null)
488
+ const onChangeBootOrder = (data: UI_T_ChangeBootOrder): void => {
489
+ virtualHardwareHardDisks.value = data[0]
490
+ virtualHardwareCdDvdDrives.value = data[1]
491
+ virtualHardwareNetworks.value = data[2]
492
+ }
493
+
494
+ const isPowerOnByDefault = ref<boolean>(true)
495
+
496
+ watch(
497
+ () => props.vmNameInWizard,
498
+ (newValue) => {
499
+ vmForm.value.name = newValue
500
+ }
501
+ )
502
+
503
+ const validateSendData = async (
504
+ value: UI_I_WizardStep[]
505
+ ): Promise<UI_I_ValidationReturn> => {
506
+ wizard.setLoader(true)
507
+ let stepHasError = false
508
+
509
+ const data = await props.validateSendDataFunc(
510
+ vmForm.value,
511
+ virtualHardwareCpu.value,
512
+ virtualHardwareMemory.value,
513
+ customizeHardware.value,
514
+ virtualHardwareNetworks.value,
515
+ virtualHardwareHardDisks.value,
516
+ virtualHardwareCdDvdDrives.value,
517
+ isPowerOnByDefault.value,
518
+ localization.value,
519
+ vmForm.value.locationPath, // для сферы
520
+ computeResourcePath.value // для сферы
521
+ )
522
+
523
+ wizard.setLoader(false)
524
+ if (data) {
525
+ stepHasError = true
526
+ selectedNavItem.value = data[0]
527
+ data[1] !== null && wizard.selectStepHard(data[1])
528
+ }
529
+
530
+ return {
531
+ stepHasError,
532
+ newValue: value,
533
+ }
534
+ }
535
+ const onFinish = (): void => {
536
+ wizard.setLoader(false)
537
+ props
538
+ .finishFunc(
539
+ vmForm.value,
540
+ virtualHardwareCpu.value,
541
+ virtualHardwareMemory.value,
542
+ customizeHardware.value,
543
+ virtualHardwareNetworks.value,
544
+ virtualHardwareHardDisks.value,
545
+ virtualHardwareCdDvdDrives.value,
546
+ isPowerOnByDefault.value,
547
+ localization.value,
548
+ vmForm.value.locationPath, // для сферы
549
+ computeResourcePath.value, // для сферы
550
+ false
551
+ )
552
+ .then(() => {
553
+ onHideModal()
554
+ wizard.setLoader(false)
555
+ })
556
+ }
557
+
558
+ const selectedNavItem = ref<UI_T_SelectedNavItem>(0)
559
+
560
+ const nameFormSubmit = ref<null | Function>(null)
561
+ const computeResourceSubmit = ref<null | Function>(null)
562
+ const storageSubmit = ref<null | Function>(null)
563
+ const customizeHardwareSubmit = ref<null | Function>(null)
564
+ const compatibility = ref<UI_I_OptionItem[]>(capabilities.compatibility)
565
+ const guestOsFamilies = ref<UI_I_OptionItem[]>(capabilities.guestOsFamilies)
566
+ const guestOsVersions = ref<UI_I_ArbitraryObject<UI_I_OptionItem[]>>(
567
+ capabilities.guestOsVersions
568
+ )
569
+ const machineTypes = ref<UI_I_OptionItem[]>(capabilities.machineTypes)
570
+ const cpuModels = ref<UI_I_OptionItem[]>(capabilities.cpuModels)
571
+ const maxCpus = ref<number>(capabilities.maxCpus)
572
+ const maxMemory = ref<number>(capabilities.maxMemory)
573
+
574
+ const onHideModal = (): void => {
575
+ emits('hide')
576
+ }
577
+ </script>
578
+
579
+ <style scoped lang="scss">
580
+ :deep(.modal-body) {
581
+ display: flex;
582
+ flex-direction: column;
583
+ }
584
+ .add-vm-content {
585
+ display: flex;
586
+ flex-direction: column;
587
+ flex: 1;
588
+ }
589
+ .vm-hardware-version {
590
+ align-self: flex-end;
591
+ margin-top: auto;
592
+ }
593
+ .power-on-by-default-wrap {
594
+ display: flex;
595
+ align-items: center;
596
+ margin-right: auto;
597
+
598
+ input {
599
+ margin-right: 6px;
600
+ }
601
+ }
602
+ </style>