bfg-common 1.5.577 → 1.5.578

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