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,679 +1,679 @@
1
- <template>
2
- <component
3
- :is="currentComponent"
4
- v-model="model"
5
- v-model:cpu-invalid="cpuInvalid"
6
- v-model:memory-invalid="memoryInvalid"
7
- v-model:video-card-invalid="videoCardInvalid"
8
- :nodes="props.nodes"
9
- :files="props.files"
10
- :is-edit="props.isEdit"
11
- :storage="props.storage"
12
- :project="props.project"
13
- :max-memory="props.maxMemory"
14
- :cpu-models="props.cpuModels"
15
- :datastore="props.datastore"
16
- :is-datastore-loading="props.isDatastoreLoading"
17
- :networks-type="networksType"
18
- :networks-table="props.networksTable"
19
- :dropdown-items="dropdownItems"
20
- :hard-disks-type="hardDisksType"
21
- :networks-index="networksIndex"
22
- :hard-disks-index="hardDisksIndex"
23
- :pci-devices-type="pciDevicesType"
24
- :is-show-file-modal="isShowFileModal"
25
- :pci-devices-index="pciDevicesIndex"
26
- :cd-dvd-drives-type="cdDvdDrivesType"
27
- :cd-dvd-drives-index="cdDvdDrivesIndex"
28
- :error-validation-fields="errorValidationFields"
29
- :get-datastore-table-func="getDatastoreTableFunc"
30
- :state="state"
31
- :video-card="videoCard"
32
- :pci-devices="pciDevicesLocal"
33
- :guest-machine-type="guestMachineType"
34
- :passthrough-devices="passthroughDevices"
35
- :mediated-devices="mediatedDevices"
36
- :vm-cpu-help-text-second="vmCpuHelpTextSecond"
37
- :compute-resource="props.computeResource"
38
- :compatibility-info="props.compatibilityInfo"
39
- :network-value-prop="networkValueProp"
40
- @add-device="onAddDevice"
41
- @get-storage="emits('get-storage', $event)"
42
- @remove-network="onRemoveNetwork"
43
- @hide-file-modal="isShowFileModal = false"
44
- @remove-hard-disk="onRemoveHardDisk(...$event)"
45
- @remove-pci-device="onRemovePciDevice"
46
- @get-networks-table="emits('get-networks-table', $event)"
47
- @add-exist-hard-disk="onAddExistHardDisk"
48
- @roll-back-hard-disk="onRollBackHardDisk"
49
- @set-invalid-network="onSetInvalidNetwork(...$event)"
50
- @remove-cd-dvd-drive="onRemoveCdDvdDrive(...$event)"
51
- @show-datastore-child="emits('show-datastore-child', $event)"
52
- @get-folders-or-files="emits('get-folders-or-files', $event)"
53
- @set-invalid-hard-disk="onSetInvalidHardDisk(...$event)"
54
- @remove-error-by-title="emits('remove-error-by-title', $event)"
55
- @roll-back-cd-dvd-drive="onRollBackCdDvdDrive"
56
- @set-invalid-pci-device="onSetInvalidPciDevice(...$event)"
57
- @get-active-device-child="emits('get-active-device-child', $event)"
58
- @send-data-pci-devices-method="onSendDataPciDevicesMethod(...$event)"
59
- @send-data-new-hard-disk-method="onSendDataNewHardDiskMethod(...$event)"
60
- @send-data-new-cd-dvd-drive-method="sendDataNewCdDvdDriveMethod(...$event)"
61
- />
62
- </template>
63
-
64
- <script setup lang="ts">
65
- import type { UI_T_Project } from '~/lib/models/types'
66
- import type { UI_I_DatastoreTableItem } from '~/lib/models/store/storage/interfaces'
67
- import type { UI_I_NetworkTableItem } from '~/lib/models/store/network/interfaces'
68
- import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
69
- import type { UI_I_FolderOrFileTreePayload } from '~/lib/models/store/storage/interfaces'
70
- import type { UI_I_FileTreeNode } from '~/components/lib/models/interfaces'
71
- import type {
72
- UI_I_SendDataNewHardDisk,
73
- UI_I_SendDataVideoCard,
74
- UI_I_InvalidKeys,
75
- UI_I_SendDataNewCdDvdDrive,
76
- // UI_I_HardDisk,
77
- UI_I_SendDataNewPciDevice,
78
- } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
79
- import type { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
80
- import type {
81
- UI_T_HardDiskType,
82
- UI_T_NetworkType,
83
- UI_T_CdDvdType,
84
- } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/types'
85
- import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
86
- import type {
87
- UI_I_DropdownTreeItem,
88
- UI_I_DropdownTreeItemChild,
89
- } from '~/components/atoms/dropdown/tree/lib/models/interfaces'
90
- import type { UI_I_Localization } from '~/lib/models/interfaces'
91
- import type {
92
- UI_I_MediatedDevice,
93
- UI_I_PciDevice,
94
- } from '~/lib/models/store/vm/interfaces'
95
- import type { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
96
- import type { UI_I_CreateVmData } from '~/components/common/vm/actions/common/lib/models/interfaces'
97
- import { dropdownItemsFunc } from './lib/config/dropdownItems'
98
-
99
- const model = defineModel<UI_I_CreateVmData>({ required: true })
100
-
101
- const props = withDefaults(
102
- defineProps<{
103
- storage: UI_I_DatastoreTableItem | null
104
- cpuModels: UI_I_OptionItem[]
105
- maxMemory: number
106
- isEdit: boolean
107
- isClone: boolean
108
- errorValidationFields: UI_I_ErrorValidationField[]
109
- nodes: UI_I_FileTreeNode[]
110
- files: UI_I_FileTreeNode[]
111
- networksTable: UI_I_NetworkTableItem[]
112
- getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
113
- datastore: UI_I_DatastoreTableItem[]
114
- isDatastoreLoading: boolean
115
- project: UI_T_Project
116
- state?: string | number
117
- vmCpuHelpTextSecond?: string
118
- hardDisks?: UI_I_SendDataNewHardDisk[] | null
119
- cdDvdDrives?: UI_I_SendDataNewCdDvdDrive[] | null
120
- videoCard?: UI_I_SendDataVideoCard
121
- pciDevices?: UI_I_SendDataNewPciDevice[]
122
- passthroughDevices?: UI_I_PciDevice[]
123
- mediatedDevices?: UI_I_MediatedDevice[]
124
- guestMachineType?: UI_I_OptionItem | null
125
- computeResource?: UI_I_TreeNode | null
126
- compatibilityInfo?: string
127
- }>(),
128
- {
129
- state: undefined,
130
- vmCpuHelpTextSecond: undefined,
131
- hardDisks: undefined,
132
- cdDvdDrives: undefined,
133
- videoCard: undefined,
134
- pciDevices: undefined,
135
- passthroughDevices: undefined,
136
- mediatedDevices: undefined,
137
- guestMachineType: undefined,
138
- computeResource: undefined,
139
- compatibilityInfo: undefined,
140
- }
141
- )
142
- const emits = defineEmits<{
143
- (event: 'invalid', value: string[]): void
144
- (event: 'get-storage', value: UI_I_TablePayload): void
145
- (event: 'get-folders-or-files', value: UI_I_FolderOrFileTreePayload): void
146
- (event: 'get-active-device-child', value: UI_I_FileTreeNode): void
147
- (event: 'show-datastore-child', value: UI_I_FileTreeNode): void
148
- (event: 'remove-error-by-title', value: string): void
149
- (event: 'get-networks-table', value: UI_I_TablePayload): void
150
- (event: 'get-pci-devices'): void
151
- }>()
152
-
153
- const { $store, $binary }: any = useNuxtApp()
154
- const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
155
- const currentComponent = computed(() =>
156
- isNewView.value
157
- ? defineAsyncComponent(() => import('./New.vue'))
158
- : defineAsyncComponent(() => import('./Old.vue'))
159
- )
160
-
161
- const localization = computed<UI_I_Localization>(() => useLocal())
162
-
163
- const dropdownItems = computed<UI_I_DropdownTreeItem[]>(() =>
164
- dropdownItemsFunc(
165
- localization.value,
166
- props.state,
167
- props.passthroughDevices,
168
- props.mediatedDevices
169
- )
170
- )
171
-
172
- const hardDisksIndex = ref<number[]>([0])
173
- const hardDisksType = ref<UI_T_HardDiskType[]>(['new'])
174
- // const hardDisksLocal = ref<UI_I_SendDataNewHardDisk[]>([
175
- // {
176
- // create: true,
177
- // size: 90,
178
- // source: '',
179
- // boot_order: -1,
180
- // },
181
- // ])
182
- if (!model.value.disk_devices?.length) {
183
- hardDisksType.value = []
184
- hardDisksIndex.value = []
185
- } else {
186
- model.value.disk_devices
187
- .filter((disk) => disk.device_type !== 'cdrom')
188
- .forEach((_disk, _index, array) => {
189
- if (!props.isEdit && !props.isClone) return
190
-
191
- const count = array.length
192
- hardDisksIndex.value = [...Array(count).keys()]
193
- if (props.isEdit) {
194
- hardDisksType.value = Array(count).fill('edit')
195
- } else if (props.isClone) {
196
- hardDisksType.value = Array(count).fill('clone')
197
- }
198
- })
199
- }
200
-
201
- // watch(
202
- // () => props.hardDisks,
203
- // (newValue) => {
204
- // if ((!props.isEdit && !props.isClone) || !newValue) return
205
- //
206
- // const count = newValue?.length || 0
207
- // hardDisksIndex.value = [...Array(count).keys()]
208
- // hardDisksLocal.value = newValue
209
- // if (props.isEdit) {
210
- // hardDisksType.value = Array(count).fill('edit')
211
- // } else if (props.isClone) {
212
- // hardDisksType.value = Array(count).fill('clone')
213
- // hardDisksLocal.value = newValue.map((hardDisk) => {
214
- // hardDisk.create = true
215
- // return hardDisk
216
- // })
217
- // }
218
- // },
219
- // { immediate: true }
220
- // )
221
-
222
- const addHardDisk = (
223
- create = true,
224
- size = 92_160, // 90GB
225
- source = '',
226
- type: UI_T_HardDiskType = 'new',
227
- provisioned_type?: number // При добавлении существующей
228
- ): void => {
229
- const newIndex = (hardDisksIndex.value.at(-1) ?? -1) + 1
230
- hardDisksIndex.value.push(newIndex)
231
- hardDisksType.value.push(type)
232
-
233
- let provisionType = 'thick'
234
- if (provisioned_type === 1) provisionType = 'thin'
235
-
236
- model.value.disk_devices = [
237
- ...model.value.disk_devices.filter((disk) => disk.device_type !== 'cdrom'),
238
- // {
239
- // create,
240
- // size,
241
- // source,
242
- // attach: true,
243
- // boot_order: 0, // Убираем галочку
244
- // provision_type: provisionType,
245
- // },
246
- {
247
- create,
248
- size,
249
- source,
250
- bus: 'virtio',
251
- storage_id: '',
252
- provision_type: 'thick',
253
- disk_mode: 'dependent',
254
- boot_order: 0, // Убираем галочку
255
- device_type: 'disk',
256
- sharing: false,
257
- shares: 0,
258
- cache: 'none',
259
- io: '',
260
- limit_iops: 0,
261
- attach: true,
262
- },
263
- ...model.value.disk_devices.filter((disk) => disk.device_type === 'cdrom'),
264
- ]
265
- // hardDisksLocal.value.push({
266
- // create,
267
- // size,
268
- // source,
269
- // attach: true,
270
- // boot_order: 0, // Убираем галочку
271
- // provision_type: provisionType,
272
- // })
273
- }
274
- const onAddExistHardDisk = (file: UI_I_FileTreeNode): void => {
275
- addHardDisk(
276
- false,
277
- $binary.bToGb(file.size),
278
- file.path,
279
- 'exist',
280
- file.provisioned_type
281
- )
282
- }
283
- const onRemoveHardDisk = (
284
- index: number,
285
- hardDisk: UI_I_SendDataNewHardDisk
286
- ): void => {
287
- const removeIndex = hardDisksIndex.value.indexOf(index)
288
-
289
- if (!hardDisk.create && !hardDisk.attach) {
290
- hardDisksType.value = hardDisksType.value.map((item, key) => {
291
- if (key === removeIndex) return 'removed'
292
- return item
293
- })
294
- return
295
- }
296
-
297
- hardDisksIndex.value = hardDisksIndex.value.filter((item) => item !== index)
298
- hardDisksType.value = hardDisksType.value.filter(
299
- (_item, key) => key !== removeIndex
300
- )
301
-
302
- model.value.disk_devices = model.value.disk_devices.filter(
303
- (_hardDisk, key: number) => {
304
- return removeIndex !== key
305
- }
306
- )
307
- // hardDisksLocal.value = hardDisksLocal.value.filter(
308
- // (_hardDisk, key: number) => {
309
- // return removeIndex !== key
310
- // }
311
- // )
312
-
313
- delete newHardDiskInvalidKeys.value[index]
314
- }
315
- const onRollBackHardDisk = (index: number): void => {
316
- const removeIndex = hardDisksIndex.value.indexOf(index)
317
- hardDisksType.value = hardDisksType.value.map((item, key) => {
318
- if (key === removeIndex) return 'edit'
319
- return item
320
- })
321
- }
322
-
323
- const networkValueProp = props.project === 'sphere' ? 'network' : 'net_bridge'
324
- const networksType = ref<UI_T_NetworkType[]>(['new'])
325
- const networksIndex = ref<number[]>([0])
326
- if (!model.value.network_devices?.length) {
327
- networksType.value = []
328
- networksIndex.value = []
329
- } else {
330
- model.value.network_devices.forEach(() => {
331
- if (!props.isEdit && !props.isClone) return
332
-
333
- const count = model.value.network_devices.length || 0
334
- networksIndex.value = [...Array(count).keys()]
335
- if (props.isEdit) {
336
- networksType.value = Array(count).fill('edit')
337
- } else if (props.isClone) {
338
- networksType.value = Array(count).fill('clone')
339
- }
340
- })
341
- }
342
-
343
- const defaultNetwork = {
344
- network: '',
345
- net_bridge: '',
346
- mac: '',
347
- target: '',
348
- model: 'virtio',
349
- boot_order: 0,
350
- }
351
- const addNetwork = (): void => {
352
- const index = (networksIndex.value.at(-1) ?? -1) + 1
353
- networksIndex.value.push(index)
354
- networksType.value.push('new')
355
-
356
- model.value.network_devices.push({
357
- ...useDeepCopy(defaultNetwork),
358
- })
359
- }
360
- const onRemoveNetwork = (index: number): void => {
361
- const removeIndex = networksIndex.value.indexOf(index)
362
- networksIndex.value = networksIndex.value.filter((item) => item !== index)
363
- networksType.value = networksType.value.filter(
364
- (_item, key) => key !== removeIndex
365
- )
366
- model.value.network_devices = model.value.network_devices.filter(
367
- (_network, key: number) => removeIndex !== key
368
- )
369
-
370
- delete newNetworkInvalidKeys.value[index]
371
- }
372
-
373
- // const defaultCdDvdDriver: UI_I_SendDataNewCdDvdDrive = {
374
- // create: false,
375
- // attach: false,
376
- // source: '',
377
- // bus: '',
378
- // device_type: 'cdrom',
379
- // boot_order: -1,
380
- // }
381
- const defaultCdDvdDriver: UI_I_SendDataNewCdDvdDrive = {
382
- source: '',
383
- storage_id: '',
384
- device_type: 'cdrom',
385
- bus: '',
386
- target: '',
387
- boot_order: 0,
388
- provision_type: 'thick',
389
- disk_mode: 'dependent',
390
- sharing: false,
391
- read_only: true,
392
- shares: 0,
393
- cache: 'none',
394
- io: 'native',
395
- limit_iops: 0,
396
- discard: 'unmap',
397
- attach: false,
398
- detach: false,
399
- remove: false,
400
- create: false,
401
- }
402
- // const cdDvdDrivesLocal = ref<UI_I_SendDataNewCdDvdDrive[]>([
403
- // useDeepCopy(defaultCdDvdDriver),
404
- // ])
405
- const cdDvdDrivesIndex = ref<number[]>([0])
406
- const cdDvdDrivesType = ref<UI_T_CdDvdType[]>(['new'])
407
- if (!model.value.disk_devices?.length) {
408
- cdDvdDrivesIndex.value = []
409
- cdDvdDrivesType.value = []
410
- } else {
411
- model.value.disk_devices
412
- .filter((disk) => disk.device_type === 'cdrom')
413
- .forEach((_disk, _index, array) => {
414
- if (!props.isEdit && !props.isClone) return
415
-
416
- const count = array.length
417
- cdDvdDrivesIndex.value = [...Array(count).keys()]
418
- if (props.isEdit) {
419
- cdDvdDrivesType.value = Array(count).fill('edit')
420
- } else if (props.isClone) {
421
- cdDvdDrivesType.value = Array(count).fill('clone')
422
- }
423
- })
424
- }
425
- // watch(
426
- // () => props.cdDvdDrives,
427
- // (newValue) => {
428
- // if ((!props.isEdit && !props.isClone) || !newValue) return
429
- //
430
- // // cdDvdDrivesLocal.value = newValue
431
- // // cdDvdDrivesType.value = Array(newValue.length).fill('edit')
432
- // const count = newValue?.length || 0
433
- // cdDvdDrivesIndex.value = [...Array(count).keys()]
434
- // cdDvdDrivesLocal.value = newValue
435
- // if (props.isEdit) {
436
- // cdDvdDrivesType.value = Array(count).fill('edit')
437
- // } else if (props.isClone) {
438
- // cdDvdDrivesType.value = Array(count).fill('new')
439
- // }
440
- // },
441
- // { immediate: true }
442
- // )
443
- const addCdDvdDrive = (): void => {
444
- const value = (cdDvdDrivesIndex.value.at(-1) ?? -1) + 1
445
- cdDvdDrivesIndex.value.push(value)
446
- cdDvdDrivesType.value.push('new')
447
- model.value.disk_devices.push({
448
- ...useDeepCopy(defaultCdDvdDriver),
449
- attach: true,
450
- boot_order: 0, // Убираем галочку
451
- })
452
- // cdDvdDrivesLocal.value.push({
453
- // ...useDeepCopy(defaultCdDvdDriver),
454
- // attach: true,
455
- // boot_order: 0, // Убираем галочку
456
- // })
457
- }
458
- const onRemoveCdDvdDrive = (
459
- index: number,
460
- cdDvdDrive: UI_I_SendDataNewCdDvdDrive
461
- ): void => {
462
- const removeIndex = cdDvdDrivesIndex.value.indexOf(index)
463
-
464
- // if (!cdDvdDrive.create && !cdDvdDrive.attach) {
465
- if (cdDvdDrivesType.value[index] === 'edit' && !cdDvdDrive.attach) {
466
- cdDvdDrivesType.value = cdDvdDrivesType.value.map((item, key) => {
467
- if (key === removeIndex) return 'removed'
468
- return item
469
- })
470
- return
471
- }
472
-
473
- cdDvdDrivesIndex.value = cdDvdDrivesIndex.value.filter(
474
- (cdDvdDrive) => cdDvdDrive !== index
475
- )
476
- cdDvdDrivesType.value = cdDvdDrivesType.value.filter(
477
- (_item, key) => key !== index
478
- )
479
- model.value.disk_devices = model.value.disk_devices.filter(
480
- (_cdDvdDrive, key: number) => removeIndex !== key
481
- )
482
- // cdDvdDrivesLocal.value = cdDvdDrivesLocal.value.filter(
483
- // (_cdDvdDrive, key: number) => removeIndex !== key
484
- // )
485
- }
486
- const onRollBackCdDvdDrive = (index: number): void => {
487
- const removeIndex = cdDvdDrivesIndex.value.indexOf(index)
488
- cdDvdDrivesType.value = cdDvdDrivesType.value.map((item, key) => {
489
- if (key === removeIndex) return 'edit'
490
- return item
491
- })
492
- }
493
-
494
- const defaultPciDevice: UI_I_SendDataNewPciDevice = {
495
- address: '',
496
- vendor_name: '',
497
- class_name: '',
498
- device_name: '',
499
- }
500
- const pciDevicesIndex = ref<number[]>([0])
501
- const pciDevicesType = ref<('new' | 'edit' | 'removed')[]>(['new'])
502
- const pciDevicesLocal = ref<UI_I_SendDataNewPciDevice[]>([])
503
- watch(
504
- () => props.pciDevices,
505
- (newValue) => {
506
- if ((!props.isEdit && !props.isClone) || !newValue) return
507
-
508
- const count = newValue?.length || 0
509
- pciDevicesIndex.value = [...Array(count).keys()]
510
- pciDevicesLocal.value = newValue || []
511
- if (props.isEdit) {
512
- pciDevicesType.value = Array(count).fill('edit')
513
- } else if (props.isClone) {
514
- pciDevicesType.value = Array(count).fill('new')
515
- }
516
- },
517
- { immediate: true }
518
- )
519
-
520
- const addPciDevice = (): void => {
521
- const newIndex = (pciDevicesIndex.value.at(-1) ?? -1) + 1
522
- pciDevicesIndex.value.push(newIndex)
523
- pciDevicesType.value.push('new')
524
-
525
- pciDevicesLocal.value.push(useDeepCopy(defaultPciDevice))
526
- model.value.passthrough_pci_devices.push(useDeepCopy(defaultPciDevice))
527
- }
528
- const onRemovePciDevice = (index: number): void => {
529
- const removeIndex = pciDevicesIndex.value.indexOf(index)
530
- pciDevicesIndex.value = pciDevicesIndex.value.filter((item) => item !== index)
531
- pciDevicesType.value = pciDevicesType.value.filter(
532
- (_item, key) => key !== removeIndex
533
- )
534
-
535
- model.value.passthrough_pci_devices =
536
- model.value.passthrough_pci_devices.filter((_pciDevice, key: number) => {
537
- return removeIndex !== key
538
- })
539
- pciDevicesLocal.value = pciDevicesLocal.value.filter(
540
- (_pciDevice, key: number) => {
541
- return removeIndex !== key
542
- }
543
- )
544
-
545
- delete newPciDeviceInvalidKeys.value[index]
546
- }
547
-
548
- const isShowFileModal = ref<boolean>(false)
549
- const onAddDevice = (item: UI_I_DropdownTreeItemChild): void => {
550
- switch (item.value) {
551
- case 1:
552
- addHardDisk()
553
- break
554
- case 2:
555
- isShowFileModal.value = true
556
- break
557
- case 5:
558
- addCdDvdDrive()
559
- break
560
- case 10:
561
- addPciDevice()
562
- break
563
- case 14:
564
- addNetwork()
565
- break
566
- }
567
- }
568
-
569
- const cpuInvalid = ref<boolean>(false)
570
- const onSendDataNewHardDiskMethod = (
571
- data: UI_I_SendDataNewHardDisk,
572
- index: number
573
- ): void => {
574
- model.value.disk_devices[index] = {
575
- ...data,
576
- boot_order: model.value.disk_devices[index]?.boot_order || 0,
577
- }
578
- }
579
- const sendDataNewCdDvdDriveMethod = (
580
- data: UI_I_SendDataNewCdDvdDrive,
581
- index: number
582
- ): void => {
583
- const cdromIndexStart = model.value.disk_devices.findIndex(
584
- (disk) => disk.device_type === 'cdrom'
585
- )
586
- model.value.disk_devices[cdromIndexStart + index] = {
587
- ...data,
588
- boot_order:
589
- model.value.disk_devices[cdromIndexStart + index]?.boot_order || 0,
590
- }
591
- }
592
- const onSendDataPciDevicesMethod = (
593
- data: UI_I_SendDataNewPciDevice,
594
- index: number
595
- ): void => {
596
- model.value.passthrough_pci_devices[index] = {
597
- ...data,
598
- }
599
- }
600
-
601
- const onSetInvalidHardDisk = (invalid: boolean, index: number): void => {
602
- newHardDiskInvalidKeys.value[index] = invalid
603
- }
604
-
605
- const onSetInvalidNetwork = (invalid: boolean, key: number): void => {
606
- newNetworkInvalidKeys.value[key] = invalid
607
- }
608
-
609
- const onSetInvalidPciDevice = (invalid: boolean, key: number): void => {
610
- newPciDeviceInvalidKeys.value[key] = invalid
611
- }
612
-
613
- const memoryInvalid = ref<boolean>(false)
614
- const videoCardInvalid = ref<boolean>(false)
615
- const newHardDiskInvalidKeys = ref<UI_I_InvalidKeys>({})
616
- const newNetworkInvalidKeys = ref<UI_I_InvalidKeys>({})
617
- const newPciDeviceInvalidKeys = ref<UI_I_InvalidKeys>({})
618
-
619
- watch(
620
- [
621
- cpuInvalid,
622
- memoryInvalid,
623
- newHardDiskInvalidKeys,
624
- newNetworkInvalidKeys,
625
- newPciDeviceInvalidKeys,
626
- videoCardInvalid,
627
- ],
628
- () => {
629
- const cpu = cpuInvalid.value ? localization.value.common.cpu : ''
630
- const memory = memoryInvalid.value ? localization.value.common.memory : ''
631
- const videoCard = videoCardInvalid.value
632
- ? localization.value.common.videoCard
633
- : ''
634
- let newHardDisk = ''
635
- Object.keys(newHardDiskInvalidKeys.value).forEach((key) => {
636
- if (!newHardDiskInvalidKeys.value[+key]) {
637
- return
638
- }
639
-
640
- newHardDisk +=
641
- (newHardDisk ? ', ' : '') +
642
- localization.value.common.newHardDisk +
643
- ' ' +
644
- (+key + 1)
645
- })
646
- let newNetwork = ''
647
- Object.keys(newNetworkInvalidKeys.value).forEach((key) => {
648
- if (!newNetworkInvalidKeys.value[+key]) {
649
- return
650
- }
651
-
652
- newNetwork +=
653
- (newNetwork ? ', ' : '') +
654
- localization.value.common.newNetwork +
655
- ' ' +
656
- (+key + 1)
657
- })
658
- // let pciDevice = ''
659
- // Object.keys(newPciDeviceInvalidKeys.value).forEach((key) => {
660
- // if (!newPciDeviceInvalidKeys.value[+key]) {
661
- // return
662
- // }
663
- //
664
- // pciDevice +=
665
- // (pciDevice ? ', ' : '') +
666
- // localization.value.common.pciDevice +
667
- // ' ' +
668
- // (+key + 1)
669
- // })
670
-
671
- emits('invalid', [cpu, memory, newHardDisk, newNetwork, videoCard])
672
- },
673
- { deep: true }
674
- )
675
-
676
- emits('get-pci-devices')
677
- </script>
678
-
679
- <style scoped lang="scss"></style>
1
+ <template>
2
+ <component
3
+ :is="currentComponent"
4
+ v-model="model"
5
+ v-model:cpu-invalid="cpuInvalid"
6
+ v-model:memory-invalid="memoryInvalid"
7
+ v-model:video-card-invalid="videoCardInvalid"
8
+ :nodes="props.nodes"
9
+ :files="props.files"
10
+ :is-edit="props.isEdit"
11
+ :storage="props.storage"
12
+ :project="props.project"
13
+ :max-memory="props.maxMemory"
14
+ :cpu-models="props.cpuModels"
15
+ :datastore="props.datastore"
16
+ :is-datastore-loading="props.isDatastoreLoading"
17
+ :networks-type="networksType"
18
+ :networks-table="props.networksTable"
19
+ :dropdown-items="dropdownItems"
20
+ :hard-disks-type="hardDisksType"
21
+ :networks-index="networksIndex"
22
+ :hard-disks-index="hardDisksIndex"
23
+ :pci-devices-type="pciDevicesType"
24
+ :is-show-file-modal="isShowFileModal"
25
+ :pci-devices-index="pciDevicesIndex"
26
+ :cd-dvd-drives-type="cdDvdDrivesType"
27
+ :cd-dvd-drives-index="cdDvdDrivesIndex"
28
+ :error-validation-fields="errorValidationFields"
29
+ :get-datastore-table-func="getDatastoreTableFunc"
30
+ :state="state"
31
+ :video-card="videoCard"
32
+ :pci-devices="pciDevicesLocal"
33
+ :guest-machine-type="guestMachineType"
34
+ :passthrough-devices="passthroughDevices"
35
+ :mediated-devices="mediatedDevices"
36
+ :vm-cpu-help-text-second="vmCpuHelpTextSecond"
37
+ :compute-resource="props.computeResource"
38
+ :compatibility-info="props.compatibilityInfo"
39
+ :network-value-prop="networkValueProp"
40
+ @add-device="onAddDevice"
41
+ @get-storage="emits('get-storage', $event)"
42
+ @remove-network="onRemoveNetwork"
43
+ @hide-file-modal="isShowFileModal = false"
44
+ @remove-hard-disk="onRemoveHardDisk(...$event)"
45
+ @remove-pci-device="onRemovePciDevice"
46
+ @get-networks-table="emits('get-networks-table', $event)"
47
+ @add-exist-hard-disk="onAddExistHardDisk"
48
+ @roll-back-hard-disk="onRollBackHardDisk"
49
+ @set-invalid-network="onSetInvalidNetwork(...$event)"
50
+ @remove-cd-dvd-drive="onRemoveCdDvdDrive(...$event)"
51
+ @show-datastore-child="emits('show-datastore-child', $event)"
52
+ @get-folders-or-files="emits('get-folders-or-files', $event)"
53
+ @set-invalid-hard-disk="onSetInvalidHardDisk(...$event)"
54
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
55
+ @roll-back-cd-dvd-drive="onRollBackCdDvdDrive"
56
+ @set-invalid-pci-device="onSetInvalidPciDevice(...$event)"
57
+ @get-active-device-child="emits('get-active-device-child', $event)"
58
+ @send-data-pci-devices-method="onSendDataPciDevicesMethod(...$event)"
59
+ @send-data-new-hard-disk-method="onSendDataNewHardDiskMethod(...$event)"
60
+ @send-data-new-cd-dvd-drive-method="sendDataNewCdDvdDriveMethod(...$event)"
61
+ />
62
+ </template>
63
+
64
+ <script setup lang="ts">
65
+ import type { UI_T_Project } from '~/lib/models/types'
66
+ import type { UI_I_DatastoreTableItem } from '~/lib/models/store/storage/interfaces'
67
+ import type { UI_I_NetworkTableItem } from '~/lib/models/store/network/interfaces'
68
+ import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
69
+ import type { UI_I_FolderOrFileTreePayload } from '~/lib/models/store/storage/interfaces'
70
+ import type { UI_I_FileTreeNode } from '~/components/lib/models/interfaces'
71
+ import type {
72
+ UI_I_SendDataNewHardDisk,
73
+ UI_I_SendDataVideoCard,
74
+ UI_I_InvalidKeys,
75
+ UI_I_SendDataNewCdDvdDrive,
76
+ // UI_I_HardDisk,
77
+ UI_I_SendDataNewPciDevice,
78
+ } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
79
+ import type { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
80
+ import type {
81
+ UI_T_HardDiskType,
82
+ UI_T_NetworkType,
83
+ UI_T_CdDvdType,
84
+ } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/types'
85
+ import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
86
+ import type {
87
+ UI_I_DropdownTreeItem,
88
+ UI_I_DropdownTreeItemChild,
89
+ } from '~/components/atoms/dropdown/tree/lib/models/interfaces'
90
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
91
+ import type {
92
+ UI_I_MediatedDevice,
93
+ UI_I_PciDevice,
94
+ } from '~/lib/models/store/vm/interfaces'
95
+ import type { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
96
+ import type { UI_I_CreateVmData } from '~/components/common/vm/actions/common/lib/models/interfaces'
97
+ import { dropdownItemsFunc } from './lib/config/dropdownItems'
98
+
99
+ const model = defineModel<UI_I_CreateVmData>({ required: true })
100
+
101
+ const props = withDefaults(
102
+ defineProps<{
103
+ storage: UI_I_DatastoreTableItem | null
104
+ cpuModels: UI_I_OptionItem[]
105
+ maxMemory: number
106
+ isEdit: boolean
107
+ isClone: boolean
108
+ errorValidationFields: UI_I_ErrorValidationField[]
109
+ nodes: UI_I_FileTreeNode[]
110
+ files: UI_I_FileTreeNode[]
111
+ networksTable: UI_I_NetworkTableItem[]
112
+ getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
113
+ datastore: UI_I_DatastoreTableItem[]
114
+ isDatastoreLoading: boolean
115
+ project: UI_T_Project
116
+ state?: string | number
117
+ vmCpuHelpTextSecond?: string
118
+ hardDisks?: UI_I_SendDataNewHardDisk[] | null
119
+ cdDvdDrives?: UI_I_SendDataNewCdDvdDrive[] | null
120
+ videoCard?: UI_I_SendDataVideoCard
121
+ pciDevices?: UI_I_SendDataNewPciDevice[]
122
+ passthroughDevices?: UI_I_PciDevice[]
123
+ mediatedDevices?: UI_I_MediatedDevice[]
124
+ guestMachineType?: UI_I_OptionItem | null
125
+ computeResource?: UI_I_TreeNode | null
126
+ compatibilityInfo?: string
127
+ }>(),
128
+ {
129
+ state: undefined,
130
+ vmCpuHelpTextSecond: undefined,
131
+ hardDisks: undefined,
132
+ cdDvdDrives: undefined,
133
+ videoCard: undefined,
134
+ pciDevices: undefined,
135
+ passthroughDevices: undefined,
136
+ mediatedDevices: undefined,
137
+ guestMachineType: undefined,
138
+ computeResource: undefined,
139
+ compatibilityInfo: undefined,
140
+ }
141
+ )
142
+ const emits = defineEmits<{
143
+ (event: 'invalid', value: string[]): void
144
+ (event: 'get-storage', value: UI_I_TablePayload): void
145
+ (event: 'get-folders-or-files', value: UI_I_FolderOrFileTreePayload): void
146
+ (event: 'get-active-device-child', value: UI_I_FileTreeNode): void
147
+ (event: 'show-datastore-child', value: UI_I_FileTreeNode): void
148
+ (event: 'remove-error-by-title', value: string): void
149
+ (event: 'get-networks-table', value: UI_I_TablePayload): void
150
+ (event: 'get-pci-devices'): void
151
+ }>()
152
+
153
+ const { $store, $binary }: any = useNuxtApp()
154
+ const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
155
+ const currentComponent = computed(() =>
156
+ isNewView.value
157
+ ? defineAsyncComponent(() => import('./New.vue'))
158
+ : defineAsyncComponent(() => import('./Old.vue'))
159
+ )
160
+
161
+ const localization = computed<UI_I_Localization>(() => useLocal())
162
+
163
+ const dropdownItems = computed<UI_I_DropdownTreeItem[]>(() =>
164
+ dropdownItemsFunc(
165
+ localization.value,
166
+ props.state,
167
+ props.passthroughDevices,
168
+ props.mediatedDevices
169
+ )
170
+ )
171
+
172
+ const hardDisksIndex = ref<number[]>([0])
173
+ const hardDisksType = ref<UI_T_HardDiskType[]>(['new'])
174
+ // const hardDisksLocal = ref<UI_I_SendDataNewHardDisk[]>([
175
+ // {
176
+ // create: true,
177
+ // size: 90,
178
+ // source: '',
179
+ // boot_order: -1,
180
+ // },
181
+ // ])
182
+ if (!model.value.disk_devices?.length) {
183
+ hardDisksType.value = []
184
+ hardDisksIndex.value = []
185
+ } else {
186
+ model.value.disk_devices
187
+ .filter((disk) => disk.device_type !== 'cdrom')
188
+ .forEach((_disk, _index, array) => {
189
+ if (!props.isEdit && !props.isClone) return
190
+
191
+ const count = array.length
192
+ hardDisksIndex.value = [...Array(count).keys()]
193
+ if (props.isEdit) {
194
+ hardDisksType.value = Array(count).fill('edit')
195
+ } else if (props.isClone) {
196
+ hardDisksType.value = Array(count).fill('clone')
197
+ }
198
+ })
199
+ }
200
+
201
+ // watch(
202
+ // () => props.hardDisks,
203
+ // (newValue) => {
204
+ // if ((!props.isEdit && !props.isClone) || !newValue) return
205
+ //
206
+ // const count = newValue?.length || 0
207
+ // hardDisksIndex.value = [...Array(count).keys()]
208
+ // hardDisksLocal.value = newValue
209
+ // if (props.isEdit) {
210
+ // hardDisksType.value = Array(count).fill('edit')
211
+ // } else if (props.isClone) {
212
+ // hardDisksType.value = Array(count).fill('clone')
213
+ // hardDisksLocal.value = newValue.map((hardDisk) => {
214
+ // hardDisk.create = true
215
+ // return hardDisk
216
+ // })
217
+ // }
218
+ // },
219
+ // { immediate: true }
220
+ // )
221
+
222
+ const addHardDisk = (
223
+ create = true,
224
+ size = 92_160, // 90GB
225
+ source = '',
226
+ type: UI_T_HardDiskType = 'new',
227
+ provisioned_type?: number // При добавлении существующей
228
+ ): void => {
229
+ const newIndex = (hardDisksIndex.value.at(-1) ?? -1) + 1
230
+ hardDisksIndex.value.push(newIndex)
231
+ hardDisksType.value.push(type)
232
+
233
+ let provisionType = 'thick'
234
+ if (provisioned_type === 1) provisionType = 'thin'
235
+
236
+ model.value.disk_devices = [
237
+ ...model.value.disk_devices.filter((disk) => disk.device_type !== 'cdrom'),
238
+ // {
239
+ // create,
240
+ // size,
241
+ // source,
242
+ // attach: true,
243
+ // boot_order: 0, // Убираем галочку
244
+ // provision_type: provisionType,
245
+ // },
246
+ {
247
+ create,
248
+ size,
249
+ source,
250
+ bus: 'virtio',
251
+ storage_id: '',
252
+ provision_type: 'thick',
253
+ disk_mode: 'dependent',
254
+ boot_order: 0, // Убираем галочку
255
+ device_type: 'disk',
256
+ sharing: false,
257
+ shares: 0,
258
+ cache: 'none',
259
+ io: '',
260
+ limit_iops: 0,
261
+ attach: true,
262
+ },
263
+ ...model.value.disk_devices.filter((disk) => disk.device_type === 'cdrom'),
264
+ ]
265
+ // hardDisksLocal.value.push({
266
+ // create,
267
+ // size,
268
+ // source,
269
+ // attach: true,
270
+ // boot_order: 0, // Убираем галочку
271
+ // provision_type: provisionType,
272
+ // })
273
+ }
274
+ const onAddExistHardDisk = (file: UI_I_FileTreeNode): void => {
275
+ addHardDisk(
276
+ false,
277
+ $binary.bToGb(file.size),
278
+ file.path,
279
+ 'exist',
280
+ file.provisioned_type
281
+ )
282
+ }
283
+ const onRemoveHardDisk = (
284
+ index: number,
285
+ hardDisk: UI_I_SendDataNewHardDisk
286
+ ): void => {
287
+ const removeIndex = hardDisksIndex.value.indexOf(index)
288
+
289
+ if (!hardDisk.create && !hardDisk.attach) {
290
+ hardDisksType.value = hardDisksType.value.map((item, key) => {
291
+ if (key === removeIndex) return 'removed'
292
+ return item
293
+ })
294
+ return
295
+ }
296
+
297
+ hardDisksIndex.value = hardDisksIndex.value.filter((item) => item !== index)
298
+ hardDisksType.value = hardDisksType.value.filter(
299
+ (_item, key) => key !== removeIndex
300
+ )
301
+
302
+ model.value.disk_devices = model.value.disk_devices.filter(
303
+ (_hardDisk, key: number) => {
304
+ return removeIndex !== key
305
+ }
306
+ )
307
+ // hardDisksLocal.value = hardDisksLocal.value.filter(
308
+ // (_hardDisk, key: number) => {
309
+ // return removeIndex !== key
310
+ // }
311
+ // )
312
+
313
+ delete newHardDiskInvalidKeys.value[index]
314
+ }
315
+ const onRollBackHardDisk = (index: number): void => {
316
+ const removeIndex = hardDisksIndex.value.indexOf(index)
317
+ hardDisksType.value = hardDisksType.value.map((item, key) => {
318
+ if (key === removeIndex) return 'edit'
319
+ return item
320
+ })
321
+ }
322
+
323
+ const networkValueProp = props.project === 'sphere' ? 'network' : 'net_bridge'
324
+ const networksType = ref<UI_T_NetworkType[]>(['new'])
325
+ const networksIndex = ref<number[]>([0])
326
+ if (!model.value.network_devices?.length) {
327
+ networksType.value = []
328
+ networksIndex.value = []
329
+ } else {
330
+ model.value.network_devices.forEach(() => {
331
+ if (!props.isEdit && !props.isClone) return
332
+
333
+ const count = model.value.network_devices.length || 0
334
+ networksIndex.value = [...Array(count).keys()]
335
+ if (props.isEdit) {
336
+ networksType.value = Array(count).fill('edit')
337
+ } else if (props.isClone) {
338
+ networksType.value = Array(count).fill('clone')
339
+ }
340
+ })
341
+ }
342
+
343
+ const defaultNetwork = {
344
+ network: '',
345
+ net_bridge: '',
346
+ mac: '',
347
+ target: '',
348
+ model: 'virtio',
349
+ boot_order: 0,
350
+ }
351
+ const addNetwork = (): void => {
352
+ const index = (networksIndex.value.at(-1) ?? -1) + 1
353
+ networksIndex.value.push(index)
354
+ networksType.value.push('new')
355
+
356
+ model.value.network_devices.push({
357
+ ...useDeepCopy(defaultNetwork),
358
+ })
359
+ }
360
+ const onRemoveNetwork = (index: number): void => {
361
+ const removeIndex = networksIndex.value.indexOf(index)
362
+ networksIndex.value = networksIndex.value.filter((item) => item !== index)
363
+ networksType.value = networksType.value.filter(
364
+ (_item, key) => key !== removeIndex
365
+ )
366
+ model.value.network_devices = model.value.network_devices.filter(
367
+ (_network, key: number) => removeIndex !== key
368
+ )
369
+
370
+ delete newNetworkInvalidKeys.value[index]
371
+ }
372
+
373
+ // const defaultCdDvdDriver: UI_I_SendDataNewCdDvdDrive = {
374
+ // create: false,
375
+ // attach: false,
376
+ // source: '',
377
+ // bus: '',
378
+ // device_type: 'cdrom',
379
+ // boot_order: -1,
380
+ // }
381
+ const defaultCdDvdDriver: UI_I_SendDataNewCdDvdDrive = {
382
+ source: '',
383
+ storage_id: '',
384
+ device_type: 'cdrom',
385
+ bus: '',
386
+ target: '',
387
+ boot_order: 0,
388
+ provision_type: 'thick',
389
+ disk_mode: 'dependent',
390
+ sharing: false,
391
+ read_only: true,
392
+ shares: 0,
393
+ cache: 'none',
394
+ io: 'native',
395
+ limit_iops: 0,
396
+ discard: 'unmap',
397
+ attach: false,
398
+ detach: false,
399
+ remove: false,
400
+ create: false,
401
+ }
402
+ // const cdDvdDrivesLocal = ref<UI_I_SendDataNewCdDvdDrive[]>([
403
+ // useDeepCopy(defaultCdDvdDriver),
404
+ // ])
405
+ const cdDvdDrivesIndex = ref<number[]>([0])
406
+ const cdDvdDrivesType = ref<UI_T_CdDvdType[]>(['new'])
407
+ if (!model.value.disk_devices?.length) {
408
+ cdDvdDrivesIndex.value = []
409
+ cdDvdDrivesType.value = []
410
+ } else {
411
+ model.value.disk_devices
412
+ .filter((disk) => disk.device_type === 'cdrom')
413
+ .forEach((_disk, _index, array) => {
414
+ if (!props.isEdit && !props.isClone) return
415
+
416
+ const count = array.length
417
+ cdDvdDrivesIndex.value = [...Array(count).keys()]
418
+ if (props.isEdit) {
419
+ cdDvdDrivesType.value = Array(count).fill('edit')
420
+ } else if (props.isClone) {
421
+ cdDvdDrivesType.value = Array(count).fill('clone')
422
+ }
423
+ })
424
+ }
425
+ // watch(
426
+ // () => props.cdDvdDrives,
427
+ // (newValue) => {
428
+ // if ((!props.isEdit && !props.isClone) || !newValue) return
429
+ //
430
+ // // cdDvdDrivesLocal.value = newValue
431
+ // // cdDvdDrivesType.value = Array(newValue.length).fill('edit')
432
+ // const count = newValue?.length || 0
433
+ // cdDvdDrivesIndex.value = [...Array(count).keys()]
434
+ // cdDvdDrivesLocal.value = newValue
435
+ // if (props.isEdit) {
436
+ // cdDvdDrivesType.value = Array(count).fill('edit')
437
+ // } else if (props.isClone) {
438
+ // cdDvdDrivesType.value = Array(count).fill('new')
439
+ // }
440
+ // },
441
+ // { immediate: true }
442
+ // )
443
+ const addCdDvdDrive = (): void => {
444
+ const value = (cdDvdDrivesIndex.value.at(-1) ?? -1) + 1
445
+ cdDvdDrivesIndex.value.push(value)
446
+ cdDvdDrivesType.value.push('new')
447
+ model.value.disk_devices.push({
448
+ ...useDeepCopy(defaultCdDvdDriver),
449
+ attach: true,
450
+ boot_order: 0, // Убираем галочку
451
+ })
452
+ // cdDvdDrivesLocal.value.push({
453
+ // ...useDeepCopy(defaultCdDvdDriver),
454
+ // attach: true,
455
+ // boot_order: 0, // Убираем галочку
456
+ // })
457
+ }
458
+ const onRemoveCdDvdDrive = (
459
+ index: number,
460
+ cdDvdDrive: UI_I_SendDataNewCdDvdDrive
461
+ ): void => {
462
+ const removeIndex = cdDvdDrivesIndex.value.indexOf(index)
463
+
464
+ // if (!cdDvdDrive.create && !cdDvdDrive.attach) {
465
+ if (cdDvdDrivesType.value[index] === 'edit' && !cdDvdDrive.attach) {
466
+ cdDvdDrivesType.value = cdDvdDrivesType.value.map((item, key) => {
467
+ if (key === removeIndex) return 'removed'
468
+ return item
469
+ })
470
+ return
471
+ }
472
+
473
+ cdDvdDrivesIndex.value = cdDvdDrivesIndex.value.filter(
474
+ (cdDvdDrive) => cdDvdDrive !== index
475
+ )
476
+ cdDvdDrivesType.value = cdDvdDrivesType.value.filter(
477
+ (_item, key) => key !== index
478
+ )
479
+ model.value.disk_devices = model.value.disk_devices.filter(
480
+ (_cdDvdDrive, key: number) => removeIndex !== key
481
+ )
482
+ // cdDvdDrivesLocal.value = cdDvdDrivesLocal.value.filter(
483
+ // (_cdDvdDrive, key: number) => removeIndex !== key
484
+ // )
485
+ }
486
+ const onRollBackCdDvdDrive = (index: number): void => {
487
+ const removeIndex = cdDvdDrivesIndex.value.indexOf(index)
488
+ cdDvdDrivesType.value = cdDvdDrivesType.value.map((item, key) => {
489
+ if (key === removeIndex) return 'edit'
490
+ return item
491
+ })
492
+ }
493
+
494
+ const defaultPciDevice: UI_I_SendDataNewPciDevice = {
495
+ address: '',
496
+ vendor_name: '',
497
+ class_name: '',
498
+ device_name: '',
499
+ }
500
+ const pciDevicesIndex = ref<number[]>([0])
501
+ const pciDevicesType = ref<('new' | 'edit' | 'removed')[]>(['new'])
502
+ const pciDevicesLocal = ref<UI_I_SendDataNewPciDevice[]>([])
503
+ watch(
504
+ () => props.pciDevices,
505
+ (newValue) => {
506
+ if ((!props.isEdit && !props.isClone) || !newValue) return
507
+
508
+ const count = newValue?.length || 0
509
+ pciDevicesIndex.value = [...Array(count).keys()]
510
+ pciDevicesLocal.value = newValue || []
511
+ if (props.isEdit) {
512
+ pciDevicesType.value = Array(count).fill('edit')
513
+ } else if (props.isClone) {
514
+ pciDevicesType.value = Array(count).fill('new')
515
+ }
516
+ },
517
+ { immediate: true }
518
+ )
519
+
520
+ const addPciDevice = (): void => {
521
+ const newIndex = (pciDevicesIndex.value.at(-1) ?? -1) + 1
522
+ pciDevicesIndex.value.push(newIndex)
523
+ pciDevicesType.value.push('new')
524
+
525
+ pciDevicesLocal.value.push(useDeepCopy(defaultPciDevice))
526
+ model.value.passthrough_pci_devices.push(useDeepCopy(defaultPciDevice))
527
+ }
528
+ const onRemovePciDevice = (index: number): void => {
529
+ const removeIndex = pciDevicesIndex.value.indexOf(index)
530
+ pciDevicesIndex.value = pciDevicesIndex.value.filter((item) => item !== index)
531
+ pciDevicesType.value = pciDevicesType.value.filter(
532
+ (_item, key) => key !== removeIndex
533
+ )
534
+
535
+ model.value.passthrough_pci_devices =
536
+ model.value.passthrough_pci_devices.filter((_pciDevice, key: number) => {
537
+ return removeIndex !== key
538
+ })
539
+ pciDevicesLocal.value = pciDevicesLocal.value.filter(
540
+ (_pciDevice, key: number) => {
541
+ return removeIndex !== key
542
+ }
543
+ )
544
+
545
+ delete newPciDeviceInvalidKeys.value[index]
546
+ }
547
+
548
+ const isShowFileModal = ref<boolean>(false)
549
+ const onAddDevice = (item: UI_I_DropdownTreeItemChild): void => {
550
+ switch (item.value) {
551
+ case 1:
552
+ addHardDisk()
553
+ break
554
+ case 2:
555
+ isShowFileModal.value = true
556
+ break
557
+ case 5:
558
+ addCdDvdDrive()
559
+ break
560
+ case 10:
561
+ addPciDevice()
562
+ break
563
+ case 14:
564
+ addNetwork()
565
+ break
566
+ }
567
+ }
568
+
569
+ const cpuInvalid = ref<boolean>(false)
570
+ const onSendDataNewHardDiskMethod = (
571
+ data: UI_I_SendDataNewHardDisk,
572
+ index: number
573
+ ): void => {
574
+ model.value.disk_devices[index] = {
575
+ ...data,
576
+ boot_order: model.value.disk_devices[index]?.boot_order || 0,
577
+ }
578
+ }
579
+ const sendDataNewCdDvdDriveMethod = (
580
+ data: UI_I_SendDataNewCdDvdDrive,
581
+ index: number
582
+ ): void => {
583
+ const cdromIndexStart = model.value.disk_devices.findIndex(
584
+ (disk) => disk.device_type === 'cdrom'
585
+ )
586
+ model.value.disk_devices[cdromIndexStart + index] = {
587
+ ...data,
588
+ boot_order:
589
+ model.value.disk_devices[cdromIndexStart + index]?.boot_order || 0,
590
+ }
591
+ }
592
+ const onSendDataPciDevicesMethod = (
593
+ data: UI_I_SendDataNewPciDevice,
594
+ index: number
595
+ ): void => {
596
+ model.value.passthrough_pci_devices[index] = {
597
+ ...data,
598
+ }
599
+ }
600
+
601
+ const onSetInvalidHardDisk = (invalid: boolean, index: number): void => {
602
+ newHardDiskInvalidKeys.value[index] = invalid
603
+ }
604
+
605
+ const onSetInvalidNetwork = (invalid: boolean, key: number): void => {
606
+ newNetworkInvalidKeys.value[key] = invalid
607
+ }
608
+
609
+ const onSetInvalidPciDevice = (invalid: boolean, key: number): void => {
610
+ newPciDeviceInvalidKeys.value[key] = invalid
611
+ }
612
+
613
+ const memoryInvalid = ref<boolean>(false)
614
+ const videoCardInvalid = ref<boolean>(false)
615
+ const newHardDiskInvalidKeys = ref<UI_I_InvalidKeys>({})
616
+ const newNetworkInvalidKeys = ref<UI_I_InvalidKeys>({})
617
+ const newPciDeviceInvalidKeys = ref<UI_I_InvalidKeys>({})
618
+
619
+ watch(
620
+ [
621
+ cpuInvalid,
622
+ memoryInvalid,
623
+ newHardDiskInvalidKeys,
624
+ newNetworkInvalidKeys,
625
+ newPciDeviceInvalidKeys,
626
+ videoCardInvalid,
627
+ ],
628
+ () => {
629
+ const cpu = cpuInvalid.value ? localization.value.common.cpu : ''
630
+ const memory = memoryInvalid.value ? localization.value.common.memory : ''
631
+ const videoCard = videoCardInvalid.value
632
+ ? localization.value.common.videoCard
633
+ : ''
634
+ let newHardDisk = ''
635
+ Object.keys(newHardDiskInvalidKeys.value).forEach((key) => {
636
+ if (!newHardDiskInvalidKeys.value[+key]) {
637
+ return
638
+ }
639
+
640
+ newHardDisk +=
641
+ (newHardDisk ? ', ' : '') +
642
+ localization.value.common.newHardDisk +
643
+ ' ' +
644
+ (+key + 1)
645
+ })
646
+ let newNetwork = ''
647
+ Object.keys(newNetworkInvalidKeys.value).forEach((key) => {
648
+ if (!newNetworkInvalidKeys.value[+key]) {
649
+ return
650
+ }
651
+
652
+ newNetwork +=
653
+ (newNetwork ? ', ' : '') +
654
+ localization.value.common.newNetwork +
655
+ ' ' +
656
+ (+key + 1)
657
+ })
658
+ // let pciDevice = ''
659
+ // Object.keys(newPciDeviceInvalidKeys.value).forEach((key) => {
660
+ // if (!newPciDeviceInvalidKeys.value[+key]) {
661
+ // return
662
+ // }
663
+ //
664
+ // pciDevice +=
665
+ // (pciDevice ? ', ' : '') +
666
+ // localization.value.common.pciDevice +
667
+ // ' ' +
668
+ // (+key + 1)
669
+ // })
670
+
671
+ emits('invalid', [cpu, memory, newHardDisk, newNetwork, videoCard])
672
+ },
673
+ { deep: true }
674
+ )
675
+
676
+ emits('get-pci-devices')
677
+ </script>
678
+
679
+ <style scoped lang="scss"></style>