bfg-common 1.5.575 → 1.5.577

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