bfg-common 1.5.572 → 1.5.573

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 (81) hide show
  1. package/assets/localization/local_be.json +6 -29
  2. package/assets/localization/local_en.json +6 -29
  3. package/assets/localization/local_hy.json +6 -29
  4. package/assets/localization/local_kk.json +6 -29
  5. package/assets/localization/local_ru.json +6 -29
  6. package/assets/localization/local_zh.json +7 -30
  7. package/components/common/diagramMain/DiagramMain.vue +1 -1
  8. package/components/common/modals/confirmByInput/ConfirmByInput.vue +1 -9
  9. package/components/common/modals/confirmByInput/ConfirmByInputNew.vue +2 -7
  10. package/components/common/monitor/overview/filters/lib/config/filterOptions.ts +0 -1
  11. package/components/common/pages/backups/modals/createBackup/CreateBackup.vue +1 -1
  12. package/components/common/pages/backups/modals/createBackup/New.vue +2 -8
  13. package/components/common/pages/backups/modals/createBackup/lib/config/steps.ts +1 -2
  14. package/components/common/pages/backups/modals/restore/Restore.vue +5 -9
  15. package/components/common/pages/backups/modals/restore/RestoreNew.vue +3 -13
  16. package/components/common/pages/backups/modals/restore/RestoreOld.vue +18 -6
  17. package/components/common/pages/scheduledTasks/table/Table.vue +1 -1
  18. package/components/common/vm/actions/add/Add.vue +52 -127
  19. package/components/common/vm/actions/add/New.vue +16 -54
  20. package/components/common/vm/actions/add/Old.vue +16 -55
  21. package/components/common/vm/actions/clone/Clone.vue +48 -121
  22. package/components/common/vm/actions/clone/new/New.vue +14 -50
  23. package/components/common/vm/actions/clone/old/Old.vue +16 -52
  24. package/components/common/vm/actions/common/customizeHardware/CustomizeHardware.vue +14 -81
  25. package/components/common/vm/actions/common/customizeHardware/CustomizeHardwareNew.vue +7 -56
  26. package/components/common/vm/actions/common/customizeHardware/CustomizeHardwareOld.vue +8 -56
  27. package/components/common/vm/actions/common/customizeHardware/virtualHardware/VirtualHardware.vue +208 -206
  28. package/components/common/vm/actions/common/customizeHardware/virtualHardware/VirtualHardwareNew.vue +223 -120
  29. package/components/common/vm/actions/common/customizeHardware/virtualHardware/VirtualHardwareOld.vue +218 -118
  30. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/CdDvdDrive.vue +66 -53
  31. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/lib/config/options.ts +1 -1
  32. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/Cpu.vue +139 -159
  33. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/CpuNew.vue +8 -15
  34. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/CpuOld.vue +8 -13
  35. package/components/common/vm/actions/common/customizeHardware/virtualHardware/memory/Memory.vue +62 -75
  36. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/NewHardDisk.vue +241 -149
  37. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/NewHardDiskNew.vue +3 -4
  38. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/NewHardDiskOld.vue +2 -3
  39. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/NewNetwork.vue +58 -96
  40. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newUsbController/NewUsbController.vue +6 -17
  41. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newUsbController/NewUsbControllerNew.vue +6 -3
  42. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newUsbController/NewUsbControllerOld.vue +6 -3
  43. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/VideoCard.vue +17 -39
  44. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/VideoCardNew.vue +6 -5
  45. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/VideoCardOld.vue +6 -5
  46. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/lib/config/options.ts +4 -4
  47. package/components/common/vm/actions/common/customizeHardware/vmoptions/Vmoptions.vue +6 -93
  48. package/components/common/vm/actions/common/customizeHardware/vmoptions/VmoptionsNew.vue +8 -62
  49. package/components/common/vm/actions/common/customizeHardware/vmoptions/VmoptionsOld.vue +8 -60
  50. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/BootOptions.vue +5 -69
  51. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/BootOptionsNew.vue +12 -32
  52. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/BootOptionsOld.vue +12 -33
  53. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/Order.vue +114 -132
  54. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/OrderNew.vue +41 -6
  55. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/OrderOld.vue +44 -6
  56. package/components/common/vm/actions/common/customizeHardware/vmoptions/generalOptions/GeneralOptions.vue +8 -23
  57. package/components/common/vm/actions/common/customizeHardware/vmoptions/generalOptions/GeneralOptionsNew.vue +21 -31
  58. package/components/common/vm/actions/common/customizeHardware/vmoptions/generalOptions/GeneralOptionsOld.vue +26 -34
  59. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/New.vue +28 -34
  60. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/Old.vue +24 -30
  61. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/RemoteConsoleOptions.vue +8 -112
  62. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/keymap/Keymap.vue +3 -3
  63. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/keymap/{KeymapNew.vue → New.vue} +6 -6
  64. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/keymap/{KeymapOld.vue → Old.vue} +5 -5
  65. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/password/Password.vue +6 -7
  66. package/components/common/vm/actions/common/customizeHardware/vmoptions/tools/Tools.vue +4 -38
  67. package/components/common/vm/actions/common/customizeHardware/vmoptions/tools/ToolsNew.vue +7 -26
  68. package/components/common/vm/actions/common/customizeHardware/vmoptions/tools/ToolsOld.vue +24 -50
  69. package/components/common/vm/actions/common/lib/models/interfaces.ts +57 -25
  70. package/components/common/vm/actions/common/select/os/New.vue +0 -19
  71. package/components/common/vm/actions/common/select/os/Old.vue +0 -34
  72. package/components/common/vm/actions/common/select/os/Os.vue +0 -25
  73. package/components/common/vm/actions/editSettings/EditSettings.vue +32 -90
  74. package/components/common/vm/actions/editSettings/EditSettingsOld.vue +14 -41
  75. package/components/common/vm/actions/editSettings/new/New.vue +14 -41
  76. package/components/common/vm/actions/lib/models/interfaces.ts +4 -29
  77. package/components/common/vm/actions/lib/utils.ts +64 -36
  78. package/package.json +1 -3
  79. package/store/tasks/mappers/recentTasks.ts +0 -4
  80. /package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/password/{PasswordNew.vue → New.vue} +0 -0
  81. /package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/password/{PasswordOld.vue → Old.vue} +0 -0
@@ -1,6 +1,7 @@
1
1
  <template>
2
2
  <common-vm-actions-common-customize-hardware-virtual-hardware-new
3
3
  v-if="isNewView"
4
+ v-model="model"
4
5
  v-model:cpu-invalid="cpuInvalid"
5
6
  v-model:memory-invalid="memoryInvalid"
6
7
  v-model:video-card-invalid="videoCardInvalid"
@@ -9,7 +10,6 @@
9
10
  :is-edit="props.isEdit"
10
11
  :storage="props.storage"
11
12
  :project="props.project"
12
- :max-cpus="props.maxCpus"
13
13
  :max-memory="props.maxMemory"
14
14
  :cpu-models="props.cpuModels"
15
15
  :datastore="props.datastore"
@@ -27,15 +27,9 @@
27
27
  :cd-dvd-drives-index="cdDvdDrivesIndex"
28
28
  :error-validation-fields="errorValidationFields"
29
29
  :get-datastore-table-func="getDatastoreTableFunc"
30
- :cpu="cpu"
31
30
  :state="state"
32
- :memory="memory"
33
- :networks="networksLocal"
34
- :hard-disks="hardDisksLocal"
35
31
  :video-card="videoCard"
36
32
  :pci-devices="pciDevicesLocal"
37
- :cd-dvd-drives="cdDvdDrivesLocal"
38
- :usb-controller="usbController"
39
33
  :guest-machine-type="guestMachineType"
40
34
  :passthrough-devices="passthroughDevices"
41
35
  :mediated-devices="mediatedDevices"
@@ -55,22 +49,18 @@
55
49
  @remove-cd-dvd-drive="onRemoveCdDvdDrive(...$event)"
56
50
  @show-datastore-child="emits('show-datastore-child', $event)"
57
51
  @get-folders-or-files="emits('get-folders-or-files', $event)"
58
- @send-data-cpu-method="onSendDataCpuMethod"
59
52
  @set-invalid-hard-disk="onSetInvalidHardDisk(...$event)"
60
53
  @remove-error-by-title="emits('remove-error-by-title', $event)"
61
54
  @roll-back-cd-dvd-drive="onRollBackCdDvdDrive"
62
55
  @set-invalid-pci-device="onSetInvalidPciDevice(...$event)"
63
56
  @get-active-device-child="emits('get-active-device-child', $event)"
64
- @send-data-memory-method="onSendDataMemoryMethod"
65
- @send-data-video-card-method="onSendDataVideoCardMethod"
66
- @send-data-new-network-method="sendDataNewNetworkMethod(...$event)"
67
57
  @send-data-pci-devices-method="onSendDataPciDevicesMethod(...$event)"
68
58
  @send-data-new-hard-disk-method="onSendDataNewHardDiskMethod(...$event)"
69
59
  @send-data-new-cd-dvd-drive-method="sendDataNewCdDvdDriveMethod(...$event)"
70
- @send-data-new-usb-controller-method="onSendDataNewUsbControllerMethod"
71
60
  />
72
61
  <common-vm-actions-common-customize-hardware-virtual-hardware-old
73
62
  v-else
63
+ v-model="model"
74
64
  v-model:cpu-invalid="cpuInvalid"
75
65
  v-model:memory-invalid="memoryInvalid"
76
66
  v-model:video-card-invalid="videoCardInvalid"
@@ -79,7 +69,6 @@
79
69
  :is-edit="props.isEdit"
80
70
  :storage="props.storage"
81
71
  :project="props.project"
82
- :max-cpus="props.maxCpus"
83
72
  :max-memory="props.maxMemory"
84
73
  :cpu-models="props.cpuModels"
85
74
  :datastore="props.datastore"
@@ -97,15 +86,9 @@
97
86
  :cd-dvd-drives-index="cdDvdDrivesIndex"
98
87
  :error-validation-fields="errorValidationFields"
99
88
  :get-datastore-table-func="getDatastoreTableFunc"
100
- :cpu="cpu"
101
89
  :state="state"
102
- :memory="memory"
103
- :networks="networksLocal"
104
- :hard-disks="hardDisksLocal"
105
90
  :video-card="videoCard"
106
91
  :pci-devices="pciDevicesLocal"
107
- :cd-dvd-drives="cdDvdDrivesLocal"
108
- :usb-controller="usbController"
109
92
  :guest-machine-type="guestMachineType"
110
93
  :passthrough-devices="passthroughDevices"
111
94
  :mediated-devices="mediatedDevices"
@@ -124,19 +107,14 @@
124
107
  @remove-cd-dvd-drive="onRemoveCdDvdDrive(...$event)"
125
108
  @show-datastore-child="emits('show-datastore-child', $event)"
126
109
  @get-folders-or-files="emits('get-folders-or-files', $event)"
127
- @send-data-cpu-method="onSendDataCpuMethod"
128
110
  @set-invalid-hard-disk="onSetInvalidHardDisk(...$event)"
129
111
  @remove-error-by-title="emits('remove-error-by-title', $event)"
130
112
  @roll-back-cd-dvd-drive="onRollBackCdDvdDrive"
131
113
  @set-invalid-pci-device="onSetInvalidPciDevice(...$event)"
132
114
  @get-active-device-child="emits('get-active-device-child', $event)"
133
- @send-data-memory-method="onSendDataMemoryMethod"
134
- @send-data-video-card-method="onSendDataVideoCardMethod"
135
- @send-data-new-network-method="sendDataNewNetworkMethod(...$event)"
136
115
  @send-data-pci-devices-method="onSendDataPciDevicesMethod(...$event)"
137
116
  @send-data-new-hard-disk-method="onSendDataNewHardDiskMethod(...$event)"
138
117
  @send-data-new-cd-dvd-drive-method="sendDataNewCdDvdDriveMethod(...$event)"
139
- @send-data-new-usb-controller-method="onSendDataNewUsbControllerMethod"
140
118
  />
141
119
  </template>
142
120
 
@@ -148,13 +126,9 @@ import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
148
126
  import type { UI_I_FolderOrFileTreePayload } from '~/lib/models/store/storage/interfaces'
149
127
  import type { UI_I_FileTreeNode } from '~/components/lib/models/interfaces'
150
128
  import type {
151
- UI_I_SendDataCpu,
152
- UI_I_SendDataMemory,
153
129
  UI_I_SendDataNewHardDisk,
154
- UI_I_SendDataNewNetwork,
155
130
  UI_I_SendDataVideoCard,
156
131
  UI_I_InvalidKeys,
157
- UI_I_SendDataVirtualHardware,
158
132
  UI_I_SendDataNewCdDvdDrive,
159
133
  // UI_I_HardDisk,
160
134
  UI_I_SendDataNewPciDevice,
@@ -172,23 +146,23 @@ import type {
172
146
  } from '~/components/atoms/dropdown/tree/lib/models/interfaces'
173
147
  import type { UI_I_Localization } from '~/lib/models/interfaces'
174
148
  import type {
175
- API_UI_I_VmEditCpu,
176
- API_UI_I_VmEditMemory,
177
149
  UI_I_MediatedDevice,
178
150
  UI_I_PciDevice,
179
151
  } from '~/lib/models/store/vm/interfaces'
180
152
  import type { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
153
+ import type { UI_I_CreateVmData } from '~/components/common/vm/actions/common/lib/models/interfaces'
181
154
  import { dropdownItemsFunc } from './lib/config/dropdownItems'
182
155
 
156
+ const model = defineModel<UI_I_CreateVmData>({ required: true })
157
+
183
158
  const props = withDefaults(
184
159
  defineProps<{
185
160
  storage: UI_I_DatastoreTableItem | null
186
161
  cpuModels: UI_I_OptionItem[]
187
- maxCpus: number
188
162
  maxMemory: number
189
163
  isEdit: boolean
190
164
  isClone: boolean
191
- errorValidationFields: UI_I_ErrorValidationField<string>[]
165
+ errorValidationFields: UI_I_ErrorValidationField[]
192
166
  nodes: UI_I_FileTreeNode[]
193
167
  files: UI_I_FileTreeNode[]
194
168
  networksTable: UI_I_NetworkTableItem[]
@@ -197,14 +171,10 @@ const props = withDefaults(
197
171
  isDatastoreLoading: boolean
198
172
  project: UI_T_Project
199
173
  state?: string | number
200
- cpu?: API_UI_I_VmEditCpu
201
- memory?: API_UI_I_VmEditMemory
202
174
  vmCpuHelpTextSecond?: string
203
175
  hardDisks?: UI_I_SendDataNewHardDisk[] | null
204
176
  cdDvdDrives?: UI_I_SendDataNewCdDvdDrive[] | null
205
- networks?: UI_I_SendDataNewNetwork[] | null
206
177
  videoCard?: UI_I_SendDataVideoCard
207
- usbController?: string
208
178
  pciDevices?: UI_I_SendDataNewPciDevice[]
209
179
  passthroughDevices?: UI_I_PciDevice[]
210
180
  mediatedDevices?: UI_I_MediatedDevice[]
@@ -214,14 +184,10 @@ const props = withDefaults(
214
184
  }>(),
215
185
  {
216
186
  state: undefined,
217
- cpu: undefined,
218
- memory: undefined,
219
187
  vmCpuHelpTextSecond: undefined,
220
188
  hardDisks: undefined,
221
189
  cdDvdDrives: undefined,
222
- networks: undefined,
223
190
  videoCard: undefined,
224
- usbController: undefined,
225
191
  pciDevices: undefined,
226
192
  passthroughDevices: undefined,
227
193
  mediatedDevices: undefined,
@@ -231,7 +197,6 @@ const props = withDefaults(
231
197
  }
232
198
  )
233
199
  const emits = defineEmits<{
234
- (event: 'send-data', value: UI_I_SendDataVirtualHardware): void
235
200
  (event: 'invalid', value: string[]): void
236
201
  (event: 'get-storage', value: UI_I_TablePayload): void
237
202
  (event: 'get-folders-or-files', value: UI_I_FolderOrFileTreePayload): void
@@ -258,38 +223,57 @@ const dropdownItems = computed<UI_I_DropdownTreeItem[]>(() =>
258
223
 
259
224
  const hardDisksIndex = ref<number[]>([0])
260
225
  const hardDisksType = ref<UI_T_HardDiskType[]>(['new'])
261
- const hardDisksLocal = ref<UI_I_SendDataNewHardDisk[]>([
262
- {
263
- create: true,
264
- size: 90,
265
- source: '',
266
- boot_order: -1,
267
- },
268
- ])
269
- watch(
270
- () => props.hardDisks,
271
- (newValue) => {
272
- if ((!props.isEdit && !props.isClone) || !newValue) return
226
+ // const hardDisksLocal = ref<UI_I_SendDataNewHardDisk[]>([
227
+ // {
228
+ // create: true,
229
+ // size: 90,
230
+ // source: '',
231
+ // boot_order: -1,
232
+ // },
233
+ // ])
234
+ if (!model.value.disk_devices?.length) {
235
+ hardDisksType.value = []
236
+ hardDisksIndex.value = []
237
+ } else {
238
+ model.value.disk_devices
239
+ .filter((disk) => disk.device_type !== 'cdrom')
240
+ .forEach((_disk, _index, array) => {
241
+ if (!props.isEdit && !props.isClone) return
242
+
243
+ const count = array.length
244
+ hardDisksIndex.value = [...Array(count).keys()]
245
+ if (props.isEdit) {
246
+ hardDisksType.value = Array(count).fill('edit')
247
+ } else if (props.isClone) {
248
+ hardDisksType.value = Array(count).fill('clone')
249
+ }
250
+ })
251
+ }
273
252
 
274
- const count = newValue?.length || 0
275
- hardDisksIndex.value = [...Array(count).keys()]
276
- hardDisksLocal.value = newValue
277
- if (props.isEdit) {
278
- hardDisksType.value = Array(count).fill('edit')
279
- } else if (props.isClone) {
280
- hardDisksType.value = Array(count).fill('clone')
281
- hardDisksLocal.value = newValue.map((hardDisk) => {
282
- hardDisk.create = true
283
- return hardDisk
284
- })
285
- }
286
- },
287
- { immediate: true }
288
- )
253
+ // watch(
254
+ // () => props.hardDisks,
255
+ // (newValue) => {
256
+ // if ((!props.isEdit && !props.isClone) || !newValue) return
257
+ //
258
+ // const count = newValue?.length || 0
259
+ // hardDisksIndex.value = [...Array(count).keys()]
260
+ // hardDisksLocal.value = newValue
261
+ // if (props.isEdit) {
262
+ // hardDisksType.value = Array(count).fill('edit')
263
+ // } else if (props.isClone) {
264
+ // hardDisksType.value = Array(count).fill('clone')
265
+ // hardDisksLocal.value = newValue.map((hardDisk) => {
266
+ // hardDisk.create = true
267
+ // return hardDisk
268
+ // })
269
+ // }
270
+ // },
271
+ // { immediate: true }
272
+ // )
289
273
 
290
274
  const addHardDisk = (
291
275
  create = true,
292
- size = 90,
276
+ size = 92_160, // 90GB
293
277
  source = '',
294
278
  type: UI_T_HardDiskType = 'new',
295
279
  provisioned_type?: number // При добавлении существующей
@@ -301,15 +285,43 @@ const addHardDisk = (
301
285
  let provisionType = 'thick'
302
286
  if (provisioned_type === 1) provisionType = 'thin'
303
287
 
304
- hardDisksLocal.value.push({
305
- create,
306
- size,
307
- source,
308
- attach: true,
309
- boot_order: 0, // Убираем галочку
310
- provision_type: provisionType,
311
- })
312
- sendData()
288
+ model.value.disk_devices = [
289
+ ...model.value.disk_devices.filter((disk) => disk.device_type !== 'cdrom'),
290
+ // {
291
+ // create,
292
+ // size,
293
+ // source,
294
+ // attach: true,
295
+ // boot_order: 0, // Убираем галочку
296
+ // provision_type: provisionType,
297
+ // },
298
+ {
299
+ create,
300
+ size,
301
+ source,
302
+ bus: 'virtio',
303
+ storage_id: '',
304
+ provision_type: 'thick',
305
+ disk_mode: 'dependent',
306
+ boot_order: 0, // Убираем галочку
307
+ device_type: 'disk',
308
+ sharing: false,
309
+ shares: 0,
310
+ cache: 'none',
311
+ io: '',
312
+ limit_iops: 0,
313
+ attach: true,
314
+ },
315
+ ...model.value.disk_devices.filter((disk) => disk.device_type === 'cdrom'),
316
+ ]
317
+ // hardDisksLocal.value.push({
318
+ // create,
319
+ // size,
320
+ // source,
321
+ // attach: true,
322
+ // boot_order: 0, // Убираем галочку
323
+ // provision_type: provisionType,
324
+ // })
313
325
  }
314
326
  const onAddExistHardDisk = (file: UI_I_FileTreeNode): void => {
315
327
  addHardDisk(
@@ -331,7 +343,6 @@ const onRemoveHardDisk = (
331
343
  if (key === removeIndex) return 'removed'
332
344
  return item
333
345
  })
334
- sendData()
335
346
  return
336
347
  }
337
348
 
@@ -340,15 +351,18 @@ const onRemoveHardDisk = (
340
351
  (_item, key) => key !== removeIndex
341
352
  )
342
353
 
343
- hardDisksLocal.value = hardDisksLocal.value.filter(
354
+ model.value.disk_devices = model.value.disk_devices.filter(
344
355
  (_hardDisk, key: number) => {
345
356
  return removeIndex !== key
346
357
  }
347
358
  )
359
+ // hardDisksLocal.value = hardDisksLocal.value.filter(
360
+ // (_hardDisk, key: number) => {
361
+ // return removeIndex !== key
362
+ // }
363
+ // )
348
364
 
349
365
  delete newHardDiskInvalidKeys.value[index]
350
- delete sendDataNewHardDisk.value[index]
351
- sendData()
352
366
  }
353
367
  const onRollBackHardDisk = (index: number): void => {
354
368
  const removeIndex = hardDisksIndex.value.indexOf(index)
@@ -358,51 +372,40 @@ const onRollBackHardDisk = (index: number): void => {
358
372
  })
359
373
  }
360
374
 
361
- const defaultNetwork = {
362
- network: '',
363
- net_bridge: '',
364
- mac: '',
365
- target: '',
366
- model: '',
367
- boot_order: -1,
368
- }
369
- const networksLocal = ref<UI_I_SendDataNewNetwork[]>([
370
- useDeepCopy(defaultNetwork),
371
- ])
372
375
  const networksType = ref<UI_T_NetworkType[]>(['new'])
373
376
  const networksIndex = ref<number[]>([0])
374
- watch(
375
- () => props.networks,
376
- (newValue) => {
377
+ if (!model.value.network_devices?.length) {
378
+ networksType.value = []
379
+ networksIndex.value = []
380
+ } else {
381
+ model.value.network_devices.forEach(() => {
377
382
  if (!props.isEdit && !props.isClone) return
378
- if (!newValue) {
379
- networksLocal.value = []
380
- networksType.value = []
381
- networksIndex.value = []
382
- return
383
- }
384
383
 
385
- // networksLocal.value = newValue
386
- // networksType.value = Array(newValue.length).fill('edit')
387
- const count = newValue?.length || 0
384
+ const count = model.value.network_devices.length || 0
388
385
  networksIndex.value = [...Array(count).keys()]
389
- networksLocal.value = newValue
390
386
  if (props.isEdit) {
391
387
  networksType.value = Array(count).fill('edit')
392
388
  } else if (props.isClone) {
393
389
  networksType.value = Array(count).fill('clone')
394
390
  }
395
- },
396
- { immediate: true }
397
- )
391
+ })
392
+ }
393
+
394
+ const defaultNetwork = {
395
+ network: '',
396
+ net_bridge: '',
397
+ mac: '',
398
+ target: '',
399
+ model: 'rtl8139',
400
+ boot_order: 0,
401
+ }
398
402
  const addNetwork = (): void => {
399
403
  const index = (networksIndex.value.at(-1) ?? -1) + 1
400
404
  networksIndex.value.push(index)
401
405
  networksType.value.push('new')
402
406
 
403
- networksLocal.value.push({
407
+ model.value.network_devices.push({
404
408
  ...useDeepCopy(defaultNetwork),
405
- boot_order: 0, // Убираем галочку
406
409
  })
407
410
  }
408
411
  const onRemoveNetwork = (index: number): void => {
@@ -411,55 +414,97 @@ const onRemoveNetwork = (index: number): void => {
411
414
  networksType.value = networksType.value.filter(
412
415
  (_item, key) => key !== removeIndex
413
416
  )
414
- networksLocal.value = networksLocal.value.filter(
417
+ model.value.network_devices = model.value.network_devices.filter(
415
418
  (_network, key: number) => removeIndex !== key
416
419
  )
417
420
 
418
421
  delete newNetworkInvalidKeys.value[index]
419
- delete sendDataNewNetwork.value[index]
420
- sendData()
421
422
  }
422
423
 
424
+ // const defaultCdDvdDriver: UI_I_SendDataNewCdDvdDrive = {
425
+ // create: false,
426
+ // attach: false,
427
+ // source: '',
428
+ // bus: '',
429
+ // device_type: 'cdrom',
430
+ // boot_order: -1,
431
+ // }
423
432
  const defaultCdDvdDriver: UI_I_SendDataNewCdDvdDrive = {
424
- create: false,
425
- attach: false,
426
433
  source: '',
427
- bus: '',
434
+ storage_id: '',
428
435
  device_type: 'cdrom',
429
- boot_order: -1,
436
+ bus: '',
437
+ target: '',
438
+ boot_order: 0,
439
+ provision_type: 'thick',
440
+ disk_mode: 'dependent',
441
+ sharing: false,
442
+ read_only: true,
443
+ shares: 0,
444
+ cache: 'none',
445
+ io: 'native',
446
+ limit_iops: 0,
447
+ discard: 'unmap',
448
+ attach: false,
449
+ detach: false,
450
+ remove: false,
451
+ create: false,
430
452
  }
431
- const cdDvdDrivesLocal = ref<UI_I_SendDataNewCdDvdDrive[]>([
432
- useDeepCopy(defaultCdDvdDriver),
433
- ])
453
+ // const cdDvdDrivesLocal = ref<UI_I_SendDataNewCdDvdDrive[]>([
454
+ // useDeepCopy(defaultCdDvdDriver),
455
+ // ])
434
456
  const cdDvdDrivesIndex = ref<number[]>([0])
435
457
  const cdDvdDrivesType = ref<UI_T_CdDvdType[]>(['new'])
436
- watch(
437
- () => props.cdDvdDrives,
438
- (newValue) => {
439
- if ((!props.isEdit && !props.isClone) || !newValue) return
440
-
441
- // cdDvdDrivesLocal.value = newValue
442
- // cdDvdDrivesType.value = Array(newValue.length).fill('edit')
443
- const count = newValue?.length || 0
444
- cdDvdDrivesIndex.value = [...Array(count).keys()]
445
- cdDvdDrivesLocal.value = newValue
446
- if (props.isEdit) {
447
- cdDvdDrivesType.value = Array(count).fill('edit')
448
- } else if (props.isClone) {
449
- cdDvdDrivesType.value = Array(count).fill('new')
450
- }
451
- },
452
- { immediate: true }
453
- )
458
+ if (!model.value.disk_devices?.length) {
459
+ cdDvdDrivesIndex.value = []
460
+ cdDvdDrivesType.value = []
461
+ } else {
462
+ model.value.disk_devices
463
+ .filter((disk) => disk.device_type === 'cdrom')
464
+ .forEach((_disk, _index, array) => {
465
+ if (!props.isEdit && !props.isClone) return
466
+
467
+ const count = array.length
468
+ cdDvdDrivesIndex.value = [...Array(count).keys()]
469
+ if (props.isEdit) {
470
+ cdDvdDrivesType.value = Array(count).fill('edit')
471
+ } else if (props.isClone) {
472
+ cdDvdDrivesType.value = Array(count).fill('clone')
473
+ }
474
+ })
475
+ }
476
+ // watch(
477
+ // () => props.cdDvdDrives,
478
+ // (newValue) => {
479
+ // if ((!props.isEdit && !props.isClone) || !newValue) return
480
+ //
481
+ // // cdDvdDrivesLocal.value = newValue
482
+ // // cdDvdDrivesType.value = Array(newValue.length).fill('edit')
483
+ // const count = newValue?.length || 0
484
+ // cdDvdDrivesIndex.value = [...Array(count).keys()]
485
+ // cdDvdDrivesLocal.value = newValue
486
+ // if (props.isEdit) {
487
+ // cdDvdDrivesType.value = Array(count).fill('edit')
488
+ // } else if (props.isClone) {
489
+ // cdDvdDrivesType.value = Array(count).fill('new')
490
+ // }
491
+ // },
492
+ // { immediate: true }
493
+ // )
454
494
  const addCdDvdDrive = (): void => {
455
495
  const value = (cdDvdDrivesIndex.value.at(-1) ?? -1) + 1
456
496
  cdDvdDrivesIndex.value.push(value)
457
497
  cdDvdDrivesType.value.push('new')
458
- cdDvdDrivesLocal.value.push({
498
+ model.value.disk_devices.push({
459
499
  ...useDeepCopy(defaultCdDvdDriver),
460
500
  attach: true,
461
501
  boot_order: 0, // Убираем галочку
462
502
  })
503
+ // cdDvdDrivesLocal.value.push({
504
+ // ...useDeepCopy(defaultCdDvdDriver),
505
+ // attach: true,
506
+ // boot_order: 0, // Убираем галочку
507
+ // })
463
508
  }
464
509
  const onRemoveCdDvdDrive = (
465
510
  index: number,
@@ -473,7 +518,6 @@ const onRemoveCdDvdDrive = (
473
518
  if (key === removeIndex) return 'removed'
474
519
  return item
475
520
  })
476
- sendData()
477
521
  return
478
522
  }
479
523
 
@@ -483,12 +527,12 @@ const onRemoveCdDvdDrive = (
483
527
  cdDvdDrivesType.value = cdDvdDrivesType.value.filter(
484
528
  (_item, key) => key !== index
485
529
  )
486
- cdDvdDrivesLocal.value = cdDvdDrivesLocal.value.filter(
530
+ model.value.disk_devices = model.value.disk_devices.filter(
487
531
  (_cdDvdDrive, key: number) => removeIndex !== key
488
532
  )
489
-
490
- delete sendDataNewCdDvdDrive.value[index]
491
- sendData()
533
+ // cdDvdDrivesLocal.value = cdDvdDrivesLocal.value.filter(
534
+ // (_cdDvdDrive, key: number) => removeIndex !== key
535
+ // )
492
536
  }
493
537
  const onRollBackCdDvdDrive = (index: number): void => {
494
538
  const removeIndex = cdDvdDrivesIndex.value.indexOf(index)
@@ -530,6 +574,7 @@ const addPciDevice = (): void => {
530
574
  pciDevicesType.value.push('new')
531
575
 
532
576
  pciDevicesLocal.value.push(useDeepCopy(defaultPciDevice))
577
+ model.value.passthrough_pci_devices.push(useDeepCopy(defaultPciDevice))
533
578
  }
534
579
  const onRemovePciDevice = (index: number): void => {
535
580
  const removeIndex = pciDevicesIndex.value.indexOf(index)
@@ -538,6 +583,10 @@ const onRemovePciDevice = (index: number): void => {
538
583
  (_item, key) => key !== removeIndex
539
584
  )
540
585
 
586
+ model.value.passthrough_pci_devices =
587
+ model.value.passthrough_pci_devices.filter((_pciDevice, key: number) => {
588
+ return removeIndex !== key
589
+ })
541
590
  pciDevicesLocal.value = pciDevicesLocal.value.filter(
542
591
  (_pciDevice, key: number) => {
543
592
  return removeIndex !== key
@@ -545,8 +594,6 @@ const onRemovePciDevice = (index: number): void => {
545
594
  )
546
595
 
547
596
  delete newPciDeviceInvalidKeys.value[index]
548
- delete sendDataNewPciDevices.value[index]
549
- sendData()
550
597
  }
551
598
 
552
599
  const isShowFileModal = ref<boolean>(false)
@@ -571,80 +618,35 @@ const onAddDevice = (item: UI_I_DropdownTreeItemChild): void => {
571
618
  }
572
619
 
573
620
  const cpuInvalid = ref<boolean>(false)
574
- const sendDataCpu = ref<UI_I_SendDataCpu | null>(null)
575
- const onSendDataCpuMethod = (data: UI_I_SendDataCpu): void => {
576
- sendDataCpu.value = data
577
- sendData()
578
- }
579
- const sendDataMemory = ref<UI_I_SendDataMemory | null>(null)
580
- const onSendDataMemoryMethod = (data: UI_I_SendDataMemory): void => {
581
- sendDataMemory.value = data
582
- sendData()
583
- }
584
- const sendDataNewHardDisk = ref<UI_I_SendDataNewHardDisk[]>([])
585
621
  const onSendDataNewHardDiskMethod = (
586
622
  data: UI_I_SendDataNewHardDisk,
587
623
  index: number
588
624
  ): void => {
589
- sendDataNewHardDisk.value[index] = data
590
- sendData()
591
- }
592
- const sendDataNewNetwork = ref<UI_I_SendDataNewNetwork[]>([])
593
- const sendDataNewNetworkMethod = (
594
- data: UI_I_SendDataNewNetwork,
595
- index: number
596
- ): void => {
597
- sendDataNewNetwork.value[index] = data
598
- sendData()
625
+ model.value.disk_devices[index] = {
626
+ ...data,
627
+ boot_order: model.value.disk_devices[index]?.boot_order || 0,
628
+ }
599
629
  }
600
- const sendDataNewCdDvdDrive = ref<UI_I_SendDataNewCdDvdDrive[]>([])
601
630
  const sendDataNewCdDvdDriveMethod = (
602
631
  data: UI_I_SendDataNewCdDvdDrive,
603
632
  index: number
604
633
  ): void => {
605
- sendDataNewCdDvdDrive.value[index] = data
606
- sendData()
607
- }
608
- const sendDataNewUsbController = ref<string | null>(null)
609
- const onSendDataNewUsbControllerMethod = (data: string): void => {
610
- sendDataNewUsbController.value = data
611
- sendData()
634
+ const cdromIndexStart = model.value.disk_devices.findIndex(
635
+ (disk) => disk.device_type === 'cdrom'
636
+ )
637
+ model.value.disk_devices[cdromIndexStart + index] = {
638
+ ...data,
639
+ boot_order:
640
+ model.value.disk_devices[cdromIndexStart + index]?.boot_order || 0,
641
+ }
612
642
  }
613
- const sendDataNewPciDevices = ref<UI_I_SendDataNewPciDevice[]>([])
614
643
  const onSendDataPciDevicesMethod = (
615
644
  data: UI_I_SendDataNewPciDevice,
616
645
  index: number
617
646
  ): void => {
618
- sendDataNewPciDevices.value[index] = data
619
- sendData()
620
- }
621
- const sendDataVideoCard = ref<UI_I_SendDataVideoCard | null>(null)
622
- const onSendDataVideoCardMethod = (data: UI_I_SendDataVideoCard): void => {
623
- sendDataVideoCard.value = data
624
- sendData()
625
- }
626
-
627
- const sendData = (): void => {
628
- const cpu = sendDataCpu.value
629
- const memory = sendDataMemory.value
630
- const hardDisks = sendDataNewHardDisk.value.flat(2)
631
- const networks = sendDataNewNetwork.value.flat(2)
632
- const cdDvdDrives = sendDataNewCdDvdDrive.value.flat(2)
633
- const pciDevices = sendDataNewPciDevices.value.flat()
634
- const usbController = sendDataNewUsbController.value
635
- const videoCard = sendDataVideoCard.value
636
-
637
- const sendData: UI_I_SendDataVirtualHardware = {
638
- cpu,
639
- memory,
640
- usbController,
641
- pciDevices,
642
- networks,
643
- hardDisks,
644
- cdDvdDrives,
645
- videoCard,
647
+ model.value.passthrough_pci_devices[index] = {
648
+ ...data,
646
649
  }
647
- emits('send-data', sendData)
648
650
  }
649
651
 
650
652
  const onSetInvalidHardDisk = (invalid: boolean, index: number): void => {