bfg-common 1.4.54 → 1.4.55

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 (49) hide show
  1. package/assets/img/icons/icons-sprite-dark-6.svg +190 -1
  2. package/assets/img/icons/icons-sprite-light-6.svg +190 -1
  3. package/assets/localization/local_be.json +1 -14
  4. package/assets/localization/local_en.json +1 -14
  5. package/assets/localization/local_hy.json +1 -14
  6. package/assets/localization/local_kk.json +1 -14
  7. package/assets/localization/local_ru.json +25 -38
  8. package/assets/localization/local_zh.json +1 -14
  9. package/components/atoms/modal/bySteps/BySteps.vue +253 -253
  10. package/components/atoms/table/dataGrid/lib/config/settingsTable.ts +4 -31
  11. package/components/atoms/table/dataGrid/lib/models/interfaces.ts +0 -5
  12. package/components/common/browse/blocks/Title.vue +91 -91
  13. package/components/common/browse/blocks/info/Date.vue +21 -21
  14. package/components/common/context/recursion/Recursion.vue +86 -86
  15. package/components/common/context/recursion/RecursionNew.vue +198 -198
  16. package/components/common/context/recursion/RecursionOld.vue +212 -212
  17. package/components/common/graph/Graph.vue +4 -5
  18. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/lib/config/utils.ts +6 -6
  19. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/timespan/Timespan.vue +1 -0
  20. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/timespan/object/Object.vue +1 -1
  21. package/components/common/pages/hardwareHealth/HardwareHealth.vue +9 -12
  22. package/components/common/pages/hardwareHealth/historyTestimony/Graph.vue +22 -103
  23. package/components/common/pages/hardwareHealth/historyTestimony/lib/models/interfaces.ts +0 -1
  24. package/components/common/pages/hardwareHealth/historyTestimony/tools/Tools.vue +4 -9
  25. package/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/ChartOptionsModal.vue +11 -29
  26. package/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/counters/Counters.vue +5 -10
  27. package/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/counters/timespan/Timespan.vue +4 -6
  28. package/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/counters/timespan/form/Form.vue +13 -13
  29. package/components/common/pages/hardwareHealth/historyTestimony/tools/lib/config/toolbar.ts +0 -4
  30. package/components/common/pages/hardwareHealth/lib/config/status.ts +1 -1
  31. package/components/common/pages/hardwareHealth/tableView/TableView.vue +2 -7
  32. package/components/common/pages/hardwareHealth/tableView/lib/config/historyTestimonyTable.ts +2 -11
  33. package/components/common/pages/hardwareHealth/tableView/lib/models/interfaces.ts +0 -1
  34. package/components/common/pages/hardwareHealth/tableView/modal/{SensorWarning.vue → sensorWarning.vue} +1 -1
  35. package/components/common/recursionTree/RecursionTree.vue +1 -5
  36. package/components/common/split/horizontal/HorizontalNew.vue +321 -321
  37. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/Cpu.vue +403 -400
  38. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/CpuHotPlug.vue +57 -52
  39. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/Hv.vue +99 -99
  40. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/streamingMode/StreamingMode.vue +85 -85
  41. package/components/common/wizards/datastore/add/Add.vue +437 -437
  42. package/composables/productNameLocal.ts +30 -30
  43. package/lib/models/interfaces.ts +0 -2
  44. package/package.json +1 -1
  45. package/plugins/recursion.ts +311 -311
  46. package/public/spice-console/lib/images/bitmap.js +203 -203
  47. package/store/tasks/mappers/recentTasks.ts +45 -45
  48. package/assets/img/icons/icons-sprite-dark-9.svg +0 -71
  49. package/assets/img/icons/icons-sprite-light-9.svg +0 -71
@@ -1,400 +1,403 @@
1
- <template>
2
- <div class="hardware-cpu">
3
- <atoms-stack-block :has-children="true" test-id="cpu-stack-block">
4
- <template #stackBlockKey>
5
- <div
6
- id="vm-wizard-toggle-block-cpu"
7
- data-id="vm-wizard-toggle-block-cpu"
8
- class="flex-align-center"
9
- >
10
- <span>{{ localization.common.cpu }}</span>
11
- <atoms-the-icon
12
- v-show="cpuInvalid"
13
- width="24px"
14
- height="24px"
15
- class="is-error tooltip-trigger"
16
- name="info"
17
- />
18
- </div>
19
- </template>
20
- <template #stackBlockContent>
21
- <div class="flex-align-center flex-space-between">
22
- <div class="flex-align-center">
23
- <atoms-tooltip-error
24
- :has-error="!!vcpusLocalAndApiErrorsTexts"
25
- selector="#vm-wizard-vcpus-field input"
26
- @remove="onRemoveValidationError"
27
- >
28
- <template #elem>
29
- <atoms-combobox
30
- id="vm-wizard-vcpus-field"
31
- class="input-text-color"
32
- v-model.number="selectedCpu"
33
- :items="cpuOptions"
34
- :disabled="isCpuDisabled"
35
- test-id="vm-wizard-cpu-combobox"
36
- @click.stop
37
- />
38
- </template>
39
- <template #content>{{ vcpusLocalAndApiErrorsTexts }}</template>
40
- </atoms-tooltip-error>
41
- </div>
42
-
43
- <common-vm-actions-common-customize-hardware-virtual-hardware-cpu-tooltip
44
- :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
45
- />
46
- </div>
47
- </template>
48
- <template #stackChildren>
49
- <common-vm-actions-common-customize-hardware-virtual-hardware-cpu-cores-per-socket
50
- v-model:selected-core-per-socket="selectedCorePerSocket"
51
- :selected-cpus="selectedCpus"
52
- :cpu-options="cpuOptions"
53
- :is-edit="props.isEdit"
54
- :disabled="isDisabled"
55
- :error-validation-fields="props.errorValidationFields"
56
- @remove-error-by-title="emits('remove-error-by-title', $event)"
57
- />
58
- <common-vm-actions-common-customize-hardware-virtual-hardware-cpu-hot-plug
59
- v-model:enable-cpu-hot-add="enableCpuHotAdd"
60
- :disabled="enableCpuHotAddDisabled"
61
- />
62
- <common-vm-actions-common-customize-hardware-virtual-hardware-cpu-max-cpu
63
- v-show="enableCpuHotAdd"
64
- v-model:selected-max-cpu.number="selectedMaxCpu"
65
- :cpu-options="maxCpuOptions"
66
- :error-validation-fields="props.errorValidationFields"
67
- :disabled="isDisabled"
68
- @invalid="maxCpuInvalid = $event"
69
- @remove-error-by-title="emits('remove-error-by-title', $event)"
70
- />
71
- <common-vm-actions-common-customize-hardware-virtual-hardware-reservation
72
- v-model:reservation="reservation"
73
- v-model:reservation-type="reservationType"
74
- :error-validation-fields="props.errorValidationFields"
75
- :disabled="isDisabled"
76
- type="mhz"
77
- component-type="cpu"
78
- @invalid="reservationInvalid = $event"
79
- @remove-error-by-title="emits('remove-error-by-title', $event)"
80
- />
81
- <common-vm-actions-common-customize-hardware-virtual-hardware-limit
82
- v-model:limit="limit"
83
- v-model:limit-type="limitType"
84
- :error-validation-fields="props.errorValidationFields"
85
- :disabled="isDisabled"
86
- type="mhz"
87
- component-type="cpu"
88
- @invalid="limitInvalid = $event"
89
- @remove-error-by-title="emits('remove-error-by-title', $event)"
90
- />
91
- <common-vm-actions-common-customize-hardware-virtual-hardware-cpu-shares
92
- v-model:shares="shares"
93
- v-model:shares-type="sharesType"
94
- :error-validation-fields="props.errorValidationFields"
95
- :disabled="isDisabled"
96
- @remove-error-by-title="emits('remove-error-by-title', $event)"
97
- @invalid="sharesInvalid = $event"
98
- />
99
- <!-- <common-vm-actions-common-customize-hardware-virtual-hardware-cpu-hv-->
100
- <!-- v-models:hardwareVirtualization="hardwareVirtualization"-->
101
- <!-- />-->
102
- <!-- <common-vm-actions-common-customize-hardware-virtual-hardware-cpu-pc-->
103
- <!-- v-models:performanceCounters="performanceCounters"-->
104
- <!-- />-->
105
- <!-- <common-vm-actions-common-customize-hardware-virtual-hardware-cpu-sa-->
106
- <!-- v-models:schedulingAffinity="schedulingAffinity"-->
107
- <!-- />-->
108
- <!-- <common-vm-actions-common-customize-hardware-virtual-hardware-cpu-iommu-->
109
- <!-- v-models:iommu="iommu"-->
110
- <!-- />-->
111
- <common-vm-actions-common-customize-hardware-virtual-hardware-cpu-model
112
- v-model:cpu-model="cpuModel"
113
- v-model:passthrough-host-cpu="passthroughHostCpu"
114
- v-model:host-model-cpu="hostModelCpu"
115
- :cpu-models="props.cpuModels"
116
- :is-edit="props.isEdit"
117
- :error-validation-fields="props.errorValidationFields"
118
- :disabled="isDisabled"
119
- @remove-error-by-title="emits('remove-error-by-title', $event)"
120
- />
121
- </template>
122
- </atoms-stack-block>
123
- </div>
124
- </template>
125
-
126
- <script setup lang="ts">
127
- import type { UI_I_SendDataCpu } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
128
- import type { UI_I_Localization } from '~/lib/models/interfaces'
129
- import type { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
130
- import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
131
- import type { API_UI_I_VmEditCpu } from '~/lib/models/store/vm/interfaces'
132
- import { cpuOptionsFunc } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/lib/config/cpuOptions'
133
-
134
- const props = defineProps<{
135
- maxCpus: number
136
- cpuModels: UI_I_OptionItem[]
137
- isEdit: boolean
138
- errorValidationFields: UI_I_ErrorValidationField<string>[]
139
- vmCpuHelpTextSecond?: string
140
- state?: string | number
141
- cpu?: API_UI_I_VmEditCpu
142
- }>()
143
- const emits = defineEmits<{
144
- (event: 'send-data', value: UI_I_SendDataCpu): void
145
- (event: 'invalid', value: boolean): void
146
- (event: 'remove-error-by-title', value: string): void
147
- }>()
148
-
149
- const localization = computed<UI_I_Localization>(() => useLocal())
150
-
151
- const isDisabled = computed<boolean>(() => {
152
- return props.state === 2
153
- })
154
-
155
- const cpuOptions = computed<UI_I_OptionItem[]>(() =>
156
- cpuOptionsFunc(localization.value, 1, props.maxCpus)
157
- )
158
-
159
- const enableCpuHotAdd = ref<boolean>(false)
160
- const enableCpuHotAddDisabled = computed<boolean>(
161
- () => selectedCpu.value >= props.maxCpus || isDisabled.value
162
- )
163
- watch(enableCpuHotAdd, (newValue) => {
164
- if (newValue) return
165
-
166
- maxCpuInvalid.value = false
167
- selectedMaxCpu.value = 1
168
- })
169
-
170
- const selectedCpu = ref<number>(
171
- isDisabled.value && enableCpuHotAdd.value ? props.maxCpus : 2
172
- )
173
- const isCpuDisabled = computed<boolean>(
174
- () => isDisabled.value && !enableCpuHotAdd.value
175
- )
176
- watch(selectedCpu, (newValue) => {
177
- selectedCpu.value = Math.floor(+newValue)
178
- if (!(selectedCpu.value % selectedCorePerSocket.value) || isDisabled.value)
179
- return
180
- selectedCorePerSocket.value = 1
181
- })
182
- const maxCpuOptions = computed<UI_I_OptionItem[]>(() =>
183
- cpuOptionsFunc(localization.value, selectedCpu.value, props.maxCpus)
184
- )
185
- watch(selectedCpu, (newValue) => {
186
- if (newValue >= props.maxCpus) {
187
- enableCpuHotAdd.value = false
188
- }
189
- // selectedMaxCpu.value =
190
- // selectedMaxCpu.value <= newValue ? newValue + 1 : selectedMaxCpu.value
191
- // if (selectedMaxCpu.value > props.maxCpus) selectedMaxCpu.value = props.maxCpus
192
- })
193
- const selectedMaxCpu = ref<number>(1)
194
- watch(
195
- () => props.maxCpus,
196
- (newValue) => {
197
- selectedMaxCpu.value = newValue
198
- }
199
- )
200
-
201
- const selectedCpus = computed<number[]>(() =>
202
- enableCpuHotAdd.value
203
- ? [selectedCpu.value, selectedMaxCpu.value]
204
- : [selectedCpu.value]
205
- )
206
-
207
- const selectedCorePerSocket = ref<number>(1)
208
-
209
- const cpuErrorLocalText = computed<string>(() => {
210
- const validValue = /^\d+(\.\d+)?$/.test(selectedCpu.value + '')
211
- if (!validValue) {
212
- return localization.value.common.inputContainsInvalidCharacters
213
- }
214
-
215
- const min = cpuOptions.value[0].value
216
- const max = cpuOptions.value[1].value
217
- if (selectedCpu.value < min || selectedCpu.value > max) {
218
- return localization.value.common.memoryMustBe
219
- .replace('{0}', min)
220
- .replace('{1}', max)
221
- }
222
-
223
- return ''
224
- })
225
-
226
- const apiVcpusError = computed<string>(() => {
227
- return (
228
- props.errorValidationFields?.find(
229
- (message) => message.field === 'cpu.vcpus'
230
- )?.error_message || ''
231
- )
232
- })
233
-
234
- const vcpusLocalAndApiErrorsTexts = computed<string>(() => {
235
- const localError = cpuErrorLocalText.value
236
- const apiError = apiVcpusError.value
237
-
238
- let result = ''
239
- if (localError && !apiError) result = localError
240
- if (!localError && apiError) result = apiError
241
- if (localError && apiError) result = localError + ', ' + apiError
242
- if (!localError && apiError) result = apiError
243
-
244
- return result
245
- })
246
- const reservationInvalid = ref<boolean>(false)
247
- const limitInvalid = ref<boolean>(false)
248
- const sharesInvalid = ref<boolean>(false)
249
- const maxCpuInvalid = ref<boolean>(false)
250
- const cpuInvalid = computed<boolean>(
251
- () =>
252
- !!cpuErrorLocalText.value ||
253
- reservationInvalid.value ||
254
- limitInvalid.value ||
255
- sharesInvalid.value ||
256
- (enableCpuHotAdd.value &&
257
- selectedCpu.value < props.maxCpus &&
258
- maxCpuInvalid.value)
259
- )
260
- watch(
261
- cpuInvalid,
262
- (newValue: boolean) => {
263
- emits('invalid', newValue)
264
- },
265
- { immediate: true }
266
- )
267
-
268
- const reservation = ref<string>('1')
269
- const reservationType = ref<string>('mhz')
270
-
271
- const limit = ref<string>('Unlimited')
272
- const limitType = ref<string>('mhz')
273
-
274
- const shares = ref<string>('2000')
275
- const sharesType = ref<string>('2000')
276
-
277
- // const hardwareVirtualization = ref<boolean>(false)
278
- //
279
- // const performanceCounters = ref<boolean>(false)
280
- //
281
- // const schedulingAffinity = ref<string>('')
282
- //
283
- // const iommu = ref<boolean>(false)
284
-
285
- // const cpuModel = ref<string>(props.cpuModels[0]?.value || '')
286
- const cpuModel = ref<string>('host-model') // PNCWEB-389
287
- watch(
288
- () => props.cpuModels,
289
- (newValue) => {
290
- cpuModel.value = newValue[0].value
291
- }
292
- )
293
- const passthroughHostCpu = ref<boolean>(false)
294
- const hostModelCpu = ref<boolean>(false)
295
-
296
- // const isShowCpuHelp = ref<boolean>(false)
297
-
298
- const { $binary } = useNuxtApp()
299
- watch(
300
- [
301
- reservation,
302
- reservationType,
303
- limit,
304
- limitType,
305
- shares,
306
- selectedCpu,
307
- selectedMaxCpu,
308
- selectedCorePerSocket,
309
- enableCpuHotAdd,
310
- cpuModel,
311
- passthroughHostCpu,
312
- hostModelCpu,
313
- ],
314
- () => {
315
- const reservationInMhz =
316
- reservationType.value === 'ghz'
317
- ? $binary.ghzToMhz(+reservation.value)
318
- : +reservation.value
319
- const limitInMhz =
320
- limit.value === 'Unlimited'
321
- ? limit.value
322
- : limitType.value === 'ghz'
323
- ? $binary.ghzToMhz(+limit.value)
324
- : +limit.value
325
- const model = passthroughHostCpu.value
326
- ? 'host-passthrough'
327
- : hostModelCpu.value
328
- ? 'host-model'
329
- : cpuModel.value
330
-
331
- emits('send-data', {
332
- model,
333
- vcpus: selectedCpu.value,
334
- max_vcpus: enableCpuHotAdd.value ? selectedMaxCpu.value : 0,
335
- core_per_socket: selectedCorePerSocket.value,
336
- reservation_mhz: reservationInMhz,
337
- limit_mhz: limitInMhz,
338
- shares: +shares.value,
339
- hotplug: enableCpuHotAdd.value,
340
- })
341
- },
342
- {
343
- immediate: true,
344
- }
345
- )
346
-
347
- // Добавляем данные для редактирования
348
- watch(
349
- () => props.cpu,
350
- (newValue) => {
351
- if (!newValue) return
352
-
353
- enableCpuHotAdd.value = newValue.hotplug
354
- selectedCpu.value = newValue.vcpus
355
- selectedMaxCpu.value = newValue.hotplug ? newValue.max_vcpus : 1
356
- selectedCorePerSocket.value = newValue.core_per_socket
357
- reservation.value = '' + newValue.reservation_mhz
358
- limit.value = '' + newValue.limit_mhz
359
- shares.value = '' + newValue.shares
360
-
361
- switch (newValue.model) {
362
- case 'host-passthrough':
363
- passthroughHostCpu.value = true
364
- cpuModel.value = ''
365
- break
366
- case 'host-model':
367
- hostModelCpu.value = true
368
- cpuModel.value = ''
369
- break
370
- default:
371
- cpuModel.value =
372
- props.cpuModels.find((model) => model.value === newValue.model)
373
- ?.value || cpuModel.value
374
- }
375
- },
376
- { immediate: true }
377
- )
378
-
379
- const onRemoveValidationError = (): void => {
380
- emits('remove-error-by-title', 'cpu.vcpus')
381
- }
382
- </script>
383
-
384
- <style scoped lang="scss">
385
- h3.cpu-help-title {
386
- margin-top: 7px;
387
- font-size: 22px;
388
- color: #565656;
389
- }
390
- p.cpu-help-text {
391
- width: 310px;
392
- margin-top: 24px;
393
- font-size: 14px;
394
- color: #565656;
395
- }
396
- a.cpu-more-info {
397
- color: #00648f;
398
- font-size: 14px;
399
- }
400
- </style>
1
+ <template>
2
+ <div class="hardware-cpu">
3
+ <atoms-stack-block :has-children="true" test-id="cpu-stack-block">
4
+ <template #stackBlockKey>
5
+ <div
6
+ id="vm-wizard-toggle-block-cpu"
7
+ data-id="vm-wizard-toggle-block-cpu"
8
+ class="flex-align-center"
9
+ >
10
+ <span>{{ localization.common.cpu }}</span>
11
+ <atoms-the-icon
12
+ v-show="cpuInvalid"
13
+ width="24px"
14
+ height="24px"
15
+ class="is-error tooltip-trigger"
16
+ name="info"
17
+ />
18
+ </div>
19
+ </template>
20
+ <template #stackBlockContent>
21
+ <div class="flex-align-center flex-space-between">
22
+ <div class="flex-align-center">
23
+ <atoms-tooltip-error
24
+ :has-error="!!vcpusLocalAndApiErrorsTexts"
25
+ selector="#vm-wizard-vcpus-field input"
26
+ @remove="onRemoveValidationError"
27
+ >
28
+ <template #elem>
29
+ <atoms-combobox
30
+ id="vm-wizard-vcpus-field"
31
+ class="input-text-color"
32
+ v-model.number="selectedCpu"
33
+ :items="cpuOptions"
34
+ :disabled="isCpuDisabled"
35
+ test-id="vm-wizard-cpu-combobox"
36
+ @click.stop
37
+ />
38
+ </template>
39
+ <template #content>{{ vcpusLocalAndApiErrorsTexts }}</template>
40
+ </atoms-tooltip-error>
41
+ </div>
42
+
43
+ <common-vm-actions-common-customize-hardware-virtual-hardware-cpu-tooltip
44
+ :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
45
+ />
46
+ </div>
47
+ </template>
48
+ <template #stackChildren>
49
+ <common-vm-actions-common-customize-hardware-virtual-hardware-cpu-cores-per-socket
50
+ v-model:selected-core-per-socket="selectedCorePerSocket"
51
+ :selected-cpus="selectedCpus"
52
+ :cpu-options="cpuOptions"
53
+ :is-edit="props.isEdit"
54
+ :disabled="isDisabled"
55
+ :error-validation-fields="props.errorValidationFields"
56
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
57
+ />
58
+ <common-vm-actions-common-customize-hardware-virtual-hardware-cpu-hot-plug
59
+ v-model:enable-cpu-hot-add="enableCpuHotAdd"
60
+ :disabled="enableCpuHotAddDisabled"
61
+ />
62
+ <common-vm-actions-common-customize-hardware-virtual-hardware-cpu-max-cpu
63
+ v-show="enableCpuHotAdd"
64
+ v-model:selected-max-cpu.number="selectedMaxCpu"
65
+ :cpu-options="maxCpuOptions"
66
+ :error-validation-fields="props.errorValidationFields"
67
+ :disabled="isDisabled"
68
+ @invalid="maxCpuInvalid = $event"
69
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
70
+ />
71
+ <common-vm-actions-common-customize-hardware-virtual-hardware-reservation
72
+ v-model:reservation="reservation"
73
+ v-model:reservation-type="reservationType"
74
+ :error-validation-fields="props.errorValidationFields"
75
+ :disabled="isDisabled"
76
+ type="mhz"
77
+ component-type="cpu"
78
+ @invalid="reservationInvalid = $event"
79
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
80
+ />
81
+ <common-vm-actions-common-customize-hardware-virtual-hardware-limit
82
+ v-model:limit="limit"
83
+ v-model:limit-type="limitType"
84
+ :error-validation-fields="props.errorValidationFields"
85
+ :disabled="isDisabled"
86
+ type="mhz"
87
+ component-type="cpu"
88
+ @invalid="limitInvalid = $event"
89
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
90
+ />
91
+ <common-vm-actions-common-customize-hardware-virtual-hardware-cpu-shares
92
+ v-model:shares="shares"
93
+ v-model:shares-type="sharesType"
94
+ :error-validation-fields="props.errorValidationFields"
95
+ :disabled="isDisabled"
96
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
97
+ @invalid="sharesInvalid = $event"
98
+ />
99
+ <!-- <common-vm-actions-common-customize-hardware-virtual-hardware-cpu-hv-->
100
+ <!-- v-models:hardwareVirtualization="hardwareVirtualization"-->
101
+ <!-- />-->
102
+ <!-- <common-vm-actions-common-customize-hardware-virtual-hardware-cpu-pc-->
103
+ <!-- v-models:performanceCounters="performanceCounters"-->
104
+ <!-- />-->
105
+ <!-- <common-vm-actions-common-customize-hardware-virtual-hardware-cpu-sa-->
106
+ <!-- v-models:schedulingAffinity="schedulingAffinity"-->
107
+ <!-- />-->
108
+ <!-- <common-vm-actions-common-customize-hardware-virtual-hardware-cpu-iommu-->
109
+ <!-- v-models:iommu="iommu"-->
110
+ <!-- />-->
111
+ <common-vm-actions-common-customize-hardware-virtual-hardware-cpu-model
112
+ v-model:cpu-model="cpuModel"
113
+ v-model:passthrough-host-cpu="passthroughHostCpu"
114
+ v-model:host-model-cpu="hostModelCpu"
115
+ :cpu-models="props.cpuModels"
116
+ :is-edit="props.isEdit"
117
+ :error-validation-fields="props.errorValidationFields"
118
+ :disabled="isDisabled"
119
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
120
+ />
121
+ </template>
122
+ </atoms-stack-block>
123
+ </div>
124
+ </template>
125
+
126
+ <script setup lang="ts">
127
+ import type { UI_I_SendDataCpu } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
128
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
129
+ import type { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
130
+ import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
131
+ import type { API_UI_I_VmEditCpu } from '~/lib/models/store/vm/interfaces'
132
+ import { cpuOptionsFunc } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/lib/config/cpuOptions'
133
+
134
+ const props = defineProps<{
135
+ maxCpus: number
136
+ cpuModels: UI_I_OptionItem[]
137
+ isEdit: boolean
138
+ errorValidationFields: UI_I_ErrorValidationField<string>[]
139
+ vmCpuHelpTextSecond?: string
140
+ state?: string | number
141
+ cpu?: API_UI_I_VmEditCpu
142
+ }>()
143
+ const emits = defineEmits<{
144
+ (event: 'send-data', value: UI_I_SendDataCpu): void
145
+ (event: 'invalid', value: boolean): void
146
+ (event: 'remove-error-by-title', value: string): void
147
+ }>()
148
+
149
+ const localization = computed<UI_I_Localization>(() => useLocal())
150
+
151
+ const isDisabled = computed<boolean>(() => {
152
+ return props.state === 2
153
+ })
154
+
155
+ const cpuOptions = computed<UI_I_OptionItem[]>(() =>
156
+ cpuOptionsFunc(localization.value, 1, props.maxCpus)
157
+ )
158
+
159
+ const enableCpuHotAdd = ref<boolean>(false)
160
+ const enableCpuHotAddDisabled = computed<boolean>(
161
+ () => selectedCpu.value >= props.maxCpus || isDisabled.value
162
+ )
163
+ watch(enableCpuHotAdd, (newValue) => {
164
+ console.log(newValue, 333)
165
+ if (newValue) return
166
+
167
+ maxCpuInvalid.value = false
168
+ selectedMaxCpu.value = 1
169
+ })
170
+
171
+ const selectedCpu = ref<number>(
172
+ isDisabled.value && enableCpuHotAdd.value ? props.maxCpus : 2
173
+ )
174
+ const isCpuDisabled = computed<boolean>(
175
+ () => isDisabled.value && !enableCpuHotAdd.value
176
+ )
177
+ watch(selectedCpu, (newValue) => {
178
+ selectedCpu.value = Math.floor(+newValue)
179
+ if (!(selectedCpu.value % selectedCorePerSocket.value) || isDisabled.value)
180
+ return
181
+ selectedCorePerSocket.value = 1
182
+ })
183
+ const maxCpuOptions = computed<UI_I_OptionItem[]>(() =>
184
+ cpuOptionsFunc(localization.value, selectedCpu.value, props.maxCpus)
185
+ )
186
+ watch(selectedCpu, (newValue) => {
187
+ if (newValue >= props.maxCpus) {
188
+ console.log(444)
189
+ enableCpuHotAdd.value = false
190
+ }
191
+ // selectedMaxCpu.value =
192
+ // selectedMaxCpu.value <= newValue ? newValue + 1 : selectedMaxCpu.value
193
+ // if (selectedMaxCpu.value > props.maxCpus) selectedMaxCpu.value = props.maxCpus
194
+ })
195
+ const selectedMaxCpu = ref<number>(1)
196
+ watch(
197
+ () => props.maxCpus,
198
+ (newValue) => {
199
+ selectedMaxCpu.value = newValue
200
+ }
201
+ )
202
+
203
+ const selectedCpus = computed<number[]>(() =>
204
+ enableCpuHotAdd.value
205
+ ? [selectedCpu.value, selectedMaxCpu.value]
206
+ : [selectedCpu.value]
207
+ )
208
+
209
+ const selectedCorePerSocket = ref<number>(1)
210
+
211
+ const cpuErrorLocalText = computed<string>(() => {
212
+ const validValue = /^\d+(\.\d+)?$/.test(selectedCpu.value + '')
213
+ if (!validValue) {
214
+ return localization.value.common.inputContainsInvalidCharacters
215
+ }
216
+
217
+ const min = cpuOptions.value[0].value
218
+ const max = cpuOptions.value[1].value
219
+ if (selectedCpu.value < min || selectedCpu.value > max) {
220
+ return localization.value.common.memoryMustBe
221
+ .replace('{0}', min)
222
+ .replace('{1}', max)
223
+ }
224
+
225
+ return ''
226
+ })
227
+
228
+ const apiVcpusError = computed<string>(() => {
229
+ return (
230
+ props.errorValidationFields?.find(
231
+ (message) => message.field === 'cpu.vcpus'
232
+ )?.error_message || ''
233
+ )
234
+ })
235
+
236
+ const vcpusLocalAndApiErrorsTexts = computed<string>(() => {
237
+ const localError = cpuErrorLocalText.value
238
+ const apiError = apiVcpusError.value
239
+
240
+ let result = ''
241
+ if (localError && !apiError) result = localError
242
+ if (!localError && apiError) result = apiError
243
+ if (localError && apiError) result = localError + ', ' + apiError
244
+ if (!localError && apiError) result = apiError
245
+
246
+ return result
247
+ })
248
+ const reservationInvalid = ref<boolean>(false)
249
+ const limitInvalid = ref<boolean>(false)
250
+ const sharesInvalid = ref<boolean>(false)
251
+ const maxCpuInvalid = ref<boolean>(false)
252
+ const cpuInvalid = computed<boolean>(
253
+ () =>
254
+ !!cpuErrorLocalText.value ||
255
+ reservationInvalid.value ||
256
+ limitInvalid.value ||
257
+ sharesInvalid.value ||
258
+ (enableCpuHotAdd.value &&
259
+ selectedCpu.value < props.maxCpus &&
260
+ maxCpuInvalid.value)
261
+ )
262
+ watch(
263
+ cpuInvalid,
264
+ (newValue: boolean) => {
265
+ emits('invalid', newValue)
266
+ },
267
+ { immediate: true }
268
+ )
269
+
270
+ const reservation = ref<string>('1')
271
+ const reservationType = ref<string>('mhz')
272
+
273
+ const limit = ref<string>('Unlimited')
274
+ const limitType = ref<string>('mhz')
275
+
276
+ const shares = ref<string>('2000')
277
+ const sharesType = ref<string>('2000')
278
+
279
+ // const hardwareVirtualization = ref<boolean>(false)
280
+ //
281
+ // const performanceCounters = ref<boolean>(false)
282
+ //
283
+ // const schedulingAffinity = ref<string>('')
284
+ //
285
+ // const iommu = ref<boolean>(false)
286
+
287
+ // const cpuModel = ref<string>(props.cpuModels[0]?.value || '')
288
+ const cpuModel = ref<string>('host-model') // PNCWEB-389
289
+ watch(
290
+ () => props.cpuModels,
291
+ (newValue) => {
292
+ cpuModel.value = newValue[0].value
293
+ }
294
+ )
295
+ const passthroughHostCpu = ref<boolean>(false)
296
+ const hostModelCpu = ref<boolean>(false)
297
+
298
+ // const isShowCpuHelp = ref<boolean>(false)
299
+
300
+ const { $binary } = useNuxtApp()
301
+ watch(
302
+ [
303
+ reservation,
304
+ reservationType,
305
+ limit,
306
+ limitType,
307
+ shares,
308
+ selectedCpu,
309
+ selectedMaxCpu,
310
+ selectedCorePerSocket,
311
+ enableCpuHotAdd,
312
+ cpuModel,
313
+ passthroughHostCpu,
314
+ hostModelCpu,
315
+ ],
316
+ () => {
317
+ const reservationInMhz =
318
+ reservationType.value === 'ghz'
319
+ ? $binary.ghzToMhz(+reservation.value)
320
+ : +reservation.value
321
+ const limitInMhz =
322
+ limit.value === 'Unlimited'
323
+ ? limit.value
324
+ : limitType.value === 'ghz'
325
+ ? $binary.ghzToMhz(+limit.value)
326
+ : +limit.value
327
+ const model = passthroughHostCpu.value
328
+ ? 'host-passthrough'
329
+ : hostModelCpu.value
330
+ ? 'host-model'
331
+ : cpuModel.value
332
+
333
+ emits('send-data', {
334
+ model,
335
+ vcpus: selectedCpu.value,
336
+ max_vcpus: enableCpuHotAdd.value ? selectedMaxCpu.value : 0,
337
+ core_per_socket: selectedCorePerSocket.value,
338
+ reservation_mhz: reservationInMhz,
339
+ limit_mhz: limitInMhz,
340
+ shares: +shares.value,
341
+ hotplug: enableCpuHotAdd.value,
342
+ })
343
+ },
344
+ {
345
+ immediate: true,
346
+ }
347
+ )
348
+
349
+ // Добавляем данные для редактирования
350
+ watch(
351
+ () => props.cpu,
352
+ (newValue) => {
353
+ if (!newValue) return
354
+
355
+ console.log(newValue.hotplug, 555)
356
+ enableCpuHotAdd.value = newValue.hotplug
357
+ selectedCpu.value = newValue.vcpus
358
+ selectedMaxCpu.value = newValue.hotplug ? newValue.max_vcpus : 1
359
+ selectedCorePerSocket.value = newValue.core_per_socket
360
+ reservation.value = '' + newValue.reservation_mhz
361
+ limit.value = '' + newValue.limit_mhz
362
+ shares.value = '' + newValue.shares
363
+
364
+ switch (newValue.model) {
365
+ case 'host-passthrough':
366
+ passthroughHostCpu.value = true
367
+ cpuModel.value = ''
368
+ break
369
+ case 'host-model':
370
+ hostModelCpu.value = true
371
+ cpuModel.value = ''
372
+ break
373
+ default:
374
+ cpuModel.value =
375
+ props.cpuModels.find((model) => model.value === newValue.model)
376
+ ?.value || cpuModel.value
377
+ }
378
+ },
379
+ { immediate: true }
380
+ )
381
+
382
+ const onRemoveValidationError = (): void => {
383
+ emits('remove-error-by-title', 'cpu.vcpus')
384
+ }
385
+ </script>
386
+
387
+ <style scoped lang="scss">
388
+ h3.cpu-help-title {
389
+ margin-top: 7px;
390
+ font-size: 22px;
391
+ color: #565656;
392
+ }
393
+ p.cpu-help-text {
394
+ width: 310px;
395
+ margin-top: 24px;
396
+ font-size: 14px;
397
+ color: #565656;
398
+ }
399
+ a.cpu-more-info {
400
+ color: #00648f;
401
+ font-size: 14px;
402
+ }
403
+ </style>