bfg-common 1.3.467 → 1.3.469

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 (109) hide show
  1. package/assets/scss/common/normalize.scss +340 -340
  2. package/components/atoms/TheIcon2.vue +1353 -1353
  3. package/components/atoms/loader/Loader.vue +30 -30
  4. package/components/atoms/loader/PreLoader.vue +38 -38
  5. package/components/atoms/switch/Switch.vue +111 -111
  6. package/components/atoms/table/compact/Compact.vue +526 -526
  7. package/components/common/adapterManager/ui/table/Header.vue +93 -93
  8. package/components/common/adapterManager/ui/table/Table.vue +162 -162
  9. package/components/common/context/Context.vue +99 -99
  10. package/components/common/layout/theHeader/LanguageSwitch.vue +102 -0
  11. package/components/common/layout/theHeader/TheHeader.vue +91 -0
  12. package/components/common/layout/theHeader/TheHeaderNew.vue +229 -0
  13. package/components/common/layout/theHeader/TheHeaderOld.vue +241 -0
  14. package/components/common/layout/theHeader/feedback/Feedback.vue +104 -0
  15. package/components/common/layout/theHeader/feedback/FeedbackNew.vue +63 -0
  16. package/components/common/layout/theHeader/feedback/FeedbackOld.vue +73 -0
  17. package/components/common/layout/theHeader/helpMenu/About.vue +110 -0
  18. package/components/common/layout/theHeader/helpMenu/HelpMenu.vue +45 -0
  19. package/components/common/layout/theHeader/helpMenu/helpMenuNew/HelpMenuNew.vue +116 -0
  20. package/components/common/layout/theHeader/helpMenu/helpMenuNew/lib/config/dropMenu.ts +25 -0
  21. package/components/common/layout/theHeader/helpMenu/helpMenuOld/HelpMenuOld.vue +69 -0
  22. package/components/common/layout/theHeader/helpMenu/helpMenuOld/lib/config/dropMenu.ts +22 -0
  23. package/components/common/layout/theHeader/helpMenu/helpMenuOld/lib/models/types.ts +1 -0
  24. package/components/common/layout/theHeader/lib/models/types.ts +5 -0
  25. package/components/common/layout/theHeader/modals/Reconnect.vue +98 -0
  26. package/components/common/layout/theHeader/modals/RedirectLogin.vue +60 -0
  27. package/components/common/layout/theHeader/userMenu/UserMenu.vue +95 -0
  28. package/components/common/layout/theHeader/userMenu/lib/models/interfaces.ts +32 -0
  29. package/components/common/layout/theHeader/userMenu/modals/changePassword/ChangePassword.vue +210 -0
  30. package/components/common/layout/theHeader/userMenu/modals/changePassword/lib/config/form.ts +31 -0
  31. package/components/common/layout/theHeader/userMenu/modals/changePassword/lib/models/interfaces.ts +12 -0
  32. package/components/common/layout/theHeader/userMenu/modals/preferences/Inventory.vue +43 -0
  33. package/components/common/layout/theHeader/userMenu/modals/preferences/Preferences.vue +119 -0
  34. package/components/common/layout/theHeader/userMenu/modals/preferences/View.vue +113 -0
  35. package/components/common/layout/theHeader/userMenu/modals/preferences/changeLanguage/ChangeLanguage.vue +148 -0
  36. package/components/common/layout/theHeader/userMenu/modals/preferences/changeLanguage/lib/config/lang.ts +10 -0
  37. package/components/common/layout/theHeader/userMenu/modals/preferences/changeLanguage/lib/config/radioOptions.ts +22 -0
  38. package/components/common/layout/theHeader/userMenu/modals/preferences/changeLanguage/lib/models/enums.ts +9 -0
  39. package/components/common/layout/theHeader/userMenu/modals/preferences/changeLanguage/lib/models/interfaces.ts +11 -0
  40. package/components/common/layout/theHeader/userMenu/modals/preferences/changeLanguage/lib/models/types.ts +1 -0
  41. package/components/common/layout/theHeader/userMenu/modals/preferences/defaultConsole/DefaultConsole.vue +66 -0
  42. package/components/common/layout/theHeader/userMenu/modals/preferences/defaultConsole/lib/config/consoleOptions.ts +30 -0
  43. package/components/common/layout/theHeader/userMenu/modals/preferences/defaultConsole/lib/models/interfaces.ts +5 -0
  44. package/components/common/layout/theHeader/userMenu/modals/preferences/lib/config/preferencesTabs.ts +68 -0
  45. package/components/common/layout/theHeader/userMenu/modals/preferences/lib/models/types.ts +1 -0
  46. package/components/common/layout/theHeader/userMenu/modals/preferences/timeFormat/TimeFormat.vue +67 -0
  47. package/components/common/layout/theHeader/userMenu/modals/preferences/timeFormat/lib/config/formatOptions.ts +27 -0
  48. package/components/common/layout/theHeader/userMenu/modals/preferences/timeFormat/lib/models/types.ts +1 -0
  49. package/components/common/layout/theHeader/userMenu/userMenuNew/UserMenuNew.vue +114 -0
  50. package/components/common/layout/theHeader/userMenu/userMenuNew/lib/config/dropMenu.ts +28 -0
  51. package/components/common/layout/theHeader/userMenu/userMenuOld/UserMenuOld.vue +36 -0
  52. package/components/common/layout/theHeader/userMenu/userMenuOld/lib/config/dropMenu.ts +36 -0
  53. package/components/common/layout/theHeader/userMenu/userMenuOld/lib/models/types.ts +5 -0
  54. package/components/common/lib/config/states.ts +160 -160
  55. package/components/common/mainNavigationPanel/MainNavigationPanel.vue +142 -142
  56. package/components/common/mainNavigationPanel/MainNavigationPanelNew.vue +248 -248
  57. package/components/common/mainNavigationPanel/MainNavigationPanelOld.vue +288 -288
  58. package/components/common/readyToComplete/ReadyToComplete.vue +15 -15
  59. package/components/common/resource/progressBlock/ProgressBlock.vue +142 -142
  60. package/components/common/split/horizontal/Horizontal.vue +70 -70
  61. package/components/common/vm/actions/clone/Clone.vue +511 -511
  62. package/components/common/vm/actions/common/customizeHardware/CustomizeHardware.vue +273 -273
  63. package/components/common/vm/actions/common/customizeHardware/virtualHardware/VirtualHardware.vue +697 -697
  64. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/Cpu.vue +400 -400
  65. package/components/common/vm/actions/common/customizeHardware/virtualHardware/memory/Memory.vue +329 -329
  66. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/NewNetwork.vue +305 -305
  67. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/NewPciDevice.vue +168 -168
  68. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newUsbController/NewUsbController.vue +82 -82
  69. package/components/common/vm/actions/common/customizeHardware/virtualHardware/other/Other.vue +32 -32
  70. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/VideoCard.vue +182 -182
  71. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/BootOptions.vue +114 -114
  72. package/components/common/vm/actions/common/customizeHardware/vmoptions/generalOptions/GeneralOptions.vue +192 -192
  73. package/components/common/vm/actions/common/customizeHardware/vmoptions/tools/Tools.vue +72 -72
  74. package/components/common/vm/actions/common/select/computeResource/ComputeResource.vue +164 -164
  75. package/components/common/vm/actions/common/select/name/Name.vue +235 -235
  76. package/components/common/vm/actions/common/select/storage/Storage.vue +198 -198
  77. package/components/common/vm/actions/editSettings/EditSettings.vue +316 -316
  78. package/components/common/weekSelect/lib/config/options.ts +10 -10
  79. package/components/common/wizards/datastore/add/Add.vue +436 -436
  80. package/components/common/wizards/datastore/add/lib/config/stepItems.ts +191 -191
  81. package/components/common/wizards/datastore/add/lib/models/interfaces.ts +38 -38
  82. package/components/common/wizards/datastore/add/lib/utils.ts +70 -70
  83. package/components/common/wizards/datastore/add/local/createName/CreateName.vue +160 -160
  84. package/components/common/wizards/datastore/add/nfs/Nfs.vue +112 -112
  85. package/components/common/wizards/datastore/add/nfs/accessibility/Accessibility.vue +104 -104
  86. package/components/common/wizards/datastore/add/nfs/accessibility/tablesView/lib/config/compatibleTable.ts +62 -62
  87. package/components/common/wizards/datastore/add/nfs/accessibility/tablesView/lib/config/hostsTableItems.ts +53 -53
  88. package/components/common/wizards/datastore/add/readyComplete/ReadyComplete.vue +86 -86
  89. package/components/common/wizards/datastore/add/readyComplete/lib/config/propertiesDetails.ts +184 -184
  90. package/components/common/wizards/datastore/add/sharedStorm/deviceSelection/DeviceSelection.vue +459 -459
  91. package/components/common/wizards/datastore/add/types/Types.vue +80 -80
  92. package/components/common/wizards/datastore/add/types/lib/config/typeOptions.ts +49 -49
  93. package/composables/useAppVersion.ts +22 -22
  94. package/composables/useEnvLanguage.ts +20 -20
  95. package/lib/utils/sendTask.ts +73 -73
  96. package/minify.js +146 -146
  97. package/package.json +2 -1
  98. package/plugins/spice-console/spice.console.ts +147 -147
  99. package/public/spice-console/application/codec.js +263 -263
  100. package/public/spice-console/lib/rasterEngine.js +907 -907
  101. package/public/spice-console/network/spicechannel.js +375 -375
  102. package/store/main/lib/interfaces.ts +9 -9
  103. package/store/tasks/actions.ts +133 -133
  104. package/store/tasks/getters.ts +25 -25
  105. package/store/tasks/lib/models/interfaces.ts +18 -18
  106. package/store/tasks/mutations.ts +58 -58
  107. package/store/tasks/state.ts +16 -16
  108. /package/components/{layout → common/layout}/theHeader/lib/models/enums.ts +0 -0
  109. /package/components/{layout → common/layout}/theHeader/lib/utils/localization.ts +0 -0
@@ -1,400 +1,400 @@
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.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 { UI_I_SendDataCpu } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
128
- import { UI_I_Localization } from '~/lib/models/interfaces'
129
- import { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
130
- import { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
131
- import { 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.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.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.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 { UI_I_SendDataCpu } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
128
+ import { UI_I_Localization } from '~/lib/models/interfaces'
129
+ import { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
130
+ import { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
131
+ import { 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.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.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>