bfg-common 1.5.536 → 1.5.538

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