bfg-common 1.5.502 → 1.5.503

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