bfg-common 1.5.595 → 1.5.596

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