bfg-common 1.5.375 → 1.5.377

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