bfg-common 1.4.745 → 1.4.747

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