bfg-common 1.4.836 → 1.4.838

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 (184) hide show
  1. package/assets/img/icons/icons-sprite-dark-3.svg +227 -227
  2. package/assets/img/icons/icons-sprite-dark-5.svg +488 -488
  3. package/assets/img/icons/icons-sprite-light-3.svg +227 -227
  4. package/assets/img/icons/icons-sprite-light-5.svg +488 -488
  5. package/assets/scss/common/normalize.scss +361 -361
  6. package/components/atoms/TheIcon3.vue +50 -50
  7. package/components/atoms/autocomplete/Autocomplete.vue +300 -300
  8. package/components/atoms/collapse/CollapseNav.vue +164 -164
  9. package/components/atoms/dropdown/dropdown/Dropdown.vue +168 -168
  10. package/components/atoms/modal/bySteps/BySteps.vue +253 -253
  11. package/components/atoms/stack/StackBlock.vue +185 -185
  12. package/components/atoms/table/dataGrid/DataGrid.vue +1704 -1704
  13. package/components/atoms/table/dataGrid/DataGridColumnSwitch.vue +222 -222
  14. package/components/atoms/table/dataGrid/lib/config/settingsTable.ts +94 -94
  15. package/components/atoms/table/dataGrid/lib/utils/export.ts +16 -16
  16. package/components/common/browse/BrowseNew.vue +237 -237
  17. package/components/common/browse/BrowseOld.vue +217 -217
  18. package/components/common/browse/blocks/contents/Files.vue +37 -37
  19. package/components/common/browse/blocks/contents/FilesOld.vue +72 -72
  20. package/components/common/browse/blocks/contents/filesNew/FilesNew.vue +96 -96
  21. package/components/common/browse/blocks/contents/filesNew/Skeleton.vue +18 -18
  22. package/components/common/browse/blocks/lib/models/types.ts +1 -1
  23. package/components/common/browse/lib/models/interfaces.ts +5 -5
  24. package/components/common/context/Context.vue +111 -111
  25. package/components/common/context/lib/models/interfaces.ts +30 -30
  26. package/components/common/context/recursion/Recursion.vue +87 -87
  27. package/components/common/context/recursion/RecursionNew.vue +237 -237
  28. package/components/common/context/recursion/RecursionOld.vue +227 -227
  29. package/components/common/details/DetailsItem.vue +109 -109
  30. package/components/common/diagramMain/Header.vue +211 -211
  31. package/components/common/diagramMain/adapter/AdapterItems.vue +61 -61
  32. package/components/common/diagramMain/lib/config/initial.ts +50 -50
  33. package/components/common/diagramMain/lib/models/types.ts +21 -21
  34. package/components/common/diagramMain/lib/utils/utils.ts +331 -331
  35. package/components/common/diagramMain/modals/ManagePhysicalAdaptersModal.vue +330 -330
  36. package/components/common/diagramMain/modals/editSettings/ConfirmTeamingSettingsModal.vue +40 -40
  37. package/components/common/diagramMain/modals/editSettings/EditSettings.vue +497 -497
  38. package/components/common/diagramMain/modals/editSettings/EditSettingsModal.vue +812 -812
  39. package/components/common/diagramMain/modals/editSettings/tabs/NetworkProperties.vue +214 -214
  40. package/components/common/diagramMain/modals/editSettings/tabs/Security.vue +189 -189
  41. package/components/common/diagramMain/modals/editSettings/tabs/SwitchProperties.vue +163 -163
  42. package/components/common/diagramMain/modals/editSettings/tabs/TeamingFailover.vue +175 -175
  43. package/components/common/diagramMain/modals/editSettings/tabs/port/IpvFourSettings.vue +346 -346
  44. package/components/common/diagramMain/modals/editSettings/tabs/port/PortProperties.vue +205 -205
  45. package/components/common/diagramMain/modals/lib/config/diagramConfig.ts +23 -23
  46. package/components/common/diagramMain/modals/lib/config/initial.ts +180 -180
  47. package/components/common/diagramMain/modals/lib/config/vmKernelAdapter.ts +90 -90
  48. package/components/common/diagramMain/modals/lib/mappers/mappers.ts +87 -87
  49. package/components/common/diagramMain/modals/lib/utils/index.ts +24 -24
  50. package/components/common/diagramMain/modals/migrateVmkernelAdapter/lib/config/steps.ts +114 -114
  51. package/components/common/diagramMain/modals/migrateVmkernelAdapter/steps/ConnectionSettings.vue +169 -169
  52. package/components/common/diagramMain/modals/migrateVmkernelAdapter/steps/SelectVmkernelAdapter.vue +159 -159
  53. package/components/common/diagramMain/modals/migrateVmkernelAdapter/validations/common.ts +14 -14
  54. package/components/common/diagramMain/modals/migrateVmkernelAdapter/validations/connectionSettings.ts +137 -137
  55. package/components/common/diagramMain/modals/migrateVmkernelAdapter/validations/selectVmkernelAdapter.ts +52 -52
  56. package/components/common/diagramMain/modals/migrateVmkernelAdapter/validations/validations.ts +19 -19
  57. package/components/common/diagramMain/port/Ports.vue +47 -47
  58. package/components/common/graph/Graph.vue +104 -104
  59. package/components/common/graph/GraphNew.vue +144 -144
  60. package/components/common/graph/GraphOld.vue +31 -31
  61. package/components/common/layout/theHeader/helpMenu/About.vue +82 -82
  62. package/components/common/layout/theHeader/helpMenu/aboutNew/AboutNew.vue +103 -103
  63. package/components/common/modals/unsavedChanges/UnsavedChanges.vue +56 -56
  64. package/components/common/monitor/overview/Overview.vue +221 -221
  65. package/components/common/monitor/overview/OverviewNew.vue +142 -142
  66. package/components/common/monitor/overview/OverviewOld.vue +139 -139
  67. package/components/common/monitor/overview/filters/Filters.vue +166 -166
  68. package/components/common/monitor/overview/filters/FiltersNew.vue +172 -172
  69. package/components/common/monitor/overview/filters/FiltersOld.vue +151 -151
  70. package/components/common/monitor/overview/filters/customIntervalModal/CustomIntervalModal.vue +175 -175
  71. package/components/common/monitor/overview/filters/customIntervalModal/CustomIntervalModalNew.vue +181 -181
  72. package/components/common/monitor/overview/filters/customIntervalModal/CustomIntervalModalOld.vue +161 -161
  73. package/components/common/pages/home/StatusContent.vue +49 -49
  74. package/components/common/pages/home/headline/Headline.vue +45 -45
  75. package/components/common/pages/home/headline/HeadlineNew.vue +71 -71
  76. package/components/common/pages/home/headline/HeadlineOld.vue +42 -42
  77. package/components/common/pages/home/lib/models/interfaces.ts +48 -48
  78. package/components/common/pages/home/widgets/Widgets.vue +49 -49
  79. package/components/common/pages/home/widgets/WidgetsNew.vue +86 -86
  80. package/components/common/pages/home/widgets/WidgetsOld.vue +34 -34
  81. package/components/common/pages/home/widgets/hosts/Hosts.vue +27 -27
  82. package/components/common/pages/home/widgets/hosts/HostsNew.vue +100 -100
  83. package/components/common/pages/home/widgets/hosts/lib/config/items.ts +23 -23
  84. package/components/common/pages/home/widgets/services/lib/config/config.ts +108 -108
  85. package/components/common/pages/home/widgets/vms/Vms.vue +26 -26
  86. package/components/common/pages/home/widgets/vms/VmsOld.vue +35 -35
  87. package/components/common/pages/home/widgets/vms/lib/config/items.ts +19 -19
  88. package/components/common/pages/packages/Packages.vue +208 -208
  89. package/components/common/pages/tasks/Tasks.vue +3 -1
  90. package/components/common/pages/tasks/table/Table.vue +1 -0
  91. package/components/common/pages/tasks/table/errorInfo/ErrorInfo.vue +23 -7
  92. package/components/common/pages/tasks/table/expandDetails/ExpandDetails.vue +1 -0
  93. package/components/common/pages/tasks/table/lib/config/config.ts +2 -2
  94. package/components/common/recursionTree/RecursionTree.vue +223 -223
  95. package/components/common/select/button/ButtonDropdown.vue +108 -108
  96. package/components/common/spiceConsole/Drawer.vue +370 -370
  97. package/components/common/spiceConsole/lib/models/interfaces.ts +5 -5
  98. package/components/common/split/horizontal/HorizontalNew.vue +376 -376
  99. package/components/common/split/horizontal/HorizontalOld.vue +337 -337
  100. package/components/common/split/vertical/Vertical.vue +160 -160
  101. package/components/common/vm/actions/add/Add.vue +621 -621
  102. package/components/common/vm/actions/clone/Clone.vue +639 -639
  103. package/components/common/vm/actions/clone/lib/config/steps.ts +129 -129
  104. package/components/common/vm/actions/common/customizeHardware/CustomizeHardware.vue +271 -271
  105. package/components/common/vm/actions/common/customizeHardware/CustomizeHardwareNew.vue +271 -271
  106. package/components/common/vm/actions/common/customizeHardware/CustomizeHardwareOld.vue +174 -174
  107. package/components/common/vm/actions/common/customizeHardware/virtualHardware/VirtualHardware.vue +694 -694
  108. package/components/common/vm/actions/common/customizeHardware/virtualHardware/browseView/BrowseView.vue +219 -219
  109. package/components/common/vm/actions/common/customizeHardware/virtualHardware/bus/BusNew.vue +117 -117
  110. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/CdDvdDriveNew.vue +161 -161
  111. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/CdDvdDriveOld.vue +165 -165
  112. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/media/Media.vue +25 -25
  113. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/media/MediaNew.vue +70 -70
  114. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/media/MediaOld.vue +50 -50
  115. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/Cpu.vue +338 -338
  116. package/components/common/vm/actions/common/customizeHardware/virtualHardware/limit/Limit.vue +220 -220
  117. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/NewHardDisk.vue +364 -364
  118. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/NewHardDiskNew.vue +229 -229
  119. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/NewHardDiskOld.vue +247 -247
  120. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/mode/ModeOld.vue +56 -56
  121. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/sharing/SharingNew.vue +44 -44
  122. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/NewNetwork.vue +283 -283
  123. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/NewNetworkNew.vue +124 -124
  124. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/location/LocationOld.vue +134 -134
  125. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/location/new/New.vue +63 -63
  126. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/location/new/table/lib/config/config.ts +95 -95
  127. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/macAddress/MacAddress.vue +119 -119
  128. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/macAddress/MacAddressNew.vue +69 -69
  129. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/macAddress/MacAddressOld.vue +83 -83
  130. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/NewPciDevice.vue +205 -205
  131. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/directPathIo/DirectPathIoNew.vue +66 -66
  132. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/directPathIo/DirectPathIoOld.vue +62 -62
  133. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/dynamicDirectPathIo/DynamicDirectPathIo.vue +31 -31
  134. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/dynamicDirectPathIo/DynamicDirectPathIoNew.vue +84 -84
  135. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/dynamicDirectPathIo/DynamicDirectPathIoOld.vue +76 -76
  136. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/note/Note.vue +15 -15
  137. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/note/NoteNew.vue +42 -42
  138. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/note/NoteOld.vue +30 -30
  139. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/nvidiaGrid/NvidiaGrid.vue +41 -41
  140. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/nvidiaGrid/NvidiaGridNew.vue +81 -81
  141. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/nvidiaGrid/NvidiaGridOld.vue +84 -84
  142. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newUsbController/NewUsbControllerNew.vue +56 -56
  143. package/components/common/vm/actions/common/customizeHardware/virtualHardware/other/Other.vue +16 -16
  144. package/components/common/vm/actions/common/customizeHardware/virtualHardware/other/OtherNew.vue +30 -30
  145. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/VideoCardNew.vue +104 -104
  146. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/VideoCardOld.vue +112 -112
  147. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/totalVideoMemory/TotalVideoMemoryNew.vue +54 -54
  148. package/components/common/vm/actions/common/customizeHardware/vmoptions/Vmoptions.vue +145 -145
  149. package/components/common/vm/actions/common/customizeHardware/vmoptions/VmoptionsNew.vue +102 -102
  150. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/BootOptionsNew.vue +75 -75
  151. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/delay/Delay.vue +26 -26
  152. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/firmware/Firmware.vue +57 -57
  153. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/firmware/FirmwareNew.vue +42 -42
  154. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/menu/MenuNew.vue +25 -25
  155. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/Order.vue +171 -171
  156. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/OrderNew.vue +50 -50
  157. package/components/common/vm/actions/common/customizeHardware/vmoptions/generalOptions/GeneralOptionsNew.vue +141 -141
  158. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/New.vue +140 -140
  159. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/copyPaste/CopyPasteNew.vue +30 -30
  160. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/fileTransfer/FileTransferNew.vue +30 -30
  161. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/folderSharing/FolderSharingNew.vue +30 -30
  162. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/keymap/Keymap.vue +32 -32
  163. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/keymap/KeymapNew.vue +39 -39
  164. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/password/Password.vue +103 -103
  165. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/password/PasswordNew.vue +102 -102
  166. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/password/PasswordOld.vue +94 -94
  167. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/usbRedirection/UsbRedirection.vue +28 -28
  168. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/usbRedirection/UsbRedirectionNew.vue +38 -38
  169. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/usbRedirection/UsbRedirectionOld.vue +44 -44
  170. package/components/common/vm/actions/common/select/storage/Storage.vue +130 -130
  171. package/components/common/vm/actions/common/select/storage/StorageOld.vue +129 -129
  172. package/components/common/vm/actions/editSettings/new/Skeleton.vue +88 -88
  173. package/components/common/wizards/datastore/add/lib/config/steps.ts +138 -138
  174. package/components/common/wizards/vm/migrate/Migrate.vue +288 -288
  175. package/composables/productNameLocal.ts +30 -30
  176. package/composables/useAppVersion.ts +21 -21
  177. package/package.json +2 -2
  178. package/plugins/date.ts +233 -233
  179. package/plugins/recursion.ts +311 -311
  180. package/public/spice-console/lib/images/bitmap.js +203 -203
  181. package/public/spice-console/network/spicechannel.js +383 -383
  182. package/store/main/mutations.ts +7 -7
  183. package/store/main/state.ts +7 -7
  184. package/store/tasks/mappers/recentTasks.ts +64 -64
@@ -1,694 +1,694 @@
1
- <template>
2
- <common-vm-actions-common-customize-hardware-virtual-hardware-new
3
- v-if="isNewView"
4
- v-model:cpu-invalid="cpuInvalid"
5
- v-model:memory-invalid="memoryInvalid"
6
- v-model:video-card-invalid="videoCardInvalid"
7
- :nodes="props.nodes"
8
- :files="props.files"
9
- :is-edit="props.isEdit"
10
- :storage="props.storage"
11
- :project="props.project"
12
- :max-cpus="props.maxCpus"
13
- :max-memory="props.maxMemory"
14
- :cpu-models="props.cpuModels"
15
- :datastore="props.datastore"
16
- :networks-type="networksType"
17
- :networks-table="props.networksTable"
18
- :dropdown-items="dropdownItems"
19
- :hard-disks-type="hardDisksType"
20
- :networks-index="networksIndex"
21
- :hard-disks-index="hardDisksIndex"
22
- :pci-devices-type="pciDevicesType"
23
- :is-show-file-modal="isShowFileModal"
24
- :pci-devices-index="pciDevicesIndex"
25
- :cd-dvd-drives-type="cdDvdDrivesType"
26
- :cd-dvd-drives-index="cdDvdDrivesIndex"
27
- :error-validation-fields="errorValidationFields"
28
- :get-datastore-table-func="getDatastoreTableFunc"
29
- :cpu="cpu"
30
- :state="state"
31
- :memory="memory"
32
- :networks="networksLocal"
33
- :hard-disks="hardDisksLocal"
34
- :video-card="videoCard"
35
- :pci-devices="pciDevicesLocal"
36
- :cd-dvd-drives="cdDvdDrivesLocal"
37
- :usb-controller="usbController"
38
- :guest-machine-type="guestMachineType"
39
- :passthrough-devices="passthroughDevices"
40
- :mediated-devices="mediatedDevices"
41
- :vm-cpu-help-text-second="vmCpuHelpTextSecond"
42
- @add-device="onAddDevice"
43
- @get-storage="emits('get-storage', $event)"
44
- @remove-network="onRemoveNetwork"
45
- @hide-file-modal="isShowFileModal = false"
46
- @remove-hard-disk="onRemoveHardDisk(...$event)"
47
- @remove-pci-device="onRemovePciDevice"
48
- @get-networks-table="emits('get-networks-table', $event)"
49
- @add-exist-hard-disk="onAddExistHardDisk"
50
- @roll-back-hard-disk="onRollBackHardDisk"
51
- @set-invalid-network="onSetInvalidNetwork(...$event)"
52
- @remove-cd-dvd-drive="onRemoveCdDvdDrive(...$event)"
53
- @show-datastore-child="emits('show-datastore-child', $event)"
54
- @get-folders-or-files="emits('get-folders-or-files', $event)"
55
- @send-data-cpu-method="onSendDataCpuMethod"
56
- @set-invalid-hard-disk="onSetInvalidHardDisk(...$event)"
57
- @remove-error-by-title="emits('remove-error-by-title', $event)"
58
- @roll-back-cd-dvd-drive="onRollBackCdDvdDrive"
59
- @set-invalid-pci-device="onSetInvalidPciDevice(...$event)"
60
- @get-active-device-child="emits('get-active-device-child', $event)"
61
- @send-data-memory-method="onSendDataMemoryMethod"
62
- @send-data-video-card-method="onSendDataVideoCardMethod"
63
- @send-data-new-network-method="sendDataNewNetworkMethod(...$event)"
64
- @send-data-pci-devices-method="onSendDataPciDevicesMethod(...$event)"
65
- @send-data-new-hard-disk-method="onSendDataNewHardDiskMethod(...$event)"
66
- @send-data-new-cd-dvd-drive-method="sendDataNewCdDvdDriveMethod(...$event)"
67
- @send-data-new-usb-controller-method="onSendDataNewUsbControllerMethod"
68
- />
69
- <common-vm-actions-common-customize-hardware-virtual-hardware-old
70
- v-else
71
- v-model:cpu-invalid="cpuInvalid"
72
- v-model:memory-invalid="memoryInvalid"
73
- v-model:video-card-invalid="videoCardInvalid"
74
- :nodes="props.nodes"
75
- :files="props.files"
76
- :is-edit="props.isEdit"
77
- :storage="props.storage"
78
- :project="props.project"
79
- :max-cpus="props.maxCpus"
80
- :max-memory="props.maxMemory"
81
- :cpu-models="props.cpuModels"
82
- :datastore="props.datastore"
83
- :networks-type="networksType"
84
- :networks-table="props.networksTable"
85
- :dropdown-items="dropdownItems"
86
- :hard-disks-type="hardDisksType"
87
- :networks-index="networksIndex"
88
- :hard-disks-index="hardDisksIndex"
89
- :pci-devices-type="pciDevicesType"
90
- :is-show-file-modal="isShowFileModal"
91
- :pci-devices-index="pciDevicesIndex"
92
- :cd-dvd-drives-type="cdDvdDrivesType"
93
- :cd-dvd-drives-index="cdDvdDrivesIndex"
94
- :error-validation-fields="errorValidationFields"
95
- :get-datastore-table-func="getDatastoreTableFunc"
96
- :cpu="cpu"
97
- :state="state"
98
- :memory="memory"
99
- :networks="networksLocal"
100
- :hard-disks="hardDisksLocal"
101
- :video-card="videoCard"
102
- :pci-devices="pciDevicesLocal"
103
- :cd-dvd-drives="cdDvdDrivesLocal"
104
- :usb-controller="usbController"
105
- :guest-machine-type="guestMachineType"
106
- :passthrough-devices="passthroughDevices"
107
- :mediated-devices="mediatedDevices"
108
- :vm-cpu-help-text-second="vmCpuHelpTextSecond"
109
- @add-device="onAddDevice"
110
- @get-storage="emits('get-storage', $event)"
111
- @remove-network="onRemoveNetwork"
112
- @hide-file-modal="isShowFileModal = false"
113
- @remove-hard-disk="onRemoveHardDisk(...$event)"
114
- @remove-pci-device="onRemovePciDevice"
115
- @get-networks-table="emits('get-networks-table', $event)"
116
- @add-exist-hard-disk="onAddExistHardDisk"
117
- @roll-back-hard-disk="onRollBackHardDisk"
118
- @set-invalid-network="onSetInvalidNetwork(...$event)"
119
- @remove-cd-dvd-drive="onRemoveCdDvdDrive(...$event)"
120
- @show-datastore-child="emits('show-datastore-child', $event)"
121
- @get-folders-or-files="emits('get-folders-or-files', $event)"
122
- @send-data-cpu-method="onSendDataCpuMethod"
123
- @set-invalid-hard-disk="onSetInvalidHardDisk(...$event)"
124
- @remove-error-by-title="emits('remove-error-by-title', $event)"
125
- @roll-back-cd-dvd-drive="onRollBackCdDvdDrive"
126
- @set-invalid-pci-device="onSetInvalidPciDevice(...$event)"
127
- @get-active-device-child="emits('get-active-device-child', $event)"
128
- @send-data-memory-method="onSendDataMemoryMethod"
129
- @send-data-video-card-method="onSendDataVideoCardMethod"
130
- @send-data-new-network-method="sendDataNewNetworkMethod(...$event)"
131
- @send-data-pci-devices-method="onSendDataPciDevicesMethod(...$event)"
132
- @send-data-new-hard-disk-method="onSendDataNewHardDiskMethod(...$event)"
133
- @send-data-new-cd-dvd-drive-method="sendDataNewCdDvdDriveMethod(...$event)"
134
- @send-data-new-usb-controller-method="onSendDataNewUsbControllerMethod"
135
- />
136
- </template>
137
-
138
- <script setup lang="ts">
139
- import type { UI_T_Project } from '~/lib/models/types'
140
- import type { UI_I_DatastoreTableItem } from '~/lib/models/store/storage/interfaces'
141
- import type { UI_I_NetworkTableItem } from '~/lib/models/store/network/interfaces'
142
- import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
143
- import type { UI_I_FolderOrFileTreePayload } from '~/lib/models/store/storage/interfaces'
144
- import type { UI_I_FileTreeNode } from '~/components/lib/models/interfaces'
145
- import type {
146
- UI_I_SendDataCpu,
147
- UI_I_SendDataMemory,
148
- UI_I_SendDataNewHardDisk,
149
- UI_I_SendDataNewNetwork,
150
- UI_I_SendDataVideoCard,
151
- UI_I_InvalidKeys,
152
- UI_I_SendDataVirtualHardware,
153
- UI_I_SendDataNewCdDvdDrive,
154
- // UI_I_HardDisk,
155
- UI_I_SendDataNewPciDevice,
156
- } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
157
- import type { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
158
- import type {
159
- UI_T_HardDiskType,
160
- UI_T_NetworkType,
161
- UI_T_CdDvdType,
162
- } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/types'
163
- import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
164
- import type {
165
- UI_I_DropdownTreeItem,
166
- UI_I_DropdownTreeItemChild,
167
- } from '~/components/atoms/dropdown/tree/lib/models/interfaces'
168
- import type { UI_I_Localization } from '~/lib/models/interfaces'
169
- import type {
170
- API_UI_I_VmEditCpu,
171
- API_UI_I_VmEditMemory,
172
- UI_I_MediatedDevice,
173
- UI_I_PciDevice,
174
- } from '~/lib/models/store/vm/interfaces'
175
- import { dropdownItemsFunc } from './lib/config/dropdownItems'
176
-
177
- const props = defineProps<{
178
- storage: UI_I_DatastoreTableItem | null
179
- cpuModels: UI_I_OptionItem[]
180
- maxCpus: number
181
- maxMemory: number
182
- isEdit: boolean
183
- isClone: boolean
184
- errorValidationFields: UI_I_ErrorValidationField<string>[]
185
- nodes: UI_I_FileTreeNode[]
186
- files: UI_I_FileTreeNode[]
187
- networksTable: UI_I_NetworkTableItem[]
188
- getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
189
- datastore: UI_I_DatastoreTableItem[]
190
- state?: string | number
191
- cpu?: API_UI_I_VmEditCpu
192
- memory?: API_UI_I_VmEditMemory
193
- vmCpuHelpTextSecond?: string
194
- hardDisks?: UI_I_SendDataNewHardDisk[] | null
195
- cdDvdDrives?: UI_I_SendDataNewCdDvdDrive[] | null
196
- networks?: UI_I_SendDataNewNetwork[] | null
197
- videoCard?: UI_I_SendDataVideoCard
198
- usbController?: string
199
- pciDevices?: UI_I_SendDataNewPciDevice[]
200
- passthroughDevices?: UI_I_PciDevice[]
201
- mediatedDevices?: UI_I_MediatedDevice[]
202
- project: UI_T_Project
203
- guestMachineType?: UI_I_OptionItem | null
204
- }>()
205
- const emits = defineEmits<{
206
- (event: 'send-data', value: UI_I_SendDataVirtualHardware): void
207
- (event: 'invalid', value: string[]): void
208
- (event: 'get-storage', value: UI_I_TablePayload): void
209
- (event: 'get-folders-or-files', value: UI_I_FolderOrFileTreePayload): void
210
- (event: 'get-active-device-child', value: UI_I_FileTreeNode): void
211
- (event: 'show-datastore-child', value: UI_I_FileTreeNode): void
212
- (event: 'remove-error-by-title', value: string): void
213
- (event: 'get-networks-table', value: UI_I_TablePayload): void
214
- (event: 'get-pci-devices'): void
215
- }>()
216
-
217
- const { $store, $binary }: any = useNuxtApp()
218
- const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
219
-
220
- const localization = computed<UI_I_Localization>(() => useLocal())
221
-
222
- const dropdownItems = computed<UI_I_DropdownTreeItem[]>(() =>
223
- dropdownItemsFunc(
224
- localization.value,
225
- props.state,
226
- props.passthroughDevices,
227
- props.mediatedDevices
228
- )
229
- )
230
-
231
- const hardDisksIndex = ref<number[]>([0])
232
- const hardDisksType = ref<UI_T_HardDiskType[]>(['new'])
233
- const hardDisksLocal = ref<UI_I_SendDataNewHardDisk[]>([
234
- {
235
- create: true,
236
- size: 90,
237
- source: '',
238
- boot_order: -1,
239
- },
240
- ])
241
- watch(
242
- () => props.hardDisks,
243
- (newValue) => {
244
- if ((!props.isEdit && !props.isClone) || !newValue) return
245
-
246
- const count = newValue?.length || 0
247
- hardDisksIndex.value = [...Array(count).keys()]
248
- hardDisksLocal.value = newValue
249
- if (props.isEdit) {
250
- hardDisksType.value = Array(count).fill('edit')
251
- } else if (props.isClone) {
252
- hardDisksType.value = Array(count).fill('clone')
253
- hardDisksLocal.value = newValue.map((hardDisk) => {
254
- hardDisk.create = true
255
- return hardDisk
256
- })
257
- }
258
- },
259
- { immediate: true }
260
- )
261
-
262
- const addHardDisk = (
263
- create = true,
264
- size = 90,
265
- source = '',
266
- type: UI_T_HardDiskType = 'new',
267
- provisioned_type?: number // При добавлении существующей
268
- ): void => {
269
- const newIndex = (hardDisksIndex.value.at(-1) ?? -1) + 1
270
- hardDisksIndex.value.push(newIndex)
271
- hardDisksType.value.push(type)
272
-
273
- let provisionType = 'thick'
274
- if (provisioned_type === 1) provisionType = 'thin'
275
-
276
- hardDisksLocal.value.push({
277
- create,
278
- size,
279
- source,
280
- attach: true,
281
- boot_order: 0, // Убираем галочку
282
- provision_type: provisionType,
283
- })
284
- sendData()
285
- }
286
- const onAddExistHardDisk = (file: UI_I_FileTreeNode): void => {
287
- addHardDisk(
288
- false,
289
- $binary.bToGb(file.size),
290
- file.path,
291
- 'exist',
292
- file.provisioned_type
293
- )
294
- }
295
- const onRemoveHardDisk = (
296
- index: number,
297
- hardDisk: UI_I_SendDataNewHardDisk
298
- ): void => {
299
- const removeIndex = hardDisksIndex.value.indexOf(index)
300
-
301
- if (!hardDisk.create && !hardDisk.attach) {
302
- hardDisksType.value = hardDisksType.value.map((item, key) => {
303
- if (key === removeIndex) return 'removed'
304
- return item
305
- })
306
- sendData()
307
- return
308
- }
309
-
310
- hardDisksIndex.value = hardDisksIndex.value.filter((item) => item !== index)
311
- hardDisksType.value = hardDisksType.value.filter(
312
- (_item, key) => key !== removeIndex
313
- )
314
-
315
- hardDisksLocal.value = hardDisksLocal.value.filter(
316
- (_hardDisk, key: number) => {
317
- return removeIndex !== key
318
- }
319
- )
320
-
321
- delete newHardDiskInvalidKeys.value[index]
322
- delete sendDataNewHardDisk.value[index]
323
- sendData()
324
- }
325
- const onRollBackHardDisk = (index: number): void => {
326
- const removeIndex = hardDisksIndex.value.indexOf(index)
327
- hardDisksType.value = hardDisksType.value.map((item, key) => {
328
- if (key === removeIndex) return 'edit'
329
- return item
330
- })
331
- }
332
-
333
- const defaultNetwork = {
334
- network: '',
335
- net_bridge: '',
336
- mac: '',
337
- target: '',
338
- model: '',
339
- boot_order: -1,
340
- }
341
- const networksLocal = ref<UI_I_SendDataNewNetwork[]>([
342
- useDeepCopy(defaultNetwork),
343
- ])
344
- const networksType = ref<UI_T_NetworkType[]>(['new'])
345
- const networksIndex = ref<number[]>([0])
346
- watch(
347
- () => props.networks,
348
- (newValue) => {
349
- if ((!props.isEdit && !props.isClone) || !newValue) return
350
-
351
- // networksLocal.value = newValue
352
- // networksType.value = Array(newValue.length).fill('edit')
353
- const count = newValue?.length || 0
354
- networksIndex.value = [...Array(count).keys()]
355
- networksLocal.value = newValue
356
- if (props.isEdit) {
357
- networksType.value = Array(count).fill('edit')
358
- } else if (props.isClone) {
359
- networksType.value = Array(count).fill('clone')
360
- }
361
- },
362
- { immediate: true }
363
- )
364
- const addNetwork = (): void => {
365
- const index = (networksIndex.value.at(-1) ?? -1) + 1
366
- networksIndex.value.push(index)
367
- networksType.value.push('new')
368
-
369
- networksLocal.value.push({
370
- ...useDeepCopy(defaultNetwork),
371
- boot_order: 0, // Убираем галочку
372
- })
373
- }
374
- const onRemoveNetwork = (index: number): void => {
375
- const removeIndex = networksIndex.value.indexOf(index)
376
- networksIndex.value = networksIndex.value.filter((item) => item !== index)
377
- networksType.value = networksType.value.filter(
378
- (_item, key) => key !== removeIndex
379
- )
380
- networksLocal.value = networksLocal.value.filter(
381
- (_network, key: number) => removeIndex !== key
382
- )
383
-
384
- delete newNetworkInvalidKeys.value[index]
385
- delete sendDataNewNetwork.value[index]
386
- sendData()
387
- }
388
-
389
- const defaultCdDvdDriver: UI_I_SendDataNewCdDvdDrive = {
390
- create: false,
391
- attach: false,
392
- source: '',
393
- bus: '',
394
- device_type: 'cdrom',
395
- boot_order: -1,
396
- }
397
- const cdDvdDrivesLocal = ref<UI_I_SendDataNewCdDvdDrive[]>([
398
- useDeepCopy(defaultCdDvdDriver),
399
- ])
400
- const cdDvdDrivesIndex = ref<number[]>([0])
401
- const cdDvdDrivesType = ref<UI_T_CdDvdType[]>(['new'])
402
- watch(
403
- () => props.cdDvdDrives,
404
- (newValue) => {
405
- if ((!props.isEdit && !props.isClone) || !newValue) return
406
-
407
- // cdDvdDrivesLocal.value = newValue
408
- // cdDvdDrivesType.value = Array(newValue.length).fill('edit')
409
- const count = newValue?.length || 0
410
- cdDvdDrivesIndex.value = [...Array(count).keys()]
411
- cdDvdDrivesLocal.value = newValue
412
- if (props.isEdit) {
413
- cdDvdDrivesType.value = Array(count).fill('edit')
414
- } else if (props.isClone) {
415
- cdDvdDrivesType.value = Array(count).fill('new')
416
- }
417
- },
418
- { immediate: true }
419
- )
420
- const addCdDvdDrive = (): void => {
421
- const value = (cdDvdDrivesIndex.value.at(-1) ?? -1) + 1
422
- cdDvdDrivesIndex.value.push(value)
423
- cdDvdDrivesType.value.push('new')
424
- cdDvdDrivesLocal.value.push({
425
- ...useDeepCopy(defaultCdDvdDriver),
426
- attach: true,
427
- boot_order: 0, // Убираем галочку
428
- })
429
- }
430
- const onRemoveCdDvdDrive = (
431
- index: number,
432
- cdDvdDrive: UI_I_SendDataNewCdDvdDrive
433
- ): void => {
434
- const removeIndex = cdDvdDrivesIndex.value.indexOf(index)
435
-
436
- // if (!cdDvdDrive.create && !cdDvdDrive.attach) {
437
- if (cdDvdDrivesType.value[index] === 'edit' && !cdDvdDrive.attach) {
438
- cdDvdDrivesType.value = cdDvdDrivesType.value.map((item, key) => {
439
- if (key === removeIndex) return 'removed'
440
- return item
441
- })
442
- sendData()
443
- return
444
- }
445
-
446
- cdDvdDrivesIndex.value = cdDvdDrivesIndex.value.filter(
447
- (cdDvdDrive) => cdDvdDrive !== index
448
- )
449
- cdDvdDrivesType.value = cdDvdDrivesType.value.filter(
450
- (_item, key) => key !== index
451
- )
452
- cdDvdDrivesLocal.value = cdDvdDrivesLocal.value.filter(
453
- (_cdDvdDrive, key: number) => removeIndex !== key
454
- )
455
-
456
- delete sendDataNewCdDvdDrive.value[index]
457
- sendData()
458
- }
459
- const onRollBackCdDvdDrive = (index: number): void => {
460
- const removeIndex = cdDvdDrivesIndex.value.indexOf(index)
461
- cdDvdDrivesType.value = cdDvdDrivesType.value.map((item, key) => {
462
- if (key === removeIndex) return 'edit'
463
- return item
464
- })
465
- }
466
-
467
- const defaultPciDevice: UI_I_SendDataNewPciDevice = {
468
- address: '',
469
- vendor_name: '',
470
- class_name: '',
471
- device_name: '',
472
- }
473
- const pciDevicesIndex = ref<number[]>([0])
474
- const pciDevicesType = ref<('new' | 'edit' | 'removed')[]>(['new'])
475
- const pciDevicesLocal = ref<UI_I_SendDataNewPciDevice[]>([])
476
- watch(
477
- () => props.pciDevices,
478
- (newValue) => {
479
- if ((!props.isEdit && !props.isClone) || !newValue) return
480
-
481
- const count = newValue?.length || 0
482
- pciDevicesIndex.value = [...Array(count).keys()]
483
- pciDevicesLocal.value = newValue || []
484
- if (props.isEdit) {
485
- pciDevicesType.value = Array(count).fill('edit')
486
- } else if (props.isClone) {
487
- pciDevicesType.value = Array(count).fill('new')
488
- }
489
- },
490
- { immediate: true }
491
- )
492
-
493
- const addPciDevice = (): void => {
494
- const newIndex = (pciDevicesIndex.value.at(-1) ?? -1) + 1
495
- pciDevicesIndex.value.push(newIndex)
496
- pciDevicesType.value.push('new')
497
-
498
- pciDevicesLocal.value.push(useDeepCopy(defaultPciDevice))
499
- }
500
- const onRemovePciDevice = (index: number): void => {
501
- const removeIndex = pciDevicesIndex.value.indexOf(index)
502
- pciDevicesIndex.value = pciDevicesIndex.value.filter((item) => item !== index)
503
- pciDevicesType.value = pciDevicesType.value.filter(
504
- (_item, key) => key !== removeIndex
505
- )
506
-
507
- pciDevicesLocal.value = pciDevicesLocal.value.filter(
508
- (_pciDevice, key: number) => {
509
- return removeIndex !== key
510
- }
511
- )
512
-
513
- delete newPciDeviceInvalidKeys.value[index]
514
- delete sendDataNewPciDevices.value[index]
515
- sendData()
516
- }
517
-
518
- const isShowFileModal = ref<boolean>(false)
519
- const onAddDevice = (item: UI_I_DropdownTreeItemChild): void => {
520
- switch (item.value) {
521
- case 1:
522
- addHardDisk()
523
- break
524
- case 2:
525
- isShowFileModal.value = true
526
- break
527
- case 5:
528
- addCdDvdDrive()
529
- break
530
- case 10:
531
- addPciDevice()
532
- break
533
- case 14:
534
- addNetwork()
535
- break
536
- }
537
- }
538
-
539
- const cpuInvalid = ref<boolean>(false)
540
- const sendDataCpu = ref<UI_I_SendDataCpu | null>(null)
541
- const onSendDataCpuMethod = (data: UI_I_SendDataCpu): void => {
542
- sendDataCpu.value = data
543
- sendData()
544
- }
545
- const sendDataMemory = ref<UI_I_SendDataMemory | null>(null)
546
- const onSendDataMemoryMethod = (data: UI_I_SendDataMemory): void => {
547
- sendDataMemory.value = data
548
- sendData()
549
- }
550
- const sendDataNewHardDisk = ref<UI_I_SendDataNewHardDisk[]>([])
551
- const onSendDataNewHardDiskMethod = (
552
- data: UI_I_SendDataNewHardDisk,
553
- index: number
554
- ): void => {
555
- sendDataNewHardDisk.value[index] = data
556
- sendData()
557
- }
558
- const sendDataNewNetwork = ref<UI_I_SendDataNewNetwork[]>([])
559
- const sendDataNewNetworkMethod = (
560
- data: UI_I_SendDataNewNetwork,
561
- index: number
562
- ): void => {
563
- sendDataNewNetwork.value[index] = data
564
- sendData()
565
- }
566
- const sendDataNewCdDvdDrive = ref<UI_I_SendDataNewCdDvdDrive[]>([])
567
- const sendDataNewCdDvdDriveMethod = (
568
- data: UI_I_SendDataNewCdDvdDrive,
569
- index: number
570
- ): void => {
571
- sendDataNewCdDvdDrive.value[index] = data
572
- sendData()
573
- }
574
- const sendDataNewUsbController = ref<string | null>(null)
575
- const onSendDataNewUsbControllerMethod = (data: string): void => {
576
- sendDataNewUsbController.value = data
577
- sendData()
578
- }
579
- const sendDataNewPciDevices = ref<UI_I_SendDataNewPciDevice[]>([])
580
- const onSendDataPciDevicesMethod = (
581
- data: UI_I_SendDataNewPciDevice,
582
- index: number
583
- ): void => {
584
- sendDataNewPciDevices.value[index] = data
585
- sendData()
586
- }
587
- const sendDataVideoCard = ref<UI_I_SendDataVideoCard | null>(null)
588
- const onSendDataVideoCardMethod = (data: UI_I_SendDataVideoCard): void => {
589
- sendDataVideoCard.value = data
590
- sendData()
591
- }
592
-
593
- const sendData = (): void => {
594
- const cpu = sendDataCpu.value
595
- const memory = sendDataMemory.value
596
- const hardDisks = sendDataNewHardDisk.value.flat(2)
597
- const networks = sendDataNewNetwork.value.flat(2)
598
- const cdDvdDrives = sendDataNewCdDvdDrive.value.flat(2)
599
- const pciDevices = sendDataNewPciDevices.value.flat()
600
- const usbController = sendDataNewUsbController.value
601
- const videoCard = sendDataVideoCard.value
602
-
603
- const sendData: UI_I_SendDataVirtualHardware = {
604
- cpu,
605
- memory,
606
- usbController,
607
- pciDevices,
608
- networks,
609
- hardDisks,
610
- cdDvdDrives,
611
- videoCard,
612
- }
613
- emits('send-data', sendData)
614
- }
615
-
616
- const onSetInvalidHardDisk = (invalid: boolean, index: number): void => {
617
- newHardDiskInvalidKeys.value[index] = invalid
618
- }
619
-
620
- const onSetInvalidNetwork = (invalid: boolean, key: number): void => {
621
- newNetworkInvalidKeys.value[key] = invalid
622
- }
623
-
624
- const onSetInvalidPciDevice = (invalid: boolean, key: number): void => {
625
- newPciDeviceInvalidKeys.value[key] = invalid
626
- }
627
-
628
- const memoryInvalid = ref<boolean>(false)
629
- const videoCardInvalid = ref<boolean>(false)
630
- const newHardDiskInvalidKeys = ref<UI_I_InvalidKeys>({})
631
- const newNetworkInvalidKeys = ref<UI_I_InvalidKeys>({})
632
- const newPciDeviceInvalidKeys = ref<UI_I_InvalidKeys>({})
633
-
634
- watch(
635
- [
636
- cpuInvalid,
637
- memoryInvalid,
638
- newHardDiskInvalidKeys,
639
- newNetworkInvalidKeys,
640
- newPciDeviceInvalidKeys,
641
- videoCardInvalid,
642
- ],
643
- () => {
644
- const cpu = cpuInvalid.value ? localization.value.common.cpu : ''
645
- const memory = memoryInvalid.value ? localization.value.common.memory : ''
646
- const videoCard = videoCardInvalid.value
647
- ? localization.value.common.videoCard
648
- : ''
649
- let newHardDisk = ''
650
- Object.keys(newHardDiskInvalidKeys.value).forEach((key) => {
651
- if (!newHardDiskInvalidKeys.value[+key]) {
652
- return
653
- }
654
-
655
- newHardDisk +=
656
- (newHardDisk ? ', ' : '') +
657
- localization.value.common.newHardDisk +
658
- ' ' +
659
- (+key + 1)
660
- })
661
- let newNetwork = ''
662
- Object.keys(newNetworkInvalidKeys.value).forEach((key) => {
663
- if (!newNetworkInvalidKeys.value[+key]) {
664
- return
665
- }
666
-
667
- newNetwork +=
668
- (newNetwork ? ', ' : '') +
669
- localization.value.common.newNetwork +
670
- ' ' +
671
- (+key + 1)
672
- })
673
- // let pciDevice = ''
674
- // Object.keys(newPciDeviceInvalidKeys.value).forEach((key) => {
675
- // if (!newPciDeviceInvalidKeys.value[+key]) {
676
- // return
677
- // }
678
- //
679
- // pciDevice +=
680
- // (pciDevice ? ', ' : '') +
681
- // localization.value.common.pciDevice +
682
- // ' ' +
683
- // (+key + 1)
684
- // })
685
-
686
- emits('invalid', [cpu, memory, newHardDisk, newNetwork, videoCard])
687
- },
688
- { deep: true }
689
- )
690
-
691
- emits('get-pci-devices')
692
- </script>
693
-
694
- <style scoped lang="scss"></style>
1
+ <template>
2
+ <common-vm-actions-common-customize-hardware-virtual-hardware-new
3
+ v-if="isNewView"
4
+ v-model:cpu-invalid="cpuInvalid"
5
+ v-model:memory-invalid="memoryInvalid"
6
+ v-model:video-card-invalid="videoCardInvalid"
7
+ :nodes="props.nodes"
8
+ :files="props.files"
9
+ :is-edit="props.isEdit"
10
+ :storage="props.storage"
11
+ :project="props.project"
12
+ :max-cpus="props.maxCpus"
13
+ :max-memory="props.maxMemory"
14
+ :cpu-models="props.cpuModels"
15
+ :datastore="props.datastore"
16
+ :networks-type="networksType"
17
+ :networks-table="props.networksTable"
18
+ :dropdown-items="dropdownItems"
19
+ :hard-disks-type="hardDisksType"
20
+ :networks-index="networksIndex"
21
+ :hard-disks-index="hardDisksIndex"
22
+ :pci-devices-type="pciDevicesType"
23
+ :is-show-file-modal="isShowFileModal"
24
+ :pci-devices-index="pciDevicesIndex"
25
+ :cd-dvd-drives-type="cdDvdDrivesType"
26
+ :cd-dvd-drives-index="cdDvdDrivesIndex"
27
+ :error-validation-fields="errorValidationFields"
28
+ :get-datastore-table-func="getDatastoreTableFunc"
29
+ :cpu="cpu"
30
+ :state="state"
31
+ :memory="memory"
32
+ :networks="networksLocal"
33
+ :hard-disks="hardDisksLocal"
34
+ :video-card="videoCard"
35
+ :pci-devices="pciDevicesLocal"
36
+ :cd-dvd-drives="cdDvdDrivesLocal"
37
+ :usb-controller="usbController"
38
+ :guest-machine-type="guestMachineType"
39
+ :passthrough-devices="passthroughDevices"
40
+ :mediated-devices="mediatedDevices"
41
+ :vm-cpu-help-text-second="vmCpuHelpTextSecond"
42
+ @add-device="onAddDevice"
43
+ @get-storage="emits('get-storage', $event)"
44
+ @remove-network="onRemoveNetwork"
45
+ @hide-file-modal="isShowFileModal = false"
46
+ @remove-hard-disk="onRemoveHardDisk(...$event)"
47
+ @remove-pci-device="onRemovePciDevice"
48
+ @get-networks-table="emits('get-networks-table', $event)"
49
+ @add-exist-hard-disk="onAddExistHardDisk"
50
+ @roll-back-hard-disk="onRollBackHardDisk"
51
+ @set-invalid-network="onSetInvalidNetwork(...$event)"
52
+ @remove-cd-dvd-drive="onRemoveCdDvdDrive(...$event)"
53
+ @show-datastore-child="emits('show-datastore-child', $event)"
54
+ @get-folders-or-files="emits('get-folders-or-files', $event)"
55
+ @send-data-cpu-method="onSendDataCpuMethod"
56
+ @set-invalid-hard-disk="onSetInvalidHardDisk(...$event)"
57
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
58
+ @roll-back-cd-dvd-drive="onRollBackCdDvdDrive"
59
+ @set-invalid-pci-device="onSetInvalidPciDevice(...$event)"
60
+ @get-active-device-child="emits('get-active-device-child', $event)"
61
+ @send-data-memory-method="onSendDataMemoryMethod"
62
+ @send-data-video-card-method="onSendDataVideoCardMethod"
63
+ @send-data-new-network-method="sendDataNewNetworkMethod(...$event)"
64
+ @send-data-pci-devices-method="onSendDataPciDevicesMethod(...$event)"
65
+ @send-data-new-hard-disk-method="onSendDataNewHardDiskMethod(...$event)"
66
+ @send-data-new-cd-dvd-drive-method="sendDataNewCdDvdDriveMethod(...$event)"
67
+ @send-data-new-usb-controller-method="onSendDataNewUsbControllerMethod"
68
+ />
69
+ <common-vm-actions-common-customize-hardware-virtual-hardware-old
70
+ v-else
71
+ v-model:cpu-invalid="cpuInvalid"
72
+ v-model:memory-invalid="memoryInvalid"
73
+ v-model:video-card-invalid="videoCardInvalid"
74
+ :nodes="props.nodes"
75
+ :files="props.files"
76
+ :is-edit="props.isEdit"
77
+ :storage="props.storage"
78
+ :project="props.project"
79
+ :max-cpus="props.maxCpus"
80
+ :max-memory="props.maxMemory"
81
+ :cpu-models="props.cpuModels"
82
+ :datastore="props.datastore"
83
+ :networks-type="networksType"
84
+ :networks-table="props.networksTable"
85
+ :dropdown-items="dropdownItems"
86
+ :hard-disks-type="hardDisksType"
87
+ :networks-index="networksIndex"
88
+ :hard-disks-index="hardDisksIndex"
89
+ :pci-devices-type="pciDevicesType"
90
+ :is-show-file-modal="isShowFileModal"
91
+ :pci-devices-index="pciDevicesIndex"
92
+ :cd-dvd-drives-type="cdDvdDrivesType"
93
+ :cd-dvd-drives-index="cdDvdDrivesIndex"
94
+ :error-validation-fields="errorValidationFields"
95
+ :get-datastore-table-func="getDatastoreTableFunc"
96
+ :cpu="cpu"
97
+ :state="state"
98
+ :memory="memory"
99
+ :networks="networksLocal"
100
+ :hard-disks="hardDisksLocal"
101
+ :video-card="videoCard"
102
+ :pci-devices="pciDevicesLocal"
103
+ :cd-dvd-drives="cdDvdDrivesLocal"
104
+ :usb-controller="usbController"
105
+ :guest-machine-type="guestMachineType"
106
+ :passthrough-devices="passthroughDevices"
107
+ :mediated-devices="mediatedDevices"
108
+ :vm-cpu-help-text-second="vmCpuHelpTextSecond"
109
+ @add-device="onAddDevice"
110
+ @get-storage="emits('get-storage', $event)"
111
+ @remove-network="onRemoveNetwork"
112
+ @hide-file-modal="isShowFileModal = false"
113
+ @remove-hard-disk="onRemoveHardDisk(...$event)"
114
+ @remove-pci-device="onRemovePciDevice"
115
+ @get-networks-table="emits('get-networks-table', $event)"
116
+ @add-exist-hard-disk="onAddExistHardDisk"
117
+ @roll-back-hard-disk="onRollBackHardDisk"
118
+ @set-invalid-network="onSetInvalidNetwork(...$event)"
119
+ @remove-cd-dvd-drive="onRemoveCdDvdDrive(...$event)"
120
+ @show-datastore-child="emits('show-datastore-child', $event)"
121
+ @get-folders-or-files="emits('get-folders-or-files', $event)"
122
+ @send-data-cpu-method="onSendDataCpuMethod"
123
+ @set-invalid-hard-disk="onSetInvalidHardDisk(...$event)"
124
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
125
+ @roll-back-cd-dvd-drive="onRollBackCdDvdDrive"
126
+ @set-invalid-pci-device="onSetInvalidPciDevice(...$event)"
127
+ @get-active-device-child="emits('get-active-device-child', $event)"
128
+ @send-data-memory-method="onSendDataMemoryMethod"
129
+ @send-data-video-card-method="onSendDataVideoCardMethod"
130
+ @send-data-new-network-method="sendDataNewNetworkMethod(...$event)"
131
+ @send-data-pci-devices-method="onSendDataPciDevicesMethod(...$event)"
132
+ @send-data-new-hard-disk-method="onSendDataNewHardDiskMethod(...$event)"
133
+ @send-data-new-cd-dvd-drive-method="sendDataNewCdDvdDriveMethod(...$event)"
134
+ @send-data-new-usb-controller-method="onSendDataNewUsbControllerMethod"
135
+ />
136
+ </template>
137
+
138
+ <script setup lang="ts">
139
+ import type { UI_T_Project } from '~/lib/models/types'
140
+ import type { UI_I_DatastoreTableItem } from '~/lib/models/store/storage/interfaces'
141
+ import type { UI_I_NetworkTableItem } from '~/lib/models/store/network/interfaces'
142
+ import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
143
+ import type { UI_I_FolderOrFileTreePayload } from '~/lib/models/store/storage/interfaces'
144
+ import type { UI_I_FileTreeNode } from '~/components/lib/models/interfaces'
145
+ import type {
146
+ UI_I_SendDataCpu,
147
+ UI_I_SendDataMemory,
148
+ UI_I_SendDataNewHardDisk,
149
+ UI_I_SendDataNewNetwork,
150
+ UI_I_SendDataVideoCard,
151
+ UI_I_InvalidKeys,
152
+ UI_I_SendDataVirtualHardware,
153
+ UI_I_SendDataNewCdDvdDrive,
154
+ // UI_I_HardDisk,
155
+ UI_I_SendDataNewPciDevice,
156
+ } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
157
+ import type { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
158
+ import type {
159
+ UI_T_HardDiskType,
160
+ UI_T_NetworkType,
161
+ UI_T_CdDvdType,
162
+ } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/types'
163
+ import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
164
+ import type {
165
+ UI_I_DropdownTreeItem,
166
+ UI_I_DropdownTreeItemChild,
167
+ } from '~/components/atoms/dropdown/tree/lib/models/interfaces'
168
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
169
+ import type {
170
+ API_UI_I_VmEditCpu,
171
+ API_UI_I_VmEditMemory,
172
+ UI_I_MediatedDevice,
173
+ UI_I_PciDevice,
174
+ } from '~/lib/models/store/vm/interfaces'
175
+ import { dropdownItemsFunc } from './lib/config/dropdownItems'
176
+
177
+ const props = defineProps<{
178
+ storage: UI_I_DatastoreTableItem | null
179
+ cpuModels: UI_I_OptionItem[]
180
+ maxCpus: number
181
+ maxMemory: number
182
+ isEdit: boolean
183
+ isClone: boolean
184
+ errorValidationFields: UI_I_ErrorValidationField<string>[]
185
+ nodes: UI_I_FileTreeNode[]
186
+ files: UI_I_FileTreeNode[]
187
+ networksTable: UI_I_NetworkTableItem[]
188
+ getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
189
+ datastore: UI_I_DatastoreTableItem[]
190
+ state?: string | number
191
+ cpu?: API_UI_I_VmEditCpu
192
+ memory?: API_UI_I_VmEditMemory
193
+ vmCpuHelpTextSecond?: string
194
+ hardDisks?: UI_I_SendDataNewHardDisk[] | null
195
+ cdDvdDrives?: UI_I_SendDataNewCdDvdDrive[] | null
196
+ networks?: UI_I_SendDataNewNetwork[] | null
197
+ videoCard?: UI_I_SendDataVideoCard
198
+ usbController?: string
199
+ pciDevices?: UI_I_SendDataNewPciDevice[]
200
+ passthroughDevices?: UI_I_PciDevice[]
201
+ mediatedDevices?: UI_I_MediatedDevice[]
202
+ project: UI_T_Project
203
+ guestMachineType?: UI_I_OptionItem | null
204
+ }>()
205
+ const emits = defineEmits<{
206
+ (event: 'send-data', value: UI_I_SendDataVirtualHardware): void
207
+ (event: 'invalid', value: string[]): void
208
+ (event: 'get-storage', value: UI_I_TablePayload): void
209
+ (event: 'get-folders-or-files', value: UI_I_FolderOrFileTreePayload): void
210
+ (event: 'get-active-device-child', value: UI_I_FileTreeNode): void
211
+ (event: 'show-datastore-child', value: UI_I_FileTreeNode): void
212
+ (event: 'remove-error-by-title', value: string): void
213
+ (event: 'get-networks-table', value: UI_I_TablePayload): void
214
+ (event: 'get-pci-devices'): void
215
+ }>()
216
+
217
+ const { $store, $binary }: any = useNuxtApp()
218
+ const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
219
+
220
+ const localization = computed<UI_I_Localization>(() => useLocal())
221
+
222
+ const dropdownItems = computed<UI_I_DropdownTreeItem[]>(() =>
223
+ dropdownItemsFunc(
224
+ localization.value,
225
+ props.state,
226
+ props.passthroughDevices,
227
+ props.mediatedDevices
228
+ )
229
+ )
230
+
231
+ const hardDisksIndex = ref<number[]>([0])
232
+ const hardDisksType = ref<UI_T_HardDiskType[]>(['new'])
233
+ const hardDisksLocal = ref<UI_I_SendDataNewHardDisk[]>([
234
+ {
235
+ create: true,
236
+ size: 90,
237
+ source: '',
238
+ boot_order: -1,
239
+ },
240
+ ])
241
+ watch(
242
+ () => props.hardDisks,
243
+ (newValue) => {
244
+ if ((!props.isEdit && !props.isClone) || !newValue) return
245
+
246
+ const count = newValue?.length || 0
247
+ hardDisksIndex.value = [...Array(count).keys()]
248
+ hardDisksLocal.value = newValue
249
+ if (props.isEdit) {
250
+ hardDisksType.value = Array(count).fill('edit')
251
+ } else if (props.isClone) {
252
+ hardDisksType.value = Array(count).fill('clone')
253
+ hardDisksLocal.value = newValue.map((hardDisk) => {
254
+ hardDisk.create = true
255
+ return hardDisk
256
+ })
257
+ }
258
+ },
259
+ { immediate: true }
260
+ )
261
+
262
+ const addHardDisk = (
263
+ create = true,
264
+ size = 90,
265
+ source = '',
266
+ type: UI_T_HardDiskType = 'new',
267
+ provisioned_type?: number // При добавлении существующей
268
+ ): void => {
269
+ const newIndex = (hardDisksIndex.value.at(-1) ?? -1) + 1
270
+ hardDisksIndex.value.push(newIndex)
271
+ hardDisksType.value.push(type)
272
+
273
+ let provisionType = 'thick'
274
+ if (provisioned_type === 1) provisionType = 'thin'
275
+
276
+ hardDisksLocal.value.push({
277
+ create,
278
+ size,
279
+ source,
280
+ attach: true,
281
+ boot_order: 0, // Убираем галочку
282
+ provision_type: provisionType,
283
+ })
284
+ sendData()
285
+ }
286
+ const onAddExistHardDisk = (file: UI_I_FileTreeNode): void => {
287
+ addHardDisk(
288
+ false,
289
+ $binary.bToGb(file.size),
290
+ file.path,
291
+ 'exist',
292
+ file.provisioned_type
293
+ )
294
+ }
295
+ const onRemoveHardDisk = (
296
+ index: number,
297
+ hardDisk: UI_I_SendDataNewHardDisk
298
+ ): void => {
299
+ const removeIndex = hardDisksIndex.value.indexOf(index)
300
+
301
+ if (!hardDisk.create && !hardDisk.attach) {
302
+ hardDisksType.value = hardDisksType.value.map((item, key) => {
303
+ if (key === removeIndex) return 'removed'
304
+ return item
305
+ })
306
+ sendData()
307
+ return
308
+ }
309
+
310
+ hardDisksIndex.value = hardDisksIndex.value.filter((item) => item !== index)
311
+ hardDisksType.value = hardDisksType.value.filter(
312
+ (_item, key) => key !== removeIndex
313
+ )
314
+
315
+ hardDisksLocal.value = hardDisksLocal.value.filter(
316
+ (_hardDisk, key: number) => {
317
+ return removeIndex !== key
318
+ }
319
+ )
320
+
321
+ delete newHardDiskInvalidKeys.value[index]
322
+ delete sendDataNewHardDisk.value[index]
323
+ sendData()
324
+ }
325
+ const onRollBackHardDisk = (index: number): void => {
326
+ const removeIndex = hardDisksIndex.value.indexOf(index)
327
+ hardDisksType.value = hardDisksType.value.map((item, key) => {
328
+ if (key === removeIndex) return 'edit'
329
+ return item
330
+ })
331
+ }
332
+
333
+ const defaultNetwork = {
334
+ network: '',
335
+ net_bridge: '',
336
+ mac: '',
337
+ target: '',
338
+ model: '',
339
+ boot_order: -1,
340
+ }
341
+ const networksLocal = ref<UI_I_SendDataNewNetwork[]>([
342
+ useDeepCopy(defaultNetwork),
343
+ ])
344
+ const networksType = ref<UI_T_NetworkType[]>(['new'])
345
+ const networksIndex = ref<number[]>([0])
346
+ watch(
347
+ () => props.networks,
348
+ (newValue) => {
349
+ if ((!props.isEdit && !props.isClone) || !newValue) return
350
+
351
+ // networksLocal.value = newValue
352
+ // networksType.value = Array(newValue.length).fill('edit')
353
+ const count = newValue?.length || 0
354
+ networksIndex.value = [...Array(count).keys()]
355
+ networksLocal.value = newValue
356
+ if (props.isEdit) {
357
+ networksType.value = Array(count).fill('edit')
358
+ } else if (props.isClone) {
359
+ networksType.value = Array(count).fill('clone')
360
+ }
361
+ },
362
+ { immediate: true }
363
+ )
364
+ const addNetwork = (): void => {
365
+ const index = (networksIndex.value.at(-1) ?? -1) + 1
366
+ networksIndex.value.push(index)
367
+ networksType.value.push('new')
368
+
369
+ networksLocal.value.push({
370
+ ...useDeepCopy(defaultNetwork),
371
+ boot_order: 0, // Убираем галочку
372
+ })
373
+ }
374
+ const onRemoveNetwork = (index: number): void => {
375
+ const removeIndex = networksIndex.value.indexOf(index)
376
+ networksIndex.value = networksIndex.value.filter((item) => item !== index)
377
+ networksType.value = networksType.value.filter(
378
+ (_item, key) => key !== removeIndex
379
+ )
380
+ networksLocal.value = networksLocal.value.filter(
381
+ (_network, key: number) => removeIndex !== key
382
+ )
383
+
384
+ delete newNetworkInvalidKeys.value[index]
385
+ delete sendDataNewNetwork.value[index]
386
+ sendData()
387
+ }
388
+
389
+ const defaultCdDvdDriver: UI_I_SendDataNewCdDvdDrive = {
390
+ create: false,
391
+ attach: false,
392
+ source: '',
393
+ bus: '',
394
+ device_type: 'cdrom',
395
+ boot_order: -1,
396
+ }
397
+ const cdDvdDrivesLocal = ref<UI_I_SendDataNewCdDvdDrive[]>([
398
+ useDeepCopy(defaultCdDvdDriver),
399
+ ])
400
+ const cdDvdDrivesIndex = ref<number[]>([0])
401
+ const cdDvdDrivesType = ref<UI_T_CdDvdType[]>(['new'])
402
+ watch(
403
+ () => props.cdDvdDrives,
404
+ (newValue) => {
405
+ if ((!props.isEdit && !props.isClone) || !newValue) return
406
+
407
+ // cdDvdDrivesLocal.value = newValue
408
+ // cdDvdDrivesType.value = Array(newValue.length).fill('edit')
409
+ const count = newValue?.length || 0
410
+ cdDvdDrivesIndex.value = [...Array(count).keys()]
411
+ cdDvdDrivesLocal.value = newValue
412
+ if (props.isEdit) {
413
+ cdDvdDrivesType.value = Array(count).fill('edit')
414
+ } else if (props.isClone) {
415
+ cdDvdDrivesType.value = Array(count).fill('new')
416
+ }
417
+ },
418
+ { immediate: true }
419
+ )
420
+ const addCdDvdDrive = (): void => {
421
+ const value = (cdDvdDrivesIndex.value.at(-1) ?? -1) + 1
422
+ cdDvdDrivesIndex.value.push(value)
423
+ cdDvdDrivesType.value.push('new')
424
+ cdDvdDrivesLocal.value.push({
425
+ ...useDeepCopy(defaultCdDvdDriver),
426
+ attach: true,
427
+ boot_order: 0, // Убираем галочку
428
+ })
429
+ }
430
+ const onRemoveCdDvdDrive = (
431
+ index: number,
432
+ cdDvdDrive: UI_I_SendDataNewCdDvdDrive
433
+ ): void => {
434
+ const removeIndex = cdDvdDrivesIndex.value.indexOf(index)
435
+
436
+ // if (!cdDvdDrive.create && !cdDvdDrive.attach) {
437
+ if (cdDvdDrivesType.value[index] === 'edit' && !cdDvdDrive.attach) {
438
+ cdDvdDrivesType.value = cdDvdDrivesType.value.map((item, key) => {
439
+ if (key === removeIndex) return 'removed'
440
+ return item
441
+ })
442
+ sendData()
443
+ return
444
+ }
445
+
446
+ cdDvdDrivesIndex.value = cdDvdDrivesIndex.value.filter(
447
+ (cdDvdDrive) => cdDvdDrive !== index
448
+ )
449
+ cdDvdDrivesType.value = cdDvdDrivesType.value.filter(
450
+ (_item, key) => key !== index
451
+ )
452
+ cdDvdDrivesLocal.value = cdDvdDrivesLocal.value.filter(
453
+ (_cdDvdDrive, key: number) => removeIndex !== key
454
+ )
455
+
456
+ delete sendDataNewCdDvdDrive.value[index]
457
+ sendData()
458
+ }
459
+ const onRollBackCdDvdDrive = (index: number): void => {
460
+ const removeIndex = cdDvdDrivesIndex.value.indexOf(index)
461
+ cdDvdDrivesType.value = cdDvdDrivesType.value.map((item, key) => {
462
+ if (key === removeIndex) return 'edit'
463
+ return item
464
+ })
465
+ }
466
+
467
+ const defaultPciDevice: UI_I_SendDataNewPciDevice = {
468
+ address: '',
469
+ vendor_name: '',
470
+ class_name: '',
471
+ device_name: '',
472
+ }
473
+ const pciDevicesIndex = ref<number[]>([0])
474
+ const pciDevicesType = ref<('new' | 'edit' | 'removed')[]>(['new'])
475
+ const pciDevicesLocal = ref<UI_I_SendDataNewPciDevice[]>([])
476
+ watch(
477
+ () => props.pciDevices,
478
+ (newValue) => {
479
+ if ((!props.isEdit && !props.isClone) || !newValue) return
480
+
481
+ const count = newValue?.length || 0
482
+ pciDevicesIndex.value = [...Array(count).keys()]
483
+ pciDevicesLocal.value = newValue || []
484
+ if (props.isEdit) {
485
+ pciDevicesType.value = Array(count).fill('edit')
486
+ } else if (props.isClone) {
487
+ pciDevicesType.value = Array(count).fill('new')
488
+ }
489
+ },
490
+ { immediate: true }
491
+ )
492
+
493
+ const addPciDevice = (): void => {
494
+ const newIndex = (pciDevicesIndex.value.at(-1) ?? -1) + 1
495
+ pciDevicesIndex.value.push(newIndex)
496
+ pciDevicesType.value.push('new')
497
+
498
+ pciDevicesLocal.value.push(useDeepCopy(defaultPciDevice))
499
+ }
500
+ const onRemovePciDevice = (index: number): void => {
501
+ const removeIndex = pciDevicesIndex.value.indexOf(index)
502
+ pciDevicesIndex.value = pciDevicesIndex.value.filter((item) => item !== index)
503
+ pciDevicesType.value = pciDevicesType.value.filter(
504
+ (_item, key) => key !== removeIndex
505
+ )
506
+
507
+ pciDevicesLocal.value = pciDevicesLocal.value.filter(
508
+ (_pciDevice, key: number) => {
509
+ return removeIndex !== key
510
+ }
511
+ )
512
+
513
+ delete newPciDeviceInvalidKeys.value[index]
514
+ delete sendDataNewPciDevices.value[index]
515
+ sendData()
516
+ }
517
+
518
+ const isShowFileModal = ref<boolean>(false)
519
+ const onAddDevice = (item: UI_I_DropdownTreeItemChild): void => {
520
+ switch (item.value) {
521
+ case 1:
522
+ addHardDisk()
523
+ break
524
+ case 2:
525
+ isShowFileModal.value = true
526
+ break
527
+ case 5:
528
+ addCdDvdDrive()
529
+ break
530
+ case 10:
531
+ addPciDevice()
532
+ break
533
+ case 14:
534
+ addNetwork()
535
+ break
536
+ }
537
+ }
538
+
539
+ const cpuInvalid = ref<boolean>(false)
540
+ const sendDataCpu = ref<UI_I_SendDataCpu | null>(null)
541
+ const onSendDataCpuMethod = (data: UI_I_SendDataCpu): void => {
542
+ sendDataCpu.value = data
543
+ sendData()
544
+ }
545
+ const sendDataMemory = ref<UI_I_SendDataMemory | null>(null)
546
+ const onSendDataMemoryMethod = (data: UI_I_SendDataMemory): void => {
547
+ sendDataMemory.value = data
548
+ sendData()
549
+ }
550
+ const sendDataNewHardDisk = ref<UI_I_SendDataNewHardDisk[]>([])
551
+ const onSendDataNewHardDiskMethod = (
552
+ data: UI_I_SendDataNewHardDisk,
553
+ index: number
554
+ ): void => {
555
+ sendDataNewHardDisk.value[index] = data
556
+ sendData()
557
+ }
558
+ const sendDataNewNetwork = ref<UI_I_SendDataNewNetwork[]>([])
559
+ const sendDataNewNetworkMethod = (
560
+ data: UI_I_SendDataNewNetwork,
561
+ index: number
562
+ ): void => {
563
+ sendDataNewNetwork.value[index] = data
564
+ sendData()
565
+ }
566
+ const sendDataNewCdDvdDrive = ref<UI_I_SendDataNewCdDvdDrive[]>([])
567
+ const sendDataNewCdDvdDriveMethod = (
568
+ data: UI_I_SendDataNewCdDvdDrive,
569
+ index: number
570
+ ): void => {
571
+ sendDataNewCdDvdDrive.value[index] = data
572
+ sendData()
573
+ }
574
+ const sendDataNewUsbController = ref<string | null>(null)
575
+ const onSendDataNewUsbControllerMethod = (data: string): void => {
576
+ sendDataNewUsbController.value = data
577
+ sendData()
578
+ }
579
+ const sendDataNewPciDevices = ref<UI_I_SendDataNewPciDevice[]>([])
580
+ const onSendDataPciDevicesMethod = (
581
+ data: UI_I_SendDataNewPciDevice,
582
+ index: number
583
+ ): void => {
584
+ sendDataNewPciDevices.value[index] = data
585
+ sendData()
586
+ }
587
+ const sendDataVideoCard = ref<UI_I_SendDataVideoCard | null>(null)
588
+ const onSendDataVideoCardMethod = (data: UI_I_SendDataVideoCard): void => {
589
+ sendDataVideoCard.value = data
590
+ sendData()
591
+ }
592
+
593
+ const sendData = (): void => {
594
+ const cpu = sendDataCpu.value
595
+ const memory = sendDataMemory.value
596
+ const hardDisks = sendDataNewHardDisk.value.flat(2)
597
+ const networks = sendDataNewNetwork.value.flat(2)
598
+ const cdDvdDrives = sendDataNewCdDvdDrive.value.flat(2)
599
+ const pciDevices = sendDataNewPciDevices.value.flat()
600
+ const usbController = sendDataNewUsbController.value
601
+ const videoCard = sendDataVideoCard.value
602
+
603
+ const sendData: UI_I_SendDataVirtualHardware = {
604
+ cpu,
605
+ memory,
606
+ usbController,
607
+ pciDevices,
608
+ networks,
609
+ hardDisks,
610
+ cdDvdDrives,
611
+ videoCard,
612
+ }
613
+ emits('send-data', sendData)
614
+ }
615
+
616
+ const onSetInvalidHardDisk = (invalid: boolean, index: number): void => {
617
+ newHardDiskInvalidKeys.value[index] = invalid
618
+ }
619
+
620
+ const onSetInvalidNetwork = (invalid: boolean, key: number): void => {
621
+ newNetworkInvalidKeys.value[key] = invalid
622
+ }
623
+
624
+ const onSetInvalidPciDevice = (invalid: boolean, key: number): void => {
625
+ newPciDeviceInvalidKeys.value[key] = invalid
626
+ }
627
+
628
+ const memoryInvalid = ref<boolean>(false)
629
+ const videoCardInvalid = ref<boolean>(false)
630
+ const newHardDiskInvalidKeys = ref<UI_I_InvalidKeys>({})
631
+ const newNetworkInvalidKeys = ref<UI_I_InvalidKeys>({})
632
+ const newPciDeviceInvalidKeys = ref<UI_I_InvalidKeys>({})
633
+
634
+ watch(
635
+ [
636
+ cpuInvalid,
637
+ memoryInvalid,
638
+ newHardDiskInvalidKeys,
639
+ newNetworkInvalidKeys,
640
+ newPciDeviceInvalidKeys,
641
+ videoCardInvalid,
642
+ ],
643
+ () => {
644
+ const cpu = cpuInvalid.value ? localization.value.common.cpu : ''
645
+ const memory = memoryInvalid.value ? localization.value.common.memory : ''
646
+ const videoCard = videoCardInvalid.value
647
+ ? localization.value.common.videoCard
648
+ : ''
649
+ let newHardDisk = ''
650
+ Object.keys(newHardDiskInvalidKeys.value).forEach((key) => {
651
+ if (!newHardDiskInvalidKeys.value[+key]) {
652
+ return
653
+ }
654
+
655
+ newHardDisk +=
656
+ (newHardDisk ? ', ' : '') +
657
+ localization.value.common.newHardDisk +
658
+ ' ' +
659
+ (+key + 1)
660
+ })
661
+ let newNetwork = ''
662
+ Object.keys(newNetworkInvalidKeys.value).forEach((key) => {
663
+ if (!newNetworkInvalidKeys.value[+key]) {
664
+ return
665
+ }
666
+
667
+ newNetwork +=
668
+ (newNetwork ? ', ' : '') +
669
+ localization.value.common.newNetwork +
670
+ ' ' +
671
+ (+key + 1)
672
+ })
673
+ // let pciDevice = ''
674
+ // Object.keys(newPciDeviceInvalidKeys.value).forEach((key) => {
675
+ // if (!newPciDeviceInvalidKeys.value[+key]) {
676
+ // return
677
+ // }
678
+ //
679
+ // pciDevice +=
680
+ // (pciDevice ? ', ' : '') +
681
+ // localization.value.common.pciDevice +
682
+ // ' ' +
683
+ // (+key + 1)
684
+ // })
685
+
686
+ emits('invalid', [cpu, memory, newHardDisk, newNetwork, videoCard])
687
+ },
688
+ { deep: true }
689
+ )
690
+
691
+ emits('get-pci-devices')
692
+ </script>
693
+
694
+ <style scoped lang="scss"></style>