bfg-common 1.1.63 → 1.1.65

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 (92) hide show
  1. package/assets/localization/local_be.json +1 -1
  2. package/assets/localization/local_hy.json +1 -1
  3. package/assets/localization/local_kk.json +1 -1
  4. package/assets/localization/local_ru.json +1 -1
  5. package/components/atoms/alert/Notification.vue +167 -167
  6. package/components/atoms/autocomplete/Autocomplete.vue +236 -236
  7. package/components/atoms/datepicker/Datepicker.vue +612 -612
  8. package/components/atoms/list/SelectList.vue +62 -62
  9. package/components/atoms/nav/NavBar.vue +116 -116
  10. package/components/atoms/nav/VerticalNavBar.vue +89 -89
  11. package/components/atoms/notificationBar/NotificationBar.vue +175 -175
  12. package/components/atoms/perPage/PerPage.vue +52 -52
  13. package/components/atoms/popup/SimplePopup.vue +90 -90
  14. package/components/atoms/step/VerticalStep.vue +104 -104
  15. package/components/atoms/switch/Switch.vue +107 -107
  16. package/components/atoms/table/dataGrid/DataGridColumnSwitch.vue +206 -206
  17. package/components/atoms/table/dataGrid/DataGridPage.vue +189 -189
  18. package/components/atoms/tabs/Tabs.vue +189 -189
  19. package/components/atoms/tooltip/Signpost.vue +224 -224
  20. package/components/common/adapterManager/AddAdapterWarningModal.vue +82 -82
  21. package/components/common/adapterManager/NoActiveAdaptersModal.vue +62 -62
  22. package/components/common/adapterManager/NoConnectedActiveAdaptersModal.vue +62 -62
  23. package/components/common/browse/Browse.vue +182 -182
  24. package/components/common/browse/blocks/Title.vue +66 -66
  25. package/components/common/diagramMain/Diagram.vue +186 -186
  26. package/components/common/diagramMain/DiagramMain.vue +986 -986
  27. package/components/common/diagramMain/adapter/AdapterItem.vue +227 -227
  28. package/components/common/diagramMain/adapter/AdapterItems.vue +57 -57
  29. package/components/common/diagramMain/modals/editSettings/tabs/port/IpvFourSettings.vue +339 -339
  30. package/components/common/diagramMain/modals/editSettings/tabs/port/PortProperties.vue +202 -202
  31. package/components/common/diagramMain/modals/remove/RemoveModal.vue +226 -226
  32. package/components/common/diagramMain/network/Contents.vue +238 -238
  33. package/components/common/feedback/Buttons.vue +232 -232
  34. package/components/common/feedback/Message.vue +468 -468
  35. package/components/common/feedback/VisitPortal.vue +54 -54
  36. package/components/common/graph/Graph.vue +18 -20
  37. package/components/common/help/navbar/left/Left.vue +159 -159
  38. package/components/common/help/navbar/left/utils/constructAccordion.ts +27 -27
  39. package/components/common/mainNavigationPanel/MainNavigationPanel.vue +359 -359
  40. package/components/common/modals/Rename.vue +165 -165
  41. package/components/common/monitor/advanced/Advanced.vue +3 -33
  42. package/components/common/monitor/advanced/GraphView.vue +4 -4
  43. package/components/common/monitor/advanced/table/Table.vue +5 -5
  44. package/components/common/monitor/advanced/tools/Tools.vue +27 -91
  45. package/components/common/monitor/advanced/tools/chartOptionsModal/ChartOptionsModal.vue +17 -101
  46. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/Counters.vue +7 -25
  47. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/config/utils.ts +0 -55
  48. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/models/interfaces.ts +1 -1
  49. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/timespan/Timespan.vue +3 -32
  50. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/timespan/form/Form.vue +8 -25
  51. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/timespan/object/Object.vue +19 -41
  52. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/timespan/object/models/interfaces.ts +1 -1
  53. package/components/common/monitor/advanced/tools/config/advancedToolbar.ts +38 -50
  54. package/components/common/monitor/config/getValidDateByOption.ts +6 -105
  55. package/components/common/monitor/overview/filters/Filters.vue +6 -6
  56. package/components/common/monitor/overview/filters/customIntervalModal/CustomIntervalModal.vue +8 -8
  57. package/components/common/monitor/overview/filters/customIntervalModal/config/dateChecker.ts +1 -1
  58. package/components/common/perPage/PerPage.vue +51 -51
  59. package/components/common/recursionTree/RecursionTree.vue +201 -201
  60. package/components/common/vm/actions/add/customizeHardware/virtualHardware/VirtualHardware.vue +641 -642
  61. package/components/common/vm/actions/add/customizeHardware/virtualHardware/cdDvdDrive/CdDvdDrive.vue +245 -274
  62. package/components/common/vm/actions/add/customizeHardware/virtualHardware/cpu/Cpu.vue +375 -375
  63. package/components/common/vm/actions/add/customizeHardware/virtualHardware/limit/Limit.vue +234 -234
  64. package/components/common/vm/actions/add/customizeHardware/virtualHardware/limit/config/options.ts +28 -28
  65. package/components/common/vm/actions/add/customizeHardware/virtualHardware/memory/Memory.vue +316 -316
  66. package/components/common/vm/actions/add/customizeHardware/virtualHardware/memory/config/memoryOptions.ts +35 -35
  67. package/components/common/vm/actions/add/customizeHardware/virtualHardware/newHardDisk/NewHardDisk.vue +447 -447
  68. package/components/common/vm/actions/add/customizeHardware/virtualHardware/newNetwork/NewNetwork.vue +1 -1
  69. package/components/common/vm/actions/add/customizeHardware/virtualHardware/reservation/Reservation.vue +235 -235
  70. package/components/common/vm/actions/add/customizeHardware/vmoptions/bootOptions/order/Order.vue +197 -195
  71. package/components/common/vm/actions/add/select/storage/config/config.ts +154 -154
  72. package/components/common/wizards/datastore/add/nfs/configuration/Configuration.vue +373 -373
  73. package/components/common/wizards/datastore/add/nfs/configuration/serversList/ServersList.vue +123 -123
  74. package/components/common/wizards/datastore/add/nfs/kerberosAuthentication/KerberosAuthentication.vue +54 -54
  75. package/components/common/wizards/datastore/add/sharedStorm/deviceSelection/hostTable/HostTable.vue +131 -131
  76. package/components/common/wizards/datastore/add/sharedStorm/partitionConfiguration/PartitionConfiguration.vue +230 -230
  77. package/models/store/interfaces.ts +37 -37
  78. package/models/store/storage/interfaces.ts +32 -32
  79. package/models/store/types.ts +32 -32
  80. package/modules/fixContentBuild/utils/methods.ts +114 -114
  81. package/package.json +1 -1
  82. package/public/spice-console/application/codec.js +257 -257
  83. package/public/spice-console/lib/rasterEngine.js +907 -907
  84. package/public/spice-console/network/spicechannel.js +369 -369
  85. package/public/spice-console-minify/lib/decoder/dixie.min.js +4 -4
  86. package/public/spice-console-minify/lib/jgestures.min.js +24 -24
  87. package/public/spice-console-minify/lib/jquery-2.0.3.min.js +24 -24
  88. package/public/spice-console-minify/lib/jquery-mousewheel.min.js +11 -11
  89. package/public/spice-console-minify/lib/jquery-visibility.min.js +1 -1
  90. package/public/spice-console-minify/lib/lodash.4.0.0.min.js +5 -5
  91. package/utils/contentBuild.ts +34 -34
  92. package/components/common/monitor/advanced/tools/utils/countCores.ts +0 -7
@@ -1,375 +1,375 @@
1
- <template>
2
- <div class="hardware-cpu">
3
- <atoms-stack-block :has-children="true">
4
- <template #stackBlockKey>
5
- <div id="vm-wizard-toggle-block-cpu" class="flex-align-center">
6
- <span>{{ localization.cpu }}</span>
7
- <atoms-the-icon
8
- v-show="cpuInvalid"
9
- width="24px"
10
- height="24px"
11
- class="is-error tooltip-trigger"
12
- name="info"
13
- />
14
- </div>
15
- </template>
16
- <template #stackBlockContent>
17
- <div class="flex-align-center flex-space-between">
18
- <div class="flex-align-center">
19
- <atoms-tooltip-error
20
- :has-error="!!vcpusLocalAndApiErrorsTexts"
21
- selector="#vm-wizard-vcpus-field input"
22
- @remove="onRemoveValidationError"
23
- >
24
- <template #elem>
25
- <atoms-combobox
26
- id="vm-wizard-vcpus-field"
27
- class="input-text-color"
28
- v-model.number="selectedCpu"
29
- :items="cpuOptions"
30
- :disabled="isCpuDisabled"
31
- @click.stop
32
- />
33
- </template>
34
- <template #content>{{ vcpusLocalAndApiErrorsTexts }}</template>
35
- </atoms-tooltip-error>
36
- </div>
37
-
38
- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-tooltip
39
- :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
40
- />
41
- </div>
42
- </template>
43
- <template #stackChildren>
44
- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-cores-per-socket
45
- v-model:selected-core-per-socket="selectedCorePerSocket"
46
- :selected-cpu="selectedCpu"
47
- :cpu-options="cpuOptions"
48
- :is-edit="props.isEdit"
49
- :disabled="isDisabled"
50
- :error-validation-fields="props.errorValidationFields"
51
- @remove-error-by-title="emits('remove-error-by-title', $event)"
52
- />
53
- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-hot-plug
54
- v-model:enable-cpu-hot-add="enableCpuHotAdd"
55
- :disabled="enableCpuHotAddDisabled"
56
- />
57
- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-max-cpu
58
- v-show="enableCpuHotAdd"
59
- v-model:selected-max-cpu.number="selectedMaxCpu"
60
- :cpu-options="maxCpuOptions"
61
- :error-validation-fields="props.errorValidationFields"
62
- :disabled="isDisabled"
63
- @invalid="maxCpuInvalid = $event"
64
- @remove-error-by-title="emits('remove-error-by-title', $event)"
65
- />
66
- <common-vm-actions-add-customize-hardware-virtual-hardware-reservation
67
- v-model:reservation="reservation"
68
- v-model:reservation-type="reservationType"
69
- :error-validation-fields="props.errorValidationFields"
70
- :disabled="isDisabled"
71
- type="mhz"
72
- component-type="cpu"
73
- @invalid="reservationInvalid = $event"
74
- @remove-error-by-title="emits('remove-error-by-title', $event)"
75
- />
76
- <common-vm-actions-add-customize-hardware-virtual-hardware-limit
77
- v-model:limit="limit"
78
- v-model:limit-type="limitType"
79
- :error-validation-fields="props.errorValidationFields"
80
- :disabled="isDisabled"
81
- type="mhz"
82
- component-type="cpu"
83
- @invalid="limitInvalid = $event"
84
- @remove-error-by-title="emits('remove-error-by-title', $event)"
85
- />
86
- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-shares
87
- v-model:shares="shares"
88
- v-model:shares-type="sharesType"
89
- :error-validation-fields="props.errorValidationFields"
90
- :disabled="isDisabled"
91
- @remove-error-by-title="emits('remove-error-by-title', $event)"
92
- @invalid="sharesInvalid = $event"
93
- />
94
- <!-- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-hv-->
95
- <!-- v-model:hardwareVirtualization="hardwareVirtualization"-->
96
- <!-- />-->
97
- <!-- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-pc-->
98
- <!-- v-model:performanceCounters="performanceCounters"-->
99
- <!-- />-->
100
- <!-- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-sa-->
101
- <!-- v-model:schedulingAffinity="schedulingAffinity"-->
102
- <!-- />-->
103
- <!-- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-iommu-->
104
- <!-- v-model:iommu="iommu"-->
105
- <!-- />-->
106
- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-model
107
- v-model:cpu-model="cpuModel"
108
- v-model:passthrough-host-cpu="passthroughHostCpu"
109
- v-model:host-model-cpu="hostModelCpu"
110
- :cpu-models="props.cpuModels"
111
- :is-edit="props.isEdit"
112
- :error-validation-fields="props.errorValidationFields"
113
- :disabled="isDisabled"
114
- @remove-error-by-title="emits('remove-error-by-title', $event)"
115
- />
116
- </template>
117
- </atoms-stack-block>
118
- </div>
119
- </template>
120
-
121
- <script setup lang="ts">
122
- import { UI_I_SendDataCpu } from '~/components/common/vm/actions/add/customizeHardware/virtualHardware/models/interfaces'
123
- import { UI_I_Localization } from '~/models/interfaces'
124
- import { UI_I_ErrorValidationField } from '~/models/store/interfaces'
125
- import { UI_I_OptionItem } from '~/components/atoms/models/interfaces'
126
- import { API_UI_I_VmEditCpu } from '~/models/store/vm/interfaces'
127
- import { cpuOptionsFunc } from '~/components/common/vm/actions/add/customizeHardware/virtualHardware/cpu/config/cpuOptions'
128
-
129
- const props = defineProps<{
130
- maxCpus: number
131
- cpuModels: UI_I_OptionItem[]
132
- isEdit: boolean
133
- errorValidationFields: UI_I_ErrorValidationField<string>[]
134
- vmCpuHelpTextSecond?: string
135
- state?: string
136
- cpu?: API_UI_I_VmEditCpu
137
- }>()
138
- const emits = defineEmits<{
139
- (event: 'send-data', value: UI_I_SendDataCpu): void
140
- (event: 'invalid', value: boolean): void
141
- (event: 'remove-error-by-title', value: string): void
142
- }>()
143
-
144
- const localization = computed<UI_I_Localization>(() => useLocal())
145
-
146
- const isDisabled = computed<boolean>(() => {
147
- return props.state === '1'
148
- })
149
-
150
- const cpuOptions = computed<UI_I_OptionItem[]>(() =>
151
- cpuOptionsFunc(localization.value, 1, props.maxCpus)
152
- )
153
-
154
- const enableCpuHotAdd = ref<boolean>(false)
155
- const enableCpuHotAddDisabled = computed<boolean>(
156
- () => selectedCpu.value >= props.maxCpus || isDisabled.value
157
- )
158
- watch(enableCpuHotAdd, (newValue) => {
159
- if (newValue) return
160
-
161
- maxCpuInvalid.value = false
162
- selectedMaxCpu.value = cpuOptions.value.at(-1)?.value
163
- })
164
-
165
- const selectedCpu = ref<number>(
166
- isDisabled.value && enableCpuHotAdd.value ? props.maxCpus : 2
167
- )
168
- const isCpuDisabled = computed<boolean>(
169
- () => isDisabled.value && !enableCpuHotAdd.value
170
- )
171
- watch(selectedCpu, (newValue) => {
172
- selectedCpu.value = Math.floor(+newValue)
173
- if (!(selectedCpu.value % selectedCorePerSocket.value)) return
174
- selectedCorePerSocket.value = 1
175
- })
176
- const maxCpuOptions = computed<UI_I_OptionItem[]>(() =>
177
- cpuOptionsFunc(localization.value, selectedCpu.value + 1, props.maxCpus)
178
- )
179
- watch(selectedCpu, (newValue) => {
180
- if (newValue >= props.maxCpus) {
181
- enableCpuHotAdd.value = false
182
- }
183
- selectedMaxCpu.value =
184
- selectedMaxCpu.value <= newValue ? newValue + 1 : selectedMaxCpu.value
185
- if (selectedMaxCpu.value > props.maxCpus) selectedMaxCpu.value = props.maxCpus
186
- })
187
- const selectedMaxCpu = ref<number>(cpuOptions.value.at(-1)?.value)
188
- watch(
189
- () => props.maxCpus,
190
- (newValue) => {
191
- selectedMaxCpu.value = newValue
192
- }
193
- )
194
-
195
- const selectedCorePerSocket = ref<number>(1)
196
-
197
- const cpuErrorLocalText = computed<string>(() => {
198
- const validValue = /^\d+(\.\d+)?$/.test(selectedCpu.value + '')
199
- if (!validValue) {
200
- return localization.value.inputContainsInvalidCharacters
201
- }
202
-
203
- const min = cpuOptions.value[0].value
204
- const max = cpuOptions.value[1].value
205
- if (selectedCpu.value < min || selectedCpu.value > max) {
206
- return localization.value.memoryMustBe
207
- .replace('{0}', min)
208
- .replace('{1}', max)
209
- }
210
-
211
- return ''
212
- })
213
-
214
- const apiVcpusError = computed<string>(() => {
215
- return (
216
- props.errorValidationFields?.find(
217
- (message) => message.field === 'cpu.vcpus'
218
- )?.error_message || ''
219
- )
220
- })
221
-
222
- const vcpusLocalAndApiErrorsTexts = computed<string>(() => {
223
- const localError = cpuErrorLocalText.value
224
- const apiError = apiVcpusError.value
225
-
226
- let result = ''
227
- if (localError && !apiError) result = localError
228
- if (!localError && apiError) result = apiError
229
- if (localError && apiError) result = localError + ', ' + apiError
230
- if (!localError && apiError) result = apiError
231
-
232
- return result
233
- })
234
- const reservationInvalid = ref<boolean>(false)
235
- const limitInvalid = ref<boolean>(false)
236
- const sharesInvalid = ref<boolean>(false)
237
- const maxCpuInvalid = ref<boolean>(false)
238
- const cpuInvalid = computed<boolean>(
239
- () =>
240
- !!cpuErrorLocalText.value ||
241
- reservationInvalid.value ||
242
- limitInvalid.value ||
243
- sharesInvalid.value ||
244
- (enableCpuHotAdd.value &&
245
- selectedCpu.value < props.maxCpus &&
246
- maxCpuInvalid.value)
247
- )
248
- watch(
249
- cpuInvalid,
250
- (newValue: boolean) => {
251
- emits('invalid', newValue)
252
- },
253
- { immediate: true }
254
- )
255
-
256
- const reservation = ref<string>('1')
257
- const reservationType = ref<string>('mhz')
258
-
259
- const limit = ref<string>('Unlimited')
260
- const limitType = ref<string>('mhz')
261
-
262
- const shares = ref<string>('2000')
263
- const sharesType = ref<string>('2000')
264
-
265
- // const hardwareVirtualization = ref<boolean>(false)
266
- //
267
- // const performanceCounters = ref<boolean>(false)
268
- //
269
- // const schedulingAffinity = ref<string>('')
270
- //
271
- // const iommu = ref<boolean>(false)
272
-
273
- const cpuModel = ref<string>(props.cpuModels[0]?.value || '')
274
- watch(
275
- () => props.cpuModels,
276
- (newValue) => {
277
- cpuModel.value = newValue[0].value
278
- }
279
- )
280
- const passthroughHostCpu = ref<boolean>(false)
281
- const hostModelCpu = ref<boolean>(false)
282
-
283
- // const isShowCpuHelp = ref<boolean>(false)
284
-
285
- const { $binary } = useNuxtApp()
286
- watch(
287
- [
288
- reservation,
289
- reservationType,
290
- limit,
291
- limitType,
292
- shares,
293
- selectedCpu,
294
- selectedMaxCpu,
295
- selectedCorePerSocket,
296
- enableCpuHotAdd,
297
- cpuModel,
298
- passthroughHostCpu,
299
- hostModelCpu,
300
- ],
301
- () => {
302
- const reservationInMhz =
303
- reservationType.value === 'ghz'
304
- ? $binary.ghzToMhz(+reservation.value)
305
- : +reservation.value
306
- const limitInMhz =
307
- limit.value === 'Unlimited'
308
- ? limit.value
309
- : limitType.value === 'ghz'
310
- ? $binary.ghzToMhz(+limit.value)
311
- : +limit.value
312
- const model = passthroughHostCpu.value
313
- ? 'host-passthrough'
314
- : hostModelCpu.value
315
- ? 'host-model'
316
- : cpuModel.value
317
-
318
- emits('send-data', {
319
- model,
320
- vcpus: selectedCpu.value,
321
- max_vcpus: enableCpuHotAdd.value ? selectedMaxCpu.value : 0,
322
- core_per_socket: selectedCorePerSocket.value,
323
- reservation_mhz: reservationInMhz,
324
- limit_mhz: limitInMhz,
325
- shares: +shares.value,
326
- hotplug: enableCpuHotAdd.value,
327
- })
328
- },
329
- {
330
- immediate: true,
331
- }
332
- )
333
-
334
- // Добавляем данные для редактирования
335
- watch(
336
- () => props.cpu,
337
- (newValue) => {
338
- if (!newValue) return
339
-
340
- enableCpuHotAdd.value = newValue.hotplug
341
- selectedCpu.value = newValue.vcpus
342
- selectedMaxCpu.value = newValue.max_vcpus
343
- selectedCorePerSocket.value = newValue.core_per_socket
344
- reservation.value = '' + newValue.reservation_mhz
345
- limit.value = '' + newValue.limit_mhz
346
- shares.value = '' + newValue.shares
347
- cpuModel.value =
348
- props.cpuModels.find((model) => model.text === props.cpu?.model)?.value ||
349
- cpuModel.value
350
- },
351
- { immediate: true }
352
- )
353
-
354
- const onRemoveValidationError = (): void => {
355
- emits('remove-error-by-title', 'cpu.vcpus')
356
- }
357
- </script>
358
-
359
- <style scoped lang="scss">
360
- h3.cpu-help-title {
361
- margin-top: 7px;
362
- font-size: 22px;
363
- color: #565656;
364
- }
365
- p.cpu-help-text {
366
- width: 310px;
367
- margin-top: 24px;
368
- font-size: 14px;
369
- color: #565656;
370
- }
371
- a.cpu-more-info {
372
- color: #00648f;
373
- font-size: 14px;
374
- }
375
- </style>
1
+ <template>
2
+ <div class="hardware-cpu">
3
+ <atoms-stack-block :has-children="true">
4
+ <template #stackBlockKey>
5
+ <div id="vm-wizard-toggle-block-cpu" class="flex-align-center">
6
+ <span>{{ localization.cpu }}</span>
7
+ <atoms-the-icon
8
+ v-show="cpuInvalid"
9
+ width="24px"
10
+ height="24px"
11
+ class="is-error tooltip-trigger"
12
+ name="info"
13
+ />
14
+ </div>
15
+ </template>
16
+ <template #stackBlockContent>
17
+ <div class="flex-align-center flex-space-between">
18
+ <div class="flex-align-center">
19
+ <atoms-tooltip-error
20
+ :has-error="!!vcpusLocalAndApiErrorsTexts"
21
+ selector="#vm-wizard-vcpus-field input"
22
+ @remove="onRemoveValidationError"
23
+ >
24
+ <template #elem>
25
+ <atoms-combobox
26
+ id="vm-wizard-vcpus-field"
27
+ class="input-text-color"
28
+ v-model.number="selectedCpu"
29
+ :items="cpuOptions"
30
+ :disabled="isCpuDisabled"
31
+ @click.stop
32
+ />
33
+ </template>
34
+ <template #content>{{ vcpusLocalAndApiErrorsTexts }}</template>
35
+ </atoms-tooltip-error>
36
+ </div>
37
+
38
+ <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-tooltip
39
+ :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
40
+ />
41
+ </div>
42
+ </template>
43
+ <template #stackChildren>
44
+ <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-cores-per-socket
45
+ v-model:selected-core-per-socket="selectedCorePerSocket"
46
+ :selected-cpu="selectedCpu"
47
+ :cpu-options="cpuOptions"
48
+ :is-edit="props.isEdit"
49
+ :disabled="isDisabled"
50
+ :error-validation-fields="props.errorValidationFields"
51
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
52
+ />
53
+ <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-hot-plug
54
+ v-model:enable-cpu-hot-add="enableCpuHotAdd"
55
+ :disabled="enableCpuHotAddDisabled"
56
+ />
57
+ <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-max-cpu
58
+ v-show="enableCpuHotAdd"
59
+ v-model:selected-max-cpu.number="selectedMaxCpu"
60
+ :cpu-options="maxCpuOptions"
61
+ :error-validation-fields="props.errorValidationFields"
62
+ :disabled="isDisabled"
63
+ @invalid="maxCpuInvalid = $event"
64
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
65
+ />
66
+ <common-vm-actions-add-customize-hardware-virtual-hardware-reservation
67
+ v-model:reservation="reservation"
68
+ v-model:reservation-type="reservationType"
69
+ :error-validation-fields="props.errorValidationFields"
70
+ :disabled="isDisabled"
71
+ type="mhz"
72
+ component-type="cpu"
73
+ @invalid="reservationInvalid = $event"
74
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
75
+ />
76
+ <common-vm-actions-add-customize-hardware-virtual-hardware-limit
77
+ v-model:limit="limit"
78
+ v-model:limit-type="limitType"
79
+ :error-validation-fields="props.errorValidationFields"
80
+ :disabled="isDisabled"
81
+ type="mhz"
82
+ component-type="cpu"
83
+ @invalid="limitInvalid = $event"
84
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
85
+ />
86
+ <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-shares
87
+ v-model:shares="shares"
88
+ v-model:shares-type="sharesType"
89
+ :error-validation-fields="props.errorValidationFields"
90
+ :disabled="isDisabled"
91
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
92
+ @invalid="sharesInvalid = $event"
93
+ />
94
+ <!-- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-hv-->
95
+ <!-- v-model:hardwareVirtualization="hardwareVirtualization"-->
96
+ <!-- />-->
97
+ <!-- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-pc-->
98
+ <!-- v-model:performanceCounters="performanceCounters"-->
99
+ <!-- />-->
100
+ <!-- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-sa-->
101
+ <!-- v-model:schedulingAffinity="schedulingAffinity"-->
102
+ <!-- />-->
103
+ <!-- <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-iommu-->
104
+ <!-- v-model:iommu="iommu"-->
105
+ <!-- />-->
106
+ <common-vm-actions-add-customize-hardware-virtual-hardware-cpu-model
107
+ v-model:cpu-model="cpuModel"
108
+ v-model:passthrough-host-cpu="passthroughHostCpu"
109
+ v-model:host-model-cpu="hostModelCpu"
110
+ :cpu-models="props.cpuModels"
111
+ :is-edit="props.isEdit"
112
+ :error-validation-fields="props.errorValidationFields"
113
+ :disabled="isDisabled"
114
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
115
+ />
116
+ </template>
117
+ </atoms-stack-block>
118
+ </div>
119
+ </template>
120
+
121
+ <script setup lang="ts">
122
+ import { UI_I_SendDataCpu } from '~/components/common/vm/actions/add/customizeHardware/virtualHardware/models/interfaces'
123
+ import { UI_I_Localization } from '~/models/interfaces'
124
+ import { UI_I_ErrorValidationField } from '~/models/store/interfaces'
125
+ import { UI_I_OptionItem } from '~/components/atoms/models/interfaces'
126
+ import { API_UI_I_VmEditCpu } from '~/models/store/vm/interfaces'
127
+ import { cpuOptionsFunc } from '~/components/common/vm/actions/add/customizeHardware/virtualHardware/cpu/config/cpuOptions'
128
+
129
+ const props = defineProps<{
130
+ maxCpus: number
131
+ cpuModels: UI_I_OptionItem[]
132
+ isEdit: boolean
133
+ errorValidationFields: UI_I_ErrorValidationField<string>[]
134
+ vmCpuHelpTextSecond?: string
135
+ state?: string
136
+ cpu?: API_UI_I_VmEditCpu
137
+ }>()
138
+ const emits = defineEmits<{
139
+ (event: 'send-data', value: UI_I_SendDataCpu): void
140
+ (event: 'invalid', value: boolean): void
141
+ (event: 'remove-error-by-title', value: string): void
142
+ }>()
143
+
144
+ const localization = computed<UI_I_Localization>(() => useLocal())
145
+
146
+ const isDisabled = computed<boolean>(() => {
147
+ return props.state === '1'
148
+ })
149
+
150
+ const cpuOptions = computed<UI_I_OptionItem[]>(() =>
151
+ cpuOptionsFunc(localization.value, 1, props.maxCpus)
152
+ )
153
+
154
+ const enableCpuHotAdd = ref<boolean>(false)
155
+ const enableCpuHotAddDisabled = computed<boolean>(
156
+ () => selectedCpu.value >= props.maxCpus || isDisabled.value
157
+ )
158
+ watch(enableCpuHotAdd, (newValue) => {
159
+ if (newValue) return
160
+
161
+ maxCpuInvalid.value = false
162
+ selectedMaxCpu.value = cpuOptions.value.at(-1)?.value
163
+ })
164
+
165
+ const selectedCpu = ref<number>(
166
+ isDisabled.value && enableCpuHotAdd.value ? props.maxCpus : 2
167
+ )
168
+ const isCpuDisabled = computed<boolean>(
169
+ () => isDisabled.value && !enableCpuHotAdd.value
170
+ )
171
+ watch(selectedCpu, (newValue) => {
172
+ selectedCpu.value = Math.floor(+newValue)
173
+ if (!(selectedCpu.value % selectedCorePerSocket.value)) return
174
+ selectedCorePerSocket.value = 1
175
+ })
176
+ const maxCpuOptions = computed<UI_I_OptionItem[]>(() =>
177
+ cpuOptionsFunc(localization.value, selectedCpu.value + 1, props.maxCpus)
178
+ )
179
+ watch(selectedCpu, (newValue) => {
180
+ if (newValue >= props.maxCpus) {
181
+ enableCpuHotAdd.value = false
182
+ }
183
+ selectedMaxCpu.value =
184
+ selectedMaxCpu.value <= newValue ? newValue + 1 : selectedMaxCpu.value
185
+ if (selectedMaxCpu.value > props.maxCpus) selectedMaxCpu.value = props.maxCpus
186
+ })
187
+ const selectedMaxCpu = ref<number>(cpuOptions.value.at(-1)?.value)
188
+ watch(
189
+ () => props.maxCpus,
190
+ (newValue) => {
191
+ selectedMaxCpu.value = newValue
192
+ }
193
+ )
194
+
195
+ const selectedCorePerSocket = ref<number>(1)
196
+
197
+ const cpuErrorLocalText = computed<string>(() => {
198
+ const validValue = /^\d+(\.\d+)?$/.test(selectedCpu.value + '')
199
+ if (!validValue) {
200
+ return localization.value.inputContainsInvalidCharacters
201
+ }
202
+
203
+ const min = cpuOptions.value[0].value
204
+ const max = cpuOptions.value[1].value
205
+ if (selectedCpu.value < min || selectedCpu.value > max) {
206
+ return localization.value.memoryMustBe
207
+ .replace('{0}', min)
208
+ .replace('{1}', max)
209
+ }
210
+
211
+ return ''
212
+ })
213
+
214
+ const apiVcpusError = computed<string>(() => {
215
+ return (
216
+ props.errorValidationFields?.find(
217
+ (message) => message.field === 'cpu.vcpus'
218
+ )?.error_message || ''
219
+ )
220
+ })
221
+
222
+ const vcpusLocalAndApiErrorsTexts = computed<string>(() => {
223
+ const localError = cpuErrorLocalText.value
224
+ const apiError = apiVcpusError.value
225
+
226
+ let result = ''
227
+ if (localError && !apiError) result = localError
228
+ if (!localError && apiError) result = apiError
229
+ if (localError && apiError) result = localError + ', ' + apiError
230
+ if (!localError && apiError) result = apiError
231
+
232
+ return result
233
+ })
234
+ const reservationInvalid = ref<boolean>(false)
235
+ const limitInvalid = ref<boolean>(false)
236
+ const sharesInvalid = ref<boolean>(false)
237
+ const maxCpuInvalid = ref<boolean>(false)
238
+ const cpuInvalid = computed<boolean>(
239
+ () =>
240
+ !!cpuErrorLocalText.value ||
241
+ reservationInvalid.value ||
242
+ limitInvalid.value ||
243
+ sharesInvalid.value ||
244
+ (enableCpuHotAdd.value &&
245
+ selectedCpu.value < props.maxCpus &&
246
+ maxCpuInvalid.value)
247
+ )
248
+ watch(
249
+ cpuInvalid,
250
+ (newValue: boolean) => {
251
+ emits('invalid', newValue)
252
+ },
253
+ { immediate: true }
254
+ )
255
+
256
+ const reservation = ref<string>('1')
257
+ const reservationType = ref<string>('mhz')
258
+
259
+ const limit = ref<string>('Unlimited')
260
+ const limitType = ref<string>('mhz')
261
+
262
+ const shares = ref<string>('2000')
263
+ const sharesType = ref<string>('2000')
264
+
265
+ // const hardwareVirtualization = ref<boolean>(false)
266
+ //
267
+ // const performanceCounters = ref<boolean>(false)
268
+ //
269
+ // const schedulingAffinity = ref<string>('')
270
+ //
271
+ // const iommu = ref<boolean>(false)
272
+
273
+ const cpuModel = ref<string>(props.cpuModels[0]?.value || '')
274
+ watch(
275
+ () => props.cpuModels,
276
+ (newValue) => {
277
+ cpuModel.value = newValue[0].value
278
+ }
279
+ )
280
+ const passthroughHostCpu = ref<boolean>(false)
281
+ const hostModelCpu = ref<boolean>(false)
282
+
283
+ // const isShowCpuHelp = ref<boolean>(false)
284
+
285
+ const { $binary } = useNuxtApp()
286
+ watch(
287
+ [
288
+ reservation,
289
+ reservationType,
290
+ limit,
291
+ limitType,
292
+ shares,
293
+ selectedCpu,
294
+ selectedMaxCpu,
295
+ selectedCorePerSocket,
296
+ enableCpuHotAdd,
297
+ cpuModel,
298
+ passthroughHostCpu,
299
+ hostModelCpu,
300
+ ],
301
+ () => {
302
+ const reservationInMhz =
303
+ reservationType.value === 'ghz'
304
+ ? $binary.ghzToMhz(+reservation.value)
305
+ : +reservation.value
306
+ const limitInMhz =
307
+ limit.value === 'Unlimited'
308
+ ? limit.value
309
+ : limitType.value === 'ghz'
310
+ ? $binary.ghzToMhz(+limit.value)
311
+ : +limit.value
312
+ const model = passthroughHostCpu.value
313
+ ? 'host-passthrough'
314
+ : hostModelCpu.value
315
+ ? 'host-model'
316
+ : cpuModel.value
317
+
318
+ emits('send-data', {
319
+ model,
320
+ vcpus: selectedCpu.value,
321
+ max_vcpus: enableCpuHotAdd.value ? selectedMaxCpu.value : 0,
322
+ core_per_socket: selectedCorePerSocket.value,
323
+ reservation_mhz: reservationInMhz,
324
+ limit_mhz: limitInMhz,
325
+ shares: +shares.value,
326
+ hotplug: enableCpuHotAdd.value,
327
+ })
328
+ },
329
+ {
330
+ immediate: true,
331
+ }
332
+ )
333
+
334
+ // Добавляем данные для редактирования
335
+ watch(
336
+ () => props.cpu,
337
+ (newValue) => {
338
+ if (!newValue) return
339
+
340
+ enableCpuHotAdd.value = newValue.hotplug
341
+ selectedCpu.value = newValue.vcpus
342
+ selectedMaxCpu.value = newValue.max_vcpus
343
+ selectedCorePerSocket.value = newValue.core_per_socket
344
+ reservation.value = '' + newValue.reservation_mhz
345
+ limit.value = '' + newValue.limit_mhz
346
+ shares.value = '' + newValue.shares
347
+ cpuModel.value =
348
+ props.cpuModels.find((model) => model.text === props.cpu?.model)?.value ||
349
+ cpuModel.value
350
+ },
351
+ { immediate: true }
352
+ )
353
+
354
+ const onRemoveValidationError = (): void => {
355
+ emits('remove-error-by-title', 'cpu.vcpus')
356
+ }
357
+ </script>
358
+
359
+ <style scoped lang="scss">
360
+ h3.cpu-help-title {
361
+ margin-top: 7px;
362
+ font-size: 22px;
363
+ color: #565656;
364
+ }
365
+ p.cpu-help-text {
366
+ width: 310px;
367
+ margin-top: 24px;
368
+ font-size: 14px;
369
+ color: #565656;
370
+ }
371
+ a.cpu-more-info {
372
+ color: #00648f;
373
+ font-size: 14px;
374
+ }
375
+ </style>