bfg-common 1.5.595 → 1.5.596

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