bfg-common 1.5.539 → 1.5.540

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