bfg-common 1.4.655 → 1.4.657

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 (153) hide show
  1. package/assets/img/icons/icons-sprite-dark-3.svg +227 -227
  2. package/assets/img/icons/icons-sprite-dark-5.svg +488 -488
  3. package/assets/img/icons/icons-sprite-light-3.svg +227 -227
  4. package/assets/img/icons/icons-sprite-light-5.svg +488 -488
  5. package/assets/localization/local_be.json +13 -1
  6. package/assets/localization/local_en.json +13 -1
  7. package/assets/localization/local_hy.json +13 -1
  8. package/assets/localization/local_kk.json +13 -1
  9. package/assets/localization/local_ru.json +14 -2
  10. package/assets/localization/local_zh.json +13 -1
  11. package/components/atoms/TheIcon3.vue +50 -50
  12. package/components/atoms/modal/bySteps/BySteps.vue +253 -253
  13. package/components/atoms/stack/StackBlock.vue +185 -185
  14. package/components/atoms/table/dataGrid/DataGrid.vue +1633 -1633
  15. package/components/atoms/table/dataGrid/DataGridColumnSwitch.vue +222 -222
  16. package/components/common/browse/BrowseNew.vue +237 -237
  17. package/components/common/browse/BrowseOld.vue +217 -217
  18. package/components/common/browse/blocks/contents/Files.vue +37 -37
  19. package/components/common/browse/blocks/contents/FilesOld.vue +72 -72
  20. package/components/common/browse/blocks/contents/filesNew/FilesNew.vue +96 -96
  21. package/components/common/browse/blocks/contents/filesNew/Skeleton.vue +18 -18
  22. package/components/common/browse/blocks/lib/models/types.ts +1 -1
  23. package/components/common/browse/lib/models/interfaces.ts +5 -5
  24. package/components/common/context/lib/models/interfaces.ts +30 -30
  25. package/components/common/context/recursion/Recursion.vue +86 -86
  26. package/components/common/context/recursion/RecursionNew.vue +199 -199
  27. package/components/common/context/recursion/RecursionOld.vue +213 -213
  28. package/components/common/diagramMain/Header.vue +211 -211
  29. package/components/common/diagramMain/adapter/AdapterItems.vue +61 -61
  30. package/components/common/diagramMain/lib/config/initial.ts +50 -50
  31. package/components/common/diagramMain/lib/models/types.ts +21 -21
  32. package/components/common/diagramMain/lib/utils/utils.ts +331 -331
  33. package/components/common/diagramMain/modals/ManagePhysicalAdaptersModal.vue +330 -330
  34. package/components/common/diagramMain/modals/editSettings/ConfirmTeamingSettingsModal.vue +40 -40
  35. package/components/common/diagramMain/modals/editSettings/EditSettings.vue +497 -497
  36. package/components/common/diagramMain/modals/editSettings/EditSettingsModal.vue +812 -812
  37. package/components/common/diagramMain/modals/editSettings/tabs/NetworkProperties.vue +214 -214
  38. package/components/common/diagramMain/modals/editSettings/tabs/Security.vue +189 -189
  39. package/components/common/diagramMain/modals/editSettings/tabs/SwitchProperties.vue +163 -163
  40. package/components/common/diagramMain/modals/editSettings/tabs/TeamingFailover.vue +175 -175
  41. package/components/common/diagramMain/modals/editSettings/tabs/TrafficShaping.vue +398 -398
  42. package/components/common/diagramMain/modals/editSettings/tabs/port/IpvFourSettings.vue +346 -346
  43. package/components/common/diagramMain/modals/editSettings/tabs/port/PortProperties.vue +205 -205
  44. package/components/common/diagramMain/modals/lib/config/diagramConfig.ts +23 -23
  45. package/components/common/diagramMain/modals/lib/config/initial.ts +180 -180
  46. package/components/common/diagramMain/modals/lib/config/vmKernelAdapter.ts +90 -90
  47. package/components/common/diagramMain/modals/lib/mappers/mappers.ts +87 -87
  48. package/components/common/diagramMain/modals/lib/utils/index.ts +24 -24
  49. package/components/common/diagramMain/modals/migrateVmkernelAdapter/MigrateVmkernelAdapter.vue +537 -537
  50. package/components/common/diagramMain/modals/migrateVmkernelAdapter/lib/config/steps.ts +114 -114
  51. package/components/common/diagramMain/modals/migrateVmkernelAdapter/steps/ConnectionSettings.vue +169 -169
  52. package/components/common/diagramMain/modals/migrateVmkernelAdapter/steps/SelectVmkernelAdapter.vue +159 -159
  53. package/components/common/diagramMain/modals/migrateVmkernelAdapter/validations/common.ts +14 -14
  54. package/components/common/diagramMain/modals/migrateVmkernelAdapter/validations/connectionSettings.ts +137 -137
  55. package/components/common/diagramMain/modals/migrateVmkernelAdapter/validations/selectVmkernelAdapter.ts +52 -52
  56. package/components/common/diagramMain/modals/migrateVmkernelAdapter/validations/validations.ts +19 -19
  57. package/components/common/diagramMain/port/Ports.vue +47 -47
  58. package/components/common/layout/theHeader/helpMenu/About.vue +85 -85
  59. package/components/common/layout/theHeader/helpMenu/aboutNew/AboutNew.vue +105 -105
  60. package/components/common/mainNavigationPanel/MainNavigationPanel.vue +152 -152
  61. package/components/common/modals/confirmByInput/ConfirmByInput.vue +206 -206
  62. package/components/common/modals/unsavedChanges/UnsavedChanges.vue +56 -56
  63. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/lib/config/utils.ts +143 -2
  64. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/lib/models/interfaces.ts +1 -0
  65. package/components/common/monitor/advanced/tools/chartOptionsModal/lib/models/types.ts +1 -1
  66. package/components/common/monitor/advanced/tools/chartOptionsModal/metrics/lib/config/optionsMetrics.ts +5 -5
  67. package/components/common/monitor/overview/filters/Filters.vue +1 -3
  68. package/components/common/monitor/overview/filters/lib/config/filterOptions.ts +27 -9
  69. package/components/common/monitor/overview/filters/lib/models/interfaces.ts +1 -0
  70. package/components/common/monitor/overview/filters/lib/models/types.ts +2 -0
  71. package/components/common/monitor/resourceAllocation/lib/models/interfaces.ts +13 -0
  72. package/components/common/monitor/resourceAllocation/resourceAllocation.vue +196 -0
  73. package/components/common/spiceConsole/Drawer.vue +370 -370
  74. package/components/common/spiceConsole/lib/models/interfaces.ts +5 -5
  75. package/components/common/split/vertical/Vertical.vue +160 -160
  76. package/components/common/vm/actions/add/Add.vue +617 -617
  77. package/components/common/vm/actions/clone/lib/config/steps.ts +129 -129
  78. package/components/common/vm/actions/common/customizeHardware/CustomizeHardware.vue +267 -267
  79. package/components/common/vm/actions/common/customizeHardware/CustomizeHardwareNew.vue +269 -269
  80. package/components/common/vm/actions/common/customizeHardware/virtualHardware/browseView/BrowseView.vue +219 -219
  81. package/components/common/vm/actions/common/customizeHardware/virtualHardware/bus/BusNew.vue +118 -118
  82. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/CdDvdDriveNew.vue +161 -161
  83. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/CdDvdDriveOld.vue +165 -165
  84. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/media/Media.vue +25 -25
  85. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/media/MediaNew.vue +55 -55
  86. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/Cpu.vue +338 -338
  87. package/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/config/dropdownItems.ts +147 -147
  88. package/components/common/vm/actions/common/customizeHardware/virtualHardware/limit/Limit.vue +220 -220
  89. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/mode/ModeOld.vue +55 -55
  90. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/sharing/SharingNew.vue +44 -44
  91. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/NewNetwork.vue +281 -281
  92. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/NewNetworkNew.vue +124 -124
  93. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/location/LocationOld.vue +134 -134
  94. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/location/new/New.vue +63 -63
  95. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/location/new/table/lib/config/config.ts +95 -95
  96. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/macAddress/MacAddress.vue +119 -119
  97. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/macAddress/MacAddressNew.vue +69 -69
  98. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/macAddress/MacAddressOld.vue +83 -83
  99. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/NewPciDeviceNew.vue +85 -85
  100. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/NewPciDeviceOld.vue +91 -91
  101. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/directPathIo/DirectPathIoNew.vue +35 -35
  102. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/dynamicDirectPathIo/DynamicDirectPathIoNew.vue +48 -48
  103. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/note/Note.vue +15 -15
  104. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/note/NoteNew.vue +42 -42
  105. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/note/NoteOld.vue +30 -30
  106. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/nvidiaGrid/NvidiaGridNew.vue +30 -30
  107. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/typeSelection/TypeSelectionNew.vue +46 -46
  108. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newUsbController/NewUsbControllerNew.vue +56 -56
  109. package/components/common/vm/actions/common/customizeHardware/virtualHardware/other/Other.vue +16 -16
  110. package/components/common/vm/actions/common/customizeHardware/virtualHardware/other/OtherNew.vue +30 -30
  111. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/VideoCardNew.vue +107 -107
  112. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/VideoCardOld.vue +115 -115
  113. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/totalVideoMemory/TotalVideoMemoryNew.vue +54 -54
  114. package/components/common/vm/actions/common/customizeHardware/vmoptions/Vmoptions.vue +145 -145
  115. package/components/common/vm/actions/common/customizeHardware/vmoptions/VmoptionsNew.vue +102 -102
  116. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/BootOptionsNew.vue +75 -75
  117. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/delay/Delay.vue +26 -26
  118. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/firmware/Firmware.vue +57 -57
  119. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/firmware/FirmwareNew.vue +42 -42
  120. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/menu/MenuNew.vue +25 -25
  121. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/Order.vue +171 -171
  122. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/OrderNew.vue +50 -50
  123. package/components/common/vm/actions/common/customizeHardware/vmoptions/generalOptions/GeneralOptionsNew.vue +141 -141
  124. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/New.vue +140 -140
  125. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/copyPaste/CopyPasteNew.vue +30 -30
  126. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/fileTransfer/FileTransferNew.vue +30 -30
  127. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/folderSharing/FolderSharingNew.vue +30 -30
  128. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/keymap/Keymap.vue +32 -32
  129. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/keymap/KeymapNew.vue +39 -39
  130. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/password/Password.vue +103 -103
  131. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/password/PasswordNew.vue +102 -102
  132. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/password/PasswordOld.vue +94 -94
  133. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/usbRedirection/UsbRedirection.vue +28 -28
  134. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/usbRedirection/UsbRedirectionNew.vue +38 -38
  135. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/usbRedirection/UsbRedirectionOld.vue +44 -44
  136. package/components/common/vm/actions/common/select/storage/Storage.vue +130 -130
  137. package/components/common/vm/actions/common/select/storage/StorageOld.vue +129 -129
  138. package/components/common/vm/actions/editSettings/EditSettings.vue +232 -232
  139. package/components/common/vm/actions/editSettings/EditSettingsOld.vue +183 -183
  140. package/components/common/vm/actions/editSettings/new/New.vue +177 -177
  141. package/components/common/vm/actions/editSettings/new/Skeleton.vue +88 -88
  142. package/components/common/wizards/datastore/add/Add.vue +1 -1
  143. package/components/common/wizards/datastore/add/nfs/accessibility/tablesView/TablesView.vue +1 -2
  144. package/components/common/wizards/network/add/lib/config/steps.ts +464 -464
  145. package/composables/productNameLocal.ts +30 -30
  146. package/package.json +1 -1
  147. package/plugins/date.ts +233 -233
  148. package/plugins/recursion.ts +311 -311
  149. package/public/spice-console/lib/images/bitmap.js +203 -203
  150. package/public/spice-console/network/spicechannel.js +383 -383
  151. package/store/main/mutations.ts +7 -7
  152. package/store/main/state.ts +7 -7
  153. package/store/tasks/mappers/recentTasks.ts +64 -64
@@ -1,617 +1,617 @@
1
- <template>
2
- <div class="add-vm">
3
- <atoms-wizard
4
- show
5
- :wizard="wizard"
6
- :selected-scheme="selectedScheme"
7
- :title="localization.common.newVirtualMachine2"
8
- :localization="localization"
9
- test-id="new-virtual-machine-wizard"
10
- @change-steps="onChangeSteps"
11
- @hide="onHideModal"
12
- @submit="onFinish"
13
- >
14
- <template #modalBody="{ selectedStep }">
15
- <div class="add-vm-content">
16
- <common-vm-actions-common-select-create-type
17
- v-show="selectedStep.id === 0"
18
- :import-from-v-m-warev-sphere="props.importFromVMWarevSphere"
19
- />
20
- <common-vm-actions-common-select-name
21
- v-show="selectedStep.id === 1 || selectedStep.id === 2"
22
- :show="selectedStep.id === 1 || selectedStep.id === 2"
23
- :name-form-submit="nameFormSubmit"
24
- :project="props.project"
25
- :data-center="props.dataCenter"
26
- @submit="onChangeName(...$event)"
27
- @check-name="emits('check-name', $event)"
28
- />
29
- <common-vm-actions-common-select-compute-resource
30
- v-if="isSphere"
31
- v-show="selectedStep.id === 3"
32
- v-model="vmForm.computeResource"
33
- :compute-resource-submit="computeResourceSubmit"
34
- :data-center="vmForm.dataCenter"
35
- :compute-resource="props.computeResource"
36
- :compute-resource-tree="props.computeResourceTree"
37
- @submit="onChangeComputeResource"
38
- @select-compute-resource-tree="onSelectComputeResourceTree"
39
- @get-compute-resource-tree="
40
- emits('get-compute-resource-tree', $event)
41
- "
42
- @show-compute-resource-tree="
43
- emits('show-compute-resource-tree', $event)
44
- "
45
- @clear-compute-resource-tree="
46
- emits('clear-compute-resource-tree', $event)
47
- "
48
- />
49
- <common-vm-actions-common-select-storage
50
- v-show="selectedStep.id === 4"
51
- :storage-submit="storageSubmit"
52
- :datastore="props.datastore"
53
- :get-datastore-table-func="props.getDatastoreTableFunc"
54
- @submit="onChangeStorage"
55
- />
56
- <common-vm-actions-common-select-compatibility
57
- v-show="selectedStep.id === 5"
58
- :options="compatibility"
59
- :error-validation-fields="props.errorValidationFields"
60
- @change="onChangeCompatibility"
61
- @remove-error-by-title="emits('remove-error-by-title', $event)"
62
- />
63
- <common-vm-actions-common-select-os
64
- v-show="selectedStep.id === 6 || selectedStep.id === 7"
65
- :families-options="guestOsFamilies"
66
- :versions-options="guestOsVersions"
67
- :machine-types-options="machineTypes"
68
- :error-validation-fields="props.errorValidationFields"
69
- @change="onChangeOs"
70
- @remove-error-by-title="emits('remove-error-by-title', $event)"
71
- />
72
- <common-vm-actions-common-customize-hardware
73
- v-show="selectedStep.id === 8"
74
- :project="props.project"
75
- :vm-name="vmForm.name"
76
- :guest-machine-type="vmForm.guestMachineType"
77
- :guest-os-family="vmForm.guestOsFamily"
78
- :guest-os-version="vmForm.guestOsVersion"
79
- :storage="vmForm.storage"
80
- :hard-disks-for-boot-options="virtualHardwareHardDisksLocal"
81
- :cd-dvd-drives-for-boot-options="virtualHardwareCdDvdDrivesLocal"
82
- :networks-for-boot-options="virtualHardwareNetworksLocal"
83
- :cd-dvd-drives="virtualHardwareCdDvdDrivesLocal"
84
- :customize-hardware-submit="customizeHardwareSubmit"
85
- :max-cpus="maxCpus"
86
- :max-memory="maxMemory"
87
- :cpu-models="cpuModels"
88
- :selected-nav-item="selectedNavItem"
89
- :nodes="props.nodes"
90
- :files="props.files"
91
- :networks-table="props.networksTable"
92
- :error-validation-fields="props.errorValidationFields"
93
- :get-datastore-table-func="props.getDatastoreTableFunc"
94
- :datastore="props.datastore"
95
- :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
96
- :passthrough-devices="props.passthroughDevices"
97
- @change-boot-order="onChangeBootOrder"
98
- @send-data="onChangeCustomizeHardware"
99
- @get-storage="emits('get-storage', $event)"
100
- @get-folders-or-files="emits('get-folders-or-files', $event)"
101
- @get-active-device-child="emits('get-active-device-child', $event)"
102
- @show-datastore-child="emits('show-datastore-child', $event)"
103
- @remove-error-by-title="emits('remove-error-by-title', $event)"
104
- @get-networks-table="emits('get-networks-table', $event)"
105
- @get-pci-devices="emits('get-pci-devices')"
106
- />
107
- <common-ready-to-complete
108
- v-if="selectedStep.id === 9"
109
- :data="props.readyCompleteTableInfo"
110
- />
111
- <span v-if="selectedStep.id > 5" class="vm-hardware-version">{{
112
- compatibilityInfo
113
- }}</span>
114
- </div>
115
- </template>
116
-
117
- <template #modalFooterContent>
118
- <div v-if="isShowPowerOn" class="power-on-by-default-wrap">
119
- <input
120
- id="power-on-by-default"
121
- v-model="isPowerOnByDefault"
122
- data-id="power-on-by-default"
123
- type="checkbox"
124
- />
125
- <label for="power-on-by-default" class="label-text-normal">{{
126
- localization.common.powerOnByDefault
127
- }}</label>
128
- </div>
129
- </template>
130
- </atoms-wizard>
131
- </div>
132
- </template>
133
-
134
- <script setup lang="ts">
135
- import type {
136
- UI_I_Localization,
137
- UI_I_ArbitraryObject,
138
- } from '~/lib/models/interfaces'
139
- import type { UI_T_Project } from '~/lib/models/types'
140
- import type { UI_I_FileTreeNode } from '~/components/lib/models/interfaces'
141
- import type { UI_I_NetworkTableItem } from '~/lib/models/store/network/interfaces'
142
- import type {
143
- UI_I_DatastoreTableItem,
144
- UI_I_FolderOrFileTreePayload,
145
- } from '~/lib/models/store/storage/interfaces'
146
- import type {
147
- API_UI_I_Error,
148
- UI_I_ErrorValidationField,
149
- } from '~/lib/models/store/interfaces'
150
- import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
151
- import type { UI_I_TableInfoItem } from '~/components/atoms/table/info/lib/models/interfaces'
152
- import type {
153
- UI_T_AddVmFinishFunc,
154
- UI_T_SelectedNavItem,
155
- } from '~/components/common/vm/actions/common/lib/models/types'
156
- import type { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
157
- import type {
158
- UI_I_ValidationReturn,
159
- UI_I_WizardStep,
160
- } from '~/components/atoms/wizard/lib/models/interfaces'
161
- import type {
162
- UI_I_Capabilities,
163
- UI_I_VmForm,
164
- UI_I_VmFormCash,
165
- } from '~/components/common/vm/actions/common/lib/models/interfaces'
166
- import type { UI_I_SendDataCustomizeHardware } from '~/components/common/vm/actions/common/customizeHardware/lib/models/interfaces'
167
- import type { UI_I_OsChange } from '~/components/common/vm/actions/common/select/lib/models/interfaces'
168
- import type {
169
- UI_I_SendDataCpu,
170
- UI_I_SendDataMemory,
171
- UI_I_SendDataNewCdDvdDrive,
172
- UI_I_SendDataNewHardDisk,
173
- UI_I_SendDataNewNetwork,
174
- } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
175
- import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
176
- import type { UI_T_ChangeBootOrder } from '~/components/common/vm/actions/lib/models/types'
177
- import type { UI_I_PciDevice } from '~/lib/models/store/vm/interfaces'
178
- import { capabilities } from '~/components/common/vm/actions/common/lib/config/capabilities'
179
- import {
180
- stepsSchemeInitial,
181
- stepsFunc,
182
- } from '~/components/common/vm/actions/add/lib/config/steps'
183
- import Wizard from '~/components/atoms/wizard/lib/utils/utils'
184
- import { mapCapabilities } from '~/components/common/vm/actions/common/lib/utils/capabilities'
185
-
186
- const props = defineProps<{
187
- project: UI_T_Project
188
- nodes: UI_I_FileTreeNode[]
189
- files: UI_I_FileTreeNode[]
190
- networksTable: UI_I_NetworkTableItem[]
191
- datastore: UI_I_DatastoreTableItem[]
192
- errorValidationFields: UI_I_ErrorValidationField[]
193
- readyCompleteTableInfo: UI_I_TableInfoItem[]
194
- vmCpuHelpTextSecond: string
195
- importFromVMWarevSphere: string
196
- finishFunc: UI_T_AddVmFinishFunc
197
- getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
198
- validateSendDataFunc: UI_T_AddVmFinishFunc<
199
- [UI_T_SelectedNavItem, null | number] | null
200
- >
201
- passthroughDevices: UI_I_PciDevice[]
202
- vmNameInWizard: string
203
- capabilities?: UI_I_Capabilities
204
- dataCenter?: UI_I_TreeNode // для сферы
205
- computeResource?: UI_I_TreeNode // для сферы
206
- computeResourceTree?: UI_I_TreeNode[] // для сферы
207
- }>()
208
-
209
- const emits = defineEmits<{
210
- (event: 'check-name', value: [string, (error: API_UI_I_Error) => void]): void
211
- (event: 'get-storage', value: UI_I_TablePayload): void
212
- (event: 'get-folders-or-files', value: UI_I_FolderOrFileTreePayload): void
213
- (event: 'get-active-device-child', value: UI_I_FileTreeNode): void
214
- (event: 'show-datastore-child', value: UI_I_FileTreeNode): void
215
- (event: 'remove-error-by-title', value: string): void
216
- (event: 'get-networks-table', value: UI_I_TablePayload): void
217
- (event: 'get-pci-devices'): void
218
- (event: 'get-pci-devices'): void
219
- (event: 'hide'): void
220
- (
221
- event: 'get-compute-resource-tree',
222
- value: { id: string | number; cb: () => void }
223
- ): void // для сферы
224
- (event: 'show-compute-resource-tree', value: UI_I_TreeNode): void // для сферы
225
- (event: 'select-compute-resource-tree', value: UI_I_TreeNode): void // для сферы
226
- (event: 'clear-compute-resource-tree'): void // для сферы
227
- }>()
228
-
229
- const isSphere = computed<boolean>(() => props.project === 'sphere')
230
-
231
- const { $recursion } = useNuxtApp()
232
-
233
- const localization = computed<UI_I_Localization>(() => useLocal())
234
-
235
- watch(
236
- () => props.capabilities,
237
- () => {
238
- if (props.capabilities) mapCapabilities(props.capabilities)
239
- },
240
- { deep: true, immediate: true }
241
- )
242
-
243
- const wizard: Wizard = new Wizard(
244
- stepsFunc(localization.value),
245
- stepsSchemeInitial
246
- )
247
- if (isSphere.value) wizard.changeScheme(1)
248
- const selectedScheme = computed<number[]>(() => wizard.selectedScheme.value)
249
- // const alertMessages = computed<string[][]>(() => wizard.alertMessages.value)
250
-
251
- const isShowPowerOn = computed<boolean>(() => wizard.selectedStepId > 8)
252
-
253
- const onChangeSteps = async (value: UI_I_WizardStep[]): Promise<void> => {
254
- wizard.changeSteps(value, validationFunc, validateSendData)
255
- }
256
- const validationFunc = async (
257
- value: UI_I_WizardStep[],
258
- currentStep: UI_I_WizardStep,
259
- nextStep: UI_I_WizardStep
260
- ): Promise<UI_I_ValidationReturn> => {
261
- let stepHasError = false
262
- let stepShouldStop = {
263
- ifOnCurrentStep: false,
264
- ifFromAnyStep: false,
265
- stoppageStepId: -1,
266
- }
267
-
268
- wizard.setLoader(true)
269
- if (
270
- wizard.isValidateForStep(
271
- isSphere.value ? 2 : 1,
272
- currentStep.id,
273
- nextStep.id
274
- )
275
- ) {
276
- const nameValidation = await checkName(value)
277
-
278
- value = nameValidation.newValue
279
- stepHasError = stepHasError || nameValidation.stepHasError
280
- } else if (
281
- isSphere.value &&
282
- wizard.isValidateForStep(3, currentStep.id, nextStep.id)
283
- ) {
284
- const computeResourceValidation = await checkComputeResource(value)
285
-
286
- value = computeResourceValidation.newValue
287
- stepHasError = stepHasError || computeResourceValidation.stepHasError
288
- } else if (wizard.isValidateForStep(4, currentStep.id, nextStep.id)) {
289
- const storageValidation = await checkStorage(value)
290
-
291
- value = storageValidation.newValue
292
-
293
- stepHasError = stepHasError || storageValidation.stepHasError
294
- } else if (wizard.isValidateForStep(8, currentStep.id, nextStep.id)) {
295
- const storageValidation = await checkCustomizeHardware(value)
296
-
297
- value = storageValidation.newValue
298
-
299
- stepHasError = stepHasError || storageValidation.stepHasError
300
- }
301
- wizard.setLoader(false)
302
-
303
- return {
304
- newValue: value,
305
- stepHasError,
306
- stepShouldStop,
307
- }
308
- }
309
- const checkName = async (
310
- value: UI_I_WizardStep[]
311
- ): Promise<UI_I_ValidationReturn> => {
312
- let stepHasError = false
313
-
314
- return new Promise((resolve) => {
315
- const step = isSphere.value ? 2 : 1
316
- nameFormSubmit.value = (isValid: boolean) => {
317
- if (!isValid) {
318
- stepHasError = wizard.setValidation(step, 'name', {
319
- fieldMessage: 'aaa',
320
- alertMessage: 'aaa',
321
- })
322
- } else if (wizard.hasMessage(step, 'name')) {
323
- value = wizard.removeValidation(step, 'name', value)
324
- }
325
-
326
- resolve({
327
- stepHasError,
328
- newValue: value,
329
- })
330
- nameFormSubmit.value = null
331
- }
332
- })
333
- }
334
- const checkComputeResource = async (
335
- value: UI_I_WizardStep[]
336
- ): Promise<UI_I_ValidationReturn> => {
337
- let stepHasError = false
338
-
339
- return new Promise((resolve) => {
340
- computeResourceSubmit.value = (isValid: boolean) => {
341
- if (!isValid) {
342
- stepHasError = wizard.setValidation(3, 'computeResource', {
343
- fieldMessage: 'aaa',
344
- alertMessage: 'aaa',
345
- })
346
- } else if (wizard.hasMessage(3, 'computeResource')) {
347
- value = wizard.removeValidation(3, 'computeResource', value)
348
- }
349
-
350
- resolve({
351
- stepHasError,
352
- newValue: value,
353
- })
354
- computeResourceSubmit.value = null
355
- }
356
- })
357
- }
358
- const checkStorage = async (
359
- value: UI_I_WizardStep[]
360
- ): Promise<UI_I_ValidationReturn> => {
361
- let stepHasError = false
362
-
363
- return new Promise((resolve) => {
364
- storageSubmit.value = (isValid: boolean) => {
365
- if (!isValid) {
366
- stepHasError = wizard.setValidation(4, 'storage', {
367
- fieldMessage: 'aaa',
368
- alertMessage: 'aaa',
369
- })
370
- } else if (wizard.hasMessage(4, 'storage')) {
371
- value = wizard.removeValidation(4, 'storage', value)
372
- }
373
-
374
- resolve({
375
- stepHasError,
376
- newValue: value,
377
- })
378
- storageSubmit.value = null
379
- }
380
- })
381
- }
382
- const checkCustomizeHardware = async (
383
- value: UI_I_WizardStep[]
384
- ): Promise<UI_I_ValidationReturn> => {
385
- let stepHasError = false
386
-
387
- return new Promise((resolve) => {
388
- customizeHardwareSubmit.value = (isValid: boolean) => {
389
- if (!isValid) {
390
- stepHasError = wizard.setValidation(8, 'customizeHardware', {
391
- fieldMessage: 'aaa',
392
- alertMessage: 'aaa',
393
- })
394
- } else if (wizard.hasMessage(8, 'customizeHardware')) {
395
- value = wizard.removeValidation(8, 'customizeHardware', value)
396
- }
397
-
398
- resolve({
399
- stepHasError,
400
- newValue: value,
401
- })
402
- storageSubmit.value = null
403
- }
404
- })
405
- }
406
-
407
- const storageIdCash = ref<string | null>(null)
408
- const vmForm = ref<UI_I_VmForm>({
409
- name: '',
410
- compatibility: '',
411
- guestMachineType: null,
412
- guestOsFamily: null,
413
- guestOsVersion: null,
414
- computeResource: null,
415
- storage: null,
416
- locationPath: '',
417
- dataCenter: null,
418
- })
419
- const vmFormCash = ref<UI_I_VmFormCash>({
420
- dataCenterId: null,
421
- computeResourceTypeAndId: null,
422
- })
423
-
424
- const onChangeName = (name: string, node: UI_I_TreeNode): void => {
425
- vmForm.value.name = name
426
- if (isSphere.value) {
427
- vmForm.value.locationPath = node.id
428
- vmForm.value.dataCenter = $recursion.findParentByValue(
429
- node,
430
- 'datacenter',
431
- 'type',
432
- 'parent'
433
- )
434
- vmFormCash.value.dataCenterId = vmForm.value.dataCenter?.id || null
435
- }
436
- }
437
- // // Для сферы
438
- const computeResourcePath = ref<string>('')
439
- const onSelectComputeResourceTree = (node: UI_I_TreeNode): void => {
440
- emits('select-compute-resource-tree', node)
441
- computeResourcePath.value = node.id
442
- }
443
- const onChangeComputeResource = (node: UI_I_TreeNode): void => {
444
- vmForm.value.computeResource = node
445
- // const type = node.type.toUpperCase()
446
- // schedRequirementsTemplate.value = `sched_requirements="(${type}_ID=${node.id})"\\`
447
- vmFormCash.value.computeResourceTypeAndId = `${node.type}${node.id}` || null
448
- }
449
- const onChangeStorage = (storage: UI_I_DatastoreTableItem | null): void => {
450
- if (!storage) return
451
-
452
- vmForm.value.storage = storage
453
- storageIdCash.value = storage.id
454
- }
455
- const compatibilityInfo = ref<string>('')
456
- const onChangeCompatibility = (compatibility: UI_I_OptionItem): void => {
457
- vmForm.value.compatibility = compatibility.value
458
-
459
- const version = compatibility.value.split('-')[1]
460
- compatibilityInfo.value = `${localization.value.common.compatibility}: ${compatibility.text} (${localization.value.common.vmVersion} ${version})`
461
- }
462
- const onChangeOs = (data: UI_I_OsChange): void => {
463
- vmForm.value.guestMachineType = data.selectedMachineType
464
- vmForm.value.guestOsFamily = data.selectedOS
465
- vmForm.value.guestOsVersion = data.selectedVersion
466
- }
467
- const customizeHardware = ref<UI_I_SendDataCustomizeHardware | null>(null)
468
- const onChangeCustomizeHardware = (
469
- data: UI_I_SendDataCustomizeHardware
470
- ): void => {
471
- customizeHardware.value = data
472
- }
473
-
474
- const virtualHardwareHardDisksLocal = computed<
475
- UI_I_SendDataNewHardDisk[] | null
476
- >(() => customizeHardware.value?.virtualHardware?.hardDisks || null)
477
- const virtualHardwareNetworksLocal = computed<UI_I_SendDataNewNetwork[] | null>(
478
- () => customizeHardware.value?.virtualHardware?.networks || null
479
- )
480
- const virtualHardwareCdDvdDrivesLocal = computed<
481
- UI_I_SendDataNewCdDvdDrive[] | null
482
- >(() => customizeHardware.value?.virtualHardware?.cdDvdDrives || null)
483
-
484
- const virtualHardwareCpu = computed<UI_I_SendDataCpu | null>(
485
- () => customizeHardware.value?.virtualHardware?.cpu || null
486
- )
487
- const virtualHardwareMemory = computed<UI_I_SendDataMemory | null>(
488
- () => customizeHardware.value?.virtualHardware?.memory || null
489
- )
490
- const virtualHardwareHardDisks = ref<UI_I_SendDataNewHardDisk[] | null>(null)
491
- const virtualHardwareCdDvdDrives = ref<UI_I_SendDataNewCdDvdDrive[] | null>(
492
- null
493
- )
494
- const virtualHardwareNetworks = ref<UI_I_SendDataNewNetwork[] | null>(null)
495
- const onChangeBootOrder = (data: UI_T_ChangeBootOrder): void => {
496
- virtualHardwareHardDisks.value = data[0]
497
- virtualHardwareCdDvdDrives.value = data[1]
498
- virtualHardwareNetworks.value = data[2]
499
- }
500
-
501
- const isPowerOnByDefault = ref<boolean>(true)
502
-
503
- watch(
504
- () => props.vmNameInWizard,
505
- (newValue) => {
506
- vmForm.value.name = newValue
507
- }
508
- )
509
-
510
- const validateSendData = async (
511
- value: UI_I_WizardStep[]
512
- ): Promise<UI_I_ValidationReturn> => {
513
- wizard.setLoader(true)
514
- let stepHasError = false
515
-
516
- const data = await props.validateSendDataFunc(
517
- vmForm.value,
518
- virtualHardwareCpu.value,
519
- virtualHardwareMemory.value,
520
- customizeHardware.value,
521
- virtualHardwareNetworks.value,
522
- virtualHardwareHardDisks.value,
523
- virtualHardwareCdDvdDrives.value,
524
- isPowerOnByDefault.value,
525
- localization.value,
526
- vmForm.value.locationPath, // для сферы
527
- computeResourcePath.value // для сферы
528
- )
529
-
530
- wizard.setLoader(false)
531
- if (data) {
532
- stepHasError = true
533
- selectedNavItem.value = data[0]
534
- data[1] !== null && wizard.selectStepHard(data[1])
535
- }
536
-
537
- return {
538
- stepHasError,
539
- newValue: value,
540
- }
541
- }
542
- const onFinish = (): void => {
543
- wizard.setLoader(false)
544
- props
545
- .finishFunc(
546
- vmForm.value,
547
- virtualHardwareCpu.value,
548
- virtualHardwareMemory.value,
549
- customizeHardware.value,
550
- virtualHardwareNetworks.value,
551
- virtualHardwareHardDisks.value,
552
- virtualHardwareCdDvdDrives.value,
553
- isPowerOnByDefault.value,
554
- localization.value,
555
- vmForm.value.locationPath, // для сферы
556
- computeResourcePath.value, // для сферы
557
- false
558
- )
559
- .then(() => {
560
- onHideModal()
561
- wizard.setLoader(false)
562
- })
563
- }
564
-
565
- const selectedNavItem = ref<UI_T_SelectedNavItem>(0)
566
-
567
- const { isDev } = useAppVersion()
568
-
569
- const nameFormSubmit = ref<null | Function>(null)
570
- const computeResourceSubmit = ref<null | Function>(null)
571
- const storageSubmit = ref<null | Function>(null)
572
- const customizeHardwareSubmit = ref<null | Function>(null)
573
- const compatibility = ref<UI_I_OptionItem[]>(
574
- capabilities.compatibility.filter((camp) => {
575
- let result = true
576
- if (isDev && camp.value === 'pvm-2') result = false
577
- return result
578
- })
579
- )
580
- const guestOsFamilies = ref<UI_I_OptionItem[]>(capabilities.guestOsFamilies)
581
- const guestOsVersions = ref<UI_I_ArbitraryObject<UI_I_OptionItem[]>>(
582
- capabilities.guestOsVersions
583
- )
584
- const machineTypes = ref<UI_I_OptionItem[]>(capabilities.machineTypes)
585
- const cpuModels = ref<UI_I_OptionItem[]>(capabilities.cpuModels)
586
- const maxCpus = ref<number>(capabilities.maxCpus)
587
- const maxMemory = ref<number>(capabilities.maxMemory)
588
-
589
- const onHideModal = (): void => {
590
- emits('hide')
591
- }
592
- </script>
593
-
594
- <style scoped lang="scss">
595
- :deep(.modal-body) {
596
- display: flex;
597
- flex-direction: column;
598
- }
599
- .add-vm-content {
600
- display: flex;
601
- flex-direction: column;
602
- flex: 1;
603
- }
604
- .vm-hardware-version {
605
- align-self: flex-end;
606
- margin-top: auto;
607
- }
608
- .power-on-by-default-wrap {
609
- display: flex;
610
- align-items: center;
611
- margin-right: auto;
612
-
613
- input {
614
- margin-right: 6px;
615
- }
616
- }
617
- </style>
1
+ <template>
2
+ <div class="add-vm">
3
+ <atoms-wizard
4
+ show
5
+ :wizard="wizard"
6
+ :selected-scheme="selectedScheme"
7
+ :title="localization.common.newVirtualMachine2"
8
+ :localization="localization"
9
+ test-id="new-virtual-machine-wizard"
10
+ @change-steps="onChangeSteps"
11
+ @hide="onHideModal"
12
+ @submit="onFinish"
13
+ >
14
+ <template #modalBody="{ selectedStep }">
15
+ <div class="add-vm-content">
16
+ <common-vm-actions-common-select-create-type
17
+ v-show="selectedStep.id === 0"
18
+ :import-from-v-m-warev-sphere="props.importFromVMWarevSphere"
19
+ />
20
+ <common-vm-actions-common-select-name
21
+ v-show="selectedStep.id === 1 || selectedStep.id === 2"
22
+ :show="selectedStep.id === 1 || selectedStep.id === 2"
23
+ :name-form-submit="nameFormSubmit"
24
+ :project="props.project"
25
+ :data-center="props.dataCenter"
26
+ @submit="onChangeName(...$event)"
27
+ @check-name="emits('check-name', $event)"
28
+ />
29
+ <common-vm-actions-common-select-compute-resource
30
+ v-if="isSphere"
31
+ v-show="selectedStep.id === 3"
32
+ v-model="vmForm.computeResource"
33
+ :compute-resource-submit="computeResourceSubmit"
34
+ :data-center="vmForm.dataCenter"
35
+ :compute-resource="props.computeResource"
36
+ :compute-resource-tree="props.computeResourceTree"
37
+ @submit="onChangeComputeResource"
38
+ @select-compute-resource-tree="onSelectComputeResourceTree"
39
+ @get-compute-resource-tree="
40
+ emits('get-compute-resource-tree', $event)
41
+ "
42
+ @show-compute-resource-tree="
43
+ emits('show-compute-resource-tree', $event)
44
+ "
45
+ @clear-compute-resource-tree="
46
+ emits('clear-compute-resource-tree', $event)
47
+ "
48
+ />
49
+ <common-vm-actions-common-select-storage
50
+ v-show="selectedStep.id === 4"
51
+ :storage-submit="storageSubmit"
52
+ :datastore="props.datastore"
53
+ :get-datastore-table-func="props.getDatastoreTableFunc"
54
+ @submit="onChangeStorage"
55
+ />
56
+ <common-vm-actions-common-select-compatibility
57
+ v-show="selectedStep.id === 5"
58
+ :options="compatibility"
59
+ :error-validation-fields="props.errorValidationFields"
60
+ @change="onChangeCompatibility"
61
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
62
+ />
63
+ <common-vm-actions-common-select-os
64
+ v-show="selectedStep.id === 6 || selectedStep.id === 7"
65
+ :families-options="guestOsFamilies"
66
+ :versions-options="guestOsVersions"
67
+ :machine-types-options="machineTypes"
68
+ :error-validation-fields="props.errorValidationFields"
69
+ @change="onChangeOs"
70
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
71
+ />
72
+ <common-vm-actions-common-customize-hardware
73
+ v-show="selectedStep.id === 8"
74
+ :project="props.project"
75
+ :vm-name="vmForm.name"
76
+ :guest-machine-type="vmForm.guestMachineType"
77
+ :guest-os-family="vmForm.guestOsFamily"
78
+ :guest-os-version="vmForm.guestOsVersion"
79
+ :storage="vmForm.storage"
80
+ :hard-disks-for-boot-options="virtualHardwareHardDisksLocal"
81
+ :cd-dvd-drives-for-boot-options="virtualHardwareCdDvdDrivesLocal"
82
+ :networks-for-boot-options="virtualHardwareNetworksLocal"
83
+ :cd-dvd-drives="virtualHardwareCdDvdDrivesLocal"
84
+ :customize-hardware-submit="customizeHardwareSubmit"
85
+ :max-cpus="maxCpus"
86
+ :max-memory="maxMemory"
87
+ :cpu-models="cpuModels"
88
+ :selected-nav-item="selectedNavItem"
89
+ :nodes="props.nodes"
90
+ :files="props.files"
91
+ :networks-table="props.networksTable"
92
+ :error-validation-fields="props.errorValidationFields"
93
+ :get-datastore-table-func="props.getDatastoreTableFunc"
94
+ :datastore="props.datastore"
95
+ :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
96
+ :passthrough-devices="props.passthroughDevices"
97
+ @change-boot-order="onChangeBootOrder"
98
+ @send-data="onChangeCustomizeHardware"
99
+ @get-storage="emits('get-storage', $event)"
100
+ @get-folders-or-files="emits('get-folders-or-files', $event)"
101
+ @get-active-device-child="emits('get-active-device-child', $event)"
102
+ @show-datastore-child="emits('show-datastore-child', $event)"
103
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
104
+ @get-networks-table="emits('get-networks-table', $event)"
105
+ @get-pci-devices="emits('get-pci-devices')"
106
+ />
107
+ <common-ready-to-complete
108
+ v-if="selectedStep.id === 9"
109
+ :data="props.readyCompleteTableInfo"
110
+ />
111
+ <span v-if="selectedStep.id > 5" class="vm-hardware-version">{{
112
+ compatibilityInfo
113
+ }}</span>
114
+ </div>
115
+ </template>
116
+
117
+ <template #modalFooterContent>
118
+ <div v-if="isShowPowerOn" class="power-on-by-default-wrap">
119
+ <input
120
+ id="power-on-by-default"
121
+ v-model="isPowerOnByDefault"
122
+ data-id="power-on-by-default"
123
+ type="checkbox"
124
+ />
125
+ <label for="power-on-by-default" class="label-text-normal">{{
126
+ localization.common.powerOnByDefault
127
+ }}</label>
128
+ </div>
129
+ </template>
130
+ </atoms-wizard>
131
+ </div>
132
+ </template>
133
+
134
+ <script setup lang="ts">
135
+ import type {
136
+ UI_I_Localization,
137
+ UI_I_ArbitraryObject,
138
+ } from '~/lib/models/interfaces'
139
+ import type { UI_T_Project } from '~/lib/models/types'
140
+ import type { UI_I_FileTreeNode } from '~/components/lib/models/interfaces'
141
+ import type { UI_I_NetworkTableItem } from '~/lib/models/store/network/interfaces'
142
+ import type {
143
+ UI_I_DatastoreTableItem,
144
+ UI_I_FolderOrFileTreePayload,
145
+ } from '~/lib/models/store/storage/interfaces'
146
+ import type {
147
+ API_UI_I_Error,
148
+ UI_I_ErrorValidationField,
149
+ } from '~/lib/models/store/interfaces'
150
+ import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
151
+ import type { UI_I_TableInfoItem } from '~/components/atoms/table/info/lib/models/interfaces'
152
+ import type {
153
+ UI_T_AddVmFinishFunc,
154
+ UI_T_SelectedNavItem,
155
+ } from '~/components/common/vm/actions/common/lib/models/types'
156
+ import type { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
157
+ import type {
158
+ UI_I_ValidationReturn,
159
+ UI_I_WizardStep,
160
+ } from '~/components/atoms/wizard/lib/models/interfaces'
161
+ import type {
162
+ UI_I_Capabilities,
163
+ UI_I_VmForm,
164
+ UI_I_VmFormCash,
165
+ } from '~/components/common/vm/actions/common/lib/models/interfaces'
166
+ import type { UI_I_SendDataCustomizeHardware } from '~/components/common/vm/actions/common/customizeHardware/lib/models/interfaces'
167
+ import type { UI_I_OsChange } from '~/components/common/vm/actions/common/select/lib/models/interfaces'
168
+ import type {
169
+ UI_I_SendDataCpu,
170
+ UI_I_SendDataMemory,
171
+ UI_I_SendDataNewCdDvdDrive,
172
+ UI_I_SendDataNewHardDisk,
173
+ UI_I_SendDataNewNetwork,
174
+ } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
175
+ import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
176
+ import type { UI_T_ChangeBootOrder } from '~/components/common/vm/actions/lib/models/types'
177
+ import type { UI_I_PciDevice } from '~/lib/models/store/vm/interfaces'
178
+ import { capabilities } from '~/components/common/vm/actions/common/lib/config/capabilities'
179
+ import {
180
+ stepsSchemeInitial,
181
+ stepsFunc,
182
+ } from '~/components/common/vm/actions/add/lib/config/steps'
183
+ import Wizard from '~/components/atoms/wizard/lib/utils/utils'
184
+ import { mapCapabilities } from '~/components/common/vm/actions/common/lib/utils/capabilities'
185
+
186
+ const props = defineProps<{
187
+ project: UI_T_Project
188
+ nodes: UI_I_FileTreeNode[]
189
+ files: UI_I_FileTreeNode[]
190
+ networksTable: UI_I_NetworkTableItem[]
191
+ datastore: UI_I_DatastoreTableItem[]
192
+ errorValidationFields: UI_I_ErrorValidationField[]
193
+ readyCompleteTableInfo: UI_I_TableInfoItem[]
194
+ vmCpuHelpTextSecond: string
195
+ importFromVMWarevSphere: string
196
+ finishFunc: UI_T_AddVmFinishFunc
197
+ getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
198
+ validateSendDataFunc: UI_T_AddVmFinishFunc<
199
+ [UI_T_SelectedNavItem, null | number] | null
200
+ >
201
+ passthroughDevices: UI_I_PciDevice[]
202
+ vmNameInWizard: string
203
+ capabilities?: UI_I_Capabilities
204
+ dataCenter?: UI_I_TreeNode // для сферы
205
+ computeResource?: UI_I_TreeNode // для сферы
206
+ computeResourceTree?: UI_I_TreeNode[] // для сферы
207
+ }>()
208
+
209
+ const emits = defineEmits<{
210
+ (event: 'check-name', value: [string, (error: API_UI_I_Error) => void]): void
211
+ (event: 'get-storage', value: UI_I_TablePayload): void
212
+ (event: 'get-folders-or-files', value: UI_I_FolderOrFileTreePayload): void
213
+ (event: 'get-active-device-child', value: UI_I_FileTreeNode): void
214
+ (event: 'show-datastore-child', value: UI_I_FileTreeNode): void
215
+ (event: 'remove-error-by-title', value: string): void
216
+ (event: 'get-networks-table', value: UI_I_TablePayload): void
217
+ (event: 'get-pci-devices'): void
218
+ (event: 'get-pci-devices'): void
219
+ (event: 'hide'): void
220
+ (
221
+ event: 'get-compute-resource-tree',
222
+ value: { id: string | number; cb: () => void }
223
+ ): void // для сферы
224
+ (event: 'show-compute-resource-tree', value: UI_I_TreeNode): void // для сферы
225
+ (event: 'select-compute-resource-tree', value: UI_I_TreeNode): void // для сферы
226
+ (event: 'clear-compute-resource-tree'): void // для сферы
227
+ }>()
228
+
229
+ const isSphere = computed<boolean>(() => props.project === 'sphere')
230
+
231
+ const { $recursion } = useNuxtApp()
232
+
233
+ const localization = computed<UI_I_Localization>(() => useLocal())
234
+
235
+ watch(
236
+ () => props.capabilities,
237
+ () => {
238
+ if (props.capabilities) mapCapabilities(props.capabilities)
239
+ },
240
+ { deep: true, immediate: true }
241
+ )
242
+
243
+ const wizard: Wizard = new Wizard(
244
+ stepsFunc(localization.value),
245
+ stepsSchemeInitial
246
+ )
247
+ if (isSphere.value) wizard.changeScheme(1)
248
+ const selectedScheme = computed<number[]>(() => wizard.selectedScheme.value)
249
+ // const alertMessages = computed<string[][]>(() => wizard.alertMessages.value)
250
+
251
+ const isShowPowerOn = computed<boolean>(() => wizard.selectedStepId > 8)
252
+
253
+ const onChangeSteps = async (value: UI_I_WizardStep[]): Promise<void> => {
254
+ wizard.changeSteps(value, validationFunc, validateSendData)
255
+ }
256
+ const validationFunc = async (
257
+ value: UI_I_WizardStep[],
258
+ currentStep: UI_I_WizardStep,
259
+ nextStep: UI_I_WizardStep
260
+ ): Promise<UI_I_ValidationReturn> => {
261
+ let stepHasError = false
262
+ let stepShouldStop = {
263
+ ifOnCurrentStep: false,
264
+ ifFromAnyStep: false,
265
+ stoppageStepId: -1,
266
+ }
267
+
268
+ wizard.setLoader(true)
269
+ if (
270
+ wizard.isValidateForStep(
271
+ isSphere.value ? 2 : 1,
272
+ currentStep.id,
273
+ nextStep.id
274
+ )
275
+ ) {
276
+ const nameValidation = await checkName(value)
277
+
278
+ value = nameValidation.newValue
279
+ stepHasError = stepHasError || nameValidation.stepHasError
280
+ } else if (
281
+ isSphere.value &&
282
+ wizard.isValidateForStep(3, currentStep.id, nextStep.id)
283
+ ) {
284
+ const computeResourceValidation = await checkComputeResource(value)
285
+
286
+ value = computeResourceValidation.newValue
287
+ stepHasError = stepHasError || computeResourceValidation.stepHasError
288
+ } else if (wizard.isValidateForStep(4, currentStep.id, nextStep.id)) {
289
+ const storageValidation = await checkStorage(value)
290
+
291
+ value = storageValidation.newValue
292
+
293
+ stepHasError = stepHasError || storageValidation.stepHasError
294
+ } else if (wizard.isValidateForStep(8, currentStep.id, nextStep.id)) {
295
+ const storageValidation = await checkCustomizeHardware(value)
296
+
297
+ value = storageValidation.newValue
298
+
299
+ stepHasError = stepHasError || storageValidation.stepHasError
300
+ }
301
+ wizard.setLoader(false)
302
+
303
+ return {
304
+ newValue: value,
305
+ stepHasError,
306
+ stepShouldStop,
307
+ }
308
+ }
309
+ const checkName = async (
310
+ value: UI_I_WizardStep[]
311
+ ): Promise<UI_I_ValidationReturn> => {
312
+ let stepHasError = false
313
+
314
+ return new Promise((resolve) => {
315
+ const step = isSphere.value ? 2 : 1
316
+ nameFormSubmit.value = (isValid: boolean) => {
317
+ if (!isValid) {
318
+ stepHasError = wizard.setValidation(step, 'name', {
319
+ fieldMessage: 'aaa',
320
+ alertMessage: 'aaa',
321
+ })
322
+ } else if (wizard.hasMessage(step, 'name')) {
323
+ value = wizard.removeValidation(step, 'name', value)
324
+ }
325
+
326
+ resolve({
327
+ stepHasError,
328
+ newValue: value,
329
+ })
330
+ nameFormSubmit.value = null
331
+ }
332
+ })
333
+ }
334
+ const checkComputeResource = async (
335
+ value: UI_I_WizardStep[]
336
+ ): Promise<UI_I_ValidationReturn> => {
337
+ let stepHasError = false
338
+
339
+ return new Promise((resolve) => {
340
+ computeResourceSubmit.value = (isValid: boolean) => {
341
+ if (!isValid) {
342
+ stepHasError = wizard.setValidation(3, 'computeResource', {
343
+ fieldMessage: 'aaa',
344
+ alertMessage: 'aaa',
345
+ })
346
+ } else if (wizard.hasMessage(3, 'computeResource')) {
347
+ value = wizard.removeValidation(3, 'computeResource', value)
348
+ }
349
+
350
+ resolve({
351
+ stepHasError,
352
+ newValue: value,
353
+ })
354
+ computeResourceSubmit.value = null
355
+ }
356
+ })
357
+ }
358
+ const checkStorage = async (
359
+ value: UI_I_WizardStep[]
360
+ ): Promise<UI_I_ValidationReturn> => {
361
+ let stepHasError = false
362
+
363
+ return new Promise((resolve) => {
364
+ storageSubmit.value = (isValid: boolean) => {
365
+ if (!isValid) {
366
+ stepHasError = wizard.setValidation(4, 'storage', {
367
+ fieldMessage: 'aaa',
368
+ alertMessage: 'aaa',
369
+ })
370
+ } else if (wizard.hasMessage(4, 'storage')) {
371
+ value = wizard.removeValidation(4, 'storage', value)
372
+ }
373
+
374
+ resolve({
375
+ stepHasError,
376
+ newValue: value,
377
+ })
378
+ storageSubmit.value = null
379
+ }
380
+ })
381
+ }
382
+ const checkCustomizeHardware = async (
383
+ value: UI_I_WizardStep[]
384
+ ): Promise<UI_I_ValidationReturn> => {
385
+ let stepHasError = false
386
+
387
+ return new Promise((resolve) => {
388
+ customizeHardwareSubmit.value = (isValid: boolean) => {
389
+ if (!isValid) {
390
+ stepHasError = wizard.setValidation(8, 'customizeHardware', {
391
+ fieldMessage: 'aaa',
392
+ alertMessage: 'aaa',
393
+ })
394
+ } else if (wizard.hasMessage(8, 'customizeHardware')) {
395
+ value = wizard.removeValidation(8, 'customizeHardware', value)
396
+ }
397
+
398
+ resolve({
399
+ stepHasError,
400
+ newValue: value,
401
+ })
402
+ storageSubmit.value = null
403
+ }
404
+ })
405
+ }
406
+
407
+ const storageIdCash = ref<string | null>(null)
408
+ const vmForm = ref<UI_I_VmForm>({
409
+ name: '',
410
+ compatibility: '',
411
+ guestMachineType: null,
412
+ guestOsFamily: null,
413
+ guestOsVersion: null,
414
+ computeResource: null,
415
+ storage: null,
416
+ locationPath: '',
417
+ dataCenter: null,
418
+ })
419
+ const vmFormCash = ref<UI_I_VmFormCash>({
420
+ dataCenterId: null,
421
+ computeResourceTypeAndId: null,
422
+ })
423
+
424
+ const onChangeName = (name: string, node: UI_I_TreeNode): void => {
425
+ vmForm.value.name = name
426
+ if (isSphere.value) {
427
+ vmForm.value.locationPath = node.id
428
+ vmForm.value.dataCenter = $recursion.findParentByValue(
429
+ node,
430
+ 'datacenter',
431
+ 'type',
432
+ 'parent'
433
+ )
434
+ vmFormCash.value.dataCenterId = vmForm.value.dataCenter?.id || null
435
+ }
436
+ }
437
+ // // Для сферы
438
+ const computeResourcePath = ref<string>('')
439
+ const onSelectComputeResourceTree = (node: UI_I_TreeNode): void => {
440
+ emits('select-compute-resource-tree', node)
441
+ computeResourcePath.value = node.id
442
+ }
443
+ const onChangeComputeResource = (node: UI_I_TreeNode): void => {
444
+ vmForm.value.computeResource = node
445
+ // const type = node.type.toUpperCase()
446
+ // schedRequirementsTemplate.value = `sched_requirements="(${type}_ID=${node.id})"\\`
447
+ vmFormCash.value.computeResourceTypeAndId = `${node.type}${node.id}` || null
448
+ }
449
+ const onChangeStorage = (storage: UI_I_DatastoreTableItem | null): void => {
450
+ if (!storage) return
451
+
452
+ vmForm.value.storage = storage
453
+ storageIdCash.value = storage.id
454
+ }
455
+ const compatibilityInfo = ref<string>('')
456
+ const onChangeCompatibility = (compatibility: UI_I_OptionItem): void => {
457
+ vmForm.value.compatibility = compatibility.value
458
+
459
+ const version = compatibility.value.split('-')[1]
460
+ compatibilityInfo.value = `${localization.value.common.compatibility}: ${compatibility.text} (${localization.value.common.vmVersion} ${version})`
461
+ }
462
+ const onChangeOs = (data: UI_I_OsChange): void => {
463
+ vmForm.value.guestMachineType = data.selectedMachineType
464
+ vmForm.value.guestOsFamily = data.selectedOS
465
+ vmForm.value.guestOsVersion = data.selectedVersion
466
+ }
467
+ const customizeHardware = ref<UI_I_SendDataCustomizeHardware | null>(null)
468
+ const onChangeCustomizeHardware = (
469
+ data: UI_I_SendDataCustomizeHardware
470
+ ): void => {
471
+ customizeHardware.value = data
472
+ }
473
+
474
+ const virtualHardwareHardDisksLocal = computed<
475
+ UI_I_SendDataNewHardDisk[] | null
476
+ >(() => customizeHardware.value?.virtualHardware?.hardDisks || null)
477
+ const virtualHardwareNetworksLocal = computed<UI_I_SendDataNewNetwork[] | null>(
478
+ () => customizeHardware.value?.virtualHardware?.networks || null
479
+ )
480
+ const virtualHardwareCdDvdDrivesLocal = computed<
481
+ UI_I_SendDataNewCdDvdDrive[] | null
482
+ >(() => customizeHardware.value?.virtualHardware?.cdDvdDrives || null)
483
+
484
+ const virtualHardwareCpu = computed<UI_I_SendDataCpu | null>(
485
+ () => customizeHardware.value?.virtualHardware?.cpu || null
486
+ )
487
+ const virtualHardwareMemory = computed<UI_I_SendDataMemory | null>(
488
+ () => customizeHardware.value?.virtualHardware?.memory || null
489
+ )
490
+ const virtualHardwareHardDisks = ref<UI_I_SendDataNewHardDisk[] | null>(null)
491
+ const virtualHardwareCdDvdDrives = ref<UI_I_SendDataNewCdDvdDrive[] | null>(
492
+ null
493
+ )
494
+ const virtualHardwareNetworks = ref<UI_I_SendDataNewNetwork[] | null>(null)
495
+ const onChangeBootOrder = (data: UI_T_ChangeBootOrder): void => {
496
+ virtualHardwareHardDisks.value = data[0]
497
+ virtualHardwareCdDvdDrives.value = data[1]
498
+ virtualHardwareNetworks.value = data[2]
499
+ }
500
+
501
+ const isPowerOnByDefault = ref<boolean>(true)
502
+
503
+ watch(
504
+ () => props.vmNameInWizard,
505
+ (newValue) => {
506
+ vmForm.value.name = newValue
507
+ }
508
+ )
509
+
510
+ const validateSendData = async (
511
+ value: UI_I_WizardStep[]
512
+ ): Promise<UI_I_ValidationReturn> => {
513
+ wizard.setLoader(true)
514
+ let stepHasError = false
515
+
516
+ const data = await props.validateSendDataFunc(
517
+ vmForm.value,
518
+ virtualHardwareCpu.value,
519
+ virtualHardwareMemory.value,
520
+ customizeHardware.value,
521
+ virtualHardwareNetworks.value,
522
+ virtualHardwareHardDisks.value,
523
+ virtualHardwareCdDvdDrives.value,
524
+ isPowerOnByDefault.value,
525
+ localization.value,
526
+ vmForm.value.locationPath, // для сферы
527
+ computeResourcePath.value // для сферы
528
+ )
529
+
530
+ wizard.setLoader(false)
531
+ if (data) {
532
+ stepHasError = true
533
+ selectedNavItem.value = data[0]
534
+ data[1] !== null && wizard.selectStepHard(data[1])
535
+ }
536
+
537
+ return {
538
+ stepHasError,
539
+ newValue: value,
540
+ }
541
+ }
542
+ const onFinish = (): void => {
543
+ wizard.setLoader(false)
544
+ props
545
+ .finishFunc(
546
+ vmForm.value,
547
+ virtualHardwareCpu.value,
548
+ virtualHardwareMemory.value,
549
+ customizeHardware.value,
550
+ virtualHardwareNetworks.value,
551
+ virtualHardwareHardDisks.value,
552
+ virtualHardwareCdDvdDrives.value,
553
+ isPowerOnByDefault.value,
554
+ localization.value,
555
+ vmForm.value.locationPath, // для сферы
556
+ computeResourcePath.value, // для сферы
557
+ false
558
+ )
559
+ .then(() => {
560
+ onHideModal()
561
+ wizard.setLoader(false)
562
+ })
563
+ }
564
+
565
+ const selectedNavItem = ref<UI_T_SelectedNavItem>(0)
566
+
567
+ const { isDev } = useAppVersion()
568
+
569
+ const nameFormSubmit = ref<null | Function>(null)
570
+ const computeResourceSubmit = ref<null | Function>(null)
571
+ const storageSubmit = ref<null | Function>(null)
572
+ const customizeHardwareSubmit = ref<null | Function>(null)
573
+ const compatibility = ref<UI_I_OptionItem[]>(
574
+ capabilities.compatibility.filter((camp) => {
575
+ let result = true
576
+ if (isDev && camp.value === 'pvm-2') result = false
577
+ return result
578
+ })
579
+ )
580
+ const guestOsFamilies = ref<UI_I_OptionItem[]>(capabilities.guestOsFamilies)
581
+ const guestOsVersions = ref<UI_I_ArbitraryObject<UI_I_OptionItem[]>>(
582
+ capabilities.guestOsVersions
583
+ )
584
+ const machineTypes = ref<UI_I_OptionItem[]>(capabilities.machineTypes)
585
+ const cpuModels = ref<UI_I_OptionItem[]>(capabilities.cpuModels)
586
+ const maxCpus = ref<number>(capabilities.maxCpus)
587
+ const maxMemory = ref<number>(capabilities.maxMemory)
588
+
589
+ const onHideModal = (): void => {
590
+ emits('hide')
591
+ }
592
+ </script>
593
+
594
+ <style scoped lang="scss">
595
+ :deep(.modal-body) {
596
+ display: flex;
597
+ flex-direction: column;
598
+ }
599
+ .add-vm-content {
600
+ display: flex;
601
+ flex-direction: column;
602
+ flex: 1;
603
+ }
604
+ .vm-hardware-version {
605
+ align-self: flex-end;
606
+ margin-top: auto;
607
+ }
608
+ .power-on-by-default-wrap {
609
+ display: flex;
610
+ align-items: center;
611
+ margin-right: auto;
612
+
613
+ input {
614
+ margin-right: 6px;
615
+ }
616
+ }
617
+ </style>