bfg-common 1.3.409 → 1.3.411

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