bfg-common 1.5.580 → 1.5.581

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 (57) hide show
  1. package/components/common/vm/actions/add/Add.vue +120 -46
  2. package/components/common/vm/actions/add/New.vue +54 -16
  3. package/components/common/vm/actions/add/Old.vue +55 -16
  4. package/components/common/vm/actions/clone/Clone.vue +116 -44
  5. package/components/common/vm/actions/clone/new/New.vue +50 -14
  6. package/components/common/vm/actions/clone/old/Old.vue +52 -16
  7. package/components/common/vm/actions/common/customizeHardware/CustomizeHardware.vue +81 -14
  8. package/components/common/vm/actions/common/customizeHardware/CustomizeHardwareNew.vue +56 -7
  9. package/components/common/vm/actions/common/customizeHardware/CustomizeHardwareOld.vue +56 -8
  10. package/components/common/vm/actions/common/customizeHardware/virtualHardware/VirtualHardware.vue +206 -211
  11. package/components/common/vm/actions/common/customizeHardware/virtualHardware/VirtualHardwareNew.vue +120 -225
  12. package/components/common/vm/actions/common/customizeHardware/virtualHardware/VirtualHardwareOld.vue +118 -220
  13. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/CdDvdDrive.vue +53 -66
  14. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/Cpu.vue +159 -139
  15. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/CpuNew.vue +15 -8
  16. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/CpuOld.vue +13 -8
  17. package/components/common/vm/actions/common/customizeHardware/virtualHardware/memory/Memory.vue +75 -62
  18. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/NewHardDisk.vue +149 -241
  19. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/NewHardDiskNew.vue +4 -3
  20. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/NewHardDiskOld.vue +3 -2
  21. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/NewNetwork.vue +100 -62
  22. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newUsbController/NewUsbController.vue +17 -6
  23. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newUsbController/NewUsbControllerNew.vue +3 -6
  24. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newUsbController/NewUsbControllerOld.vue +3 -6
  25. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/VideoCard.vue +39 -17
  26. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/VideoCardNew.vue +5 -6
  27. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/VideoCardOld.vue +5 -6
  28. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/lib/config/options.ts +4 -4
  29. package/components/common/vm/actions/common/customizeHardware/vmoptions/Vmoptions.vue +93 -6
  30. package/components/common/vm/actions/common/customizeHardware/vmoptions/VmoptionsNew.vue +60 -8
  31. package/components/common/vm/actions/common/customizeHardware/vmoptions/VmoptionsOld.vue +58 -8
  32. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/BootOptions.vue +69 -5
  33. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/BootOptionsNew.vue +32 -12
  34. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/BootOptionsOld.vue +33 -12
  35. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/Order.vue +132 -114
  36. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/OrderNew.vue +6 -41
  37. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/OrderOld.vue +6 -44
  38. package/components/common/vm/actions/common/customizeHardware/vmoptions/generalOptions/GeneralOptions.vue +23 -8
  39. package/components/common/vm/actions/common/customizeHardware/vmoptions/generalOptions/GeneralOptionsNew.vue +31 -21
  40. package/components/common/vm/actions/common/customizeHardware/vmoptions/generalOptions/GeneralOptionsOld.vue +34 -26
  41. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/New.vue +34 -28
  42. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/Old.vue +30 -24
  43. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/RemoteConsoleOptions.vue +112 -8
  44. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/keymap/Keymap.vue +3 -3
  45. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/keymap/{New.vue → KeymapNew.vue} +6 -6
  46. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/keymap/{Old.vue → KeymapOld.vue} +5 -5
  47. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/password/Password.vue +7 -6
  48. package/components/common/vm/actions/common/customizeHardware/vmoptions/tools/Tools.vue +27 -9
  49. package/components/common/vm/actions/common/lib/models/interfaces.ts +25 -58
  50. package/components/common/vm/actions/editSettings/EditSettings.vue +90 -32
  51. package/components/common/vm/actions/editSettings/EditSettingsOld.vue +41 -14
  52. package/components/common/vm/actions/editSettings/new/New.vue +41 -14
  53. package/components/common/vm/actions/lib/models/interfaces.ts +29 -4
  54. package/components/common/vm/actions/lib/utils.ts +36 -64
  55. package/package.json +1 -1
  56. /package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/password/{New.vue → PasswordNew.vue} +0 -0
  57. /package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/password/{Old.vue → PasswordOld.vue} +0 -0
@@ -1,9 +1,9 @@
1
1
  <template>
2
2
  <common-vm-actions-common-customize-hardware-virtual-hardware-new-network-new
3
3
  v-if="isNewView"
4
- v-model:selected-location="networkValue"
5
- v-model:adapter-type="model"
6
- v-model:mac-address="mac"
4
+ v-model:selected-location="selectedLocation"
5
+ v-model:adapter-type="adapterType"
6
+ v-model:mac-address="macAddress"
7
7
  v-model:mac-address-type="macAddressType"
8
8
  v-model:new-network-invalid="newNetworkInvalid"
9
9
  :index="props.index"
@@ -26,9 +26,9 @@
26
26
  />
27
27
  <common-vm-actions-common-customize-hardware-virtual-hardware-new-network-old
28
28
  v-else
29
- v-model:selected-location="networkValue"
30
- v-model:adapter-type="model"
31
- v-model:mac-address="mac"
29
+ v-model:selected-location="selectedLocation"
30
+ v-model:adapter-type="adapterType"
31
+ v-model:mac-address="macAddress"
32
32
  v-model:mac-address-type="macAddressType"
33
33
  v-model:new-network-invalid="newNetworkInvalid"
34
34
  :index="props.index"
@@ -56,38 +56,23 @@ import type { UI_T_Project } from '~/lib/models/types'
56
56
  import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
57
57
  import type { UI_I_NetworkTableItem } from '~/lib/models/store/network/interfaces'
58
58
  import type { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
59
+ import type { UI_I_SendDataNewNetwork } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
59
60
  import type { UI_T_NetworkType } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/types'
60
61
  import type {
61
62
  UI_I_Localization,
62
63
  UI_I_HTMLSelectElement,
63
64
  } from '~/lib/models/interfaces'
64
65
  import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
65
- import type { UI_I_CreateVmData } from '~/components/common/vm/actions/common/lib/models/interfaces'
66
-
67
- const network = defineModel<UI_I_CreateVmData['network_devices'][0]['network']>(
68
- 'network',
69
- { required: true }
70
- )
71
-
72
- const mac = defineModel<UI_I_CreateVmData['network_devices'][0]['mac']>('mac', {
73
- required: true,
74
- })
75
- const model = defineModel<UI_I_CreateVmData['network_devices'][0]['model']>(
76
- 'model',
77
- {
78
- required: true,
79
- }
80
- )
81
66
 
82
67
  const props = withDefaults(
83
68
  defineProps<{
84
69
  project: UI_T_Project
85
70
  index: number
86
71
  type: UI_T_NetworkType
72
+ network: UI_I_SendDataNewNetwork
87
73
  networksTable: UI_I_NetworkTableItem[]
88
74
  errorValidationFields: UI_I_ErrorValidationField[]
89
75
  isEdit: boolean
90
- networkValueProp: 'network' | 'net_bridge'
91
76
  state?: string | number
92
77
  }>(),
93
78
  {
@@ -95,27 +80,18 @@ const props = withDefaults(
95
80
  }
96
81
  )
97
82
  const emits = defineEmits<{
83
+ (event: 'send-data', value: UI_I_SendDataNewNetwork): void
98
84
  (event: 'invalid', value: boolean): void
99
85
  (event: 'remove'): void
100
86
  (event: 'remove-error-by-title', value: string): void
101
87
  (event: 'get-networks-table', value: UI_I_TablePayload): void
102
88
  }>()
103
89
 
104
- const networkValue = defineModel<
105
- UI_I_CreateVmData['network_devices'][0][props.networkValueProp]
106
- >('networkValue', { required: true })
107
- watch(networkValue, (newValue) => {
108
- const selectedOption = locationOptions.value.find(
109
- (option) => option.value === newValue
110
- )
111
- if (selectedOption) {
112
- network.value = selectedOption.text
113
- }
114
- })
115
-
116
90
  const { $store }: any = useNuxtApp()
117
91
  const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
118
92
 
93
+ const valueProp = props.project === 'sphere' ? 'network' : 'net_bridge'
94
+
119
95
  const localization = computed<UI_I_Localization>(() => useLocal())
120
96
 
121
97
  const isRunning = computed<boolean>(() => {
@@ -126,7 +102,7 @@ const isRemovable = computed<boolean>(() => {
126
102
  return (
127
103
  !props.isEdit ||
128
104
  !isRunning.value ||
129
- (isRunning.value && model.value === 'virtio')
105
+ (isRunning.value && adapterType.value === 'virtio')
130
106
  )
131
107
  })
132
108
 
@@ -142,15 +118,9 @@ const label = computed<string>(() => {
142
118
  // }
143
119
 
144
120
  const selectedLocationOld = ref<string>('')
121
+ const selectedLocation = ref<string>('')
145
122
  const locationOptions = ref<UI_I_OptionItem[]>([])
146
123
 
147
- if (networkValue.value) {
148
- locationOptions.value = [
149
- { text: network.value, value: networkValue.value },
150
- { text: `${localization.value.common.browse}...`, value: '' },
151
- ]
152
- }
153
-
154
124
  const getNetworks = (): void => {
155
125
  // if (props.networksTable.length) return // Из-за этого кода был баг. Открыть визард вм -> создать сеть -> открыть визард вм и в списке сетей нету новой сети
156
126
 
@@ -179,8 +149,9 @@ watch(
179
149
  watch(
180
150
  () => props.networksTable,
181
151
  (newValue) => {
182
- if (!newValue.length && props.type !== 'new') return
183
-
152
+ const isExistValue = newValue.some(
153
+ (network) => network[valueProp] === selectedLocation.value
154
+ )
184
155
  if (!newValue.length) {
185
156
  locationOptions.value = [
186
157
  {
@@ -188,33 +159,29 @@ watch(
188
159
  value: 'noAvailableNetworks',
189
160
  },
190
161
  ]
191
- networkValue.value = 'noAvailableNetworks'
162
+ selectedLocation.value = 'noAvailableNetworks'
192
163
  newNetworkInvalid.value = true
193
164
  return
194
165
  }
195
166
  newNetworkInvalid.value = false
196
167
 
197
- const isExistValue = newValue.some(
198
- (networkLocal) => networkLocal[props.networkValueProp] === networkValue.value
199
- )
200
-
201
168
  if (props.type === 'edit' || isExistValue) return
202
169
 
203
- selectedLocationOld.value = newValue[0][props.networkValueProp] || ''
204
- networkValue.value = newValue[0][props.networkValueProp] || ''
170
+ selectedLocationOld.value = newValue[0][valueProp] || ''
171
+ selectedLocation.value = newValue[0][valueProp] || ''
205
172
 
206
173
  locationOptions.value = [
207
- { text: newValue[0].name, value: newValue[0][props.networkValueProp] },
174
+ { text: newValue[0].name, value: newValue[0][valueProp] },
208
175
  { text: `${localization.value.common.browse}...`, value: '' },
209
176
  ]
210
177
  },
211
- { immediate: true, deep: true }
178
+ { immediate: true }
212
179
  )
213
180
 
214
181
  const locationModalIsShow = ref<boolean>(false)
215
182
  const onHideLocationModal = (): void => {
216
183
  locationModalIsShow.value = false
217
- networkValue.value = selectedLocationOld.value
184
+ selectedLocation.value = selectedLocationOld.value
218
185
  }
219
186
  const changeLocation = (event: UI_I_HTMLSelectElement): void => {
220
187
  const value = event.target.value
@@ -224,16 +191,17 @@ const changeLocation = (event: UI_I_HTMLSelectElement): void => {
224
191
  }
225
192
 
226
193
  selectedLocationOld.value = value
227
- networkValue.value = value
194
+ selectedLocation.value = value
195
+ // netBridge.value = value
228
196
  }
229
- const onSelectLocation = (networkLocal: UI_I_NetworkTableItem): void => {
197
+ const onSelectLocation = (network: UI_I_NetworkTableItem): void => {
230
198
  locationModalIsShow.value = false
231
199
 
232
- selectedLocationOld.value = networkLocal[props.networkValueProp]
233
- networkValue.value = networkLocal[props.networkValueProp]
200
+ selectedLocationOld.value = network[valueProp]
201
+ selectedLocation.value = network[valueProp]
234
202
 
235
203
  const hasNetwork = locationOptions.value.some(
236
- (option) => option.value === networkLocal[props.networkValueProp]
204
+ (option) => option.value === network[valueProp]
237
205
  )
238
206
  if (hasNetwork) {
239
207
  return
@@ -241,17 +209,87 @@ const onSelectLocation = (networkLocal: UI_I_NetworkTableItem): void => {
241
209
 
242
210
  locationOptions.value = [
243
211
  ...locationOptions.value.slice(0, -1),
244
- { text: networkLocal.name, value: networkLocal[props.networkValueProp] },
212
+ { text: network.name, value: network[valueProp] },
245
213
  locationOptions.value[locationOptions.value.length - 1],
246
214
  ]
247
215
  }
216
+
217
+ // const adapterType = ref<string>('rtl8139')
218
+ const adapterType = ref<string>('virtio') // Семён попросил
219
+
220
+ const target = ref<string>('')
221
+
222
+ const macAddress = ref<string>('')
248
223
  const macAddressType = ref<string>('automatic')
249
224
 
225
+ let cashNetwork = {
226
+ network: '',
227
+ mac: '',
228
+ }
229
+ if (props.network.mac) {
230
+ cashNetwork.network = props.network[valueProp]
231
+ cashNetwork.mac = props.network.mac
232
+ }
233
+ watch(selectedLocation, (newValue) => {
234
+ if (newValue !== cashNetwork.network) {
235
+ macAddressType.value = 'automatic'
236
+ macAddress.value = ''
237
+ } else {
238
+ macAddressType.value = cashNetwork.mac ? 'manual' : 'automatic'
239
+ setTimeout(() => {
240
+ macAddress.value = cashNetwork.mac
241
+ },0)
242
+ }
243
+ })
244
+
245
+ watch(
246
+ [selectedLocation, adapterType, macAddress, macAddressType, locationOptions],
247
+ () => {
248
+ const option = locationOptions.value.find(
249
+ (option) => option.value === selectedLocation.value
250
+ )
251
+ if (!option) return
252
+
253
+ emits('send-data', {
254
+ network: option.text,
255
+ // net_bridge: props.project === 'procurator' ? option.value : '',
256
+ net_bridge: option.value,
257
+ target: target.value,
258
+ model: adapterType.value,
259
+ mac: macAddress.value,
260
+ boot_order: props.network.boot_order,
261
+ })
262
+ },
263
+ { immediate: true }
264
+ )
265
+
266
+ // Добавляем данные для редактирования
267
+ watch(
268
+ () => props.network,
269
+ (newValue) => {
270
+ // if (props.type !== 'edit') return
271
+ if (props.type !== 'edit' && props.type !== 'clone') return
272
+
273
+ locationOptions.value = [
274
+ { text: newValue.network, value: newValue[valueProp] },
275
+ { text: `${localization.value.common.browse}...`, value: '' },
276
+ ]
277
+ selectedLocation.value = newValue[valueProp]
278
+
279
+ adapterType.value = newValue.model
280
+ target.value = newValue.target
281
+ // Сбрасываем mac address при клонировании
282
+ macAddress.value = props.type === 'clone' ? '' : newValue.mac
283
+ macAddressType.value = props.type === 'clone' ? 'automatic' : 'manual'
284
+ },
285
+ { immediate: true }
286
+ )
287
+
250
288
  watch(
251
289
  isRunning,
252
290
  (newValue) => {
253
291
  if (newValue && props.type === 'new') {
254
- model.value = 'virtio'
292
+ adapterType.value = 'virtio'
255
293
  }
256
294
  },
257
295
  { immediate: true }
@@ -1,14 +1,14 @@
1
1
  <template>
2
2
  <common-vm-actions-common-customize-hardware-virtual-hardware-new-usb-controller-new
3
3
  v-if="isNewView"
4
- v-model="model"
4
+ v-model:selected-usb-controller="selectedUsbController"
5
5
  :is-edit="props.isEdit"
6
6
  :selected-usb-controller-text="selectedUsbControllerText"
7
7
  :usb-controller-options="usbControllerOptions"
8
8
  />
9
9
  <common-vm-actions-common-customize-hardware-virtual-hardware-new-usb-controller-old
10
10
  v-else
11
- v-model="model"
11
+ v-model:selected-usb-controller="selectedUsbController"
12
12
  :is-edit="props.isEdit"
13
13
  :selected-usb-controller-text="selectedUsbControllerText"
14
14
  :usb-controller-options="usbControllerOptions"
@@ -17,31 +17,42 @@
17
17
 
18
18
  <script setup lang="ts">
19
19
  import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
20
- import type { UI_I_CreateVmData } from '~/components/common/vm/actions/common/lib/models/interfaces'
21
20
  import { usbControllerOptionsConfig } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/newUsbController/lib/config/options'
22
21
 
23
- const model = defineModel<UI_I_CreateVmData['usb_controllers'][0]['type']>({ required: true })
24
-
25
22
  const props = withDefaults(
26
23
  defineProps<{
24
+ usbController: string
27
25
  isEdit: boolean
28
26
  state?: string | number
29
27
  }>(),
30
28
  {
29
+ usbController: 'usb2',
31
30
  state: undefined,
32
31
  }
33
32
  )
33
+ const emits = defineEmits<{
34
+ (event: 'send-data', value: string): void
35
+ }>()
34
36
 
35
37
  const { $store }: any = useNuxtApp()
36
38
  const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
37
39
 
38
40
  const usbControllerOptions = ref<UI_I_OptionItem[]>(usbControllerOptionsConfig)
41
+ const selectedUsbController = ref<string>(props.usbController)
39
42
  const selectedUsbControllerText = computed<string>(
40
43
  () =>
41
44
  usbControllerOptions.value.find(
42
- (option) => option.value === model.value
45
+ (option) => option.value === selectedUsbController.value
43
46
  )?.text || ''
44
47
  )
48
+
49
+ watch(
50
+ selectedUsbController,
51
+ (newValue) => {
52
+ emits('send-data', newValue)
53
+ },
54
+ { immediate: true }
55
+ )
45
56
  </script>
46
57
 
47
58
  <style scoped lang="scss"></style>
@@ -21,7 +21,7 @@
21
21
  <ui-select
22
22
  v-else
23
23
  id="usb-controller-select"
24
- v-model="model"
24
+ v-model="selectedUsbController"
25
25
  :items="props.usbControllerOptions"
26
26
  :disabled="props.isEdit"
27
27
  width="auto"
@@ -33,13 +33,10 @@
33
33
  </template>
34
34
 
35
35
  <script setup lang="ts">
36
- import type { UI_I_Localization } from '~/lib/models/interfaces'
37
36
  import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
38
- import type { UI_I_CreateVmData } from '~/components/common/vm/actions/common/lib/models/interfaces'
37
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
39
38
 
40
- const model = defineModel<UI_I_CreateVmData['usb_controllers'][0]['type']>({
41
- required: true,
42
- })
39
+ const selectedUsbController = defineModel<string>('selectedUsbController')
43
40
 
44
41
  const props = defineProps<{
45
42
  isEdit: boolean
@@ -20,7 +20,7 @@
20
20
  <div v-else class="select">
21
21
  <select
22
22
  id="usb-controller-select"
23
- v-model="model"
23
+ v-model="selectedUsbController"
24
24
  :disabled="props.isEdit"
25
25
  data-id="usb-controller-select"
26
26
  @click.stop
@@ -40,13 +40,10 @@
40
40
  </template>
41
41
 
42
42
  <script setup lang="ts">
43
- import type { UI_I_Localization } from '~/lib/models/interfaces'
44
43
  import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
45
- import type { UI_I_CreateVmData } from '~/components/common/vm/actions/common/lib/models/interfaces'
44
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
46
45
 
47
- const model = defineModel<UI_I_CreateVmData['usb_controllers'][0]['type']>({
48
- required: true,
49
- })
46
+ const selectedUsbController = defineModel<string>('selectedUsbController')
50
47
 
51
48
  const props = defineProps<{
52
49
  isEdit: boolean
@@ -1,8 +1,9 @@
1
1
  <template>
2
2
  <common-vm-actions-common-customize-hardware-virtual-hardware-video-card-new
3
3
  v-if="isNewView"
4
- v-model="model"
5
4
  v-model:invalid="invalid"
5
+ v-model:number-displays="numberDisplays"
6
+ v-model:video-card-model="videoCardModel"
6
7
  :is-edit="props.isEdit"
7
8
  :error-validation-fields="props.errorValidationFields"
8
9
  :video-card-model-name="videoCardModelName"
@@ -17,8 +18,9 @@
17
18
  />
18
19
  <common-vm-actions-common-customize-hardware-virtual-hardware-video-card-old
19
20
  v-else
20
- v-model="model"
21
21
  v-model:invalid="invalid"
22
+ v-model:number-displays="numberDisplays"
23
+ v-model:video-card-model="videoCardModel"
22
24
  :is-edit="props.isEdit"
23
25
  :error-validation-fields="props.errorValidationFields"
24
26
  :video-card-model-name="videoCardModelName"
@@ -38,12 +40,9 @@ import type { UI_I_SendDataVideoCard } from '~/components/common/vm/actions/comm
38
40
  import type { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
39
41
  import type { UI_I_Localization } from '~/lib/models/interfaces'
40
42
  import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
41
- import type { UI_I_CreateVmData } from '~/components/common/vm/actions/common/lib/models/interfaces'
42
43
  import { videoCardModelOptionsConfigFunc } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/model/lib/config/options'
43
44
  import { numberDisplaysOptionsFunc } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/lib/config/options'
44
45
 
45
- const model = defineModel<UI_I_CreateVmData['video_card']>({ required: true })
46
-
47
46
  const props = withDefaults(
48
47
  defineProps<{
49
48
  isEdit: boolean
@@ -57,6 +56,7 @@ const props = withDefaults(
57
56
  }
58
57
  )
59
58
  const emits = defineEmits<{
59
+ (event: 'send-data', value: UI_I_SendDataVideoCard): void
60
60
  (event: 'invalid', value: boolean): void
61
61
  (event: 'remove-error-by-title', value: string): void
62
62
  }>()
@@ -68,30 +68,32 @@ const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
68
68
 
69
69
  const isDisabled = computed<boolean>(() => props.isEdit && props.state !== 1)
70
70
  const isDisabledNumberDisplays = computed<boolean>(
71
- () => model.value.adapter === 'none'
71
+ () => videoCardModel.value === 'none'
72
72
  )
73
73
  watch(isDisabled, (newValue) => {
74
74
  if (!newValue) {
75
75
  return
76
76
  }
77
77
 
78
- model.value.displays = 1
78
+ numberDisplays.value = '1'
79
79
  })
80
80
 
81
+ const videoCardModel = ref<string>('qxl')
81
82
  const videoCardModelOptions = computed<UI_I_OptionItem[]>(() =>
82
83
  videoCardModelOptionsConfigFunc(localization.value)
83
84
  )
84
85
  const videoCardModelName = computed<string>(
85
86
  () =>
86
87
  videoCardModelOptions.value.find(
87
- (videoCard) => videoCard.value === model.value.adapter
88
+ (videoCard) => videoCard.value === videoCardModel.value
88
89
  )?.text || ''
89
90
  )
90
91
 
92
+ const numberDisplays = ref<string>('1')
91
93
  const numberDisplaysOptions = computed<UI_I_OptionItem[]>(() => {
92
94
  const result = numberDisplaysOptionsFunc()
93
- if (model.value.adapter === 'none') {
94
- result.unshift({ text: '0', value: 0 })
95
+ if (videoCardModel.value === 'none') {
96
+ result.unshift({ text: '0', value: '0' })
95
97
  }
96
98
  return result
97
99
  })
@@ -108,17 +110,37 @@ watch(
108
110
 
109
111
  // const graphics = ref(false)
110
112
 
111
- const changeNumberDisplays = (modelLocal: string): void => {
112
- if (modelLocal === 'none') {
113
- model.value.displays = 0
114
- } else if (model.value.displays === 0) {
115
- model.value.displays = 1
113
+ const changeNumberDisplays = (model: any): void => {
114
+ if (model === 'none') {
115
+ numberDisplays.value = '0'
116
+ } else if (numberDisplays.value === '0') {
117
+ numberDisplays.value = '1'
116
118
  }
117
119
  }
118
120
  watch(
119
- () => model.value.adapter,
121
+ // [numberDisplays, totalVideoMemory, videoCardModel],
122
+ [numberDisplays, videoCardModel],
123
+ ([_newValue1, newValue2]) => {
124
+ changeNumberDisplays(newValue2)
125
+
126
+ emits('send-data', {
127
+ adapter: videoCardModel.value,
128
+ displays: +numberDisplays.value,
129
+ // memory_mb: totalVideoMemory.value,
130
+ })
131
+ },
132
+ { immediate: true }
133
+ )
134
+
135
+ // Добавляем данные для редактирования
136
+ watch(
137
+ () => props.videoCard,
120
138
  (newValue) => {
121
- changeNumberDisplays(newValue)
139
+ if (!newValue) return
140
+
141
+ videoCardModel.value = newValue.adapter
142
+ numberDisplays.value = '' + newValue.displays
143
+ // totalVideoMemory.value = newValue.memory_mb
122
144
  },
123
145
  { immediate: true }
124
146
  )
@@ -26,7 +26,7 @@
26
26
  <template #stackBlockContent>
27
27
  <ui-select
28
28
  id="vm-wizard-video-card"
29
- v-model="model.adapter"
29
+ v-model="videoCardModel"
30
30
  :items="props.videoCardModelOptions"
31
31
  :disabled="props.isEdit && props.state !== 1"
32
32
  :error-text="props.errorText"
@@ -38,7 +38,7 @@
38
38
  </template>
39
39
  <template #stackChildren>
40
40
  <common-vm-actions-common-customize-hardware-virtual-hardware-video-card-number-displays
41
- v-model:number-displays="model.displays"
41
+ v-model:number-displays="numberDisplays"
42
42
  :number-displays-options="props.numberDisplaysOptions"
43
43
  :disabled="props.isDisabled || props.isDisabledNumberDisplays"
44
44
  :error-validation-fields="props.errorValidationFields"
@@ -56,7 +56,7 @@
56
56
  <!-- v-models:graphics="graphics"-->
57
57
  <!-- />-->
58
58
  <!-- <common-vm-actions-common-customize-hardware-virtual-hardware-video-card-model-->
59
- <!-- v-model:video-card-model="model.adapter"-->
59
+ <!-- v-model:video-card-model="videoCardModel"-->
60
60
  <!-- :disabled="props.isDisabled"-->
61
61
  <!-- />-->
62
62
  </template>
@@ -67,14 +67,13 @@
67
67
  import type { UI_I_Localization } from '~/lib/models/interfaces'
68
68
  import type { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
69
69
  import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
70
- import type {UI_I_CreateVmData} from "~/components/common/vm/actions/common/lib/models/interfaces";
71
-
72
- const model = defineModel<UI_I_CreateVmData['video_card']>({ required: true })
73
70
 
74
71
  const invalid = defineModel<boolean>('invalid', { required: true })
72
+ const numberDisplays = defineModel<string>('numberDisplays', { required: true })
75
73
  // const totalVideoMemory = defineModel<number>('totalVideoMemory', {
76
74
  // required: true,
77
75
  // })
76
+ const videoCardModel = defineModel<string>('videoCardModel', { required: true })
78
77
 
79
78
  const props = withDefaults(
80
79
  defineProps<{
@@ -30,7 +30,7 @@
30
30
  <div class="select">
31
31
  <select
32
32
  id="vm-wizard-video-card"
33
- v-model="model.adapter"
33
+ v-model="videoCardModel"
34
34
  :disabled="props.isEdit && props.state !== 1"
35
35
  data-id="vm-wizard-video-card-select"
36
36
  class="vm-wizard-video-card input-text-color"
@@ -51,7 +51,7 @@
51
51
  </template>
52
52
  <template #stackChildren>
53
53
  <common-vm-actions-common-customize-hardware-virtual-hardware-video-card-number-displays
54
- v-model:number-displays="model.displays"
54
+ v-model:number-displays="numberDisplays"
55
55
  :number-displays-options="props.numberDisplaysOptions"
56
56
  :disabled="props.isDisabled || props.isDisabledNumberDisplays"
57
57
  :error-validation-fields="props.errorValidationFields"
@@ -69,7 +69,7 @@
69
69
  <!-- v-models:graphics="graphics"-->
70
70
  <!-- />-->
71
71
  <!-- <common-vm-actions-common-customize-hardware-virtual-hardware-video-card-model-->
72
- <!-- v-model:video-card-model="model.adapter"-->
72
+ <!-- v-model:video-card-model="videoCardModel"-->
73
73
  <!-- :disabled="props.isDisabled"-->
74
74
  <!-- />-->
75
75
  </template>
@@ -81,14 +81,13 @@
81
81
  import type { UI_I_Localization } from '~/lib/models/interfaces'
82
82
  import type { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
83
83
  import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
84
- import type {UI_I_CreateVmData} from "~/components/common/vm/actions/common/lib/models/interfaces";
85
-
86
- const model = defineModel<UI_I_CreateVmData['video_card']>({ required: true })
87
84
 
88
85
  const invalid = defineModel<boolean>('invalid', { required: true })
86
+ const numberDisplays = defineModel<string>('numberDisplays', { required: true })
89
87
  // const totalVideoMemory = defineModel<number>('totalVideoMemory', {
90
88
  // required: true,
91
89
  // })
90
+ const videoCardModel = defineModel<string>('videoCardModel', { required: true })
92
91
 
93
92
  const props = withDefaults(
94
93
  defineProps<{
@@ -1,10 +1,10 @@
1
1
  import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
2
2
 
3
3
  export const numberDisplaysOptionsFunc = (): UI_I_OptionItem[] => [
4
- { text: '1', value: 1 },
5
- { text: '2', value: 2 },
6
- { text: '3', value: 3 },
7
- { text: '4', value: 4 },
4
+ { text: '1', value: '1' },
5
+ { text: '2', value: '2' },
6
+ { text: '3', value: '3' },
7
+ { text: '4', value: '4' },
8
8
  // { text: '5', value: '5' },
9
9
  // { text: '6', value: '6' },
10
10
  // { text: '7', value: '7' },