bfg-common 1.5.541 → 1.5.543

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 (116) hide show
  1. package/CODE_STYLE.md +109 -109
  2. package/assets/img/icons/icons-sprite-dark-3.svg +227 -227
  3. package/assets/img/icons/icons-sprite-dark-5.svg +488 -488
  4. package/assets/img/icons/icons-sprite-light-3.svg +227 -227
  5. package/assets/img/icons/icons-sprite-light-5.svg +488 -488
  6. package/components/atoms/TheIcon3.vue +50 -50
  7. package/components/atoms/collapse/CollapseNav.vue +170 -170
  8. package/components/atoms/perPage/PerPage.vue +58 -58
  9. package/components/atoms/table/dataGrid/DataGrid.vue +1718 -1718
  10. package/components/atoms/table/dataGrid/DataGridPagination.vue +97 -97
  11. package/components/atoms/table/dataGrid/lib/config/settingsTable.ts +94 -94
  12. package/components/atoms/table/dataGrid/lib/utils/export.ts +16 -16
  13. package/components/common/backup/storage/actions/add/Add.vue +251 -251
  14. package/components/common/backup/storage/actions/add/lib/utils.ts +51 -51
  15. package/components/common/browse/blocks/contents/filesNew/Skeleton.vue +18 -18
  16. package/components/common/diagramMain/modals/lib/config/portModal.ts +251 -251
  17. package/components/common/diagramMain/modals/lib/config/vCenterModal.ts +48 -48
  18. package/components/common/diagramMain/port/Port.vue +580 -580
  19. package/components/common/layout/theHeader/helpMenu/About.vue +79 -79
  20. package/components/common/layout/theHeader/helpMenu/aboutOld/AboutOld.vue +79 -79
  21. package/components/common/pages/backups/DetailView.vue +52 -52
  22. package/components/common/pages/backups/lib/models/interfaces.ts +36 -36
  23. package/components/common/pages/backups/modals/Modals.vue +243 -243
  24. package/components/common/pages/backups/modals/createBackup/New.vue +8 -2
  25. package/components/common/pages/backups/modals/createBackup/configuration/maxBandwidth/lib/config/options.ts +6 -6
  26. package/components/common/pages/backups/modals/createBackup/lib/config/readyToCompleteOptions.ts +69 -69
  27. package/components/common/pages/backups/modals/lib/config/restore.ts +115 -115
  28. package/components/common/pages/backups/modals/lib/models/interfaces.ts +186 -186
  29. package/components/common/pages/backups/modals/restore/Restore.vue +5 -4
  30. package/components/common/pages/backups/modals/restore/name/lib/models/interfaces.ts +6 -6
  31. package/components/common/pages/home/lib/models/interfaces.ts +48 -48
  32. package/components/common/pages/home/widgets/hosts/Hosts.vue +27 -27
  33. package/components/common/pages/home/widgets/hosts/lib/config/items.ts +23 -23
  34. package/components/common/pages/home/widgets/vms/VmsOld.vue +35 -35
  35. package/components/common/pages/home/widgets/vms/lib/config/items.ts +19 -19
  36. package/components/common/pages/scheduledTasks/lib/utils/utils.ts +84 -84
  37. package/components/common/readyToComplete/ReadyToComplete.vue +17 -17
  38. package/components/common/select/radio/RadioGroup.vue +137 -137
  39. package/components/common/spiceConsole/Drawer.vue +420 -420
  40. package/components/common/spiceConsole/SpiceConsole.vue +184 -184
  41. package/components/common/spiceConsole/lib/models/interfaces.ts +5 -5
  42. package/components/common/tools/Actions.vue +207 -207
  43. package/components/common/treeView/TreeView.vue +52 -52
  44. package/components/common/vm/actions/add/Add.vue +950 -950
  45. package/components/common/vm/actions/add/New.vue +690 -690
  46. package/components/common/vm/actions/add/Old.vue +402 -402
  47. package/components/common/vm/actions/add/lib/config/steps.ts +347 -347
  48. package/components/common/vm/actions/clone/Clone.vue +809 -809
  49. package/components/common/vm/actions/clone/new/New.vue +457 -457
  50. package/components/common/vm/actions/clone/old/Old.vue +378 -378
  51. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/Cpu.vue +368 -368
  52. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/shares/Shares.vue +140 -140
  53. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/shares/lib/config/options.ts +28 -28
  54. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/NewHardDisk.vue +427 -427
  55. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/location/Location.vue +154 -154
  56. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/macAddress/MacAddress.vue +119 -119
  57. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/dynamicDirectPathIo/DynamicDirectPathIo.vue +31 -31
  58. package/components/common/vm/actions/common/customizeHardware/virtualHardware/other/Other.vue +16 -16
  59. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/numberDisplays/NumberDisplays.vue +53 -53
  60. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/delay/Delay.vue +32 -32
  61. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/firmware/Firmware.vue +60 -60
  62. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/Order.vue +174 -174
  63. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/keymap/Keymap.vue +32 -32
  64. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/password/Password.vue +103 -103
  65. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/usbRedirection/UsbRedirection.vue +28 -28
  66. package/components/common/vm/actions/common/select/compatibility/Old.vue +107 -107
  67. package/components/common/vm/actions/common/select/createType/CreateType.vue +38 -38
  68. package/components/common/vm/actions/common/select/createType/lib/models/interfaces.ts +5 -5
  69. package/components/common/vm/actions/common/select/os/Old.vue +152 -152
  70. package/components/common/vm/actions/common/select/os/Os.vue +139 -139
  71. package/components/common/vm/actions/common/select/storage/Old.vue +125 -125
  72. package/components/common/vm/actions/common/select/storage/Storage.vue +178 -178
  73. package/components/common/vm/actions/common/select/storage/new/New.vue +311 -311
  74. package/components/common/vm/actions/common/select/storage/new/lib/models/interfaces.ts +5 -5
  75. package/components/common/vm/actions/common/select/storage/new/lib/utils/utils.ts +21 -21
  76. package/components/common/vm/actions/common/select/template/old/Old.vue +50 -50
  77. package/components/common/vm/actions/editSettings/new/Skeleton.vue +88 -88
  78. package/components/common/vm/actions/register/Register.vue +352 -352
  79. package/components/common/vm/actions/register/lib/config/steps.ts +86 -86
  80. package/components/common/wizards/common/compatibility/Compatibility.vue +35 -35
  81. package/components/common/wizards/common/compatibility/New.vue +99 -99
  82. package/components/common/wizards/common/compatibility/Old.vue +53 -53
  83. package/components/common/wizards/common/steps/computeResource/ComputeResource.vue +86 -86
  84. package/components/common/wizards/common/steps/computeResource/New.vue +93 -93
  85. package/components/common/wizards/common/steps/computeResource/Old.vue +103 -103
  86. package/components/common/wizards/common/steps/name/Name.vue +178 -178
  87. package/components/common/wizards/common/steps/name/New.vue +221 -221
  88. package/components/common/wizards/common/steps/name/Old.vue +121 -121
  89. package/components/common/wizards/common/steps/name/lib/models/interfaces.ts +4 -4
  90. package/components/common/wizards/common/steps/name/location/Location.vue +85 -85
  91. package/components/common/wizards/common/steps/name/location/New.vue +40 -40
  92. package/components/common/wizards/datastore/add/Add.vue +228 -228
  93. package/components/common/wizards/datastore/add/lib/utils.ts +85 -85
  94. package/components/common/wizards/datastore/add/steps/typeMode/lib/config/typeOptions.ts +43 -43
  95. package/components/common/wizards/vm/migrate/select/computeResource/ComputeResource.vue +205 -205
  96. package/components/common/wizards/vm/migrate/select/network/Network.vue +103 -103
  97. package/composables/useAppVersion.ts +21 -21
  98. package/composables/useLocal.ts +6 -6
  99. package/composables/useLocalCommon.ts +39 -39
  100. package/package.json +1 -1
  101. package/plugins/console.ts +21 -21
  102. package/plugins/date.ts +233 -233
  103. package/plugins/mouse.ts +21 -21
  104. package/plugins/panelStates.ts +70 -70
  105. package/plugins/text.ts +59 -59
  106. package/public/spice-console/application/clientgui.js +854 -854
  107. package/public/spice-console/application/packetfactory.js +211 -211
  108. package/public/spice-console/application/virtualmouse.js +147 -147
  109. package/public/spice-console/lib/images/bitmap.js +203 -203
  110. package/public/spice-console/network/spicechannel.js +440 -440
  111. package/public/spice-console/process/cursorprocess.js +121 -121
  112. package/public/spice-console/process/inputprocess.js +227 -227
  113. package/public/spice-console/process/mainprocess.js +210 -210
  114. package/public/spice-console/run.js +210 -210
  115. package/store/main/mutations.ts +7 -7
  116. package/store/main/state.ts +7 -7
@@ -1,809 +1,809 @@
1
- <template>
2
- <common-vm-actions-clone-new
3
- v-if="isNewView"
4
- v-model:vm-form="vmForm"
5
- v-model:scheduler-task-form="schedulerTaskForm"
6
- v-model:vm-name="vmName"
7
- v-model:compute-resource="vmForm.computeResource"
8
- v-model:location="location"
9
- :project="props.project"
10
- :vm-settings="vmSettings"
11
- :nodes="props.nodes"
12
- :files="props.files"
13
- :networks-table="props.networksTable"
14
- :datastore="props.datastore"
15
- :is-datastore-loading="props.isDatastoreLoading"
16
- :error-validation-fields="props.errorValidationFields"
17
- :ready-complete-table-info="props.readyCompleteTableInfo"
18
- :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
19
- :get-datastore-table-func="props.getDatastoreTableFunc"
20
- :passthrough-devices="props.passthroughDevices"
21
- :mediated-devices="props.mediatedDevices"
22
- :name-request-url="props.nameRequestUrl"
23
- :selected-virtual-machine="props.selectedVirtualMachine"
24
- :is-new-vm-from-template="props.isNewVmFromTemplate"
25
- :compute-resource-tree="props.computeResourceTree"
26
- :location-nodes="props.locationNodes"
27
- :wizard="wizard"
28
- :selected-scheme="selectedScheme"
29
- :title="title"
30
- :name-form-submit="nameFormSubmit"
31
- :storage-submit="storageSubmit"
32
- :customize-hardware-submit="customizeHardwareSubmit"
33
- :selected-nav-item="selectedNavItem"
34
- :allowed-location-kinds="allowedLocationKinds"
35
- :is-sphere="isSphere"
36
- :location-description="locationDescription"
37
- :name-test-ids="nameTestIds"
38
- :virtual-hardware-hard-disks-local="virtualHardwareHardDisksLocal"
39
- :virtual-hardware-networks-local="virtualHardwareNetworksLocal"
40
- :virtual-hardware-cd-dvd-drives-local="virtualHardwareCdDvdDrivesLocal"
41
- :guest-os-families="guestOsFamilies"
42
- :guest-os-versions="guestOsVersions"
43
- :machine-types="machineTypes"
44
- :dynamic-steps="dynamicSteps"
45
- :is-loading-compute-tree="isLoadingComputeTree"
46
- :compute-resource-alert="computeResourceAlert"
47
- :compatibility-text="compatibilityText"
48
- @get-folders-or-files="emits('get-folders-or-files', $event)"
49
- @change-name="onChangeName"
50
- @change-storage="onChangeStorage"
51
- @change-select-options="onChangeSelectOptions"
52
- @change-boot-order="onChangeBootOrder"
53
- @change-customize-hardware="onChangeCustomizeHardware"
54
- @get-storage="emits('get-storage', $event)"
55
- @get-active-device-child="emits('get-active-device-child', $event)"
56
- @show-datastore-child="emits('show-datastore-child', $event)"
57
- @remove-error-by-title="emits('remove-error-by-title', $event)"
58
- @get-networks-table="emits('get-networks-table', $event)"
59
- @get-pci-devices="emits('get-pci-devices')"
60
- @change-steps="onChangeSteps"
61
- @hide="onHideModal"
62
- @finish="onFinish"
63
- />
64
- <common-vm-actions-clone-old
65
- v-else
66
- v-model:vm-form="vmForm"
67
- v-model:scheduler-task-form="schedulerTaskForm"
68
- v-model:vm-name="vmName"
69
- v-model:compute-resource="vmForm.computeResource"
70
- v-model:location="location"
71
- :project="props.project"
72
- :vm-settings="vmSettings"
73
- :nodes="props.nodes"
74
- :files="props.files"
75
- :networks-table="props.networksTable"
76
- :datastore="props.datastore"
77
- :is-datastore-loading="props.isDatastoreLoading"
78
- :error-validation-fields="props.errorValidationFields"
79
- :ready-complete-table-info="props.readyCompleteTableInfo"
80
- :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
81
- :get-datastore-table-func="props.getDatastoreTableFunc"
82
- :passthrough-devices="props.passthroughDevices"
83
- :mediated-devices="props.mediatedDevices"
84
- :name-request-url="props.nameRequestUrl"
85
- :selected-virtual-machine="props.selectedVirtualMachine"
86
- :is-new-vm-from-template="props.isNewVmFromTemplate"
87
- :compute-resource-tree="props.computeResourceTree"
88
- :location-nodes="props.locationNodes"
89
- :wizard="wizard"
90
- :selected-scheme="selectedScheme"
91
- :title="title"
92
- :name-form-submit="nameFormSubmit"
93
- :storage-submit="storageSubmit"
94
- :customize-hardware-submit="customizeHardwareSubmit"
95
- :selected-nav-item="selectedNavItem"
96
- :is-loading="isLoading"
97
- :allowed-location-kinds="allowedLocationKinds"
98
- :is-sphere="isSphere"
99
- :location-description="locationDescription"
100
- :name-test-ids="nameTestIds"
101
- :virtual-hardware-hard-disks-local="virtualHardwareHardDisksLocal"
102
- :virtual-hardware-networks-local="virtualHardwareNetworksLocal"
103
- :virtual-hardware-cd-dvd-drives-local="virtualHardwareCdDvdDrivesLocal"
104
- :guest-os-families="guestOsFamilies"
105
- :guest-os-versions="guestOsVersions"
106
- :machine-types="machineTypes"
107
- :dynamic-steps="dynamicSteps"
108
- :is-loading-compute-tree="isLoadingComputeTree"
109
- :compute-resource-alert="computeResourceAlert"
110
- :compatibility-text="compatibilityText"
111
- @get-folders-or-files="emits('get-folders-or-files', $event)"
112
- @change-name="onChangeName"
113
- @change-storage="onChangeStorage"
114
- @change-select-options="onChangeSelectOptions"
115
- @change-boot-order="onChangeBootOrder"
116
- @change-customize-hardware="onChangeCustomizeHardware"
117
- @get-storage="emits('get-storage', $event)"
118
- @get-active-device-child="emits('get-active-device-child', $event)"
119
- @show-datastore-child="emits('show-datastore-child', $event)"
120
- @remove-error-by-title="emits('remove-error-by-title', $event)"
121
- @get-networks-table="emits('get-networks-table', $event)"
122
- @get-pci-devices="emits('get-pci-devices')"
123
- @change-steps="onChangeSteps"
124
- @hide="onHideModal"
125
- @finish="onFinish"
126
- />
127
- </template>
128
-
129
- <script setup lang="ts">
130
- import type {
131
- UI_I_ValidationReturn,
132
- UI_I_WizardStep,
133
- } from '~/node_modules/bfg-uikit/components/ui/wizard/lib/models/interfaces'
134
- import Wizard from '~/node_modules/bfg-uikit/components/ui/wizard/lib/utils/utils'
135
- import type {
136
- UI_I_DatastoreTableItem,
137
- UI_I_FolderOrFileTreePayload,
138
- } from '~/lib/models/store/storage/interfaces'
139
- import type { UI_I_NetworkTableItem } from '~/lib/models/store/network/interfaces'
140
- import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
141
- import type { UI_I_FileTreeNode } from '~/components/lib/models/interfaces'
142
- import type {
143
- UI_I_ArbitraryObject,
144
- UI_I_Localization,
145
- } from '~/lib/models/interfaces'
146
- import type { UI_I_SendDataCustomizeHardware } from '~/components/common/vm/actions/common/customizeHardware/lib/models/interfaces'
147
- import type { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
148
- import type {
149
- UI_I_SendDataCpu,
150
- UI_I_SendDataMemory,
151
- UI_I_SendDataNewCdDvdDrive,
152
- UI_I_SendDataNewHardDisk,
153
- UI_I_SendDataNewNetwork,
154
- } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
155
- import type { UI_T_SelectedNavItem } from '~/components/common/vm/actions/common/lib/models/types'
156
- import type { UI_I_TableInfoItem } from '~/components/atoms/table/info/lib/models/interfaces'
157
- import type { UI_T_ChangeBootOrder } from '~/components/common/vm/actions/lib/models/types'
158
- import type { UI_T_Project } from '~/lib/models/types'
159
- import type {
160
- UI_I_MediatedDevice,
161
- UI_I_PciDevice,
162
- UI_I_VmSettings,
163
- } from '~/lib/models/store/vm/interfaces'
164
- import type { UI_I_VmForm } from '~/components/common/vm/actions/common/lib/models/interfaces'
165
- import type { UI_I_Capabilities } from '~/components/common/vm/actions/common/lib/models/interfaces'
166
- import type { UI_I_ScheduleNewTasksForm } from '~/components/common/pages/scheduledTasks/modals/lib/models/interfaces'
167
- import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
168
- import type { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
169
- import type { UI_I_NameTestIds } from '~/components/common/wizards/common/steps/name/lib/models/interfaces'
170
- import type { UI_T_CompatibilityStatus } from '~/components/common/wizards/common/compatibility/lib/models/types'
171
- import {
172
- stepsSchemeInitial,
173
- stepsFunc,
174
- dynamicSteps,
175
- } from '~/components/common/vm/actions/clone/lib/config/steps'
176
- import { mapCapabilities } from '~/components/common/vm/actions/common/lib/utils/capabilities'
177
- import { scheduledTaskDefaultFormFunc } from '~/components/common/pages/scheduledTasks/modals/lib/config/createScheduledTask'
178
- import { capabilities } from '~/components/common/vm/actions/common/lib/config/capabilities'
179
-
180
- const props = withDefaults(
181
- defineProps<{
182
- project: UI_T_Project
183
- vmSettings: UI_I_VmSettings | null
184
- nodes: UI_I_FileTreeNode[]
185
- files: UI_I_FileTreeNode[]
186
- networksTable: UI_I_NetworkTableItem[]
187
- datastore: UI_I_DatastoreTableItem[]
188
- isDatastoreLoading: boolean
189
- errorValidationFields: UI_I_ErrorValidationField[]
190
- readyCompleteTableInfo: UI_I_TableInfoItem[]
191
- vmCpuHelpTextSecond: string
192
- finishFunc: any
193
- getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
194
- validateSendDataFunc: any
195
- passthroughDevices: UI_I_PciDevice[]
196
- mediatedDevices: UI_I_MediatedDevice[]
197
- vmNameInWizard: string
198
- nameRequestUrl: string
199
- capabilities?: UI_I_Capabilities
200
- schedulerTask?: any // TODO надо interface переместить глобално
201
- selectedVirtualMachine?: string
202
- isNewVmFromTemplate?: boolean
203
- dataCenter?: UI_I_TreeNode | null // для сферы
204
- computeResource?: UI_I_TreeNode // для сферы
205
- computeResourceTree?: UI_I_TreeNode[] // для сферы
206
- locationNodes?: UI_I_TreeNode[] // для сферы
207
- }>(),
208
- {
209
- capabilities: undefined,
210
- schedulerTask: undefined,
211
- selectedVirtualMachine: '',
212
- isNewVmFromTemplate: undefined,
213
- dataCenter: null,
214
- computeResource: null,
215
- computeResourceTree: undefined,
216
- locationNodes: () => [],
217
- }
218
- )
219
-
220
- const emits = defineEmits<{
221
- (event: 'get-storage', value: UI_I_TablePayload): void
222
- (event: 'get-folders-or-files', value: UI_I_FolderOrFileTreePayload): void
223
- (event: 'get-active-device-child', value: UI_I_FileTreeNode): void
224
- (event: 'show-datastore-child', value: UI_I_FileTreeNode): void
225
- (event: 'remove-error-by-title', value: string): void
226
- (event: 'get-networks-table', value: UI_I_TablePayload): void
227
- (event: 'get-pci-devices'): void
228
- (event: 'hide'): void
229
- (
230
- event: 'get-compute-resource-tree',
231
- value: { id: string | number; cb: () => void }
232
- ): void // для сферы
233
- (event: 'select-compute-resource-tree', value: UI_I_TreeNode): void // для сферы
234
- }>()
235
-
236
- const { $store, $recursion } = useNuxtApp()
237
-
238
- const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
239
-
240
- const localization = computed<UI_I_Localization>(() => useLocal())
241
-
242
- const isSphere = computed<boolean>(() => props.project === 'sphere')
243
-
244
- const location = ref<UI_I_TreeNode | null>(props.dataCenter) // для сферы
245
-
246
- const isScheduledTasks = computed<boolean>(
247
- () => props.schedulerTask?.isSchedulerTask
248
- )
249
-
250
- const title = computed<string>(() => {
251
- const { scheduleNewTasks, scheduleTaskEdit, cloneExistingVirtualMachine } =
252
- localization.value.common
253
-
254
- let result = cloneExistingVirtualMachine
255
- if (isScheduledTasks.value) {
256
- const schedulerMode = props.schedulerTask.editTask
257
- ? scheduleTaskEdit
258
- : scheduleNewTasks
259
-
260
- result = `${schedulerMode} (${cloneExistingVirtualMachine})`
261
- }
262
-
263
- if (props.isNewVmFromTemplate) {
264
- result = localization.value.vmWizard.deployFromTemplate
265
- }
266
-
267
- return result
268
- })
269
-
270
- watch(
271
- () => props.capabilities,
272
- () => {
273
- if (props.capabilities) {
274
- mapCapabilities(props.capabilities)
275
- }
276
- },
277
- { deep: true, immediate: true }
278
- )
279
-
280
- const wizard: Wizard = new Wizard(
281
- stepsFunc(localization.value),
282
- stepsSchemeInitial
283
- )
284
-
285
- const selectedScheme = computed<number[]>(() => wizard.selectedScheme.value)
286
-
287
- watch(
288
- isScheduledTasks,
289
- (newValue: boolean) => {
290
- if (newValue) {
291
- wizard.changeScheme(isSphere.value ? 12 : 4)
292
- } else {
293
- wizard.changeScheme(isSphere.value ? 8 : 0)
294
- wizard.selectStepHard(isSphere.value ? 2 : 1)
295
- }
296
- },
297
- { immediate: true }
298
- )
299
-
300
- const allowedLocationKinds = ref<number[]>([3, 7]) // TODO use from config
301
- const locationDescription = computed<string>(
302
- () => localization.value.common.selectLocationVirtualMachine
303
- )
304
-
305
- const nameTestIds = ref<UI_I_NameTestIds>({
306
- name: 'virtual-machine-name',
307
- helpIcon: 'show-vm-name-help-icon',
308
- })
309
-
310
- const schedulerTaskForm = ref<UI_I_ScheduleNewTasksForm>(
311
- useDeepCopy(scheduledTaskDefaultFormFunc())
312
- )
313
- watch(
314
- props.schedulerTask,
315
- (newValue) => {
316
- if (!newValue?.isSchedulerTask) return
317
- schedulerTaskForm.value = newValue.data
318
- },
319
- { immediate: true, deep: true }
320
- )
321
- watch(
322
- schedulerTaskForm,
323
- (newValue: UI_I_ScheduleNewTasksForm) => {
324
- if (isScheduledTasks.value) wizard.setDisabledNextButton(newValue.isValid)
325
- },
326
- { immediate: true, deep: true }
327
- )
328
-
329
- const onChangeSteps = async (value: UI_I_WizardStep[]): Promise<void> => {
330
- wizard.changeSteps(value, validationFunc, validateSendData)
331
- }
332
-
333
- const validationFunc = async (
334
- value: UI_I_WizardStep[],
335
- currentStep: UI_I_WizardStep,
336
- nextStep: UI_I_WizardStep
337
- ): Promise<UI_I_ValidationReturn> => {
338
- let stepHasError = false
339
- let stepShouldStop = {
340
- ifOnCurrentStep: false,
341
- ifFromAnyStep: false,
342
- stoppageStepId: -1,
343
- }
344
-
345
- wizard.setLoader(true)
346
- if (
347
- wizard.isValidateForStep(
348
- isSphere.value ? dynamicSteps.selectNameFolder : dynamicSteps.selectName,
349
- currentStep.id,
350
- nextStep.id
351
- )
352
- ) {
353
- const nameValidation = await checkName(value)
354
-
355
- value = nameValidation.newValue
356
- stepHasError = stepHasError || nameValidation.stepHasError
357
- } else if (
358
- isSphere.value &&
359
- wizard.isValidateForStep(
360
- dynamicSteps.selectComputeResource,
361
- currentStep.id,
362
- nextStep.id
363
- )
364
- ) {
365
- const computeResourceValidation = await checkComputeResource(value)
366
-
367
- value = computeResourceValidation.newValue
368
- stepHasError = stepHasError || computeResourceValidation.stepHasError
369
- } else if (
370
- wizard.isValidateForStep(
371
- dynamicSteps.selectStorage,
372
- currentStep.id,
373
- nextStep.id
374
- )
375
- ) {
376
- const storageValidation = await checkStorage(value)
377
-
378
- value = storageValidation.newValue
379
-
380
- stepHasError = stepHasError || storageValidation.stepHasError
381
- } else if (
382
- wizard.isValidateForStep(
383
- dynamicSteps.customizeHardware,
384
- currentStep.id,
385
- nextStep.id
386
- )
387
- ) {
388
- const customizeHardwareValidation = await checkCustomizeHardware(value)
389
-
390
- value = customizeHardwareValidation.newValue
391
-
392
- stepHasError = stepHasError || customizeHardwareValidation.stepHasError
393
- }
394
- wizard.setLoader(false)
395
-
396
- return {
397
- newValue: value,
398
- stepHasError,
399
- stepShouldStop,
400
- }
401
- }
402
- const checkName = async (
403
- value: UI_I_WizardStep[]
404
- ): Promise<UI_I_ValidationReturn> => {
405
- let stepHasError = false
406
-
407
- return new Promise((resolve) => {
408
- const step = isSphere.value
409
- ? dynamicSteps.selectNameFolder
410
- : dynamicSteps.selectName
411
- nameFormSubmit.value = (isValid: boolean) => {
412
- if (!isValid) {
413
- stepHasError = wizard.setValidation(step, 'name', {
414
- fieldMessage: 'aaa',
415
- alertMessage: 'aaa',
416
- })
417
- } else if (wizard.hasMessage(step, 'name')) {
418
- value = wizard.removeValidation(step, 'name', value)
419
- }
420
-
421
- resolve({
422
- stepHasError,
423
- newValue: value,
424
- })
425
- nameFormSubmit.value = null
426
- }
427
- })
428
- }
429
- const compatibilityText = computed<[UI_T_CompatibilityStatus, string]>(() => {
430
- const { computeResource } = vmForm.value
431
-
432
- if (!computeResource)
433
- return [
434
- 'none',
435
- localization.value.vmWizard.noDestinationComputeResourceSelected,
436
- ]
437
-
438
- let res: [UI_T_CompatibilityStatus, string] = [
439
- 'success',
440
- localization.value.common.compatibilityChecksSucceeded,
441
- ]
442
-
443
- if (!['cluster', 'host', 'resource_pool'].includes(computeResource?.type)) {
444
- res = [
445
- 'error',
446
- localization.value.common.selectValidClusterOrHostDestination,
447
- ]
448
- }
449
- if (computeResource?.type === 'cluster') {
450
- const hasHost = !!computeResource.nodes.length
451
- if (!hasHost) {
452
- res = ['error', localization.value.common.clusterNotContainAnyHosts]
453
- }
454
- }
455
-
456
- if (computeResource?.type === 'host') {
457
- if (computeResource.state === 'Error') {
458
- // TODO check Maintenance Mode
459
- res = [
460
- 'error',
461
- localization.value.common.selectedHostDisconnectedMaintenanceMode,
462
- ]
463
- }
464
- }
465
-
466
- return res
467
- })
468
- const computeResourceAlert = ref<string[]>([])
469
- const checkComputeResource = (
470
- value: UI_I_WizardStep[]
471
- ): UI_I_ValidationReturn => {
472
- let stepHasError = false
473
-
474
- const { computeResource } = vmForm.value
475
-
476
- if (
477
- !computeResource ||
478
- // compatibilityText.value[0] !== 1 ||
479
- computeResource.type === 'datacenter' ||
480
- computeResource.type === 'folder' ||
481
- (computeResource.type === 'cluster' && !computeResource.nodes.length)
482
- ) {
483
- computeResourceAlert.value = [
484
- localization.value.common.specifyValidClusterOrHostDestination,
485
- ]
486
- stepHasError = wizard.setValidation(
487
- dynamicSteps.selectComputeResource,
488
- 'computeResource',
489
- {
490
- fieldMessage: 'aaa',
491
- alertMessage: 'aaa',
492
- }
493
- )
494
- } else {
495
- computeResourceAlert.value = []
496
- if (
497
- wizard.hasMessage(dynamicSteps.selectComputeResource, 'computeResource')
498
- ) {
499
- value = wizard.removeValidation(
500
- dynamicSteps.selectComputeResource,
501
- 'computeResource',
502
- value
503
- )
504
- }
505
- }
506
-
507
- return {
508
- stepHasError,
509
- newValue: value,
510
- }
511
- }
512
- const checkStorage = async (
513
- value: UI_I_WizardStep[]
514
- ): Promise<UI_I_ValidationReturn> => {
515
- let stepHasError = false
516
-
517
- return new Promise((resolve) => {
518
- storageSubmit.value = (isValid: boolean) => {
519
- if (!isValid) {
520
- stepHasError = wizard.setValidation(
521
- dynamicSteps.selectStorage,
522
- 'storage',
523
- {
524
- fieldMessage: 'aaa',
525
- alertMessage: 'aaa',
526
- }
527
- )
528
- } else if (wizard.hasMessage(dynamicSteps.selectStorage, 'storage')) {
529
- value = wizard.removeValidation(
530
- dynamicSteps.selectStorage,
531
- 'storage',
532
- value
533
- )
534
- }
535
-
536
- resolve({
537
- stepHasError,
538
- newValue: value,
539
- })
540
- storageSubmit.value = null
541
- }
542
- })
543
- }
544
- const checkCustomizeHardware = async (
545
- value: UI_I_WizardStep[]
546
- ): Promise<UI_I_ValidationReturn> => {
547
- let stepHasError = false
548
-
549
- return new Promise((resolve) => {
550
- customizeHardwareSubmit.value = (isValid: boolean) => {
551
- if (!isValid) {
552
- stepHasError = wizard.setValidation(
553
- dynamicSteps.customizeHardware,
554
- 'customizeHardware',
555
- {
556
- fieldMessage: 'aaa',
557
- alertMessage: 'aaa',
558
- }
559
- )
560
- } else if (
561
- wizard.hasMessage(dynamicSteps.customizeHardware, 'customizeHardware')
562
- ) {
563
- value = wizard.removeValidation(
564
- dynamicSteps.customizeHardware,
565
- 'customizeHardware',
566
- value
567
- )
568
- }
569
-
570
- resolve({
571
- stepHasError,
572
- newValue: value,
573
- })
574
- storageSubmit.value = null
575
- }
576
- })
577
- }
578
-
579
- const vmForm = ref<UI_I_VmForm>({
580
- name: '',
581
- compatibility: '',
582
- guestMachineType: null,
583
- guestOsFamily: null,
584
- guestOsVersion: null,
585
- computeResource: props.computeResource,
586
- storage: null,
587
- locationPath: '',
588
- dataCenter: null,
589
- options: [],
590
- })
591
-
592
- const isLoadingComputeTree = ref<boolean>(false)
593
- const onChangeName = (data: [string, UI_I_TreeNode | null]): void => {
594
- const [name, node] = data
595
-
596
- vmForm.value.name = name
597
- if (isSphere.value) {
598
- vmForm.value.locationPath = node.id
599
- vmForm.value.dataCenter = $recursion.findParentByValue(
600
- node,
601
- 'datacenter',
602
- 'type',
603
- 'parent'
604
- )
605
- isLoadingComputeTree.value = true
606
- emits('get-compute-resource-tree', {
607
- id: node.id,
608
- cb: () => {
609
- isLoadingComputeTree.value = false
610
- },
611
- })
612
- }
613
- }
614
- const onChangeStorage = (storage: UI_I_DatastoreTableItem | null): void => {
615
- if (!storage) return
616
-
617
- vmForm.value.storage = storage
618
- }
619
- const onChangeSelectOptions = (options: string[]): void => {
620
- vmForm.value.options = options
621
- if (
622
- options.includes('customize-os') &&
623
- options.includes('customize-hardware')
624
- ) {
625
- let procuratorSchame = isScheduledTasks.value ? 7 : 3
626
- let sphereSchame = isScheduledTasks.value ? 15 : 11
627
- wizard.changeScheme(isSphere.value ? sphereSchame : procuratorSchame)
628
- } else if (options.includes('customize-os')) {
629
- let procuratorSchame = isScheduledTasks.value ? 5 : 1
630
- let sphereSchame = isScheduledTasks.value ? 13 : 9
631
- wizard.changeScheme(isSphere.value ? sphereSchame : procuratorSchame)
632
- } else if (options.includes('customize-hardware')) {
633
- let procuratorSchame = isScheduledTasks.value ? 6 : 2
634
- let sphereSchame = isScheduledTasks.value ? 14 : 10
635
- wizard.changeScheme(isSphere.value ? sphereSchame : procuratorSchame)
636
- } else {
637
- let procuratorSchame = isScheduledTasks.value ? 4 : 0
638
- let sphereSchame = isScheduledTasks.value ? 12 : 8
639
- wizard.changeScheme(isSphere.value ? sphereSchame : procuratorSchame)
640
- }
641
-
642
- // Change power on by default
643
- isPowerOnByDefault.value = options.includes('power-on')
644
- }
645
- const customizeHardware = ref<UI_I_SendDataCustomizeHardware | null>(null)
646
- const onChangeCustomizeHardware = (
647
- data: UI_I_SendDataCustomizeHardware
648
- ): void => {
649
- customizeHardware.value = data
650
- }
651
-
652
- const virtualHardwareHardDisksLocal = computed<
653
- UI_I_SendDataNewHardDisk[] | null
654
- >(() => customizeHardware.value?.virtualHardware?.hardDisks || null)
655
- const virtualHardwareNetworksLocal = computed<UI_I_SendDataNewNetwork[] | null>(
656
- () => customizeHardware.value?.virtualHardware?.networks || null
657
- )
658
- const virtualHardwareCdDvdDrivesLocal = computed<
659
- UI_I_SendDataNewCdDvdDrive[] | null
660
- >(() => customizeHardware.value?.virtualHardware?.cdDvdDrives || null)
661
-
662
- const virtualHardwareCpu = computed<UI_I_SendDataCpu | null>(
663
- () => customizeHardware.value?.virtualHardware?.cpu || null
664
- )
665
- const virtualHardwareMemory = computed<UI_I_SendDataMemory | null>(
666
- () => customizeHardware.value?.virtualHardware?.memory || null
667
- )
668
- const virtualHardwareHardDisks = ref<UI_I_SendDataNewHardDisk[] | null>(null)
669
- const virtualHardwareCdDvdDrives = ref<UI_I_SendDataNewCdDvdDrive[] | null>(
670
- null
671
- )
672
- const virtualHardwareNetworks = ref<UI_I_SendDataNewNetwork[] | null>(null)
673
- const onChangeBootOrder = (data: UI_T_ChangeBootOrder): void => {
674
- virtualHardwareHardDisks.value = data[0]
675
- virtualHardwareCdDvdDrives.value = data[1]
676
- virtualHardwareNetworks.value = data[2]
677
- }
678
-
679
- const isPowerOnByDefault = ref<boolean>(false)
680
-
681
- watch(
682
- () => props.vmNameInWizard,
683
- (newValue) => {
684
- vmForm.value.name = newValue
685
- }
686
- )
687
-
688
- const validateSendData = async (
689
- value: UI_I_WizardStep[]
690
- ): Promise<UI_I_ValidationReturn> => {
691
- wizard.setLoader(true)
692
- let stepHasError = false
693
-
694
- const data = await props.validateSendDataFunc(
695
- vmForm.value,
696
- virtualHardwareCpu.value,
697
- virtualHardwareMemory.value,
698
- customizeHardware.value,
699
- virtualHardwareNetworks.value,
700
- virtualHardwareHardDisks.value,
701
- virtualHardwareCdDvdDrives.value,
702
- isPowerOnByDefault.value,
703
- localization.value,
704
- vmForm.value.locationPath, // для сферы
705
- // computeResourcePath.value // для сферы
706
- vmSettings.value.host_id // для сферы // TODO rollback
707
- )
708
-
709
- wizard.setLoader(false)
710
- if (data) {
711
- stepHasError = true
712
- selectedNavItem.value = data[0]
713
- }
714
-
715
- return {
716
- stepHasError,
717
- newValue: value,
718
- }
719
- }
720
-
721
- const isLoading = ref<boolean>(false)
722
- const onFinish = (): void => {
723
- isLoading.value = true
724
- wizard.setLoader(false)
725
- props
726
- .finishFunc(
727
- vmForm.value,
728
- virtualHardwareCpu.value,
729
- virtualHardwareMemory.value,
730
- customizeHardware.value,
731
- virtualHardwareNetworks.value,
732
- virtualHardwareHardDisks.value,
733
- virtualHardwareCdDvdDrives.value,
734
- isPowerOnByDefault.value,
735
- localization.value,
736
- vmForm.value.locationPath, // для сферы
737
- // computeResourcePath.value, // для сферы
738
- vmSettings.value.host_id, // для сферы // TODO rollback
739
- false,
740
- schedulerTaskForm.value,
741
- props.schedulerTask
742
- )
743
- .then(() => {
744
- isLoading.value = false
745
- onHideModal()
746
- wizard.setLoader(false)
747
- })
748
- }
749
-
750
- const selectedNavItem = ref<UI_T_SelectedNavItem>(0)
751
-
752
- const nameFormSubmit = ref<null | Function>(null)
753
- const storageSubmit = ref<null | Function>(null)
754
- const customizeHardwareSubmit = ref<null | Function>(null)
755
-
756
- const vmSettings = computed<UI_I_VmSettings | null>(() => props.vmSettings)
757
- const vmName = ref<string>(vmSettings.value?.name || '')
758
-
759
- const guestOsFamilies = ref<UI_I_OptionItem[]>(
760
- capabilities.value.guestOsFamilies
761
- )
762
- const guestOsVersions = ref<UI_I_ArbitraryObject<UI_I_OptionItem[]>>(
763
- capabilities.value.guestOsVersions
764
- )
765
- const machineTypes = ref<UI_I_OptionItem[]>(capabilities.value.machineTypes)
766
-
767
- // Для сферы
768
- const computeResourcePath = ref<string>('')
769
- watch(
770
- () => vmForm.value.computeResource,
771
- (newValue, oldValue) => {
772
- if (newValue && newValue.id !== oldValue?.id) {
773
- onSelectComputeResourceTree(newValue)
774
- }
775
- },
776
- { deep: true }
777
- )
778
- const onSelectComputeResourceTree = (node: UI_I_TreeNode): void => {
779
- emits('select-compute-resource-tree', node)
780
- computeResourcePath.value = String(node.id)
781
- }
782
-
783
- watch(vmSettings, (newValue) => {
784
- vmName.value = newValue?.name || ''
785
-
786
- if (newValue?.guestOsFamily)
787
- vmForm.value.guestOsFamily = newValue.guestOsFamily
788
- if (newValue?.guestMachineType)
789
- vmForm.value.guestMachineType = newValue.guestMachineType
790
- if (newValue?.guestOsVersion)
791
- vmForm.value.guestOsVersion = newValue.guestOsVersion
792
-
793
- if (newValue?.compatibility)
794
- vmForm.value.compatibility = newValue.compatibility
795
-
796
- if (newValue?.storage) {
797
- const datastore = props.datastore.find(
798
- (item) => item.id === newValue.storage.id
799
- )
800
- if (datastore) vmForm.value.storage = datastore
801
- }
802
- })
803
-
804
- const onHideModal = (): void => {
805
- emits('hide')
806
- }
807
- </script>
808
-
809
- <style scoped lang="scss"></style>
1
+ <template>
2
+ <common-vm-actions-clone-new
3
+ v-if="isNewView"
4
+ v-model:vm-form="vmForm"
5
+ v-model:scheduler-task-form="schedulerTaskForm"
6
+ v-model:vm-name="vmName"
7
+ v-model:compute-resource="vmForm.computeResource"
8
+ v-model:location="location"
9
+ :project="props.project"
10
+ :vm-settings="vmSettings"
11
+ :nodes="props.nodes"
12
+ :files="props.files"
13
+ :networks-table="props.networksTable"
14
+ :datastore="props.datastore"
15
+ :is-datastore-loading="props.isDatastoreLoading"
16
+ :error-validation-fields="props.errorValidationFields"
17
+ :ready-complete-table-info="props.readyCompleteTableInfo"
18
+ :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
19
+ :get-datastore-table-func="props.getDatastoreTableFunc"
20
+ :passthrough-devices="props.passthroughDevices"
21
+ :mediated-devices="props.mediatedDevices"
22
+ :name-request-url="props.nameRequestUrl"
23
+ :selected-virtual-machine="props.selectedVirtualMachine"
24
+ :is-new-vm-from-template="props.isNewVmFromTemplate"
25
+ :compute-resource-tree="props.computeResourceTree"
26
+ :location-nodes="props.locationNodes"
27
+ :wizard="wizard"
28
+ :selected-scheme="selectedScheme"
29
+ :title="title"
30
+ :name-form-submit="nameFormSubmit"
31
+ :storage-submit="storageSubmit"
32
+ :customize-hardware-submit="customizeHardwareSubmit"
33
+ :selected-nav-item="selectedNavItem"
34
+ :allowed-location-kinds="allowedLocationKinds"
35
+ :is-sphere="isSphere"
36
+ :location-description="locationDescription"
37
+ :name-test-ids="nameTestIds"
38
+ :virtual-hardware-hard-disks-local="virtualHardwareHardDisksLocal"
39
+ :virtual-hardware-networks-local="virtualHardwareNetworksLocal"
40
+ :virtual-hardware-cd-dvd-drives-local="virtualHardwareCdDvdDrivesLocal"
41
+ :guest-os-families="guestOsFamilies"
42
+ :guest-os-versions="guestOsVersions"
43
+ :machine-types="machineTypes"
44
+ :dynamic-steps="dynamicSteps"
45
+ :is-loading-compute-tree="isLoadingComputeTree"
46
+ :compute-resource-alert="computeResourceAlert"
47
+ :compatibility-text="compatibilityText"
48
+ @get-folders-or-files="emits('get-folders-or-files', $event)"
49
+ @change-name="onChangeName"
50
+ @change-storage="onChangeStorage"
51
+ @change-select-options="onChangeSelectOptions"
52
+ @change-boot-order="onChangeBootOrder"
53
+ @change-customize-hardware="onChangeCustomizeHardware"
54
+ @get-storage="emits('get-storage', $event)"
55
+ @get-active-device-child="emits('get-active-device-child', $event)"
56
+ @show-datastore-child="emits('show-datastore-child', $event)"
57
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
58
+ @get-networks-table="emits('get-networks-table', $event)"
59
+ @get-pci-devices="emits('get-pci-devices')"
60
+ @change-steps="onChangeSteps"
61
+ @hide="onHideModal"
62
+ @finish="onFinish"
63
+ />
64
+ <common-vm-actions-clone-old
65
+ v-else
66
+ v-model:vm-form="vmForm"
67
+ v-model:scheduler-task-form="schedulerTaskForm"
68
+ v-model:vm-name="vmName"
69
+ v-model:compute-resource="vmForm.computeResource"
70
+ v-model:location="location"
71
+ :project="props.project"
72
+ :vm-settings="vmSettings"
73
+ :nodes="props.nodes"
74
+ :files="props.files"
75
+ :networks-table="props.networksTable"
76
+ :datastore="props.datastore"
77
+ :is-datastore-loading="props.isDatastoreLoading"
78
+ :error-validation-fields="props.errorValidationFields"
79
+ :ready-complete-table-info="props.readyCompleteTableInfo"
80
+ :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
81
+ :get-datastore-table-func="props.getDatastoreTableFunc"
82
+ :passthrough-devices="props.passthroughDevices"
83
+ :mediated-devices="props.mediatedDevices"
84
+ :name-request-url="props.nameRequestUrl"
85
+ :selected-virtual-machine="props.selectedVirtualMachine"
86
+ :is-new-vm-from-template="props.isNewVmFromTemplate"
87
+ :compute-resource-tree="props.computeResourceTree"
88
+ :location-nodes="props.locationNodes"
89
+ :wizard="wizard"
90
+ :selected-scheme="selectedScheme"
91
+ :title="title"
92
+ :name-form-submit="nameFormSubmit"
93
+ :storage-submit="storageSubmit"
94
+ :customize-hardware-submit="customizeHardwareSubmit"
95
+ :selected-nav-item="selectedNavItem"
96
+ :is-loading="isLoading"
97
+ :allowed-location-kinds="allowedLocationKinds"
98
+ :is-sphere="isSphere"
99
+ :location-description="locationDescription"
100
+ :name-test-ids="nameTestIds"
101
+ :virtual-hardware-hard-disks-local="virtualHardwareHardDisksLocal"
102
+ :virtual-hardware-networks-local="virtualHardwareNetworksLocal"
103
+ :virtual-hardware-cd-dvd-drives-local="virtualHardwareCdDvdDrivesLocal"
104
+ :guest-os-families="guestOsFamilies"
105
+ :guest-os-versions="guestOsVersions"
106
+ :machine-types="machineTypes"
107
+ :dynamic-steps="dynamicSteps"
108
+ :is-loading-compute-tree="isLoadingComputeTree"
109
+ :compute-resource-alert="computeResourceAlert"
110
+ :compatibility-text="compatibilityText"
111
+ @get-folders-or-files="emits('get-folders-or-files', $event)"
112
+ @change-name="onChangeName"
113
+ @change-storage="onChangeStorage"
114
+ @change-select-options="onChangeSelectOptions"
115
+ @change-boot-order="onChangeBootOrder"
116
+ @change-customize-hardware="onChangeCustomizeHardware"
117
+ @get-storage="emits('get-storage', $event)"
118
+ @get-active-device-child="emits('get-active-device-child', $event)"
119
+ @show-datastore-child="emits('show-datastore-child', $event)"
120
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
121
+ @get-networks-table="emits('get-networks-table', $event)"
122
+ @get-pci-devices="emits('get-pci-devices')"
123
+ @change-steps="onChangeSteps"
124
+ @hide="onHideModal"
125
+ @finish="onFinish"
126
+ />
127
+ </template>
128
+
129
+ <script setup lang="ts">
130
+ import type {
131
+ UI_I_ValidationReturn,
132
+ UI_I_WizardStep,
133
+ } from '~/node_modules/bfg-uikit/components/ui/wizard/lib/models/interfaces'
134
+ import Wizard from '~/node_modules/bfg-uikit/components/ui/wizard/lib/utils/utils'
135
+ import type {
136
+ UI_I_DatastoreTableItem,
137
+ UI_I_FolderOrFileTreePayload,
138
+ } from '~/lib/models/store/storage/interfaces'
139
+ import type { UI_I_NetworkTableItem } from '~/lib/models/store/network/interfaces'
140
+ import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
141
+ import type { UI_I_FileTreeNode } from '~/components/lib/models/interfaces'
142
+ import type {
143
+ UI_I_ArbitraryObject,
144
+ UI_I_Localization,
145
+ } from '~/lib/models/interfaces'
146
+ import type { UI_I_SendDataCustomizeHardware } from '~/components/common/vm/actions/common/customizeHardware/lib/models/interfaces'
147
+ import type { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
148
+ import type {
149
+ UI_I_SendDataCpu,
150
+ UI_I_SendDataMemory,
151
+ UI_I_SendDataNewCdDvdDrive,
152
+ UI_I_SendDataNewHardDisk,
153
+ UI_I_SendDataNewNetwork,
154
+ } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
155
+ import type { UI_T_SelectedNavItem } from '~/components/common/vm/actions/common/lib/models/types'
156
+ import type { UI_I_TableInfoItem } from '~/components/atoms/table/info/lib/models/interfaces'
157
+ import type { UI_T_ChangeBootOrder } from '~/components/common/vm/actions/lib/models/types'
158
+ import type { UI_T_Project } from '~/lib/models/types'
159
+ import type {
160
+ UI_I_MediatedDevice,
161
+ UI_I_PciDevice,
162
+ UI_I_VmSettings,
163
+ } from '~/lib/models/store/vm/interfaces'
164
+ import type { UI_I_VmForm } from '~/components/common/vm/actions/common/lib/models/interfaces'
165
+ import type { UI_I_Capabilities } from '~/components/common/vm/actions/common/lib/models/interfaces'
166
+ import type { UI_I_ScheduleNewTasksForm } from '~/components/common/pages/scheduledTasks/modals/lib/models/interfaces'
167
+ import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
168
+ import type { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
169
+ import type { UI_I_NameTestIds } from '~/components/common/wizards/common/steps/name/lib/models/interfaces'
170
+ import type { UI_T_CompatibilityStatus } from '~/components/common/wizards/common/compatibility/lib/models/types'
171
+ import {
172
+ stepsSchemeInitial,
173
+ stepsFunc,
174
+ dynamicSteps,
175
+ } from '~/components/common/vm/actions/clone/lib/config/steps'
176
+ import { mapCapabilities } from '~/components/common/vm/actions/common/lib/utils/capabilities'
177
+ import { scheduledTaskDefaultFormFunc } from '~/components/common/pages/scheduledTasks/modals/lib/config/createScheduledTask'
178
+ import { capabilities } from '~/components/common/vm/actions/common/lib/config/capabilities'
179
+
180
+ const props = withDefaults(
181
+ defineProps<{
182
+ project: UI_T_Project
183
+ vmSettings: UI_I_VmSettings | null
184
+ nodes: UI_I_FileTreeNode[]
185
+ files: UI_I_FileTreeNode[]
186
+ networksTable: UI_I_NetworkTableItem[]
187
+ datastore: UI_I_DatastoreTableItem[]
188
+ isDatastoreLoading: boolean
189
+ errorValidationFields: UI_I_ErrorValidationField[]
190
+ readyCompleteTableInfo: UI_I_TableInfoItem[]
191
+ vmCpuHelpTextSecond: string
192
+ finishFunc: any
193
+ getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
194
+ validateSendDataFunc: any
195
+ passthroughDevices: UI_I_PciDevice[]
196
+ mediatedDevices: UI_I_MediatedDevice[]
197
+ vmNameInWizard: string
198
+ nameRequestUrl: string
199
+ capabilities?: UI_I_Capabilities
200
+ schedulerTask?: any // TODO надо interface переместить глобално
201
+ selectedVirtualMachine?: string
202
+ isNewVmFromTemplate?: boolean
203
+ dataCenter?: UI_I_TreeNode | null // для сферы
204
+ computeResource?: UI_I_TreeNode // для сферы
205
+ computeResourceTree?: UI_I_TreeNode[] // для сферы
206
+ locationNodes?: UI_I_TreeNode[] // для сферы
207
+ }>(),
208
+ {
209
+ capabilities: undefined,
210
+ schedulerTask: undefined,
211
+ selectedVirtualMachine: '',
212
+ isNewVmFromTemplate: undefined,
213
+ dataCenter: null,
214
+ computeResource: null,
215
+ computeResourceTree: undefined,
216
+ locationNodes: () => [],
217
+ }
218
+ )
219
+
220
+ const emits = defineEmits<{
221
+ (event: 'get-storage', value: UI_I_TablePayload): void
222
+ (event: 'get-folders-or-files', value: UI_I_FolderOrFileTreePayload): void
223
+ (event: 'get-active-device-child', value: UI_I_FileTreeNode): void
224
+ (event: 'show-datastore-child', value: UI_I_FileTreeNode): void
225
+ (event: 'remove-error-by-title', value: string): void
226
+ (event: 'get-networks-table', value: UI_I_TablePayload): void
227
+ (event: 'get-pci-devices'): void
228
+ (event: 'hide'): void
229
+ (
230
+ event: 'get-compute-resource-tree',
231
+ value: { id: string | number; cb: () => void }
232
+ ): void // для сферы
233
+ (event: 'select-compute-resource-tree', value: UI_I_TreeNode): void // для сферы
234
+ }>()
235
+
236
+ const { $store, $recursion } = useNuxtApp()
237
+
238
+ const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
239
+
240
+ const localization = computed<UI_I_Localization>(() => useLocal())
241
+
242
+ const isSphere = computed<boolean>(() => props.project === 'sphere')
243
+
244
+ const location = ref<UI_I_TreeNode | null>(props.dataCenter) // для сферы
245
+
246
+ const isScheduledTasks = computed<boolean>(
247
+ () => props.schedulerTask?.isSchedulerTask
248
+ )
249
+
250
+ const title = computed<string>(() => {
251
+ const { scheduleNewTasks, scheduleTaskEdit, cloneExistingVirtualMachine } =
252
+ localization.value.common
253
+
254
+ let result = cloneExistingVirtualMachine
255
+ if (isScheduledTasks.value) {
256
+ const schedulerMode = props.schedulerTask.editTask
257
+ ? scheduleTaskEdit
258
+ : scheduleNewTasks
259
+
260
+ result = `${schedulerMode} (${cloneExistingVirtualMachine})`
261
+ }
262
+
263
+ if (props.isNewVmFromTemplate) {
264
+ result = localization.value.vmWizard.deployFromTemplate
265
+ }
266
+
267
+ return result
268
+ })
269
+
270
+ watch(
271
+ () => props.capabilities,
272
+ () => {
273
+ if (props.capabilities) {
274
+ mapCapabilities(props.capabilities)
275
+ }
276
+ },
277
+ { deep: true, immediate: true }
278
+ )
279
+
280
+ const wizard: Wizard = new Wizard(
281
+ stepsFunc(localization.value),
282
+ stepsSchemeInitial
283
+ )
284
+
285
+ const selectedScheme = computed<number[]>(() => wizard.selectedScheme.value)
286
+
287
+ watch(
288
+ isScheduledTasks,
289
+ (newValue: boolean) => {
290
+ if (newValue) {
291
+ wizard.changeScheme(isSphere.value ? 12 : 4)
292
+ } else {
293
+ wizard.changeScheme(isSphere.value ? 8 : 0)
294
+ wizard.selectStepHard(isSphere.value ? 2 : 1)
295
+ }
296
+ },
297
+ { immediate: true }
298
+ )
299
+
300
+ const allowedLocationKinds = ref<number[]>([3, 7]) // TODO use from config
301
+ const locationDescription = computed<string>(
302
+ () => localization.value.common.selectLocationVirtualMachine
303
+ )
304
+
305
+ const nameTestIds = ref<UI_I_NameTestIds>({
306
+ name: 'virtual-machine-name',
307
+ helpIcon: 'show-vm-name-help-icon',
308
+ })
309
+
310
+ const schedulerTaskForm = ref<UI_I_ScheduleNewTasksForm>(
311
+ useDeepCopy(scheduledTaskDefaultFormFunc())
312
+ )
313
+ watch(
314
+ props.schedulerTask,
315
+ (newValue) => {
316
+ if (!newValue?.isSchedulerTask) return
317
+ schedulerTaskForm.value = newValue.data
318
+ },
319
+ { immediate: true, deep: true }
320
+ )
321
+ watch(
322
+ schedulerTaskForm,
323
+ (newValue: UI_I_ScheduleNewTasksForm) => {
324
+ if (isScheduledTasks.value) wizard.setDisabledNextButton(newValue.isValid)
325
+ },
326
+ { immediate: true, deep: true }
327
+ )
328
+
329
+ const onChangeSteps = async (value: UI_I_WizardStep[]): Promise<void> => {
330
+ wizard.changeSteps(value, validationFunc, validateSendData)
331
+ }
332
+
333
+ const validationFunc = async (
334
+ value: UI_I_WizardStep[],
335
+ currentStep: UI_I_WizardStep,
336
+ nextStep: UI_I_WizardStep
337
+ ): Promise<UI_I_ValidationReturn> => {
338
+ let stepHasError = false
339
+ let stepShouldStop = {
340
+ ifOnCurrentStep: false,
341
+ ifFromAnyStep: false,
342
+ stoppageStepId: -1,
343
+ }
344
+
345
+ wizard.setLoader(true)
346
+ if (
347
+ wizard.isValidateForStep(
348
+ isSphere.value ? dynamicSteps.selectNameFolder : dynamicSteps.selectName,
349
+ currentStep.id,
350
+ nextStep.id
351
+ )
352
+ ) {
353
+ const nameValidation = await checkName(value)
354
+
355
+ value = nameValidation.newValue
356
+ stepHasError = stepHasError || nameValidation.stepHasError
357
+ } else if (
358
+ isSphere.value &&
359
+ wizard.isValidateForStep(
360
+ dynamicSteps.selectComputeResource,
361
+ currentStep.id,
362
+ nextStep.id
363
+ )
364
+ ) {
365
+ const computeResourceValidation = await checkComputeResource(value)
366
+
367
+ value = computeResourceValidation.newValue
368
+ stepHasError = stepHasError || computeResourceValidation.stepHasError
369
+ } else if (
370
+ wizard.isValidateForStep(
371
+ dynamicSteps.selectStorage,
372
+ currentStep.id,
373
+ nextStep.id
374
+ )
375
+ ) {
376
+ const storageValidation = await checkStorage(value)
377
+
378
+ value = storageValidation.newValue
379
+
380
+ stepHasError = stepHasError || storageValidation.stepHasError
381
+ } else if (
382
+ wizard.isValidateForStep(
383
+ dynamicSteps.customizeHardware,
384
+ currentStep.id,
385
+ nextStep.id
386
+ )
387
+ ) {
388
+ const customizeHardwareValidation = await checkCustomizeHardware(value)
389
+
390
+ value = customizeHardwareValidation.newValue
391
+
392
+ stepHasError = stepHasError || customizeHardwareValidation.stepHasError
393
+ }
394
+ wizard.setLoader(false)
395
+
396
+ return {
397
+ newValue: value,
398
+ stepHasError,
399
+ stepShouldStop,
400
+ }
401
+ }
402
+ const checkName = async (
403
+ value: UI_I_WizardStep[]
404
+ ): Promise<UI_I_ValidationReturn> => {
405
+ let stepHasError = false
406
+
407
+ return new Promise((resolve) => {
408
+ const step = isSphere.value
409
+ ? dynamicSteps.selectNameFolder
410
+ : dynamicSteps.selectName
411
+ nameFormSubmit.value = (isValid: boolean) => {
412
+ if (!isValid) {
413
+ stepHasError = wizard.setValidation(step, 'name', {
414
+ fieldMessage: 'aaa',
415
+ alertMessage: 'aaa',
416
+ })
417
+ } else if (wizard.hasMessage(step, 'name')) {
418
+ value = wizard.removeValidation(step, 'name', value)
419
+ }
420
+
421
+ resolve({
422
+ stepHasError,
423
+ newValue: value,
424
+ })
425
+ nameFormSubmit.value = null
426
+ }
427
+ })
428
+ }
429
+ const compatibilityText = computed<[UI_T_CompatibilityStatus, string]>(() => {
430
+ const { computeResource } = vmForm.value
431
+
432
+ if (!computeResource)
433
+ return [
434
+ 'none',
435
+ localization.value.vmWizard.noDestinationComputeResourceSelected,
436
+ ]
437
+
438
+ let res: [UI_T_CompatibilityStatus, string] = [
439
+ 'success',
440
+ localization.value.common.compatibilityChecksSucceeded,
441
+ ]
442
+
443
+ if (!['cluster', 'host', 'resource_pool'].includes(computeResource?.type)) {
444
+ res = [
445
+ 'error',
446
+ localization.value.common.selectValidClusterOrHostDestination,
447
+ ]
448
+ }
449
+ if (computeResource?.type === 'cluster') {
450
+ const hasHost = !!computeResource.nodes.length
451
+ if (!hasHost) {
452
+ res = ['error', localization.value.common.clusterNotContainAnyHosts]
453
+ }
454
+ }
455
+
456
+ if (computeResource?.type === 'host') {
457
+ if (computeResource.state === 'Error') {
458
+ // TODO check Maintenance Mode
459
+ res = [
460
+ 'error',
461
+ localization.value.common.selectedHostDisconnectedMaintenanceMode,
462
+ ]
463
+ }
464
+ }
465
+
466
+ return res
467
+ })
468
+ const computeResourceAlert = ref<string[]>([])
469
+ const checkComputeResource = (
470
+ value: UI_I_WizardStep[]
471
+ ): UI_I_ValidationReturn => {
472
+ let stepHasError = false
473
+
474
+ const { computeResource } = vmForm.value
475
+
476
+ if (
477
+ !computeResource ||
478
+ // compatibilityText.value[0] !== 1 ||
479
+ computeResource.type === 'datacenter' ||
480
+ computeResource.type === 'folder' ||
481
+ (computeResource.type === 'cluster' && !computeResource.nodes.length)
482
+ ) {
483
+ computeResourceAlert.value = [
484
+ localization.value.common.specifyValidClusterOrHostDestination,
485
+ ]
486
+ stepHasError = wizard.setValidation(
487
+ dynamicSteps.selectComputeResource,
488
+ 'computeResource',
489
+ {
490
+ fieldMessage: 'aaa',
491
+ alertMessage: 'aaa',
492
+ }
493
+ )
494
+ } else {
495
+ computeResourceAlert.value = []
496
+ if (
497
+ wizard.hasMessage(dynamicSteps.selectComputeResource, 'computeResource')
498
+ ) {
499
+ value = wizard.removeValidation(
500
+ dynamicSteps.selectComputeResource,
501
+ 'computeResource',
502
+ value
503
+ )
504
+ }
505
+ }
506
+
507
+ return {
508
+ stepHasError,
509
+ newValue: value,
510
+ }
511
+ }
512
+ const checkStorage = async (
513
+ value: UI_I_WizardStep[]
514
+ ): Promise<UI_I_ValidationReturn> => {
515
+ let stepHasError = false
516
+
517
+ return new Promise((resolve) => {
518
+ storageSubmit.value = (isValid: boolean) => {
519
+ if (!isValid) {
520
+ stepHasError = wizard.setValidation(
521
+ dynamicSteps.selectStorage,
522
+ 'storage',
523
+ {
524
+ fieldMessage: 'aaa',
525
+ alertMessage: 'aaa',
526
+ }
527
+ )
528
+ } else if (wizard.hasMessage(dynamicSteps.selectStorage, 'storage')) {
529
+ value = wizard.removeValidation(
530
+ dynamicSteps.selectStorage,
531
+ 'storage',
532
+ value
533
+ )
534
+ }
535
+
536
+ resolve({
537
+ stepHasError,
538
+ newValue: value,
539
+ })
540
+ storageSubmit.value = null
541
+ }
542
+ })
543
+ }
544
+ const checkCustomizeHardware = async (
545
+ value: UI_I_WizardStep[]
546
+ ): Promise<UI_I_ValidationReturn> => {
547
+ let stepHasError = false
548
+
549
+ return new Promise((resolve) => {
550
+ customizeHardwareSubmit.value = (isValid: boolean) => {
551
+ if (!isValid) {
552
+ stepHasError = wizard.setValidation(
553
+ dynamicSteps.customizeHardware,
554
+ 'customizeHardware',
555
+ {
556
+ fieldMessage: 'aaa',
557
+ alertMessage: 'aaa',
558
+ }
559
+ )
560
+ } else if (
561
+ wizard.hasMessage(dynamicSteps.customizeHardware, 'customizeHardware')
562
+ ) {
563
+ value = wizard.removeValidation(
564
+ dynamicSteps.customizeHardware,
565
+ 'customizeHardware',
566
+ value
567
+ )
568
+ }
569
+
570
+ resolve({
571
+ stepHasError,
572
+ newValue: value,
573
+ })
574
+ storageSubmit.value = null
575
+ }
576
+ })
577
+ }
578
+
579
+ const vmForm = ref<UI_I_VmForm>({
580
+ name: '',
581
+ compatibility: '',
582
+ guestMachineType: null,
583
+ guestOsFamily: null,
584
+ guestOsVersion: null,
585
+ computeResource: props.computeResource,
586
+ storage: null,
587
+ locationPath: '',
588
+ dataCenter: null,
589
+ options: [],
590
+ })
591
+
592
+ const isLoadingComputeTree = ref<boolean>(false)
593
+ const onChangeName = (data: [string, UI_I_TreeNode | null]): void => {
594
+ const [name, node] = data
595
+
596
+ vmForm.value.name = name
597
+ if (isSphere.value) {
598
+ vmForm.value.locationPath = node.id
599
+ vmForm.value.dataCenter = $recursion.findParentByValue(
600
+ node,
601
+ 'datacenter',
602
+ 'type',
603
+ 'parent'
604
+ )
605
+ isLoadingComputeTree.value = true
606
+ emits('get-compute-resource-tree', {
607
+ id: node.id,
608
+ cb: () => {
609
+ isLoadingComputeTree.value = false
610
+ },
611
+ })
612
+ }
613
+ }
614
+ const onChangeStorage = (storage: UI_I_DatastoreTableItem | null): void => {
615
+ if (!storage) return
616
+
617
+ vmForm.value.storage = storage
618
+ }
619
+ const onChangeSelectOptions = (options: string[]): void => {
620
+ vmForm.value.options = options
621
+ if (
622
+ options.includes('customize-os') &&
623
+ options.includes('customize-hardware')
624
+ ) {
625
+ let procuratorSchame = isScheduledTasks.value ? 7 : 3
626
+ let sphereSchame = isScheduledTasks.value ? 15 : 11
627
+ wizard.changeScheme(isSphere.value ? sphereSchame : procuratorSchame)
628
+ } else if (options.includes('customize-os')) {
629
+ let procuratorSchame = isScheduledTasks.value ? 5 : 1
630
+ let sphereSchame = isScheduledTasks.value ? 13 : 9
631
+ wizard.changeScheme(isSphere.value ? sphereSchame : procuratorSchame)
632
+ } else if (options.includes('customize-hardware')) {
633
+ let procuratorSchame = isScheduledTasks.value ? 6 : 2
634
+ let sphereSchame = isScheduledTasks.value ? 14 : 10
635
+ wizard.changeScheme(isSphere.value ? sphereSchame : procuratorSchame)
636
+ } else {
637
+ let procuratorSchame = isScheduledTasks.value ? 4 : 0
638
+ let sphereSchame = isScheduledTasks.value ? 12 : 8
639
+ wizard.changeScheme(isSphere.value ? sphereSchame : procuratorSchame)
640
+ }
641
+
642
+ // Change power on by default
643
+ isPowerOnByDefault.value = options.includes('power-on')
644
+ }
645
+ const customizeHardware = ref<UI_I_SendDataCustomizeHardware | null>(null)
646
+ const onChangeCustomizeHardware = (
647
+ data: UI_I_SendDataCustomizeHardware
648
+ ): void => {
649
+ customizeHardware.value = data
650
+ }
651
+
652
+ const virtualHardwareHardDisksLocal = computed<
653
+ UI_I_SendDataNewHardDisk[] | null
654
+ >(() => customizeHardware.value?.virtualHardware?.hardDisks || null)
655
+ const virtualHardwareNetworksLocal = computed<UI_I_SendDataNewNetwork[] | null>(
656
+ () => customizeHardware.value?.virtualHardware?.networks || null
657
+ )
658
+ const virtualHardwareCdDvdDrivesLocal = computed<
659
+ UI_I_SendDataNewCdDvdDrive[] | null
660
+ >(() => customizeHardware.value?.virtualHardware?.cdDvdDrives || null)
661
+
662
+ const virtualHardwareCpu = computed<UI_I_SendDataCpu | null>(
663
+ () => customizeHardware.value?.virtualHardware?.cpu || null
664
+ )
665
+ const virtualHardwareMemory = computed<UI_I_SendDataMemory | null>(
666
+ () => customizeHardware.value?.virtualHardware?.memory || null
667
+ )
668
+ const virtualHardwareHardDisks = ref<UI_I_SendDataNewHardDisk[] | null>(null)
669
+ const virtualHardwareCdDvdDrives = ref<UI_I_SendDataNewCdDvdDrive[] | null>(
670
+ null
671
+ )
672
+ const virtualHardwareNetworks = ref<UI_I_SendDataNewNetwork[] | null>(null)
673
+ const onChangeBootOrder = (data: UI_T_ChangeBootOrder): void => {
674
+ virtualHardwareHardDisks.value = data[0]
675
+ virtualHardwareCdDvdDrives.value = data[1]
676
+ virtualHardwareNetworks.value = data[2]
677
+ }
678
+
679
+ const isPowerOnByDefault = ref<boolean>(false)
680
+
681
+ watch(
682
+ () => props.vmNameInWizard,
683
+ (newValue) => {
684
+ vmForm.value.name = newValue
685
+ }
686
+ )
687
+
688
+ const validateSendData = async (
689
+ value: UI_I_WizardStep[]
690
+ ): Promise<UI_I_ValidationReturn> => {
691
+ wizard.setLoader(true)
692
+ let stepHasError = false
693
+
694
+ const data = await props.validateSendDataFunc(
695
+ vmForm.value,
696
+ virtualHardwareCpu.value,
697
+ virtualHardwareMemory.value,
698
+ customizeHardware.value,
699
+ virtualHardwareNetworks.value,
700
+ virtualHardwareHardDisks.value,
701
+ virtualHardwareCdDvdDrives.value,
702
+ isPowerOnByDefault.value,
703
+ localization.value,
704
+ vmForm.value.locationPath, // для сферы
705
+ // computeResourcePath.value // для сферы
706
+ vmSettings.value.host_id // для сферы // TODO rollback
707
+ )
708
+
709
+ wizard.setLoader(false)
710
+ if (data) {
711
+ stepHasError = true
712
+ selectedNavItem.value = data[0]
713
+ }
714
+
715
+ return {
716
+ stepHasError,
717
+ newValue: value,
718
+ }
719
+ }
720
+
721
+ const isLoading = ref<boolean>(false)
722
+ const onFinish = (): void => {
723
+ isLoading.value = true
724
+ wizard.setLoader(false)
725
+ props
726
+ .finishFunc(
727
+ vmForm.value,
728
+ virtualHardwareCpu.value,
729
+ virtualHardwareMemory.value,
730
+ customizeHardware.value,
731
+ virtualHardwareNetworks.value,
732
+ virtualHardwareHardDisks.value,
733
+ virtualHardwareCdDvdDrives.value,
734
+ isPowerOnByDefault.value,
735
+ localization.value,
736
+ vmForm.value.locationPath, // для сферы
737
+ // computeResourcePath.value, // для сферы
738
+ vmSettings.value.host_id, // для сферы // TODO rollback
739
+ false,
740
+ schedulerTaskForm.value,
741
+ props.schedulerTask
742
+ )
743
+ .then(() => {
744
+ isLoading.value = false
745
+ onHideModal()
746
+ wizard.setLoader(false)
747
+ })
748
+ }
749
+
750
+ const selectedNavItem = ref<UI_T_SelectedNavItem>(0)
751
+
752
+ const nameFormSubmit = ref<null | Function>(null)
753
+ const storageSubmit = ref<null | Function>(null)
754
+ const customizeHardwareSubmit = ref<null | Function>(null)
755
+
756
+ const vmSettings = computed<UI_I_VmSettings | null>(() => props.vmSettings)
757
+ const vmName = ref<string>(vmSettings.value?.name || '')
758
+
759
+ const guestOsFamilies = ref<UI_I_OptionItem[]>(
760
+ capabilities.value.guestOsFamilies
761
+ )
762
+ const guestOsVersions = ref<UI_I_ArbitraryObject<UI_I_OptionItem[]>>(
763
+ capabilities.value.guestOsVersions
764
+ )
765
+ const machineTypes = ref<UI_I_OptionItem[]>(capabilities.value.machineTypes)
766
+
767
+ // Для сферы
768
+ const computeResourcePath = ref<string>('')
769
+ watch(
770
+ () => vmForm.value.computeResource,
771
+ (newValue, oldValue) => {
772
+ if (newValue && newValue.id !== oldValue?.id) {
773
+ onSelectComputeResourceTree(newValue)
774
+ }
775
+ },
776
+ { deep: true }
777
+ )
778
+ const onSelectComputeResourceTree = (node: UI_I_TreeNode): void => {
779
+ emits('select-compute-resource-tree', node)
780
+ computeResourcePath.value = String(node.id)
781
+ }
782
+
783
+ watch(vmSettings, (newValue) => {
784
+ vmName.value = newValue?.name || ''
785
+
786
+ if (newValue?.guestOsFamily)
787
+ vmForm.value.guestOsFamily = newValue.guestOsFamily
788
+ if (newValue?.guestMachineType)
789
+ vmForm.value.guestMachineType = newValue.guestMachineType
790
+ if (newValue?.guestOsVersion)
791
+ vmForm.value.guestOsVersion = newValue.guestOsVersion
792
+
793
+ if (newValue?.compatibility)
794
+ vmForm.value.compatibility = newValue.compatibility
795
+
796
+ if (newValue?.storage) {
797
+ const datastore = props.datastore.find(
798
+ (item) => item.id === newValue.storage.id
799
+ )
800
+ if (datastore) vmForm.value.storage = datastore
801
+ }
802
+ })
803
+
804
+ const onHideModal = (): void => {
805
+ emits('hide')
806
+ }
807
+ </script>
808
+
809
+ <style scoped lang="scss"></style>