bfg-common 1.5.521 → 1.5.523

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