bfg-common 1.5.262 → 1.5.264

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 (140) hide show
  1. package/CODE_STYLE.md +109 -109
  2. package/assets/localization/local_be.json +27 -2
  3. package/assets/localization/local_en.json +27 -2
  4. package/assets/localization/local_hy.json +27 -2
  5. package/assets/localization/local_kk.json +27 -2
  6. package/assets/localization/local_ru.json +27 -2
  7. package/assets/localization/local_zh.json +27 -2
  8. package/assets/scss/common/theme.scss +24 -0
  9. package/components/atoms/TheIcon3.vue +50 -50
  10. package/components/atoms/perPage/PerPage.vue +58 -58
  11. package/components/atoms/stack/StackBlock.vue +185 -185
  12. package/components/atoms/table/dataGrid/DataGrid.vue +1717 -1717
  13. package/components/atoms/table/dataGrid/lib/config/settingsTable.ts +94 -94
  14. package/components/atoms/table/dataGrid/lib/utils/export.ts +16 -16
  15. package/components/atoms/table/info/lib/models/interfaces.ts +10 -10
  16. package/components/atoms/tabs/VerticalTabs.vue +105 -105
  17. package/components/common/backup/storage/actions/add/Add.vue +250 -250
  18. package/components/common/backup/storage/actions/add/Old.vue +116 -116
  19. package/components/common/backup/storage/actions/add/lib/config/steps.ts +168 -168
  20. package/components/common/backup/storage/actions/add/steps/hostAccessibility/HostAccessibility.vue +52 -52
  21. package/components/common/backup/storage/actions/add/steps/name/New.vue +102 -102
  22. package/components/common/backup/storage/actions/add/steps/nameAndConfigure/NameAndConfigure.vue +42 -42
  23. package/components/common/backup/storage/actions/add/steps/readyComplete/ReadyComplete.vue +45 -45
  24. package/components/common/backup/storage/actions/add/steps/readyComplete/ReadyCompleteNew.vue +160 -160
  25. package/components/common/backup/storage/actions/add/steps/readyComplete/lib/config/propertiesDetails.ts +243 -243
  26. package/components/common/backup/storage/actions/delete/Delete.vue +65 -65
  27. package/components/common/browse/blocks/contents/filesNew/Skeleton.vue +18 -18
  28. package/components/common/context/lib/models/interfaces.ts +31 -31
  29. package/components/common/diagramMain/DiagramMain.vue +897 -897
  30. package/components/common/diagramMain/Header.vue +214 -214
  31. package/components/common/diagramMain/modals/viewSettings/viewSettings/ViewSettingsOld.vue +1 -1
  32. package/components/common/layout/theHeader/helpMenu/About.vue +82 -82
  33. package/components/common/layout/theHeader/userMenu/modals/preferences/view/ViewOld.vue +112 -112
  34. package/components/common/monitor/overview/OverviewOld.vue +139 -139
  35. package/components/common/pages/home/headline/Headline.vue +45 -45
  36. package/components/common/pages/home/headline/HeadlineOld.vue +42 -42
  37. package/components/common/pages/home/lib/models/interfaces.ts +48 -48
  38. package/components/common/pages/home/widgets/Widgets.vue +49 -49
  39. package/components/common/pages/home/widgets/WidgetsNew.vue +86 -86
  40. package/components/common/pages/home/widgets/WidgetsOld.vue +34 -34
  41. package/components/common/pages/home/widgets/hosts/Hosts.vue +27 -27
  42. package/components/common/pages/home/widgets/hosts/lib/config/items.ts +23 -23
  43. package/components/common/pages/home/widgets/vms/Vms.vue +26 -26
  44. package/components/common/pages/home/widgets/vms/VmsOld.vue +35 -35
  45. package/components/common/pages/home/widgets/vms/lib/config/items.ts +19 -19
  46. package/components/common/pages/licensing/listView/ListView.vue +2 -2
  47. package/components/common/pages/packages/Packages.vue +208 -208
  48. package/components/common/pages/shortcuts/block/BlockOld.vue +68 -68
  49. package/components/common/readyToComplete/ReadyToComplete.vue +17 -17
  50. package/components/common/recursionTree/RecursionTree.vue +223 -223
  51. package/components/common/resource/simple/Simple.vue +2 -2
  52. package/components/common/select/button/ButtonDropdown.vue +108 -108
  53. package/components/common/spiceConsole/Drawer.vue +377 -377
  54. package/components/common/spiceConsole/lib/models/interfaces.ts +5 -5
  55. package/components/common/vm/actions/add/Add.vue +823 -823
  56. package/components/common/vm/actions/add/Old.vue +382 -382
  57. package/components/common/vm/actions/add/folderTreeView/FolderTreeView.vue +72 -72
  58. package/components/common/vm/actions/add/folderTreeView/New.vue +40 -40
  59. package/components/common/vm/actions/add/folderTreeView/Old.vue +50 -50
  60. package/components/common/vm/actions/clone/lib/config/steps.ts +291 -291
  61. package/components/common/vm/actions/clone/toTemplate/lib/config/steps.ts +116 -116
  62. package/components/common/vm/actions/common/customizeHardware/virtualHardware/VirtualHardwareOld.vue +321 -321
  63. package/components/common/vm/actions/common/customizeHardware/virtualHardware/browseView/BrowseView.vue +227 -227
  64. package/components/common/vm/actions/common/customizeHardware/virtualHardware/bus/Bus.vue +100 -100
  65. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/CdDvdDrive.vue +232 -232
  66. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/CdDvdDriveOld.vue +168 -168
  67. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/media/Media.vue +25 -25
  68. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/media/MediaNew.vue +78 -78
  69. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/media/MediaOld.vue +50 -50
  70. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/shares/Shares.vue +140 -140
  71. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/shares/lib/config/options.ts +28 -28
  72. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/tooltip/TooltipNew.vue +154 -154
  73. package/components/common/vm/actions/common/customizeHardware/virtualHardware/limit/Limit.vue +220 -220
  74. package/components/common/vm/actions/common/customizeHardware/virtualHardware/memory/Memory.vue +307 -307
  75. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/NewHardDisk.vue +385 -385
  76. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/location/Location.vue +154 -154
  77. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/location/LocationNew.vue +75 -75
  78. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/location/LocationOld.vue +85 -85
  79. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/NewNetwork.vue +288 -288
  80. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/location/new/table/lib/config/config.ts +94 -94
  81. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/macAddress/MacAddress.vue +119 -119
  82. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/NewPciDevice.vue +205 -205
  83. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/directPathIo/DirectPathIoNew.vue +66 -66
  84. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/directPathIo/DirectPathIoOld.vue +62 -62
  85. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/dynamicDirectPathIo/DynamicDirectPathIo.vue +31 -31
  86. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/dynamicDirectPathIo/DynamicDirectPathIoOld.vue +76 -76
  87. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/note/Note.vue +15 -15
  88. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/note/NoteNew.vue +42 -42
  89. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/note/NoteOld.vue +30 -30
  90. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/nvidiaGrid/NvidiaGridOld.vue +84 -84
  91. package/components/common/vm/actions/common/customizeHardware/virtualHardware/other/Other.vue +16 -16
  92. package/components/common/vm/actions/common/customizeHardware/virtualHardware/other/inputDevices/InputDevicesNew.vue +40 -40
  93. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/VideoCard.vue +154 -147
  94. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/VideoCardNew.vue +2 -1
  95. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/VideoCardOld.vue +2 -1
  96. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/numberDisplays/NumberDisplays.vue +53 -53
  97. package/components/common/vm/actions/common/customizeHardware/vmoptions/Vmoptions.vue +145 -145
  98. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/delay/Delay.vue +32 -32
  99. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/firmware/Firmware.vue +60 -60
  100. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/Order.vue +174 -174
  101. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/copyPaste/CopyPasteNew.vue +31 -31
  102. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/fileTransfer/FileTransferNew.vue +31 -31
  103. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/keymap/Keymap.vue +32 -32
  104. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/password/Password.vue +103 -103
  105. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/password/PasswordNew.vue +128 -128
  106. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/usbRedirection/UsbRedirection.vue +28 -28
  107. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/usbRedirection/UsbRedirectionNew.vue +39 -39
  108. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/usbRedirection/UsbRedirectionOld.vue +44 -44
  109. package/components/common/vm/actions/common/lib/utils/capabilities.ts +52 -52
  110. package/components/common/vm/actions/common/select/compatibility/Old.vue +107 -107
  111. package/components/common/vm/actions/common/select/computeResource/treeView/New.vue +44 -44
  112. package/components/common/vm/actions/common/select/computeResource/treeView/TreeView.vue +118 -118
  113. package/components/common/vm/actions/common/select/createType/CreateType.vue +38 -38
  114. package/components/common/vm/actions/common/select/createType/lib/models/interfaces.ts +5 -5
  115. package/components/common/vm/actions/common/select/name/Name.vue +174 -174
  116. package/components/common/vm/actions/common/select/os/Old.vue +152 -152
  117. package/components/common/vm/actions/common/select/os/Os.vue +139 -139
  118. package/components/common/vm/actions/common/select/storage/new/lib/models/interfaces.ts +5 -5
  119. package/components/common/vm/actions/common/select/storage/new/lib/utils/utils.ts +21 -21
  120. package/components/common/vm/actions/editSettings/new/Skeleton.vue +88 -88
  121. package/components/common/vmt/actions/add/Add.vue +641 -641
  122. package/components/common/vmt/actions/add/lib/config/steps.ts +107 -107
  123. package/components/common/vmt/actions/add/lib/models/interfaces.ts +23 -23
  124. package/components/common/wizards/vm/migrate/lib/config/constructDataReady.ts +220 -220
  125. package/components/common/wizards/vm/migrate/lib/config/steps.ts +157 -157
  126. package/components/common/wizards/vm/migrate/lib/validations.ts +68 -68
  127. package/components/common/wizards/vm/migrate/select/computeResource/tableView/TableView.vue +135 -135
  128. package/components/common/wizards/vm/migrate/select/network/Network.vue +103 -103
  129. package/components/common/wizards/vm/migrate/select/network/table/network/lib/config/advancedTable.ts +91 -91
  130. package/composables/productNameLocal.ts +30 -30
  131. package/composables/useAppVersion.ts +21 -21
  132. package/package.json +2 -2
  133. package/plugins/date.ts +233 -233
  134. package/plugins/panelStates.ts +70 -70
  135. package/plugins/text.ts +59 -59
  136. package/public/spice-console/lib/images/bitmap.js +203 -203
  137. package/public/spice-console/network/spicechannel.js +387 -387
  138. package/store/main/mutations.ts +7 -7
  139. package/store/main/state.ts +7 -7
  140. package/store/tasks/mappers/recentTasks.ts +64 -64
@@ -1,823 +1,823 @@
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(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
- () => wizard.selectedStepId > dynamicSteps.customizeHardware
288
- )
289
-
290
- const onChangeSteps = async (value: UI_I_WizardStep[]): Promise<void> => {
291
- wizard.changeSteps(value, validationFunc, validateSendData)
292
- }
293
- const validationFunc = async (
294
- value: UI_I_WizardStep[],
295
- currentStep: UI_I_WizardStep,
296
- nextStep: UI_I_WizardStep
297
- ): Promise<UI_I_ValidationReturn> => {
298
- let stepHasError = false
299
- let stepShouldStop = {
300
- ifOnCurrentStep: false,
301
- ifFromAnyStep: false,
302
- stoppageStepId: -1,
303
- }
304
-
305
- wizard.setLoader(true)
306
- if (
307
- wizard.isValidateForStep(
308
- dynamicSteps.selectTemplate,
309
- currentStep.id,
310
- nextStep.id
311
- )
312
- ) {
313
- const templateValidation = await checkTemplate(value)
314
-
315
- value = templateValidation.newValue
316
- stepHasError = stepHasError || templateValidation.stepHasError
317
- } else if (
318
- wizard.isValidateForStep(
319
- isSphere.value ? dynamicSteps.selectNameFolder : dynamicSteps.selectName,
320
- currentStep.id,
321
- nextStep.id
322
- )
323
- ) {
324
- const nameValidation = await onCheckName(value)
325
-
326
- value = nameValidation.newValue
327
- stepHasError = stepHasError || nameValidation.stepHasError
328
- } else if (
329
- isSphere.value &&
330
- wizard.isValidateForStep(
331
- dynamicSteps.selectComputeResource,
332
- currentStep.id,
333
- nextStep.id
334
- )
335
- ) {
336
- const computeResourceValidation = await checkComputeResource(value)
337
-
338
- value = computeResourceValidation.newValue
339
- stepHasError = stepHasError || computeResourceValidation.stepHasError
340
- } else if (
341
- wizard.isValidateForStep(
342
- dynamicSteps.selectStorage,
343
- currentStep.id,
344
- nextStep.id
345
- )
346
- ) {
347
- const storageValidation = await checkStorage(value)
348
-
349
- value = storageValidation.newValue
350
-
351
- stepHasError = stepHasError || storageValidation.stepHasError
352
- } else if (
353
- wizard.isValidateForStep(
354
- dynamicSteps.customizeHardware,
355
- currentStep.id,
356
- nextStep.id
357
- )
358
- ) {
359
- const validation = await checkCustomizeHardware(value)
360
-
361
- value = validation.newValue
362
-
363
- stepHasError = stepHasError || validation.stepHasError
364
- } else if (
365
- wizard.isValidateForStep(
366
- dynamicSteps.customizeHardwareTemplate,
367
- currentStep.id,
368
- nextStep.id
369
- )
370
- ) {
371
- const validation = await checkCustomizeHardwareForTemplate(value)
372
-
373
- value = validation.newValue
374
-
375
- stepHasError = stepHasError || validation.stepHasError
376
- }
377
- wizard.setLoader(false)
378
-
379
- return {
380
- newValue: value,
381
- stepHasError,
382
- stepShouldStop,
383
- }
384
- }
385
-
386
- const checkTemplate = async (
387
- value: UI_I_WizardStep[]
388
- ): Promise<UI_I_ValidationReturn> => {
389
- let stepHasError = false
390
-
391
- return new Promise((resolve) => {
392
- templateSubmit.value = (isValid: boolean) => {
393
- if (!isValid) {
394
- stepHasError = wizard.setValidation(
395
- dynamicSteps.selectTemplate,
396
- 'template',
397
- {
398
- fieldMessage: 'aaa',
399
- alertMessage: 'aaa',
400
- }
401
- )
402
- } else if (wizard.hasMessage(dynamicSteps.selectTemplate, 'template')) {
403
- value = wizard.removeValidation(
404
- dynamicSteps.selectTemplate,
405
- 'template',
406
- value
407
- )
408
- }
409
-
410
- resolve({
411
- stepHasError,
412
- newValue: value,
413
- })
414
- templateSubmit.value = null
415
- }
416
- })
417
- }
418
- const onCheckName = async (
419
- value: UI_I_WizardStep[]
420
- ): Promise<UI_I_ValidationReturn> => {
421
- let stepHasError = false
422
-
423
- return new Promise((resolve) => {
424
- const step = isSphere.value
425
- ? dynamicSteps.selectNameFolder
426
- : dynamicSteps.selectName
427
- nameFormSubmit.value = (isValid: boolean) => {
428
- if (!isValid) {
429
- stepHasError = wizard.setValidation(step, 'name', {
430
- fieldMessage: 'aaa',
431
- alertMessage: 'aaa',
432
- })
433
- } else if (wizard.hasMessage(step, 'name')) {
434
- value = wizard.removeValidation(step, 'name', value)
435
- }
436
-
437
- resolve({
438
- stepHasError,
439
- newValue: value,
440
- })
441
- nameFormSubmit.value = null
442
- }
443
- })
444
- }
445
- const checkComputeResource = async (
446
- value: UI_I_WizardStep[]
447
- ): Promise<UI_I_ValidationReturn> => {
448
- let stepHasError = false
449
-
450
- return new Promise((resolve) => {
451
- computeResourceSubmit.value = (isValid: boolean) => {
452
- if (!isValid) {
453
- stepHasError = wizard.setValidation(
454
- dynamicSteps.selectComputeResource,
455
- 'computeResource',
456
- {
457
- fieldMessage: 'aaa',
458
- alertMessage: 'aaa',
459
- }
460
- )
461
- } else if (
462
- wizard.hasMessage(dynamicSteps.selectComputeResource, 'computeResource')
463
- ) {
464
- value = wizard.removeValidation(
465
- dynamicSteps.selectComputeResource,
466
- 'computeResource',
467
- value
468
- )
469
- }
470
-
471
- resolve({
472
- stepHasError,
473
- newValue: value,
474
- })
475
- computeResourceSubmit.value = null
476
- }
477
- })
478
- }
479
- const checkStorage = async (
480
- value: UI_I_WizardStep[]
481
- ): Promise<UI_I_ValidationReturn> => {
482
- let stepHasError = false
483
-
484
- return new Promise((resolve) => {
485
- storageSubmit.value = (isValid: boolean) => {
486
- if (!isValid) {
487
- stepHasError = wizard.setValidation(
488
- dynamicSteps.selectStorage,
489
- 'storage',
490
- {
491
- fieldMessage: 'aaa',
492
- alertMessage: 'aaa',
493
- }
494
- )
495
- } else if (wizard.hasMessage(dynamicSteps.selectStorage, 'storage')) {
496
- value = wizard.removeValidation(
497
- dynamicSteps.selectStorage,
498
- 'storage',
499
- value
500
- )
501
- }
502
-
503
- resolve({
504
- stepHasError,
505
- newValue: value,
506
- })
507
- storageSubmit.value = null
508
- }
509
- })
510
- }
511
- const checkCustomizeHardware = async (
512
- value: UI_I_WizardStep[]
513
- ): Promise<UI_I_ValidationReturn> => {
514
- let stepHasError = false
515
-
516
- return new Promise((resolve) => {
517
- customizeHardwareSubmit.value = (isValid: boolean) => {
518
- if (!isValid) {
519
- stepHasError = wizard.setValidation(
520
- dynamicSteps.customizeHardware,
521
- 'customizeHardware',
522
- {
523
- fieldMessage: 'aaa',
524
- alertMessage: 'aaa',
525
- }
526
- )
527
- } else if (
528
- wizard.hasMessage(dynamicSteps.customizeHardware, 'customizeHardware')
529
- ) {
530
- value = wizard.removeValidation(
531
- dynamicSteps.customizeHardware,
532
- 'customizeHardware',
533
- value
534
- )
535
- }
536
-
537
- resolve({
538
- stepHasError,
539
- newValue: value,
540
- })
541
- storageSubmit.value = null
542
- }
543
- })
544
- }
545
- const checkCustomizeHardwareForTemplate = async (
546
- value: UI_I_WizardStep[]
547
- ): Promise<UI_I_ValidationReturn> => {
548
- let stepHasError = false
549
-
550
- return new Promise((resolve) => {
551
- customizeHardwareForTemplateSubmit.value = (isValid: boolean) => {
552
- if (!isValid) {
553
- stepHasError = wizard.setValidation(dynamicSteps.customizeHardwareTemplate,
554
- 'customizeHardwareForTemplate',
555
- {
556
- fieldMessage: 'aaa',
557
- alertMessage: 'aaa',
558
- }
559
- )
560
- } else if (
561
- wizard.hasMessage(dynamicSteps.customizeHardwareTemplate,
562
- 'customizeHardwareForTemplate'
563
- )
564
- ) {
565
- value = wizard.removeValidation(dynamicSteps.customizeHardwareTemplate,
566
- 'customizeHardwareForTemplate',
567
- value
568
- )
569
- }
570
-
571
- resolve({
572
- stepHasError,
573
- newValue: value,
574
- })
575
- storageSubmit.value = null
576
- }
577
- })
578
- }
579
-
580
- const storageIdCash = ref<string | null>(null)
581
- const vmForm = ref<UI_I_VmForm>({
582
- name: '',
583
- compatibility: '',
584
- guestMachineType: null,
585
- guestOsFamily: null,
586
- guestOsVersion: null,
587
- computeResource: null,
588
- storage: null,
589
- locationPath: '',
590
- dataCenter: null,
591
- })
592
-
593
- // TODO remove (not used)
594
- const vmFormCash = ref<UI_I_VmFormCash>({
595
- dataCenterId: null,
596
- computeResourceTypeAndId: null,
597
- })
598
-
599
- const onChangeName = (name: string, node: UI_I_TreeNode | null): void => {
600
- vmForm.value.name = name
601
- if (isSphere.value) {
602
- vmForm.value.locationPath = node.id
603
- vmForm.value.dataCenter = $recursion.findParentByValue(
604
- node,
605
- 'datacenter',
606
- 'type',
607
- 'parent'
608
- )
609
- vmFormCash.value.dataCenterId = vmForm.value.dataCenter?.id || null
610
- }
611
- }
612
- // // Для сферы
613
- const computeResourcePath = ref<string>('')
614
- const onSelectComputeResourceTree = (node: UI_I_TreeNode): void => {
615
- emits('select-compute-resource-tree', node)
616
- computeResourcePath.value = node.id
617
- }
618
- const onChangeComputeResource = (node: UI_I_TreeNode): void => {
619
- vmForm.value.computeResource = node
620
- // const type = node.type.toUpperCase()
621
- // schedRequirementsTemplate.value = `sched_requirements="(${type}_ID=${node.id})"\\`
622
- vmFormCash.value.computeResourceTypeAndId = `${node.type}${node.id}` || null
623
- }
624
- const onChangeStorage = (storage: UI_I_DatastoreTableItem | null): void => {
625
- if (!storage) return
626
-
627
- vmForm.value.storage = storage
628
- storageIdCash.value = storage.id
629
- }
630
- const compatibilityInfo = ref<string>('')
631
- const onChangeCompatibility = (compatibility: UI_I_OptionItem): void => {
632
- vmForm.value.compatibility = compatibility.value
633
-
634
- const version = compatibility.value.split('-')[1]
635
- compatibilityInfo.value = `${localization.value.common.compatibility}: ${compatibility.text} (${localization.value.common.vmVersion} ${version})`
636
- }
637
- const customizeHardware = ref<UI_I_SendDataCustomizeHardware | null>(null)
638
- const onChangeCustomizeHardware = (
639
- data: UI_I_SendDataCustomizeHardware
640
- ): void => {
641
- customizeHardware.value = data
642
- }
643
-
644
- const virtualHardwareHardDisksLocal = computed<
645
- UI_I_SendDataNewHardDisk[] | null
646
- >(() => customizeHardware.value?.virtualHardware?.hardDisks || null)
647
- const virtualHardwareNetworksLocal = computed<UI_I_SendDataNewNetwork[] | null>(
648
- () => customizeHardware.value?.virtualHardware?.networks || null
649
- )
650
- const virtualHardwareCdDvdDrivesLocal = computed<
651
- UI_I_SendDataNewCdDvdDrive[] | null
652
- >(() => customizeHardware.value?.virtualHardware?.cdDvdDrives || null)
653
-
654
- const virtualHardwareCpu = computed<UI_I_SendDataCpu | null>(
655
- () => customizeHardware.value?.virtualHardware?.cpu || null
656
- )
657
- const virtualHardwareMemory = computed<UI_I_SendDataMemory | null>(
658
- () => customizeHardware.value?.virtualHardware?.memory || null
659
- )
660
- const virtualHardwareHardDisks = ref<UI_I_SendDataNewHardDisk[] | null>(null)
661
- const virtualHardwareCdDvdDrives = ref<UI_I_SendDataNewCdDvdDrive[] | null>(
662
- null
663
- )
664
- const virtualHardwareNetworks = ref<UI_I_SendDataNewNetwork[] | null>(null)
665
- const onChangeBootOrder = (data: UI_T_ChangeBootOrder): void => {
666
- virtualHardwareHardDisks.value = data[0]
667
- virtualHardwareCdDvdDrives.value = data[1]
668
- virtualHardwareNetworks.value = data[2]
669
- }
670
-
671
- const isPowerOnByDefault = ref<boolean>(true)
672
-
673
- watch(
674
- () => props.vmNameInWizard,
675
- (newValue) => {
676
- vmForm.value.name = newValue
677
- }
678
- )
679
-
680
- const validateSendData = async (
681
- value: UI_I_WizardStep[]
682
- ): Promise<UI_I_ValidationReturn> => {
683
- wizard.setLoader(true)
684
- let stepHasError = false
685
-
686
- const data = await props.validateSendDataFunc(
687
- vmForm.value,
688
- virtualHardwareCpu.value,
689
- virtualHardwareMemory.value,
690
- customizeHardware.value,
691
- virtualHardwareNetworks.value,
692
- virtualHardwareHardDisks.value,
693
- virtualHardwareCdDvdDrives.value,
694
- isPowerOnByDefault.value,
695
- localization.value,
696
- vmForm.value.locationPath, // для сферы
697
- computeResourcePath.value // для сферы
698
- )
699
-
700
- wizard.setLoader(false)
701
- if (data) {
702
- stepHasError = true
703
- selectedNavItem.value = data[0]
704
- data[1] !== null && wizard.selectStepHard(data[1])
705
- }
706
-
707
- return {
708
- stepHasError,
709
- newValue: value,
710
- }
711
- }
712
-
713
- const isLoading = ref<boolean>(false)
714
- const onFinish = (): void => {
715
- isLoading.value = true
716
- wizard.setLoader(false)
717
- props
718
- .finishFunc(
719
- vmForm.value,
720
- virtualHardwareCpu.value,
721
- virtualHardwareMemory.value,
722
- customizeHardware.value,
723
- virtualHardwareNetworks.value,
724
- virtualHardwareHardDisks.value,
725
- virtualHardwareCdDvdDrives.value,
726
- isPowerOnByDefault.value,
727
- localization.value,
728
- vmForm.value.locationPath, // для сферы
729
- computeResourcePath.value, // для сферы
730
- false
731
- )
732
- .then(() => {
733
- onHideModal()
734
- wizard.setLoader(false)
735
- isLoading.value = false
736
- })
737
- }
738
-
739
- const selectedNavItem = ref<UI_T_SelectedNavItem>(0)
740
-
741
- const nameFormSubmit = ref<null | Function>(null)
742
- const templateSubmit = ref<null | Function>(null)
743
- const computeResourceSubmit = ref<null | Function>(null)
744
- const storageSubmit = ref<null | Function>(null)
745
- const customizeHardwareSubmit = ref<null | Function>(null)
746
- const customizeHardwareForTemplateSubmit = ref<null | Function>(null)
747
- const compatibility = ref<UI_I_OptionItem[]>(
748
- capabilities.value.compatibility.filter((camp) => {
749
- let result = true
750
- // if (isDev && camp.value === 'pvm-2') result = false
751
- if (camp.value === 'pvm-2') result = false
752
- return result
753
- })
754
- )
755
- const guestOsFamilies = ref<UI_I_OptionItem[]>(
756
- capabilities.value.guestOsFamilies
757
- )
758
- const guestOsVersions = ref<UI_I_ArbitraryObject<UI_I_OptionItem[]>>(
759
- capabilities.value.guestOsVersions
760
- )
761
- const machineTypes = ref<UI_I_OptionItem[]>(capabilities.value.machineTypes)
762
- const cpuModels = ref<UI_I_OptionItem[]>(capabilities.value.cpuModels)
763
- const maxCpus = ref<number>(capabilities.value.maxCpus)
764
- const maxMemory = ref<number>(capabilities.value.maxMemory)
765
-
766
- const selectedTemplate = ref<string>('')
767
- const onChangeTemplate = (node: UI_I_TreeNode): void => {
768
- selectedTemplate.value = node.id.toString()
769
- emits('select-template', node.id.toString())
770
- }
771
- const selectedOptions = ref<string[]>([])
772
- const onChangeSelectOptions = (options: string[]) => {
773
- selectedOptions.value = options
774
- if (
775
- options.includes('customize-os') &&
776
- options.includes('customize-hardware')
777
- ) {
778
- wizard.changeScheme(5)
779
- } else if (options.includes('customize-os')) {
780
- wizard.changeScheme(3)
781
- } else if (options.includes('customize-hardware')) {
782
- wizard.changeScheme(4)
783
- } else {
784
- wizard.changeScheme(2)
785
- }
786
-
787
- isPowerOnByDefault.value = options.includes('power-on')
788
- }
789
-
790
- const onHideModal = (): void => {
791
- emits('hide')
792
- }
793
-
794
- watch(
795
- () => props.vmtSettings,
796
- (newValue) => {
797
- if (newValue) {
798
- vmForm.value.name = newValue.name
799
- vmForm.value.compatibility =
800
- newValue.compatibility || vmForm.value.compatibility
801
- vmForm.value.storage = newValue.storage
802
- if (customizeHardware.value?.virtualHardware) {
803
- customizeHardware.value.virtualHardware.cdDvdDrives =
804
- newValue.cdDvdDrives
805
- customizeHardware.value.virtualHardware.hardDisks = newValue.hardDisks
806
- customizeHardware.value.virtualHardware.networks = newValue.networks
807
- customizeHardware.value.virtualHardware.cpu = newValue.cpu
808
- customizeHardware.value.virtualHardware.memory = newValue.memory
809
- customizeHardware.value.virtualHardware.videoCard = newValue.videoCard
810
- customizeHardware.value.virtualHardware.usbController =
811
- newValue.usbController
812
- customizeHardware.value.virtualHardware.pciDevices = newValue.pciDevices
813
- customizeHardware.value.vmOptions = newValue.options
814
- }
815
- maxCpus.value = newValue.cpu.max_vcpus
816
- cpuModels.value = newValue.cpu.model
817
- isPowerOnByDefault.value = false
818
- }
819
- }
820
- )
821
- </script>
822
-
823
- <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(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
+ () => wizard.selectedStepId > dynamicSteps.customizeHardware
288
+ )
289
+
290
+ const onChangeSteps = async (value: UI_I_WizardStep[]): Promise<void> => {
291
+ wizard.changeSteps(value, validationFunc, validateSendData)
292
+ }
293
+ const validationFunc = async (
294
+ value: UI_I_WizardStep[],
295
+ currentStep: UI_I_WizardStep,
296
+ nextStep: UI_I_WizardStep
297
+ ): Promise<UI_I_ValidationReturn> => {
298
+ let stepHasError = false
299
+ let stepShouldStop = {
300
+ ifOnCurrentStep: false,
301
+ ifFromAnyStep: false,
302
+ stoppageStepId: -1,
303
+ }
304
+
305
+ wizard.setLoader(true)
306
+ if (
307
+ wizard.isValidateForStep(
308
+ dynamicSteps.selectTemplate,
309
+ currentStep.id,
310
+ nextStep.id
311
+ )
312
+ ) {
313
+ const templateValidation = await checkTemplate(value)
314
+
315
+ value = templateValidation.newValue
316
+ stepHasError = stepHasError || templateValidation.stepHasError
317
+ } else if (
318
+ wizard.isValidateForStep(
319
+ isSphere.value ? dynamicSteps.selectNameFolder : dynamicSteps.selectName,
320
+ currentStep.id,
321
+ nextStep.id
322
+ )
323
+ ) {
324
+ const nameValidation = await onCheckName(value)
325
+
326
+ value = nameValidation.newValue
327
+ stepHasError = stepHasError || nameValidation.stepHasError
328
+ } else if (
329
+ isSphere.value &&
330
+ wizard.isValidateForStep(
331
+ dynamicSteps.selectComputeResource,
332
+ currentStep.id,
333
+ nextStep.id
334
+ )
335
+ ) {
336
+ const computeResourceValidation = await checkComputeResource(value)
337
+
338
+ value = computeResourceValidation.newValue
339
+ stepHasError = stepHasError || computeResourceValidation.stepHasError
340
+ } else if (
341
+ wizard.isValidateForStep(
342
+ dynamicSteps.selectStorage,
343
+ currentStep.id,
344
+ nextStep.id
345
+ )
346
+ ) {
347
+ const storageValidation = await checkStorage(value)
348
+
349
+ value = storageValidation.newValue
350
+
351
+ stepHasError = stepHasError || storageValidation.stepHasError
352
+ } else if (
353
+ wizard.isValidateForStep(
354
+ dynamicSteps.customizeHardware,
355
+ currentStep.id,
356
+ nextStep.id
357
+ )
358
+ ) {
359
+ const validation = await checkCustomizeHardware(value)
360
+
361
+ value = validation.newValue
362
+
363
+ stepHasError = stepHasError || validation.stepHasError
364
+ } else if (
365
+ wizard.isValidateForStep(
366
+ dynamicSteps.customizeHardwareTemplate,
367
+ currentStep.id,
368
+ nextStep.id
369
+ )
370
+ ) {
371
+ const validation = await checkCustomizeHardwareForTemplate(value)
372
+
373
+ value = validation.newValue
374
+
375
+ stepHasError = stepHasError || validation.stepHasError
376
+ }
377
+ wizard.setLoader(false)
378
+
379
+ return {
380
+ newValue: value,
381
+ stepHasError,
382
+ stepShouldStop,
383
+ }
384
+ }
385
+
386
+ const checkTemplate = async (
387
+ value: UI_I_WizardStep[]
388
+ ): Promise<UI_I_ValidationReturn> => {
389
+ let stepHasError = false
390
+
391
+ return new Promise((resolve) => {
392
+ templateSubmit.value = (isValid: boolean) => {
393
+ if (!isValid) {
394
+ stepHasError = wizard.setValidation(
395
+ dynamicSteps.selectTemplate,
396
+ 'template',
397
+ {
398
+ fieldMessage: 'aaa',
399
+ alertMessage: 'aaa',
400
+ }
401
+ )
402
+ } else if (wizard.hasMessage(dynamicSteps.selectTemplate, 'template')) {
403
+ value = wizard.removeValidation(
404
+ dynamicSteps.selectTemplate,
405
+ 'template',
406
+ value
407
+ )
408
+ }
409
+
410
+ resolve({
411
+ stepHasError,
412
+ newValue: value,
413
+ })
414
+ templateSubmit.value = null
415
+ }
416
+ })
417
+ }
418
+ const onCheckName = async (
419
+ value: UI_I_WizardStep[]
420
+ ): Promise<UI_I_ValidationReturn> => {
421
+ let stepHasError = false
422
+
423
+ return new Promise((resolve) => {
424
+ const step = isSphere.value
425
+ ? dynamicSteps.selectNameFolder
426
+ : dynamicSteps.selectName
427
+ nameFormSubmit.value = (isValid: boolean) => {
428
+ if (!isValid) {
429
+ stepHasError = wizard.setValidation(step, 'name', {
430
+ fieldMessage: 'aaa',
431
+ alertMessage: 'aaa',
432
+ })
433
+ } else if (wizard.hasMessage(step, 'name')) {
434
+ value = wizard.removeValidation(step, 'name', value)
435
+ }
436
+
437
+ resolve({
438
+ stepHasError,
439
+ newValue: value,
440
+ })
441
+ nameFormSubmit.value = null
442
+ }
443
+ })
444
+ }
445
+ const checkComputeResource = async (
446
+ value: UI_I_WizardStep[]
447
+ ): Promise<UI_I_ValidationReturn> => {
448
+ let stepHasError = false
449
+
450
+ return new Promise((resolve) => {
451
+ computeResourceSubmit.value = (isValid: boolean) => {
452
+ if (!isValid) {
453
+ stepHasError = wizard.setValidation(
454
+ dynamicSteps.selectComputeResource,
455
+ 'computeResource',
456
+ {
457
+ fieldMessage: 'aaa',
458
+ alertMessage: 'aaa',
459
+ }
460
+ )
461
+ } else if (
462
+ wizard.hasMessage(dynamicSteps.selectComputeResource, 'computeResource')
463
+ ) {
464
+ value = wizard.removeValidation(
465
+ dynamicSteps.selectComputeResource,
466
+ 'computeResource',
467
+ value
468
+ )
469
+ }
470
+
471
+ resolve({
472
+ stepHasError,
473
+ newValue: value,
474
+ })
475
+ computeResourceSubmit.value = null
476
+ }
477
+ })
478
+ }
479
+ const checkStorage = async (
480
+ value: UI_I_WizardStep[]
481
+ ): Promise<UI_I_ValidationReturn> => {
482
+ let stepHasError = false
483
+
484
+ return new Promise((resolve) => {
485
+ storageSubmit.value = (isValid: boolean) => {
486
+ if (!isValid) {
487
+ stepHasError = wizard.setValidation(
488
+ dynamicSteps.selectStorage,
489
+ 'storage',
490
+ {
491
+ fieldMessage: 'aaa',
492
+ alertMessage: 'aaa',
493
+ }
494
+ )
495
+ } else if (wizard.hasMessage(dynamicSteps.selectStorage, 'storage')) {
496
+ value = wizard.removeValidation(
497
+ dynamicSteps.selectStorage,
498
+ 'storage',
499
+ value
500
+ )
501
+ }
502
+
503
+ resolve({
504
+ stepHasError,
505
+ newValue: value,
506
+ })
507
+ storageSubmit.value = null
508
+ }
509
+ })
510
+ }
511
+ const checkCustomizeHardware = async (
512
+ value: UI_I_WizardStep[]
513
+ ): Promise<UI_I_ValidationReturn> => {
514
+ let stepHasError = false
515
+
516
+ return new Promise((resolve) => {
517
+ customizeHardwareSubmit.value = (isValid: boolean) => {
518
+ if (!isValid) {
519
+ stepHasError = wizard.setValidation(
520
+ dynamicSteps.customizeHardware,
521
+ 'customizeHardware',
522
+ {
523
+ fieldMessage: 'aaa',
524
+ alertMessage: 'aaa',
525
+ }
526
+ )
527
+ } else if (
528
+ wizard.hasMessage(dynamicSteps.customizeHardware, 'customizeHardware')
529
+ ) {
530
+ value = wizard.removeValidation(
531
+ dynamicSteps.customizeHardware,
532
+ 'customizeHardware',
533
+ value
534
+ )
535
+ }
536
+
537
+ resolve({
538
+ stepHasError,
539
+ newValue: value,
540
+ })
541
+ storageSubmit.value = null
542
+ }
543
+ })
544
+ }
545
+ const checkCustomizeHardwareForTemplate = async (
546
+ value: UI_I_WizardStep[]
547
+ ): Promise<UI_I_ValidationReturn> => {
548
+ let stepHasError = false
549
+
550
+ return new Promise((resolve) => {
551
+ customizeHardwareForTemplateSubmit.value = (isValid: boolean) => {
552
+ if (!isValid) {
553
+ stepHasError = wizard.setValidation(dynamicSteps.customizeHardwareTemplate,
554
+ 'customizeHardwareForTemplate',
555
+ {
556
+ fieldMessage: 'aaa',
557
+ alertMessage: 'aaa',
558
+ }
559
+ )
560
+ } else if (
561
+ wizard.hasMessage(dynamicSteps.customizeHardwareTemplate,
562
+ 'customizeHardwareForTemplate'
563
+ )
564
+ ) {
565
+ value = wizard.removeValidation(dynamicSteps.customizeHardwareTemplate,
566
+ 'customizeHardwareForTemplate',
567
+ value
568
+ )
569
+ }
570
+
571
+ resolve({
572
+ stepHasError,
573
+ newValue: value,
574
+ })
575
+ storageSubmit.value = null
576
+ }
577
+ })
578
+ }
579
+
580
+ const storageIdCash = ref<string | null>(null)
581
+ const vmForm = ref<UI_I_VmForm>({
582
+ name: '',
583
+ compatibility: '',
584
+ guestMachineType: null,
585
+ guestOsFamily: null,
586
+ guestOsVersion: null,
587
+ computeResource: null,
588
+ storage: null,
589
+ locationPath: '',
590
+ dataCenter: null,
591
+ })
592
+
593
+ // TODO remove (not used)
594
+ const vmFormCash = ref<UI_I_VmFormCash>({
595
+ dataCenterId: null,
596
+ computeResourceTypeAndId: null,
597
+ })
598
+
599
+ const onChangeName = (name: string, node: UI_I_TreeNode | null): void => {
600
+ vmForm.value.name = name
601
+ if (isSphere.value) {
602
+ vmForm.value.locationPath = node.id
603
+ vmForm.value.dataCenter = $recursion.findParentByValue(
604
+ node,
605
+ 'datacenter',
606
+ 'type',
607
+ 'parent'
608
+ )
609
+ vmFormCash.value.dataCenterId = vmForm.value.dataCenter?.id || null
610
+ }
611
+ }
612
+ // // Для сферы
613
+ const computeResourcePath = ref<string>('')
614
+ const onSelectComputeResourceTree = (node: UI_I_TreeNode): void => {
615
+ emits('select-compute-resource-tree', node)
616
+ computeResourcePath.value = node.id
617
+ }
618
+ const onChangeComputeResource = (node: UI_I_TreeNode): void => {
619
+ vmForm.value.computeResource = node
620
+ // const type = node.type.toUpperCase()
621
+ // schedRequirementsTemplate.value = `sched_requirements="(${type}_ID=${node.id})"\\`
622
+ vmFormCash.value.computeResourceTypeAndId = `${node.type}${node.id}` || null
623
+ }
624
+ const onChangeStorage = (storage: UI_I_DatastoreTableItem | null): void => {
625
+ if (!storage) return
626
+
627
+ vmForm.value.storage = storage
628
+ storageIdCash.value = storage.id
629
+ }
630
+ const compatibilityInfo = ref<string>('')
631
+ const onChangeCompatibility = (compatibility: UI_I_OptionItem): void => {
632
+ vmForm.value.compatibility = compatibility.value
633
+
634
+ const version = compatibility.value.split('-')[1]
635
+ compatibilityInfo.value = `${localization.value.common.compatibility}: ${compatibility.text} (${localization.value.common.vmVersion} ${version})`
636
+ }
637
+ const customizeHardware = ref<UI_I_SendDataCustomizeHardware | null>(null)
638
+ const onChangeCustomizeHardware = (
639
+ data: UI_I_SendDataCustomizeHardware
640
+ ): void => {
641
+ customizeHardware.value = data
642
+ }
643
+
644
+ const virtualHardwareHardDisksLocal = computed<
645
+ UI_I_SendDataNewHardDisk[] | null
646
+ >(() => customizeHardware.value?.virtualHardware?.hardDisks || null)
647
+ const virtualHardwareNetworksLocal = computed<UI_I_SendDataNewNetwork[] | null>(
648
+ () => customizeHardware.value?.virtualHardware?.networks || null
649
+ )
650
+ const virtualHardwareCdDvdDrivesLocal = computed<
651
+ UI_I_SendDataNewCdDvdDrive[] | null
652
+ >(() => customizeHardware.value?.virtualHardware?.cdDvdDrives || null)
653
+
654
+ const virtualHardwareCpu = computed<UI_I_SendDataCpu | null>(
655
+ () => customizeHardware.value?.virtualHardware?.cpu || null
656
+ )
657
+ const virtualHardwareMemory = computed<UI_I_SendDataMemory | null>(
658
+ () => customizeHardware.value?.virtualHardware?.memory || null
659
+ )
660
+ const virtualHardwareHardDisks = ref<UI_I_SendDataNewHardDisk[] | null>(null)
661
+ const virtualHardwareCdDvdDrives = ref<UI_I_SendDataNewCdDvdDrive[] | null>(
662
+ null
663
+ )
664
+ const virtualHardwareNetworks = ref<UI_I_SendDataNewNetwork[] | null>(null)
665
+ const onChangeBootOrder = (data: UI_T_ChangeBootOrder): void => {
666
+ virtualHardwareHardDisks.value = data[0]
667
+ virtualHardwareCdDvdDrives.value = data[1]
668
+ virtualHardwareNetworks.value = data[2]
669
+ }
670
+
671
+ const isPowerOnByDefault = ref<boolean>(true)
672
+
673
+ watch(
674
+ () => props.vmNameInWizard,
675
+ (newValue) => {
676
+ vmForm.value.name = newValue
677
+ }
678
+ )
679
+
680
+ const validateSendData = async (
681
+ value: UI_I_WizardStep[]
682
+ ): Promise<UI_I_ValidationReturn> => {
683
+ wizard.setLoader(true)
684
+ let stepHasError = false
685
+
686
+ const data = await props.validateSendDataFunc(
687
+ vmForm.value,
688
+ virtualHardwareCpu.value,
689
+ virtualHardwareMemory.value,
690
+ customizeHardware.value,
691
+ virtualHardwareNetworks.value,
692
+ virtualHardwareHardDisks.value,
693
+ virtualHardwareCdDvdDrives.value,
694
+ isPowerOnByDefault.value,
695
+ localization.value,
696
+ vmForm.value.locationPath, // для сферы
697
+ computeResourcePath.value // для сферы
698
+ )
699
+
700
+ wizard.setLoader(false)
701
+ if (data) {
702
+ stepHasError = true
703
+ selectedNavItem.value = data[0]
704
+ data[1] !== null && wizard.selectStepHard(data[1])
705
+ }
706
+
707
+ return {
708
+ stepHasError,
709
+ newValue: value,
710
+ }
711
+ }
712
+
713
+ const isLoading = ref<boolean>(false)
714
+ const onFinish = (): void => {
715
+ isLoading.value = true
716
+ wizard.setLoader(false)
717
+ props
718
+ .finishFunc(
719
+ vmForm.value,
720
+ virtualHardwareCpu.value,
721
+ virtualHardwareMemory.value,
722
+ customizeHardware.value,
723
+ virtualHardwareNetworks.value,
724
+ virtualHardwareHardDisks.value,
725
+ virtualHardwareCdDvdDrives.value,
726
+ isPowerOnByDefault.value,
727
+ localization.value,
728
+ vmForm.value.locationPath, // для сферы
729
+ computeResourcePath.value, // для сферы
730
+ false
731
+ )
732
+ .then(() => {
733
+ onHideModal()
734
+ wizard.setLoader(false)
735
+ isLoading.value = false
736
+ })
737
+ }
738
+
739
+ const selectedNavItem = ref<UI_T_SelectedNavItem>(0)
740
+
741
+ const nameFormSubmit = ref<null | Function>(null)
742
+ const templateSubmit = ref<null | Function>(null)
743
+ const computeResourceSubmit = ref<null | Function>(null)
744
+ const storageSubmit = ref<null | Function>(null)
745
+ const customizeHardwareSubmit = ref<null | Function>(null)
746
+ const customizeHardwareForTemplateSubmit = ref<null | Function>(null)
747
+ const compatibility = ref<UI_I_OptionItem[]>(
748
+ capabilities.value.compatibility.filter((camp) => {
749
+ let result = true
750
+ // if (isDev && camp.value === 'pvm-2') result = false
751
+ if (camp.value === 'pvm-2') result = false
752
+ return result
753
+ })
754
+ )
755
+ const guestOsFamilies = ref<UI_I_OptionItem[]>(
756
+ capabilities.value.guestOsFamilies
757
+ )
758
+ const guestOsVersions = ref<UI_I_ArbitraryObject<UI_I_OptionItem[]>>(
759
+ capabilities.value.guestOsVersions
760
+ )
761
+ const machineTypes = ref<UI_I_OptionItem[]>(capabilities.value.machineTypes)
762
+ const cpuModels = ref<UI_I_OptionItem[]>(capabilities.value.cpuModels)
763
+ const maxCpus = ref<number>(capabilities.value.maxCpus)
764
+ const maxMemory = ref<number>(capabilities.value.maxMemory)
765
+
766
+ const selectedTemplate = ref<string>('')
767
+ const onChangeTemplate = (node: UI_I_TreeNode): void => {
768
+ selectedTemplate.value = node.id.toString()
769
+ emits('select-template', node.id.toString())
770
+ }
771
+ const selectedOptions = ref<string[]>([])
772
+ const onChangeSelectOptions = (options: string[]) => {
773
+ selectedOptions.value = options
774
+ if (
775
+ options.includes('customize-os') &&
776
+ options.includes('customize-hardware')
777
+ ) {
778
+ wizard.changeScheme(5)
779
+ } else if (options.includes('customize-os')) {
780
+ wizard.changeScheme(3)
781
+ } else if (options.includes('customize-hardware')) {
782
+ wizard.changeScheme(4)
783
+ } else {
784
+ wizard.changeScheme(2)
785
+ }
786
+
787
+ isPowerOnByDefault.value = options.includes('power-on')
788
+ }
789
+
790
+ const onHideModal = (): void => {
791
+ emits('hide')
792
+ }
793
+
794
+ watch(
795
+ () => props.vmtSettings,
796
+ (newValue) => {
797
+ if (newValue) {
798
+ vmForm.value.name = newValue.name
799
+ vmForm.value.compatibility =
800
+ newValue.compatibility || vmForm.value.compatibility
801
+ vmForm.value.storage = newValue.storage
802
+ if (customizeHardware.value?.virtualHardware) {
803
+ customizeHardware.value.virtualHardware.cdDvdDrives =
804
+ newValue.cdDvdDrives
805
+ customizeHardware.value.virtualHardware.hardDisks = newValue.hardDisks
806
+ customizeHardware.value.virtualHardware.networks = newValue.networks
807
+ customizeHardware.value.virtualHardware.cpu = newValue.cpu
808
+ customizeHardware.value.virtualHardware.memory = newValue.memory
809
+ customizeHardware.value.virtualHardware.videoCard = newValue.videoCard
810
+ customizeHardware.value.virtualHardware.usbController =
811
+ newValue.usbController
812
+ customizeHardware.value.virtualHardware.pciDevices = newValue.pciDevices
813
+ customizeHardware.value.vmOptions = newValue.options
814
+ }
815
+ maxCpus.value = newValue.cpu.max_vcpus
816
+ cpuModels.value = newValue.cpu.model
817
+ isPowerOnByDefault.value = false
818
+ }
819
+ }
820
+ )
821
+ </script>
822
+
823
+ <style scoped lang="scss"></style>