bfg-common 1.5.591 → 1.5.592

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 (261) hide show
  1. package/CODE_STYLE.md +109 -109
  2. package/assets/img/icons/icons-sprite-dark-3.svg +227 -227
  3. package/assets/img/icons/icons-sprite-dark-5.svg +488 -488
  4. package/assets/img/icons/icons-sprite-light-3.svg +227 -227
  5. package/assets/img/icons/icons-sprite-light-5.svg +488 -488
  6. package/components/atoms/TheIcon3.vue +50 -50
  7. package/components/atoms/collapse/CollapseNav.vue +170 -170
  8. package/components/atoms/perPage/PerPage.vue +58 -58
  9. package/components/atoms/table/dataGrid/DataGrid.vue +1718 -1718
  10. package/components/atoms/table/dataGrid/DataGridPagination.vue +97 -97
  11. package/components/atoms/table/dataGrid/lib/config/settingsTable.ts +94 -94
  12. package/components/atoms/table/dataGrid/lib/utils/export.ts +16 -16
  13. package/components/common/backup/storage/actions/add/lib/utils.ts +51 -51
  14. package/components/common/browse/blocks/contents/filesNew/Skeleton.vue +18 -18
  15. package/components/common/browse/blocks/lib/models/types.ts +1 -1
  16. package/components/common/browse/lib/models/interfaces.ts +5 -5
  17. package/components/common/diagramMain/network/Contents.vue +497 -497
  18. package/components/common/layout/theHeader/helpMenu/About.vue +79 -79
  19. package/components/common/layout/theHeader/helpMenu/aboutOld/AboutOld.vue +79 -79
  20. package/components/common/pages/backups/DetailView.vue +52 -52
  21. package/components/common/pages/backups/lib/models/interfaces.ts +36 -36
  22. package/components/common/pages/backups/modals/Modals.vue +243 -243
  23. package/components/common/pages/backups/modals/createBackup/configuration/maxBandwidth/lib/config/options.ts +6 -6
  24. package/components/common/pages/backups/modals/createBackup/lib/config/readyToCompleteOptions.ts +69 -69
  25. package/components/common/pages/backups/modals/lib/config/restore.ts +115 -115
  26. package/components/common/pages/backups/modals/lib/models/interfaces.ts +186 -186
  27. package/components/common/pages/backups/modals/restore/name/lib/models/interfaces.ts +6 -6
  28. package/components/common/pages/home/lib/models/interfaces.ts +48 -48
  29. package/components/common/pages/home/widgets/hosts/Hosts.vue +27 -27
  30. package/components/common/pages/home/widgets/hosts/lib/config/items.ts +23 -23
  31. package/components/common/pages/home/widgets/vms/VmsOld.vue +35 -35
  32. package/components/common/pages/home/widgets/vms/lib/config/items.ts +19 -19
  33. package/components/common/pages/scheduledTasks/lib/utils/utils.ts +84 -84
  34. package/components/common/readyToComplete/ReadyToComplete.vue +17 -17
  35. package/components/common/select/radio/RadioGroup.vue +137 -137
  36. package/components/common/spiceConsole/Drawer.vue +420 -420
  37. package/components/common/spiceConsole/SpiceConsole.vue +184 -184
  38. package/components/common/spiceConsole/lib/models/interfaces.ts +5 -5
  39. package/components/common/tools/Actions.vue +207 -207
  40. package/components/common/treeView/TreeView.vue +52 -52
  41. package/components/common/vm/actions/add/Add.vue +819 -886
  42. package/components/common/vm/actions/common/customizeHardware/CustomizeHardware.vue +205 -241
  43. package/components/common/vm/actions/common/customizeHardware/{CustomizeHardwareNew.vue → New.vue} +325 -325
  44. package/components/common/vm/actions/common/customizeHardware/virtualHardware/VirtualHardware.vue +679 -733
  45. package/components/common/vm/actions/common/customizeHardware/virtualHardware/bus/Bus.vue +101 -110
  46. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/CdDvdDrive.vue +227 -252
  47. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/media/Media.vue +29 -30
  48. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/Cpu.vue +322 -348
  49. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/coresPerSocket/CoresPerSocket.vue +81 -86
  50. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/hotPlug/HotPlug.vue +40 -40
  51. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/maxCpu/MaxCpu.vue +91 -94
  52. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/model/Model.vue +92 -124
  53. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/shares/Shares.vue +133 -140
  54. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/shares/lib/config/options.ts +28 -28
  55. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/tooltip/Tooltip.vue +27 -25
  56. package/components/common/vm/actions/common/customizeHardware/virtualHardware/limit/Limit.vue +214 -221
  57. package/components/common/vm/actions/common/customizeHardware/virtualHardware/memory/Memory.vue +280 -300
  58. package/components/common/vm/actions/common/customizeHardware/virtualHardware/memory/{MemoryNew.vue → New.vue} +158 -158
  59. package/components/common/vm/actions/common/customizeHardware/virtualHardware/memory/{MemoryOld.vue → Old.vue} +155 -155
  60. package/components/common/vm/actions/common/customizeHardware/virtualHardware/memory/hotPlug/HotPlug.vue +29 -29
  61. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/{NewHardDiskNew.vue → New.vue} +0 -2
  62. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/NewHardDisk.vue +483 -521
  63. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/{NewHardDiskOld.vue → Old.vue} +1 -6
  64. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/cache/Cache.vue +59 -63
  65. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/file/File.vue +24 -25
  66. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/limitIops/LimitIops.vue +96 -103
  67. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/location/Location.vue +142 -154
  68. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/location/storageModal/StorageModal.vue +55 -61
  69. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/maximumSize/MaximumSize.vue +26 -26
  70. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/mode/Mode.vue +61 -65
  71. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/provisioning/Provisioning.vue +57 -61
  72. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/sharing/Sharing.vue +59 -63
  73. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/NewNetwork.vue +257 -277
  74. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/adapterType/AdapterType.vue +56 -60
  75. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/location/Location.vue +65 -71
  76. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/macAddress/MacAddress.vue +111 -119
  77. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/NewPciDevice.vue +199 -210
  78. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/directPathIo/DirectPathIo.vue +27 -29
  79. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/dynamicDirectPathIo/DynamicDirectPathIo.vue +29 -31
  80. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/note/Note.vue +23 -22
  81. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/nvidiaGrid/NvidiaGrid.vue +40 -41
  82. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/typeSelection/TypeSelection.vue +34 -35
  83. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newUsbController/NewUsbController.vue +47 -47
  84. package/components/common/vm/actions/common/customizeHardware/virtualHardware/other/Other.vue +15 -16
  85. package/components/common/vm/actions/common/customizeHardware/virtualHardware/other/inputDevices/InputDevices.vue +15 -15
  86. package/components/common/vm/actions/common/customizeHardware/virtualHardware/reservation/Reservation.vue +194 -197
  87. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/VideoCard.vue +129 -140
  88. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/model/Model.vue +35 -37
  89. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/numberDisplays/NumberDisplays.vue +50 -53
  90. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/totalVideoMemory/TotalVideoMemory.vue +104 -107
  91. package/components/common/vm/actions/common/customizeHardware/vmoptions/Vmoptions.vue +70 -76
  92. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/BootOptions.vue +42 -46
  93. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/delay/Delay.vue +32 -32
  94. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/firmware/Firmware.vue +57 -60
  95. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/menu/Menu.vue +25 -26
  96. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/Order.vue +155 -156
  97. package/components/common/vm/actions/common/customizeHardware/vmoptions/generalOptions/GeneralOptions.vue +82 -86
  98. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/RemoteConsoleOptions.vue +74 -74
  99. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/copyPaste/CopyPaste.vue +25 -26
  100. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/fileTransfer/FileTransfer.vue +25 -26
  101. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/folderSharing/FolderSharing.vue +17 -20
  102. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/keymap/Keymap.vue +32 -32
  103. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/password/Password.vue +99 -102
  104. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/usbRedirection/UsbRedirection.vue +28 -28
  105. package/components/common/vm/actions/common/customizeHardware/vmoptions/tools/Tools.vue +42 -42
  106. package/components/common/vm/actions/common/select/compatibility/Compatibility.vue +105 -107
  107. package/components/common/vm/actions/common/select/compatibility/Old.vue +107 -107
  108. package/components/common/vm/actions/common/select/createType/CreateType.vue +36 -38
  109. package/components/common/vm/actions/common/select/createType/lib/models/interfaces.ts +5 -5
  110. package/components/common/vm/actions/common/select/options/Options.vue +53 -54
  111. package/components/common/vm/actions/common/select/os/Os.vue +152 -164
  112. package/components/common/vm/actions/common/select/storage/Old.vue +125 -125
  113. package/components/common/vm/actions/common/select/storage/Storage.vue +170 -178
  114. package/components/common/vm/actions/common/select/storage/new/New.vue +311 -311
  115. package/components/common/vm/actions/common/select/storage/new/lib/models/interfaces.ts +5 -5
  116. package/components/common/vm/actions/common/select/storage/new/lib/utils/utils.ts +21 -21
  117. package/components/common/vm/actions/common/select/template/Template.vue +75 -77
  118. package/components/common/vm/actions/common/select/template/old/Old.vue +50 -50
  119. package/components/common/vm/actions/common/select/template/treeView/TreeView.vue +85 -87
  120. package/components/common/vm/actions/editSettings/new/Skeleton.vue +88 -88
  121. package/components/common/vm/actions/register/Register.vue +352 -352
  122. package/components/common/vm/actions/register/lib/config/steps.ts +86 -86
  123. package/components/common/wizards/common/compatibility/Compatibility.vue +35 -35
  124. package/components/common/wizards/common/compatibility/New.vue +99 -99
  125. package/components/common/wizards/common/compatibility/Old.vue +53 -53
  126. package/components/common/wizards/common/steps/computeResource/ComputeResource.vue +86 -86
  127. package/components/common/wizards/common/steps/computeResource/New.vue +93 -93
  128. package/components/common/wizards/common/steps/name/Name.vue +178 -178
  129. package/components/common/wizards/common/steps/name/New.vue +221 -221
  130. package/components/common/wizards/common/steps/name/Old.vue +121 -121
  131. package/components/common/wizards/common/steps/name/lib/models/interfaces.ts +4 -4
  132. package/components/common/wizards/common/steps/name/location/Location.vue +85 -85
  133. package/components/common/wizards/common/steps/name/location/New.vue +40 -40
  134. package/components/common/wizards/datastore/add/Add.vue +228 -228
  135. package/components/common/wizards/datastore/add/lib/utils.ts +85 -85
  136. package/components/common/wizards/datastore/add/steps/typeMode/lib/config/typeOptions.ts +43 -43
  137. package/components/common/wizards/vm/migrate/select/computeResource/ComputeResource.vue +205 -205
  138. package/components/common/wizards/vm/migrate/select/network/Network.vue +103 -103
  139. package/composables/useAppVersion.ts +21 -21
  140. package/composables/useLocal.ts +6 -6
  141. package/composables/useLocalCommon.ts +39 -39
  142. package/package.json +1 -1
  143. package/plugins/console.ts +21 -21
  144. package/plugins/date.ts +233 -233
  145. package/plugins/mouse.ts +21 -21
  146. package/plugins/panelStates.ts +70 -70
  147. package/plugins/text.ts +59 -59
  148. package/plugins/time.ts +58 -58
  149. package/public/spice-console/application/clientgui.js +854 -854
  150. package/public/spice-console/application/packetfactory.js +211 -211
  151. package/public/spice-console/application/virtualmouse.js +147 -147
  152. package/public/spice-console/lib/images/bitmap.js +203 -203
  153. package/public/spice-console/network/spicechannel.js +440 -440
  154. package/public/spice-console/process/cursorprocess.js +121 -121
  155. package/public/spice-console/process/inputprocess.js +227 -227
  156. package/public/spice-console/process/mainprocess.js +210 -210
  157. package/public/spice-console/run.js +210 -210
  158. package/store/main/mutations.ts +7 -7
  159. package/store/main/state.ts +7 -7
  160. /package/components/common/vm/actions/common/customizeHardware/{CustomizeHardwareOld.vue → Old.vue} +0 -0
  161. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/{VirtualHardwareNew.vue → New.vue} +0 -0
  162. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/{VirtualHardwareOld.vue → Old.vue} +0 -0
  163. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/bus/{BusNew.vue → New.vue} +0 -0
  164. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/bus/{BusOld.vue → Old.vue} +0 -0
  165. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/{CdDvdDriveNew.vue → New.vue} +0 -0
  166. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/{CdDvdDriveOld.vue → Old.vue} +0 -0
  167. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/media/{MediaNew.vue → New.vue} +0 -0
  168. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/media/{MediaOld.vue → Old.vue} +0 -0
  169. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/{CpuNew.vue → New.vue} +0 -0
  170. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/{CpuOld.vue → Old.vue} +0 -0
  171. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/coresPerSocket/{CoresPerSocketNew.vue → New.vue} +0 -0
  172. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/coresPerSocket/{CoresPerSocketOld.vue → Old.vue} +0 -0
  173. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/hotPlug/{HotPlugNew.vue → New.vue} +0 -0
  174. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/hotPlug/{HotPlugOld.vue → Old.vue} +0 -0
  175. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/maxCpu/{MaxCpuNew.vue → New.vue} +0 -0
  176. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/maxCpu/{MaxCpuOld.vue → Old.vue} +0 -0
  177. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/model/{ModelNew.vue → New.vue} +0 -0
  178. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/model/{ModelOld.vue → Old.vue} +0 -0
  179. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/shares/{SharesNew.vue → New.vue} +0 -0
  180. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/shares/{SharesOld.vue → Old.vue} +0 -0
  181. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/tooltip/{TooltipNew.vue → New.vue} +0 -0
  182. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/tooltip/{TooltipOld.vue → Old.vue} +0 -0
  183. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/limit/{LimitNew.vue → New.vue} +0 -0
  184. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/limit/{LimitOld.vue → Old.vue} +0 -0
  185. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/memory/hotPlug/{HotPlugNew.vue → New.vue} +0 -0
  186. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/memory/hotPlug/{HotPlugOld.vue → Old.vue} +0 -0
  187. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/cache/{CacheNew.vue → New.vue} +0 -0
  188. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/cache/{CacheOld.vue → Old.vue} +0 -0
  189. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/file/{FileNew.vue → New.vue} +0 -0
  190. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/file/{FileOld.vue → Old.vue} +0 -0
  191. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/limitIops/{LimitIopsNew.vue → New.vue} +0 -0
  192. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/limitIops/{LimitIopsOld.vue → Old.vue} +0 -0
  193. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/location/{LocationNew.vue → New.vue} +0 -0
  194. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/location/{LocationOld.vue → Old.vue} +0 -0
  195. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/maximumSize/{MaximumSizeNew.vue → New.vue} +0 -0
  196. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/maximumSize/{MaximumSizeOld.vue → Old.vue} +0 -0
  197. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/mode/{ModeNew.vue → New.vue} +0 -0
  198. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/mode/{ModeOld.vue → Old.vue} +0 -0
  199. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/provisioning/{ProvisioningNew.vue → New.vue} +0 -0
  200. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/provisioning/{ProvisioningOld.vue → Old.vue} +0 -0
  201. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/sharing/{SharingNew.vue → New.vue} +0 -0
  202. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/sharing/{SharingOld.vue → Old.vue} +0 -0
  203. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/{NewNetworkNew.vue → New.vue} +0 -0
  204. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/{NewNetworkOld.vue → Old.vue} +0 -0
  205. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/adapterType/{AdapterTypeNew.vue → New.vue} +0 -0
  206. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/adapterType/{AdapterTypeOld.vue → Old.vue} +0 -0
  207. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/location/{LocationOld.vue → Old.vue} +0 -0
  208. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/macAddress/{MacAddressNew.vue → New.vue} +0 -0
  209. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/macAddress/{MacAddressOld.vue → Old.vue} +0 -0
  210. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/{NewPciDeviceNew.vue → New.vue} +0 -0
  211. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/{NewPciDeviceOld.vue → Old.vue} +0 -0
  212. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/directPathIo/{DirectPathIoNew.vue → New.vue} +0 -0
  213. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/directPathIo/{DirectPathIoOld.vue → Old.vue} +0 -0
  214. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/dynamicDirectPathIo/{DynamicDirectPathIoNew.vue → New.vue} +0 -0
  215. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/dynamicDirectPathIo/{DynamicDirectPathIoOld.vue → Old.vue} +0 -0
  216. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/note/{NoteNew.vue → New.vue} +0 -0
  217. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/note/{NoteOld.vue → Old.vue} +0 -0
  218. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/nvidiaGrid/{NvidiaGridNew.vue → New.vue} +0 -0
  219. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/nvidiaGrid/{NvidiaGridOld.vue → Old.vue} +0 -0
  220. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/typeSelection/{TypeSelectionNew.vue → New.vue} +0 -0
  221. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/typeSelection/{TypeSelectionOld.vue → Old.vue} +0 -0
  222. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newUsbController/{NewUsbControllerNew.vue → New.vue} +0 -0
  223. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/newUsbController/{NewUsbControllerOld.vue → Old.vue} +0 -0
  224. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/other/{OtherNew.vue → New.vue} +0 -0
  225. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/other/{OtherOld.vue → Old.vue} +0 -0
  226. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/other/inputDevices/{InputDevicesNew.vue → New.vue} +0 -0
  227. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/other/inputDevices/{InputDevicesOld.vue → Old.vue} +0 -0
  228. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/reservation/{ReservationNew.vue → New.vue} +0 -0
  229. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/reservation/{ReservationOld.vue → Old.vue} +0 -0
  230. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/{VideoCardNew.vue → New.vue} +0 -0
  231. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/{VideoCardOld.vue → Old.vue} +0 -0
  232. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/model/{ModelNew.vue → New.vue} +0 -0
  233. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/model/{ModelOld.vue → Old.vue} +0 -0
  234. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/numberDisplays/{NumberDisplaysNew.vue → New.vue} +0 -0
  235. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/numberDisplays/{NumberDisplaysOld.vue → Old.vue} +0 -0
  236. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/totalVideoMemory/{TotalVideoMemoryNew.vue → New.vue} +0 -0
  237. /package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/totalVideoMemory/{TotalVideoMemoryOld.vue → Old.vue} +0 -0
  238. /package/components/common/vm/actions/common/customizeHardware/vmoptions/{VmoptionsNew.vue → New.vue} +0 -0
  239. /package/components/common/vm/actions/common/customizeHardware/vmoptions/{VmoptionsOld.vue → Old.vue} +0 -0
  240. /package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/{BootOptionsNew.vue → New.vue} +0 -0
  241. /package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/{BootOptionsOld.vue → Old.vue} +0 -0
  242. /package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/delay/{DelayNew.vue → New.vue} +0 -0
  243. /package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/delay/{DelayOld.vue → Old.vue} +0 -0
  244. /package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/firmware/{FirmwareNew.vue → New.vue} +0 -0
  245. /package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/firmware/{FirmwareOld.vue → Old.vue} +0 -0
  246. /package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/menu/{MenuNew.vue → New.vue} +0 -0
  247. /package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/menu/{MenuOld.vue → Old.vue} +0 -0
  248. /package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/{OrderNew.vue → New.vue} +0 -0
  249. /package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/{OrderOld.vue → Old.vue} +0 -0
  250. /package/components/common/vm/actions/common/customizeHardware/vmoptions/generalOptions/{GeneralOptionsNew.vue → New.vue} +0 -0
  251. /package/components/common/vm/actions/common/customizeHardware/vmoptions/generalOptions/{GeneralOptionsOld.vue → Old.vue} +0 -0
  252. /package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/copyPaste/{CopyPasteNew.vue → New.vue} +0 -0
  253. /package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/copyPaste/{CopyPasteOld.vue → Old.vue} +0 -0
  254. /package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/fileTransfer/{FileTransferNew.vue → New.vue} +0 -0
  255. /package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/fileTransfer/{FileTransferOld.vue → Old.vue} +0 -0
  256. /package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/folderSharing/{FolderSharingNew.vue → New.vue} +0 -0
  257. /package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/folderSharing/{FolderSharingOld.vue → Old.vue} +0 -0
  258. /package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/usbRedirection/{UsbRedirectionNew.vue → New.vue} +0 -0
  259. /package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/usbRedirection/{UsbRedirectionOld.vue → Old.vue} +0 -0
  260. /package/components/common/vm/actions/common/customizeHardware/vmoptions/tools/{ToolsNew.vue → New.vue} +0 -0
  261. /package/components/common/vm/actions/common/customizeHardware/vmoptions/tools/{ToolsOld.vue → Old.vue} +0 -0
@@ -1,733 +1,679 @@
1
- <template>
2
- <common-vm-actions-common-customize-hardware-virtual-hardware-new
3
- v-if="isNewView"
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
- <common-vm-actions-common-customize-hardware-virtual-hardware-old
63
- v-else
64
- v-model="model"
65
- v-model:cpu-invalid="cpuInvalid"
66
- v-model:memory-invalid="memoryInvalid"
67
- v-model:video-card-invalid="videoCardInvalid"
68
- :nodes="props.nodes"
69
- :files="props.files"
70
- :is-edit="props.isEdit"
71
- :storage="props.storage"
72
- :project="props.project"
73
- :max-memory="props.maxMemory"
74
- :cpu-models="props.cpuModels"
75
- :datastore="props.datastore"
76
- :is-datastore-loading="props.isDatastoreLoading"
77
- :networks-type="networksType"
78
- :networks-table="props.networksTable"
79
- :dropdown-items="dropdownItems"
80
- :hard-disks-type="hardDisksType"
81
- :networks-index="networksIndex"
82
- :hard-disks-index="hardDisksIndex"
83
- :pci-devices-type="pciDevicesType"
84
- :is-show-file-modal="isShowFileModal"
85
- :pci-devices-index="pciDevicesIndex"
86
- :cd-dvd-drives-type="cdDvdDrivesType"
87
- :cd-dvd-drives-index="cdDvdDrivesIndex"
88
- :error-validation-fields="errorValidationFields"
89
- :get-datastore-table-func="getDatastoreTableFunc"
90
- :state="state"
91
- :video-card="videoCard"
92
- :pci-devices="pciDevicesLocal"
93
- :guest-machine-type="guestMachineType"
94
- :passthrough-devices="passthroughDevices"
95
- :mediated-devices="mediatedDevices"
96
- :vm-cpu-help-text-second="vmCpuHelpTextSecond"
97
- :compute-resource="props.computeResource"
98
- :network-value-prop="networkValueProp"
99
- @add-device="onAddDevice"
100
- @get-storage="emits('get-storage', $event)"
101
- @remove-network="onRemoveNetwork"
102
- @hide-file-modal="isShowFileModal = false"
103
- @remove-hard-disk="onRemoveHardDisk(...$event)"
104
- @remove-pci-device="onRemovePciDevice"
105
- @get-networks-table="emits('get-networks-table', $event)"
106
- @add-exist-hard-disk="onAddExistHardDisk"
107
- @roll-back-hard-disk="onRollBackHardDisk"
108
- @set-invalid-network="onSetInvalidNetwork(...$event)"
109
- @remove-cd-dvd-drive="onRemoveCdDvdDrive(...$event)"
110
- @show-datastore-child="emits('show-datastore-child', $event)"
111
- @get-folders-or-files="emits('get-folders-or-files', $event)"
112
- @set-invalid-hard-disk="onSetInvalidHardDisk(...$event)"
113
- @remove-error-by-title="emits('remove-error-by-title', $event)"
114
- @roll-back-cd-dvd-drive="onRollBackCdDvdDrive"
115
- @set-invalid-pci-device="onSetInvalidPciDevice(...$event)"
116
- @get-active-device-child="emits('get-active-device-child', $event)"
117
- @send-data-pci-devices-method="onSendDataPciDevicesMethod(...$event)"
118
- @send-data-new-hard-disk-method="onSendDataNewHardDiskMethod(...$event)"
119
- @send-data-new-cd-dvd-drive-method="sendDataNewCdDvdDriveMethod(...$event)"
120
- />
121
- </template>
122
-
123
- <script setup lang="ts">
124
- import type { UI_T_Project } from '~/lib/models/types'
125
- import type { UI_I_DatastoreTableItem } from '~/lib/models/store/storage/interfaces'
126
- import type { UI_I_NetworkTableItem } from '~/lib/models/store/network/interfaces'
127
- import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
128
- import type { UI_I_FolderOrFileTreePayload } from '~/lib/models/store/storage/interfaces'
129
- import type { UI_I_FileTreeNode } from '~/components/lib/models/interfaces'
130
- import type {
131
- UI_I_SendDataNewHardDisk,
132
- UI_I_SendDataVideoCard,
133
- UI_I_InvalidKeys,
134
- UI_I_SendDataNewCdDvdDrive,
135
- // UI_I_HardDisk,
136
- UI_I_SendDataNewPciDevice,
137
- } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
138
- import type { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
139
- import type {
140
- UI_T_HardDiskType,
141
- UI_T_NetworkType,
142
- UI_T_CdDvdType,
143
- } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/types'
144
- import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
145
- import type {
146
- UI_I_DropdownTreeItem,
147
- UI_I_DropdownTreeItemChild,
148
- } from '~/components/atoms/dropdown/tree/lib/models/interfaces'
149
- import type { UI_I_Localization } from '~/lib/models/interfaces'
150
- import type {
151
- UI_I_MediatedDevice,
152
- UI_I_PciDevice,
153
- } from '~/lib/models/store/vm/interfaces'
154
- import type { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
155
- import type { UI_I_CreateVmData } from '~/components/common/vm/actions/common/lib/models/interfaces'
156
- import { dropdownItemsFunc } from './lib/config/dropdownItems'
157
-
158
- const model = defineModel<UI_I_CreateVmData>({ required: true })
159
-
160
- const props = withDefaults(
161
- defineProps<{
162
- storage: UI_I_DatastoreTableItem | null
163
- cpuModels: UI_I_OptionItem[]
164
- maxMemory: number
165
- isEdit: boolean
166
- isClone: boolean
167
- errorValidationFields: UI_I_ErrorValidationField[]
168
- nodes: UI_I_FileTreeNode[]
169
- files: UI_I_FileTreeNode[]
170
- networksTable: UI_I_NetworkTableItem[]
171
- getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
172
- datastore: UI_I_DatastoreTableItem[]
173
- isDatastoreLoading: boolean
174
- project: UI_T_Project
175
- state?: string | number
176
- vmCpuHelpTextSecond?: string
177
- hardDisks?: UI_I_SendDataNewHardDisk[] | null
178
- cdDvdDrives?: UI_I_SendDataNewCdDvdDrive[] | null
179
- videoCard?: UI_I_SendDataVideoCard
180
- pciDevices?: UI_I_SendDataNewPciDevice[]
181
- passthroughDevices?: UI_I_PciDevice[]
182
- mediatedDevices?: UI_I_MediatedDevice[]
183
- guestMachineType?: UI_I_OptionItem | null
184
- computeResource?: UI_I_TreeNode | null
185
- compatibilityInfo?: string
186
- }>(),
187
- {
188
- state: undefined,
189
- vmCpuHelpTextSecond: undefined,
190
- hardDisks: undefined,
191
- cdDvdDrives: undefined,
192
- videoCard: undefined,
193
- pciDevices: undefined,
194
- passthroughDevices: undefined,
195
- mediatedDevices: undefined,
196
- guestMachineType: undefined,
197
- computeResource: undefined,
198
- compatibilityInfo: undefined,
199
- }
200
- )
201
- const emits = defineEmits<{
202
- (event: 'invalid', value: string[]): void
203
- (event: 'get-storage', value: UI_I_TablePayload): void
204
- (event: 'get-folders-or-files', value: UI_I_FolderOrFileTreePayload): void
205
- (event: 'get-active-device-child', value: UI_I_FileTreeNode): void
206
- (event: 'show-datastore-child', value: UI_I_FileTreeNode): void
207
- (event: 'remove-error-by-title', value: string): void
208
- (event: 'get-networks-table', value: UI_I_TablePayload): void
209
- (event: 'get-pci-devices'): void
210
- }>()
211
-
212
- const { $store, $binary }: any = useNuxtApp()
213
- const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
214
-
215
- const localization = computed<UI_I_Localization>(() => useLocal())
216
-
217
- const dropdownItems = computed<UI_I_DropdownTreeItem[]>(() =>
218
- dropdownItemsFunc(
219
- localization.value,
220
- props.state,
221
- props.passthroughDevices,
222
- props.mediatedDevices
223
- )
224
- )
225
-
226
- const hardDisksIndex = ref<number[]>([0])
227
- const hardDisksType = ref<UI_T_HardDiskType[]>(['new'])
228
- // const hardDisksLocal = ref<UI_I_SendDataNewHardDisk[]>([
229
- // {
230
- // create: true,
231
- // size: 90,
232
- // source: '',
233
- // boot_order: -1,
234
- // },
235
- // ])
236
- if (!model.value.disk_devices?.length) {
237
- hardDisksType.value = []
238
- hardDisksIndex.value = []
239
- } else {
240
- model.value.disk_devices
241
- .filter((disk) => disk.device_type !== 'cdrom')
242
- .forEach((_disk, _index, array) => {
243
- if (!props.isEdit && !props.isClone) return
244
-
245
- const count = array.length
246
- hardDisksIndex.value = [...Array(count).keys()]
247
- if (props.isEdit) {
248
- hardDisksType.value = Array(count).fill('edit')
249
- } else if (props.isClone) {
250
- hardDisksType.value = Array(count).fill('clone')
251
- }
252
- })
253
- }
254
-
255
- // watch(
256
- // () => props.hardDisks,
257
- // (newValue) => {
258
- // if ((!props.isEdit && !props.isClone) || !newValue) return
259
- //
260
- // const count = newValue?.length || 0
261
- // hardDisksIndex.value = [...Array(count).keys()]
262
- // hardDisksLocal.value = newValue
263
- // if (props.isEdit) {
264
- // hardDisksType.value = Array(count).fill('edit')
265
- // } else if (props.isClone) {
266
- // hardDisksType.value = Array(count).fill('clone')
267
- // hardDisksLocal.value = newValue.map((hardDisk) => {
268
- // hardDisk.create = true
269
- // return hardDisk
270
- // })
271
- // }
272
- // },
273
- // { immediate: true }
274
- // )
275
-
276
- const addHardDisk = (
277
- create = true,
278
- size = 92_160, // 90GB
279
- source = '',
280
- type: UI_T_HardDiskType = 'new',
281
- provisioned_type?: number // При добавлении существующей
282
- ): void => {
283
- const newIndex = (hardDisksIndex.value.at(-1) ?? -1) + 1
284
- hardDisksIndex.value.push(newIndex)
285
- hardDisksType.value.push(type)
286
-
287
- let provisionType = 'thick'
288
- if (provisioned_type === 1) provisionType = 'thin'
289
-
290
- model.value.disk_devices = [
291
- ...model.value.disk_devices.filter((disk) => disk.device_type !== 'cdrom'),
292
- // {
293
- // create,
294
- // size,
295
- // source,
296
- // attach: true,
297
- // boot_order: 0, // Убираем галочку
298
- // provision_type: provisionType,
299
- // },
300
- {
301
- create,
302
- size,
303
- source,
304
- bus: 'virtio',
305
- storage_id: '',
306
- provision_type: 'thick',
307
- disk_mode: 'dependent',
308
- boot_order: 0, // Убираем галочку
309
- device_type: 'disk',
310
- sharing: false,
311
- shares: 0,
312
- cache: 'none',
313
- io: '',
314
- limit_iops: 0,
315
- attach: true,
316
- },
317
- ...model.value.disk_devices.filter((disk) => disk.device_type === 'cdrom'),
318
- ]
319
- // hardDisksLocal.value.push({
320
- // create,
321
- // size,
322
- // source,
323
- // attach: true,
324
- // boot_order: 0, // Убираем галочку
325
- // provision_type: provisionType,
326
- // })
327
- }
328
- const onAddExistHardDisk = (file: UI_I_FileTreeNode): void => {
329
- addHardDisk(
330
- false,
331
- $binary.bToGb(file.size),
332
- file.path,
333
- 'exist',
334
- file.provisioned_type
335
- )
336
- }
337
- const onRemoveHardDisk = (
338
- index: number,
339
- hardDisk: UI_I_SendDataNewHardDisk
340
- ): void => {
341
- const removeIndex = hardDisksIndex.value.indexOf(index)
342
-
343
- if (!hardDisk.create && !hardDisk.attach) {
344
- hardDisksType.value = hardDisksType.value.map((item, key) => {
345
- if (key === removeIndex) return 'removed'
346
- return item
347
- })
348
- return
349
- }
350
-
351
- hardDisksIndex.value = hardDisksIndex.value.filter((item) => item !== index)
352
- hardDisksType.value = hardDisksType.value.filter(
353
- (_item, key) => key !== removeIndex
354
- )
355
-
356
- model.value.disk_devices = model.value.disk_devices.filter(
357
- (_hardDisk, key: number) => {
358
- return removeIndex !== key
359
- }
360
- )
361
- // hardDisksLocal.value = hardDisksLocal.value.filter(
362
- // (_hardDisk, key: number) => {
363
- // return removeIndex !== key
364
- // }
365
- // )
366
-
367
- delete newHardDiskInvalidKeys.value[index]
368
- }
369
- const onRollBackHardDisk = (index: number): void => {
370
- const removeIndex = hardDisksIndex.value.indexOf(index)
371
- hardDisksType.value = hardDisksType.value.map((item, key) => {
372
- if (key === removeIndex) return 'edit'
373
- return item
374
- })
375
- }
376
-
377
- const networkValueProp = props.project === 'sphere' ? 'network' : 'net_bridge'
378
- const networksType = ref<UI_T_NetworkType[]>(['new'])
379
- const networksIndex = ref<number[]>([0])
380
- if (!model.value.network_devices?.length) {
381
- networksType.value = []
382
- networksIndex.value = []
383
- } else {
384
- model.value.network_devices.forEach(() => {
385
- if (!props.isEdit && !props.isClone) return
386
-
387
- const count = model.value.network_devices.length || 0
388
- networksIndex.value = [...Array(count).keys()]
389
- if (props.isEdit) {
390
- networksType.value = Array(count).fill('edit')
391
- } else if (props.isClone) {
392
- networksType.value = Array(count).fill('clone')
393
- }
394
- })
395
- }
396
-
397
- const defaultNetwork = {
398
- network: '',
399
- net_bridge: '',
400
- mac: '',
401
- target: '',
402
- model: 'virtio',
403
- boot_order: 0,
404
- }
405
- const addNetwork = (): void => {
406
- const index = (networksIndex.value.at(-1) ?? -1) + 1
407
- networksIndex.value.push(index)
408
- networksType.value.push('new')
409
-
410
- model.value.network_devices.push({
411
- ...useDeepCopy(defaultNetwork),
412
- })
413
- }
414
- const onRemoveNetwork = (index: number): void => {
415
- const removeIndex = networksIndex.value.indexOf(index)
416
- networksIndex.value = networksIndex.value.filter((item) => item !== index)
417
- networksType.value = networksType.value.filter(
418
- (_item, key) => key !== removeIndex
419
- )
420
- model.value.network_devices = model.value.network_devices.filter(
421
- (_network, key: number) => removeIndex !== key
422
- )
423
-
424
- delete newNetworkInvalidKeys.value[index]
425
- }
426
-
427
- // const defaultCdDvdDriver: UI_I_SendDataNewCdDvdDrive = {
428
- // create: false,
429
- // attach: false,
430
- // source: '',
431
- // bus: '',
432
- // device_type: 'cdrom',
433
- // boot_order: -1,
434
- // }
435
- const defaultCdDvdDriver: UI_I_SendDataNewCdDvdDrive = {
436
- source: '',
437
- storage_id: '',
438
- device_type: 'cdrom',
439
- bus: '',
440
- target: '',
441
- boot_order: 0,
442
- provision_type: 'thick',
443
- disk_mode: 'dependent',
444
- sharing: false,
445
- read_only: true,
446
- shares: 0,
447
- cache: 'none',
448
- io: 'native',
449
- limit_iops: 0,
450
- discard: 'unmap',
451
- attach: false,
452
- detach: false,
453
- remove: false,
454
- create: false,
455
- }
456
- // const cdDvdDrivesLocal = ref<UI_I_SendDataNewCdDvdDrive[]>([
457
- // useDeepCopy(defaultCdDvdDriver),
458
- // ])
459
- const cdDvdDrivesIndex = ref<number[]>([0])
460
- const cdDvdDrivesType = ref<UI_T_CdDvdType[]>(['new'])
461
- if (!model.value.disk_devices?.length) {
462
- cdDvdDrivesIndex.value = []
463
- cdDvdDrivesType.value = []
464
- } else {
465
- model.value.disk_devices
466
- .filter((disk) => disk.device_type === 'cdrom')
467
- .forEach((_disk, _index, array) => {
468
- if (!props.isEdit && !props.isClone) return
469
-
470
- const count = array.length
471
- cdDvdDrivesIndex.value = [...Array(count).keys()]
472
- if (props.isEdit) {
473
- cdDvdDrivesType.value = Array(count).fill('edit')
474
- } else if (props.isClone) {
475
- cdDvdDrivesType.value = Array(count).fill('clone')
476
- }
477
- })
478
- }
479
- // watch(
480
- // () => props.cdDvdDrives,
481
- // (newValue) => {
482
- // if ((!props.isEdit && !props.isClone) || !newValue) return
483
- //
484
- // // cdDvdDrivesLocal.value = newValue
485
- // // cdDvdDrivesType.value = Array(newValue.length).fill('edit')
486
- // const count = newValue?.length || 0
487
- // cdDvdDrivesIndex.value = [...Array(count).keys()]
488
- // cdDvdDrivesLocal.value = newValue
489
- // if (props.isEdit) {
490
- // cdDvdDrivesType.value = Array(count).fill('edit')
491
- // } else if (props.isClone) {
492
- // cdDvdDrivesType.value = Array(count).fill('new')
493
- // }
494
- // },
495
- // { immediate: true }
496
- // )
497
- const addCdDvdDrive = (): void => {
498
- const value = (cdDvdDrivesIndex.value.at(-1) ?? -1) + 1
499
- cdDvdDrivesIndex.value.push(value)
500
- cdDvdDrivesType.value.push('new')
501
- model.value.disk_devices.push({
502
- ...useDeepCopy(defaultCdDvdDriver),
503
- attach: true,
504
- boot_order: 0, // Убираем галочку
505
- })
506
- // cdDvdDrivesLocal.value.push({
507
- // ...useDeepCopy(defaultCdDvdDriver),
508
- // attach: true,
509
- // boot_order: 0, // Убираем галочку
510
- // })
511
- }
512
- const onRemoveCdDvdDrive = (
513
- index: number,
514
- cdDvdDrive: UI_I_SendDataNewCdDvdDrive
515
- ): void => {
516
- const removeIndex = cdDvdDrivesIndex.value.indexOf(index)
517
-
518
- // if (!cdDvdDrive.create && !cdDvdDrive.attach) {
519
- if (cdDvdDrivesType.value[index] === 'edit' && !cdDvdDrive.attach) {
520
- cdDvdDrivesType.value = cdDvdDrivesType.value.map((item, key) => {
521
- if (key === removeIndex) return 'removed'
522
- return item
523
- })
524
- return
525
- }
526
-
527
- cdDvdDrivesIndex.value = cdDvdDrivesIndex.value.filter(
528
- (cdDvdDrive) => cdDvdDrive !== index
529
- )
530
- cdDvdDrivesType.value = cdDvdDrivesType.value.filter(
531
- (_item, key) => key !== index
532
- )
533
- model.value.disk_devices = model.value.disk_devices.filter(
534
- (_cdDvdDrive, key: number) => removeIndex !== key
535
- )
536
- // cdDvdDrivesLocal.value = cdDvdDrivesLocal.value.filter(
537
- // (_cdDvdDrive, key: number) => removeIndex !== key
538
- // )
539
- }
540
- const onRollBackCdDvdDrive = (index: number): void => {
541
- const removeIndex = cdDvdDrivesIndex.value.indexOf(index)
542
- cdDvdDrivesType.value = cdDvdDrivesType.value.map((item, key) => {
543
- if (key === removeIndex) return 'edit'
544
- return item
545
- })
546
- }
547
-
548
- const defaultPciDevice: UI_I_SendDataNewPciDevice = {
549
- address: '',
550
- vendor_name: '',
551
- class_name: '',
552
- device_name: '',
553
- }
554
- const pciDevicesIndex = ref<number[]>([0])
555
- const pciDevicesType = ref<('new' | 'edit' | 'removed')[]>(['new'])
556
- const pciDevicesLocal = ref<UI_I_SendDataNewPciDevice[]>([])
557
- watch(
558
- () => props.pciDevices,
559
- (newValue) => {
560
- if ((!props.isEdit && !props.isClone) || !newValue) return
561
-
562
- const count = newValue?.length || 0
563
- pciDevicesIndex.value = [...Array(count).keys()]
564
- pciDevicesLocal.value = newValue || []
565
- if (props.isEdit) {
566
- pciDevicesType.value = Array(count).fill('edit')
567
- } else if (props.isClone) {
568
- pciDevicesType.value = Array(count).fill('new')
569
- }
570
- },
571
- { immediate: true }
572
- )
573
-
574
- const addPciDevice = (): void => {
575
- const newIndex = (pciDevicesIndex.value.at(-1) ?? -1) + 1
576
- pciDevicesIndex.value.push(newIndex)
577
- pciDevicesType.value.push('new')
578
-
579
- pciDevicesLocal.value.push(useDeepCopy(defaultPciDevice))
580
- model.value.passthrough_pci_devices.push(useDeepCopy(defaultPciDevice))
581
- }
582
- const onRemovePciDevice = (index: number): void => {
583
- const removeIndex = pciDevicesIndex.value.indexOf(index)
584
- pciDevicesIndex.value = pciDevicesIndex.value.filter((item) => item !== index)
585
- pciDevicesType.value = pciDevicesType.value.filter(
586
- (_item, key) => key !== removeIndex
587
- )
588
-
589
- model.value.passthrough_pci_devices =
590
- model.value.passthrough_pci_devices.filter((_pciDevice, key: number) => {
591
- return removeIndex !== key
592
- })
593
- pciDevicesLocal.value = pciDevicesLocal.value.filter(
594
- (_pciDevice, key: number) => {
595
- return removeIndex !== key
596
- }
597
- )
598
-
599
- delete newPciDeviceInvalidKeys.value[index]
600
- }
601
-
602
- const isShowFileModal = ref<boolean>(false)
603
- const onAddDevice = (item: UI_I_DropdownTreeItemChild): void => {
604
- switch (item.value) {
605
- case 1:
606
- addHardDisk()
607
- break
608
- case 2:
609
- isShowFileModal.value = true
610
- break
611
- case 5:
612
- addCdDvdDrive()
613
- break
614
- case 10:
615
- addPciDevice()
616
- break
617
- case 14:
618
- addNetwork()
619
- break
620
- }
621
- }
622
-
623
- const cpuInvalid = ref<boolean>(false)
624
- const onSendDataNewHardDiskMethod = (
625
- data: UI_I_SendDataNewHardDisk,
626
- index: number
627
- ): void => {
628
- model.value.disk_devices[index] = {
629
- ...data,
630
- boot_order: model.value.disk_devices[index]?.boot_order || 0,
631
- }
632
- }
633
- const sendDataNewCdDvdDriveMethod = (
634
- data: UI_I_SendDataNewCdDvdDrive,
635
- index: number
636
- ): void => {
637
- const cdromIndexStart = model.value.disk_devices.findIndex(
638
- (disk) => disk.device_type === 'cdrom'
639
- )
640
- model.value.disk_devices[cdromIndexStart + index] = {
641
- ...data,
642
- boot_order:
643
- model.value.disk_devices[cdromIndexStart + index]?.boot_order || 0,
644
- }
645
- }
646
- const onSendDataPciDevicesMethod = (
647
- data: UI_I_SendDataNewPciDevice,
648
- index: number
649
- ): void => {
650
- model.value.passthrough_pci_devices[index] = {
651
- ...data,
652
- }
653
- }
654
-
655
- const onSetInvalidHardDisk = (invalid: boolean, index: number): void => {
656
- newHardDiskInvalidKeys.value[index] = invalid
657
- }
658
-
659
- const onSetInvalidNetwork = (invalid: boolean, key: number): void => {
660
- newNetworkInvalidKeys.value[key] = invalid
661
- }
662
-
663
- const onSetInvalidPciDevice = (invalid: boolean, key: number): void => {
664
- newPciDeviceInvalidKeys.value[key] = invalid
665
- }
666
-
667
- const memoryInvalid = ref<boolean>(false)
668
- const videoCardInvalid = ref<boolean>(false)
669
- const newHardDiskInvalidKeys = ref<UI_I_InvalidKeys>({})
670
- const newNetworkInvalidKeys = ref<UI_I_InvalidKeys>({})
671
- const newPciDeviceInvalidKeys = ref<UI_I_InvalidKeys>({})
672
-
673
- watch(
674
- [
675
- cpuInvalid,
676
- memoryInvalid,
677
- newHardDiskInvalidKeys,
678
- newNetworkInvalidKeys,
679
- newPciDeviceInvalidKeys,
680
- videoCardInvalid,
681
- ],
682
- () => {
683
- const cpu = cpuInvalid.value ? localization.value.common.cpu : ''
684
- const memory = memoryInvalid.value ? localization.value.common.memory : ''
685
- const videoCard = videoCardInvalid.value
686
- ? localization.value.common.videoCard
687
- : ''
688
- let newHardDisk = ''
689
- Object.keys(newHardDiskInvalidKeys.value).forEach((key) => {
690
- if (!newHardDiskInvalidKeys.value[+key]) {
691
- return
692
- }
693
-
694
- newHardDisk +=
695
- (newHardDisk ? ', ' : '') +
696
- localization.value.common.newHardDisk +
697
- ' ' +
698
- (+key + 1)
699
- })
700
- let newNetwork = ''
701
- Object.keys(newNetworkInvalidKeys.value).forEach((key) => {
702
- if (!newNetworkInvalidKeys.value[+key]) {
703
- return
704
- }
705
-
706
- newNetwork +=
707
- (newNetwork ? ', ' : '') +
708
- localization.value.common.newNetwork +
709
- ' ' +
710
- (+key + 1)
711
- })
712
- // let pciDevice = ''
713
- // Object.keys(newPciDeviceInvalidKeys.value).forEach((key) => {
714
- // if (!newPciDeviceInvalidKeys.value[+key]) {
715
- // return
716
- // }
717
- //
718
- // pciDevice +=
719
- // (pciDevice ? ', ' : '') +
720
- // localization.value.common.pciDevice +
721
- // ' ' +
722
- // (+key + 1)
723
- // })
724
-
725
- emits('invalid', [cpu, memory, newHardDisk, newNetwork, videoCard])
726
- },
727
- { deep: true }
728
- )
729
-
730
- emits('get-pci-devices')
731
- </script>
732
-
733
- <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>