bfg-common 1.5.501 → 1.5.502

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