bfg-common 1.5.540 → 1.5.541

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 (124) hide show
  1. package/CODE_STYLE.md +109 -109
  2. package/assets/img/icons/icons-sprite-dark-3.svg +227 -227
  3. package/assets/img/icons/icons-sprite-dark-5.svg +488 -488
  4. package/assets/img/icons/icons-sprite-light-3.svg +227 -227
  5. package/assets/img/icons/icons-sprite-light-5.svg +488 -488
  6. package/components/atoms/TheIcon3.vue +50 -50
  7. package/components/atoms/collapse/CollapseNav.vue +170 -170
  8. package/components/atoms/perPage/PerPage.vue +58 -58
  9. package/components/atoms/table/dataGrid/DataGrid.vue +1718 -1718
  10. package/components/atoms/table/dataGrid/DataGridPagination.vue +97 -97
  11. package/components/atoms/table/dataGrid/lib/config/settingsTable.ts +94 -94
  12. package/components/atoms/table/dataGrid/lib/utils/export.ts +16 -16
  13. package/components/common/backup/storage/actions/add/Add.vue +251 -251
  14. package/components/common/backup/storage/actions/add/lib/utils.ts +51 -51
  15. package/components/common/browse/blocks/contents/filesNew/Skeleton.vue +18 -18
  16. package/components/common/diagramMain/modals/lib/config/portModal.ts +251 -251
  17. package/components/common/diagramMain/modals/lib/config/vCenterModal.ts +48 -48
  18. package/components/common/diagramMain/port/Port.vue +580 -580
  19. package/components/common/layout/theHeader/helpMenu/About.vue +79 -79
  20. package/components/common/layout/theHeader/helpMenu/aboutOld/AboutOld.vue +79 -79
  21. package/components/common/pages/backups/DetailView.vue +52 -52
  22. package/components/common/pages/backups/lib/models/interfaces.ts +36 -36
  23. package/components/common/pages/backups/modals/Modals.vue +243 -243
  24. package/components/common/pages/backups/modals/createBackup/configuration/backupWindow/BackupWindow.vue +29 -29
  25. package/components/common/pages/backups/modals/createBackup/configuration/maxBandwidth/MaxBandwidth.vue +69 -69
  26. package/components/common/pages/backups/modals/createBackup/configuration/strategy/Strategy.vue +38 -38
  27. package/components/common/pages/backups/modals/createBackup/lib/config/readyToCompleteOptions.ts +69 -69
  28. package/components/common/pages/backups/modals/createBackup/lib/models/interfaces.ts +8 -8
  29. package/components/common/pages/backups/modals/lib/config/restore.ts +115 -115
  30. package/components/common/pages/backups/modals/lib/models/interfaces.ts +186 -186
  31. package/components/common/pages/backups/modals/restore/name/lib/models/interfaces.ts +6 -6
  32. package/components/common/pages/backups/modals/restore/networks/Networks.vue +1 -0
  33. package/components/common/pages/hardwareHealth/tableView/lib/config/sensorTable.ts +1 -1
  34. package/components/common/pages/hardwareHealth/tableView/modal/SensorWarning.vue +1 -1
  35. package/components/common/pages/home/lib/models/interfaces.ts +48 -48
  36. package/components/common/pages/home/widgets/hosts/Hosts.vue +27 -27
  37. package/components/common/pages/home/widgets/hosts/lib/config/items.ts +23 -23
  38. package/components/common/pages/home/widgets/vms/VmsOld.vue +35 -35
  39. package/components/common/pages/home/widgets/vms/lib/config/items.ts +19 -19
  40. package/components/common/pages/scheduledTasks/lib/utils/utils.ts +84 -84
  41. package/components/common/readyToComplete/ReadyToComplete.vue +17 -17
  42. package/components/common/select/radio/RadioGroup.vue +137 -137
  43. package/components/common/spiceConsole/Drawer.vue +420 -420
  44. package/components/common/spiceConsole/SpiceConsole.vue +184 -184
  45. package/components/common/spiceConsole/lib/models/interfaces.ts +5 -5
  46. package/components/common/tools/Actions.vue +207 -207
  47. package/components/common/tooltip/Help.vue +5 -0
  48. package/components/common/treeView/TreeView.vue +52 -52
  49. package/components/common/vm/actions/add/Add.vue +950 -949
  50. package/components/common/vm/actions/add/New.vue +690 -689
  51. package/components/common/vm/actions/add/Old.vue +402 -400
  52. package/components/common/vm/actions/add/lib/config/steps.ts +347 -347
  53. package/components/common/vm/actions/clone/Clone.vue +809 -808
  54. package/components/common/vm/actions/clone/new/New.vue +457 -454
  55. package/components/common/vm/actions/clone/old/Old.vue +378 -378
  56. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/Cpu.vue +368 -368
  57. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/shares/Shares.vue +140 -140
  58. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/shares/lib/config/options.ts +28 -28
  59. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/NewHardDisk.vue +427 -427
  60. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/location/Location.vue +154 -154
  61. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/macAddress/MacAddress.vue +119 -119
  62. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/dynamicDirectPathIo/DynamicDirectPathIo.vue +31 -31
  63. package/components/common/vm/actions/common/customizeHardware/virtualHardware/other/Other.vue +16 -16
  64. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/numberDisplays/NumberDisplays.vue +53 -53
  65. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/delay/Delay.vue +32 -32
  66. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/firmware/Firmware.vue +60 -60
  67. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/Order.vue +174 -174
  68. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/keymap/Keymap.vue +32 -32
  69. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/password/Password.vue +103 -103
  70. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/usbRedirection/UsbRedirection.vue +28 -28
  71. package/components/common/vm/actions/common/select/compatibility/Old.vue +107 -107
  72. package/components/common/vm/actions/common/select/createType/CreateType.vue +38 -38
  73. package/components/common/vm/actions/common/select/createType/lib/models/interfaces.ts +5 -5
  74. package/components/common/vm/actions/common/select/os/Old.vue +152 -152
  75. package/components/common/vm/actions/common/select/os/Os.vue +139 -139
  76. package/components/common/vm/actions/common/select/storage/Old.vue +125 -132
  77. package/components/common/vm/actions/common/select/storage/Storage.vue +178 -167
  78. package/components/common/vm/actions/common/select/storage/new/New.vue +311 -330
  79. package/components/common/vm/actions/common/select/storage/new/lib/models/interfaces.ts +5 -5
  80. package/components/common/vm/actions/common/select/storage/new/lib/utils/utils.ts +21 -21
  81. package/components/common/vm/actions/common/select/template/old/Old.vue +50 -50
  82. package/components/common/vm/actions/editSettings/new/Skeleton.vue +88 -88
  83. package/components/common/vm/actions/register/Register.vue +352 -352
  84. package/components/common/vm/actions/register/lib/config/steps.ts +86 -86
  85. package/components/common/wizards/common/{steps/computeResource/compatibility → compatibility}/Compatibility.vue +35 -31
  86. package/components/common/wizards/common/{steps/computeResource/compatibility → compatibility}/New.vue +99 -98
  87. package/components/common/wizards/common/{steps/computeResource/compatibility → compatibility}/Old.vue +53 -54
  88. package/components/common/wizards/common/{steps/computeResource/compatibility → compatibility}/lib/models/enums.ts +1 -1
  89. package/components/common/wizards/common/compatibility/lib/models/types.ts +1 -0
  90. package/components/common/wizards/common/steps/computeResource/ComputeResource.vue +86 -85
  91. package/components/common/wizards/common/steps/computeResource/New.vue +93 -92
  92. package/components/common/wizards/common/steps/computeResource/Old.vue +103 -102
  93. package/components/common/wizards/common/steps/name/Name.vue +178 -178
  94. package/components/common/wizards/common/steps/name/New.vue +221 -221
  95. package/components/common/wizards/common/steps/name/Old.vue +121 -121
  96. package/components/common/wizards/common/steps/name/lib/models/interfaces.ts +4 -4
  97. package/components/common/wizards/common/steps/name/location/Location.vue +85 -85
  98. package/components/common/wizards/common/steps/name/location/New.vue +40 -40
  99. package/components/common/wizards/datastore/add/Add.vue +228 -228
  100. package/components/common/wizards/datastore/add/lib/utils.ts +85 -85
  101. package/components/common/wizards/datastore/add/steps/typeMode/lib/config/typeOptions.ts +43 -43
  102. package/components/common/wizards/vm/migrate/select/computeResource/ComputeResource.vue +205 -195
  103. package/components/common/wizards/vm/migrate/select/network/Network.vue +103 -103
  104. package/components/common/wizards/vm/migrate/select/storage/Storage.vue +1 -1
  105. package/composables/useAppVersion.ts +21 -21
  106. package/composables/useLocal.ts +6 -6
  107. package/composables/useLocalCommon.ts +39 -39
  108. package/package.json +1 -1
  109. package/plugins/console.ts +21 -21
  110. package/plugins/date.ts +233 -233
  111. package/plugins/mouse.ts +21 -21
  112. package/plugins/panelStates.ts +70 -70
  113. package/plugins/text.ts +59 -59
  114. package/public/spice-console/application/clientgui.js +854 -854
  115. package/public/spice-console/application/packetfactory.js +211 -211
  116. package/public/spice-console/application/virtualmouse.js +147 -147
  117. package/public/spice-console/lib/images/bitmap.js +203 -203
  118. package/public/spice-console/network/spicechannel.js +440 -440
  119. package/public/spice-console/process/cursorprocess.js +121 -121
  120. package/public/spice-console/process/inputprocess.js +227 -227
  121. package/public/spice-console/process/mainprocess.js +210 -210
  122. package/public/spice-console/run.js +210 -210
  123. package/store/main/mutations.ts +7 -7
  124. package/store/main/state.ts +7 -7
@@ -1,368 +1,368 @@
1
- <template>
2
- <common-vm-actions-common-customize-hardware-virtual-hardware-cpu-new
3
- v-if="isNewView"
4
- v-model:selected-cpu="selectedCpu"
5
- v-model:selected-core-per-socket="selectedCorePerSocket"
6
- v-model:enable-cpu-hot-add="enableCpuHotAdd"
7
- v-model:selected-max-cpu="selectedMaxCpu"
8
- v-model:reservation="reservation"
9
- v-model:reservation-type="reservationType"
10
- v-model:limit="limit"
11
- v-model:limit-type="limitType"
12
- v-model:shares="shares"
13
- v-model:shares-type="sharesType"
14
- v-model:cpu-model="cpuModel"
15
- v-model:passthrough-host-cpu="passthroughHostCpu"
16
- v-model:host-model-cpu="hostModelCpu"
17
- :max-cpus="props.maxCpus"
18
- :cpu-models="props.cpuModels"
19
- :is-edit="props.isEdit"
20
- :error-validation-fields="props.errorValidationFields"
21
- :cpu-invalid="cpuInvalid"
22
- :vcpus-local-and-api-errors-texts="vcpusLocalAndApiErrorsTexts"
23
- :cpu-options="cpuOptions"
24
- :is-cpu-disabled="isCpuDisabled"
25
- :selected-cpus="selectedCpus"
26
- :is-disabled="isDisabled"
27
- :enable-cpu-hot-add-disabled="enableCpuHotAddDisabled"
28
- :max-cpu-options="maxCpuOptions"
29
- :vm-cpu-help-text-second="vmCpuHelpTextSecond"
30
- @remove-error-by-title="emits('remove-error-by-title', $event)"
31
- @remove-validation-error="onRemoveValidationError"
32
- @max-cpu-invalid="maxCpuInvalid = $event"
33
- @reservation-invalid="reservationInvalid = $event"
34
- @limit-invalid="limitInvalid = $event"
35
- @shares-invalid="sharesInvalid = $event"
36
- />
37
- <common-vm-actions-common-customize-hardware-virtual-hardware-cpu-old
38
- v-else
39
- v-model:selected-cpu="selectedCpu"
40
- v-model:selected-core-per-socket="selectedCorePerSocket"
41
- v-model:enable-cpu-hot-add="enableCpuHotAdd"
42
- v-model:selected-max-cpu="selectedMaxCpu"
43
- v-model:reservation="reservation"
44
- v-model:reservation-type="reservationType"
45
- v-model:limit="limit"
46
- v-model:limit-type="limitType"
47
- v-model:shares="shares"
48
- v-model:shares-type="sharesType"
49
- v-model:cpu-model="cpuModel"
50
- v-model:passthrough-host-cpu="passthroughHostCpu"
51
- v-model:host-model-cpu="hostModelCpu"
52
- :max-cpus="props.maxCpus"
53
- :cpu-models="props.cpuModels"
54
- :is-edit="props.isEdit"
55
- :error-validation-fields="props.errorValidationFields"
56
- :cpu-invalid="cpuInvalid"
57
- :vcpus-local-and-api-errors-texts="vcpusLocalAndApiErrorsTexts"
58
- :cpu-options="cpuOptions"
59
- :is-cpu-disabled="isCpuDisabled"
60
- :selected-cpus="selectedCpus"
61
- :is-disabled="isDisabled"
62
- :enable-cpu-hot-add-disabled="enableCpuHotAddDisabled"
63
- :max-cpu-options="maxCpuOptions"
64
- :vm-cpu-help-text-second="vmCpuHelpTextSecond"
65
- @remove-error-by-title="emits('remove-error-by-title', $event)"
66
- @remove-validation-error="onRemoveValidationError"
67
- @max-cpu-invalid="maxCpuInvalid = $event"
68
- @reservation-invalid="reservationInvalid = $event"
69
- @limit-invalid="limitInvalid = $event"
70
- @shares-invalid="sharesInvalid = $event"
71
- />
72
- </template>
73
-
74
- <script setup lang="ts">
75
- import type { UI_I_SendDataCpu } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
76
- import type { UI_I_Localization } from '~/lib/models/interfaces'
77
- import type { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
78
- import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
79
- import type { API_UI_I_VmEditCpu } from '~/lib/models/store/vm/interfaces'
80
- import { cpuOptionsFunc } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/lib/config/cpuOptions'
81
-
82
- const props = withDefaults(
83
- defineProps<{
84
- maxCpus: number
85
- cpuModels: UI_I_OptionItem[]
86
- isEdit: boolean
87
- errorValidationFields: UI_I_ErrorValidationField<string>[]
88
- vmCpuHelpTextSecond?: string
89
- state?: string | number
90
- cpu?: API_UI_I_VmEditCpu
91
- }>(),
92
- {
93
- state: undefined,
94
- cpu: undefined,
95
- }
96
- )
97
- const emits = defineEmits<{
98
- (event: 'send-data', value: UI_I_SendDataCpu): void
99
- (event: 'invalid', value: boolean): void
100
- (event: 'remove-error-by-title', value: string): void
101
- }>()
102
-
103
- const { $store, $binary }: any = useNuxtApp()
104
- const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
105
-
106
- const localization = computed<UI_I_Localization>(() => useLocal())
107
-
108
- const isDisabled = computed<boolean>(() => {
109
- return props.state === 2
110
- })
111
-
112
- const cpuOptions = computed<UI_I_OptionItem[]>(() =>
113
- cpuOptionsFunc(localization.value, 1, props.maxCpus)
114
- )
115
-
116
- const enableCpuHotAdd = ref<boolean>(false)
117
- const enableCpuHotAddDisabled = computed<boolean>(
118
- // () => selectedCpu.value >= props.maxCpus || isDisabled.value
119
- () => isDisabled.value // pc-1766
120
- )
121
- watch(enableCpuHotAdd, (newValue) => {
122
- if (newValue) {
123
- selectedMaxCpu.value = Math.max(selectedCpu.value, selectedMaxCpu.value)
124
- return
125
- }
126
-
127
- maxCpuInvalid.value = false
128
- selectedMaxCpu.value = 1
129
- })
130
-
131
- const selectedCpu = ref<number>(
132
- isDisabled.value && enableCpuHotAdd.value ? props.maxCpus : 2
133
- )
134
- const isCpuDisabled = computed<boolean>(
135
- () => isDisabled.value && !enableCpuHotAdd.value
136
- )
137
- watch(selectedCpu, (newValue) => {
138
- selectedCpu.value = Math.floor(+newValue)
139
- if (!(selectedCpu.value % selectedCorePerSocket.value) || isDisabled.value)
140
- return
141
- selectedCorePerSocket.value = 1
142
- })
143
- // watch(selectedCpu, (newValue) => {
144
- // if (enableCpuHotAdd.value && enableCpuHotAddDisabled.value) return
145
-
146
- // if (newValue >= props.maxCpus) { // pc-1766
147
- // enableCpuHotAdd.value = false
148
- // }
149
- // selectedMaxCpu.value =
150
- // selectedMaxCpu.value <= newValue ? newValue + 1 : selectedMaxCpu.value
151
- // if (selectedMaxCpu.value > props.maxCpus) selectedMaxCpu.value = props.maxCpus
152
- // })
153
- const maxCpuOptions = computed<UI_I_OptionItem[]>(() =>
154
- cpuOptionsFunc(localization.value, selectedCpu.value, props.maxCpus)
155
- )
156
- const selectedMaxCpu = ref<number>(1)
157
- watch(
158
- () => props.maxCpus,
159
- (newValue) => {
160
- selectedMaxCpu.value = newValue
161
- }
162
- )
163
-
164
- const selectedCpus = computed<number[]>(() =>
165
- enableCpuHotAdd.value
166
- ? [selectedCpu.value, selectedMaxCpu.value]
167
- : [selectedCpu.value]
168
- )
169
-
170
- const selectedCorePerSocket = ref<number>(1)
171
-
172
- const cpuErrorLocalText = computed<string>(() => {
173
- const validValue = /^\d+(\.\d+)?$/.test(selectedCpu.value + '')
174
- if (!validValue) {
175
- return localization.value.common.inputContainsInvalidCharacters
176
- }
177
-
178
- const min = cpuOptions.value[0].value
179
- const max = cpuOptions.value[1].value
180
- if (selectedCpu.value < min || selectedCpu.value > max) {
181
- return localization.value.vmWizard.cpuMustBe
182
- .replace('{0}', min)
183
- .replace('{1}', max)
184
- }
185
-
186
- return ''
187
- })
188
-
189
- const apiVcpusError = computed<string>(() => {
190
- return (
191
- props.errorValidationFields?.find(
192
- (message) => message.field === 'cpu.vcpus'
193
- )?.error_message || ''
194
- )
195
- })
196
-
197
- const vcpusLocalAndApiErrorsTexts = computed<string>(() => {
198
- const localError = cpuErrorLocalText.value
199
- const apiError = apiVcpusError.value
200
-
201
- let result = ''
202
- if (localError && !apiError) result = localError
203
- if (!localError && apiError) result = apiError
204
- if (localError && apiError) result = localError + ', ' + apiError
205
- if (!localError && apiError) result = apiError
206
-
207
- return result
208
- })
209
- const reservationInvalid = ref<boolean>(false)
210
- const limitInvalid = ref<boolean>(false)
211
- const sharesInvalid = ref<boolean>(false)
212
- const maxCpuInvalid = ref<boolean>(false)
213
- const cpuInvalid = computed<boolean>(
214
- () =>
215
- !!cpuErrorLocalText.value ||
216
- reservationInvalid.value ||
217
- limitInvalid.value ||
218
- sharesInvalid.value ||
219
- (enableCpuHotAdd.value &&
220
- // selectedCpu.value < props.maxCpus && // pc-1766
221
- maxCpuInvalid.value)
222
- )
223
- watch(
224
- cpuInvalid,
225
- (newValue: boolean) => {
226
- emits('invalid', newValue)
227
- },
228
- { immediate: true }
229
- )
230
-
231
- const reservation = ref<string>('1')
232
- const reservationType = ref<string>('mhz')
233
-
234
- const limit = ref<string>('Unlimited')
235
- const limitType = ref<string>('mhz')
236
-
237
- const shares = ref<string>('2000')
238
- const sharesType = ref<string>('2000')
239
-
240
- // const hardwareVirtualization = ref<boolean>(false)
241
- //
242
- // const performanceCounters = ref<boolean>(false)
243
- //
244
- // const schedulingAffinity = ref<string>('')
245
- //
246
- // const iommu = ref<boolean>(false)
247
-
248
- // const cpuModel = ref<string>(props.cpuModels[0]?.value || '')
249
- const cpuModel = ref<string>('') // PNCWEB-389
250
- watch(
251
- () => props.cpuModels,
252
- (newValue) => {
253
- cpuModel.value = newValue[0].value
254
- }
255
- )
256
- const passthroughHostCpu = ref<boolean>(false)
257
- const hostModelCpu = ref<boolean>(true)
258
-
259
- // const isShowCpuHelp = ref<boolean>(false)
260
-
261
- watch(
262
- [
263
- reservation,
264
- reservationType,
265
- limit,
266
- limitType,
267
- shares,
268
- selectedCpu,
269
- selectedMaxCpu,
270
- selectedCorePerSocket,
271
- enableCpuHotAdd,
272
- cpuModel,
273
- passthroughHostCpu,
274
- hostModelCpu,
275
- ],
276
- () => {
277
- const reservationInMhz =
278
- reservationType.value === 'ghz'
279
- ? $binary.ghzToMhz(+reservation.value)
280
- : +reservation.value
281
- const limitInMhz =
282
- limit.value === 'Unlimited'
283
- ? limit.value
284
- : limitType.value === 'ghz'
285
- ? $binary.ghzToMhz(+limit.value)
286
- : +limit.value
287
- const model = passthroughHostCpu.value
288
- ? 'host-passthrough'
289
- : hostModelCpu.value
290
- ? 'host-model'
291
- : cpuModel.value
292
-
293
- emits('send-data', {
294
- model,
295
- vcpus: selectedCpu.value,
296
- max_vcpus: enableCpuHotAdd.value ? selectedMaxCpu.value : 0,
297
- core_per_socket: selectedCorePerSocket.value,
298
- reservation_mhz: reservationInMhz,
299
- limit_mhz: limitInMhz,
300
- shares: +shares.value,
301
- hotplug: enableCpuHotAdd.value,
302
- })
303
- },
304
- {
305
- immediate: true,
306
- }
307
- )
308
-
309
- // Добавляем данные для редактирования
310
- watch(
311
- () => props.cpu,
312
- (newValue) => {
313
- if (!newValue) return
314
-
315
- enableCpuHotAdd.value = newValue.hotplug
316
- selectedCpu.value = newValue.vcpus
317
- selectedMaxCpu.value = newValue.hotplug ? newValue.max_vcpus : 1
318
- selectedCorePerSocket.value = newValue.core_per_socket
319
- shares.value = '' + newValue.shares
320
- sharesType.value = '' + newValue.shares
321
-
322
- const reservationInGhz = $binary.mhzToGhz(newValue.reservation_mhz)
323
- if (reservationInGhz < 1) {
324
- reservation.value = newValue.reservation_mhz.toString()
325
- reservationType.value = 'mhz'
326
- } else {
327
- reservation.value = reservationInGhz
328
- reservationType.value = 'ghz'
329
- }
330
-
331
- if (typeof newValue.limit_mhz === 'string') limit.value = newValue.limit_mhz
332
- else {
333
- const limitInGhz = $binary.mhzToGhz(newValue.limit_mhz)
334
- if (limitInGhz < 1) {
335
- limit.value = newValue.limit_mhz.toString()
336
- limitType.value = 'mhz'
337
- } else {
338
- limit.value = limitInGhz
339
- limitType.value = 'ghz'
340
- }
341
- }
342
-
343
- switch (newValue.model) {
344
- case 'host-passthrough':
345
- passthroughHostCpu.value = true
346
- hostModelCpu.value = false
347
- cpuModel.value = ''
348
- break
349
- case 'host-model':
350
- passthroughHostCpu.value = false
351
- hostModelCpu.value = true
352
- cpuModel.value = ''
353
- break
354
- default:
355
- cpuModel.value =
356
- props.cpuModels.find((model) => model.value === newValue.model)
357
- ?.value || cpuModel.value
358
- }
359
- },
360
- { immediate: true }
361
- )
362
-
363
- const onRemoveValidationError = (): void => {
364
- emits('remove-error-by-title', 'cpu.vcpus')
365
- }
366
- </script>
367
-
368
- <style scoped lang="scss"></style>
1
+ <template>
2
+ <common-vm-actions-common-customize-hardware-virtual-hardware-cpu-new
3
+ v-if="isNewView"
4
+ v-model:selected-cpu="selectedCpu"
5
+ v-model:selected-core-per-socket="selectedCorePerSocket"
6
+ v-model:enable-cpu-hot-add="enableCpuHotAdd"
7
+ v-model:selected-max-cpu="selectedMaxCpu"
8
+ v-model:reservation="reservation"
9
+ v-model:reservation-type="reservationType"
10
+ v-model:limit="limit"
11
+ v-model:limit-type="limitType"
12
+ v-model:shares="shares"
13
+ v-model:shares-type="sharesType"
14
+ v-model:cpu-model="cpuModel"
15
+ v-model:passthrough-host-cpu="passthroughHostCpu"
16
+ v-model:host-model-cpu="hostModelCpu"
17
+ :max-cpus="props.maxCpus"
18
+ :cpu-models="props.cpuModels"
19
+ :is-edit="props.isEdit"
20
+ :error-validation-fields="props.errorValidationFields"
21
+ :cpu-invalid="cpuInvalid"
22
+ :vcpus-local-and-api-errors-texts="vcpusLocalAndApiErrorsTexts"
23
+ :cpu-options="cpuOptions"
24
+ :is-cpu-disabled="isCpuDisabled"
25
+ :selected-cpus="selectedCpus"
26
+ :is-disabled="isDisabled"
27
+ :enable-cpu-hot-add-disabled="enableCpuHotAddDisabled"
28
+ :max-cpu-options="maxCpuOptions"
29
+ :vm-cpu-help-text-second="vmCpuHelpTextSecond"
30
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
31
+ @remove-validation-error="onRemoveValidationError"
32
+ @max-cpu-invalid="maxCpuInvalid = $event"
33
+ @reservation-invalid="reservationInvalid = $event"
34
+ @limit-invalid="limitInvalid = $event"
35
+ @shares-invalid="sharesInvalid = $event"
36
+ />
37
+ <common-vm-actions-common-customize-hardware-virtual-hardware-cpu-old
38
+ v-else
39
+ v-model:selected-cpu="selectedCpu"
40
+ v-model:selected-core-per-socket="selectedCorePerSocket"
41
+ v-model:enable-cpu-hot-add="enableCpuHotAdd"
42
+ v-model:selected-max-cpu="selectedMaxCpu"
43
+ v-model:reservation="reservation"
44
+ v-model:reservation-type="reservationType"
45
+ v-model:limit="limit"
46
+ v-model:limit-type="limitType"
47
+ v-model:shares="shares"
48
+ v-model:shares-type="sharesType"
49
+ v-model:cpu-model="cpuModel"
50
+ v-model:passthrough-host-cpu="passthroughHostCpu"
51
+ v-model:host-model-cpu="hostModelCpu"
52
+ :max-cpus="props.maxCpus"
53
+ :cpu-models="props.cpuModels"
54
+ :is-edit="props.isEdit"
55
+ :error-validation-fields="props.errorValidationFields"
56
+ :cpu-invalid="cpuInvalid"
57
+ :vcpus-local-and-api-errors-texts="vcpusLocalAndApiErrorsTexts"
58
+ :cpu-options="cpuOptions"
59
+ :is-cpu-disabled="isCpuDisabled"
60
+ :selected-cpus="selectedCpus"
61
+ :is-disabled="isDisabled"
62
+ :enable-cpu-hot-add-disabled="enableCpuHotAddDisabled"
63
+ :max-cpu-options="maxCpuOptions"
64
+ :vm-cpu-help-text-second="vmCpuHelpTextSecond"
65
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
66
+ @remove-validation-error="onRemoveValidationError"
67
+ @max-cpu-invalid="maxCpuInvalid = $event"
68
+ @reservation-invalid="reservationInvalid = $event"
69
+ @limit-invalid="limitInvalid = $event"
70
+ @shares-invalid="sharesInvalid = $event"
71
+ />
72
+ </template>
73
+
74
+ <script setup lang="ts">
75
+ import type { UI_I_SendDataCpu } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
76
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
77
+ import type { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
78
+ import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
79
+ import type { API_UI_I_VmEditCpu } from '~/lib/models/store/vm/interfaces'
80
+ import { cpuOptionsFunc } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/lib/config/cpuOptions'
81
+
82
+ const props = withDefaults(
83
+ defineProps<{
84
+ maxCpus: number
85
+ cpuModels: UI_I_OptionItem[]
86
+ isEdit: boolean
87
+ errorValidationFields: UI_I_ErrorValidationField<string>[]
88
+ vmCpuHelpTextSecond?: string
89
+ state?: string | number
90
+ cpu?: API_UI_I_VmEditCpu
91
+ }>(),
92
+ {
93
+ state: undefined,
94
+ cpu: undefined,
95
+ }
96
+ )
97
+ const emits = defineEmits<{
98
+ (event: 'send-data', value: UI_I_SendDataCpu): void
99
+ (event: 'invalid', value: boolean): void
100
+ (event: 'remove-error-by-title', value: string): void
101
+ }>()
102
+
103
+ const { $store, $binary }: any = useNuxtApp()
104
+ const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
105
+
106
+ const localization = computed<UI_I_Localization>(() => useLocal())
107
+
108
+ const isDisabled = computed<boolean>(() => {
109
+ return props.state === 2
110
+ })
111
+
112
+ const cpuOptions = computed<UI_I_OptionItem[]>(() =>
113
+ cpuOptionsFunc(localization.value, 1, props.maxCpus)
114
+ )
115
+
116
+ const enableCpuHotAdd = ref<boolean>(false)
117
+ const enableCpuHotAddDisabled = computed<boolean>(
118
+ // () => selectedCpu.value >= props.maxCpus || isDisabled.value
119
+ () => isDisabled.value // pc-1766
120
+ )
121
+ watch(enableCpuHotAdd, (newValue) => {
122
+ if (newValue) {
123
+ selectedMaxCpu.value = Math.max(selectedCpu.value, selectedMaxCpu.value)
124
+ return
125
+ }
126
+
127
+ maxCpuInvalid.value = false
128
+ selectedMaxCpu.value = 1
129
+ })
130
+
131
+ const selectedCpu = ref<number>(
132
+ isDisabled.value && enableCpuHotAdd.value ? props.maxCpus : 2
133
+ )
134
+ const isCpuDisabled = computed<boolean>(
135
+ () => isDisabled.value && !enableCpuHotAdd.value
136
+ )
137
+ watch(selectedCpu, (newValue) => {
138
+ selectedCpu.value = Math.floor(+newValue)
139
+ if (!(selectedCpu.value % selectedCorePerSocket.value) || isDisabled.value)
140
+ return
141
+ selectedCorePerSocket.value = 1
142
+ })
143
+ // watch(selectedCpu, (newValue) => {
144
+ // if (enableCpuHotAdd.value && enableCpuHotAddDisabled.value) return
145
+
146
+ // if (newValue >= props.maxCpus) { // pc-1766
147
+ // enableCpuHotAdd.value = false
148
+ // }
149
+ // selectedMaxCpu.value =
150
+ // selectedMaxCpu.value <= newValue ? newValue + 1 : selectedMaxCpu.value
151
+ // if (selectedMaxCpu.value > props.maxCpus) selectedMaxCpu.value = props.maxCpus
152
+ // })
153
+ const maxCpuOptions = computed<UI_I_OptionItem[]>(() =>
154
+ cpuOptionsFunc(localization.value, selectedCpu.value, props.maxCpus)
155
+ )
156
+ const selectedMaxCpu = ref<number>(1)
157
+ watch(
158
+ () => props.maxCpus,
159
+ (newValue) => {
160
+ selectedMaxCpu.value = newValue
161
+ }
162
+ )
163
+
164
+ const selectedCpus = computed<number[]>(() =>
165
+ enableCpuHotAdd.value
166
+ ? [selectedCpu.value, selectedMaxCpu.value]
167
+ : [selectedCpu.value]
168
+ )
169
+
170
+ const selectedCorePerSocket = ref<number>(1)
171
+
172
+ const cpuErrorLocalText = computed<string>(() => {
173
+ const validValue = /^\d+(\.\d+)?$/.test(selectedCpu.value + '')
174
+ if (!validValue) {
175
+ return localization.value.common.inputContainsInvalidCharacters
176
+ }
177
+
178
+ const min = cpuOptions.value[0].value
179
+ const max = cpuOptions.value[1].value
180
+ if (selectedCpu.value < min || selectedCpu.value > max) {
181
+ return localization.value.vmWizard.cpuMustBe
182
+ .replace('{0}', min)
183
+ .replace('{1}', max)
184
+ }
185
+
186
+ return ''
187
+ })
188
+
189
+ const apiVcpusError = computed<string>(() => {
190
+ return (
191
+ props.errorValidationFields?.find(
192
+ (message) => message.field === 'cpu.vcpus'
193
+ )?.error_message || ''
194
+ )
195
+ })
196
+
197
+ const vcpusLocalAndApiErrorsTexts = computed<string>(() => {
198
+ const localError = cpuErrorLocalText.value
199
+ const apiError = apiVcpusError.value
200
+
201
+ let result = ''
202
+ if (localError && !apiError) result = localError
203
+ if (!localError && apiError) result = apiError
204
+ if (localError && apiError) result = localError + ', ' + apiError
205
+ if (!localError && apiError) result = apiError
206
+
207
+ return result
208
+ })
209
+ const reservationInvalid = ref<boolean>(false)
210
+ const limitInvalid = ref<boolean>(false)
211
+ const sharesInvalid = ref<boolean>(false)
212
+ const maxCpuInvalid = ref<boolean>(false)
213
+ const cpuInvalid = computed<boolean>(
214
+ () =>
215
+ !!cpuErrorLocalText.value ||
216
+ reservationInvalid.value ||
217
+ limitInvalid.value ||
218
+ sharesInvalid.value ||
219
+ (enableCpuHotAdd.value &&
220
+ // selectedCpu.value < props.maxCpus && // pc-1766
221
+ maxCpuInvalid.value)
222
+ )
223
+ watch(
224
+ cpuInvalid,
225
+ (newValue: boolean) => {
226
+ emits('invalid', newValue)
227
+ },
228
+ { immediate: true }
229
+ )
230
+
231
+ const reservation = ref<string>('1')
232
+ const reservationType = ref<string>('mhz')
233
+
234
+ const limit = ref<string>('Unlimited')
235
+ const limitType = ref<string>('mhz')
236
+
237
+ const shares = ref<string>('2000')
238
+ const sharesType = ref<string>('2000')
239
+
240
+ // const hardwareVirtualization = ref<boolean>(false)
241
+ //
242
+ // const performanceCounters = ref<boolean>(false)
243
+ //
244
+ // const schedulingAffinity = ref<string>('')
245
+ //
246
+ // const iommu = ref<boolean>(false)
247
+
248
+ // const cpuModel = ref<string>(props.cpuModels[0]?.value || '')
249
+ const cpuModel = ref<string>('') // PNCWEB-389
250
+ watch(
251
+ () => props.cpuModels,
252
+ (newValue) => {
253
+ cpuModel.value = newValue[0].value
254
+ }
255
+ )
256
+ const passthroughHostCpu = ref<boolean>(false)
257
+ const hostModelCpu = ref<boolean>(true)
258
+
259
+ // const isShowCpuHelp = ref<boolean>(false)
260
+
261
+ watch(
262
+ [
263
+ reservation,
264
+ reservationType,
265
+ limit,
266
+ limitType,
267
+ shares,
268
+ selectedCpu,
269
+ selectedMaxCpu,
270
+ selectedCorePerSocket,
271
+ enableCpuHotAdd,
272
+ cpuModel,
273
+ passthroughHostCpu,
274
+ hostModelCpu,
275
+ ],
276
+ () => {
277
+ const reservationInMhz =
278
+ reservationType.value === 'ghz'
279
+ ? $binary.ghzToMhz(+reservation.value)
280
+ : +reservation.value
281
+ const limitInMhz =
282
+ limit.value === 'Unlimited'
283
+ ? limit.value
284
+ : limitType.value === 'ghz'
285
+ ? $binary.ghzToMhz(+limit.value)
286
+ : +limit.value
287
+ const model = passthroughHostCpu.value
288
+ ? 'host-passthrough'
289
+ : hostModelCpu.value
290
+ ? 'host-model'
291
+ : cpuModel.value
292
+
293
+ emits('send-data', {
294
+ model,
295
+ vcpus: selectedCpu.value,
296
+ max_vcpus: enableCpuHotAdd.value ? selectedMaxCpu.value : 0,
297
+ core_per_socket: selectedCorePerSocket.value,
298
+ reservation_mhz: reservationInMhz,
299
+ limit_mhz: limitInMhz,
300
+ shares: +shares.value,
301
+ hotplug: enableCpuHotAdd.value,
302
+ })
303
+ },
304
+ {
305
+ immediate: true,
306
+ }
307
+ )
308
+
309
+ // Добавляем данные для редактирования
310
+ watch(
311
+ () => props.cpu,
312
+ (newValue) => {
313
+ if (!newValue) return
314
+
315
+ enableCpuHotAdd.value = newValue.hotplug
316
+ selectedCpu.value = newValue.vcpus
317
+ selectedMaxCpu.value = newValue.hotplug ? newValue.max_vcpus : 1
318
+ selectedCorePerSocket.value = newValue.core_per_socket
319
+ shares.value = '' + newValue.shares
320
+ sharesType.value = '' + newValue.shares
321
+
322
+ const reservationInGhz = $binary.mhzToGhz(newValue.reservation_mhz)
323
+ if (reservationInGhz < 1) {
324
+ reservation.value = newValue.reservation_mhz.toString()
325
+ reservationType.value = 'mhz'
326
+ } else {
327
+ reservation.value = reservationInGhz
328
+ reservationType.value = 'ghz'
329
+ }
330
+
331
+ if (typeof newValue.limit_mhz === 'string') limit.value = newValue.limit_mhz
332
+ else {
333
+ const limitInGhz = $binary.mhzToGhz(newValue.limit_mhz)
334
+ if (limitInGhz < 1) {
335
+ limit.value = newValue.limit_mhz.toString()
336
+ limitType.value = 'mhz'
337
+ } else {
338
+ limit.value = limitInGhz
339
+ limitType.value = 'ghz'
340
+ }
341
+ }
342
+
343
+ switch (newValue.model) {
344
+ case 'host-passthrough':
345
+ passthroughHostCpu.value = true
346
+ hostModelCpu.value = false
347
+ cpuModel.value = ''
348
+ break
349
+ case 'host-model':
350
+ passthroughHostCpu.value = false
351
+ hostModelCpu.value = true
352
+ cpuModel.value = ''
353
+ break
354
+ default:
355
+ cpuModel.value =
356
+ props.cpuModels.find((model) => model.value === newValue.model)
357
+ ?.value || cpuModel.value
358
+ }
359
+ },
360
+ { immediate: true }
361
+ )
362
+
363
+ const onRemoveValidationError = (): void => {
364
+ emits('remove-error-by-title', 'cpu.vcpus')
365
+ }
366
+ </script>
367
+
368
+ <style scoped lang="scss"></style>