bfg-common 1.5.502 → 1.5.503

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 (122) 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/assets/localization/local_be.json +0 -4
  7. package/assets/localization/local_en.json +0 -4
  8. package/assets/localization/local_hy.json +0 -4
  9. package/assets/localization/local_kk.json +0 -4
  10. package/assets/localization/local_ru.json +0 -4
  11. package/assets/localization/local_zh.json +0 -4
  12. package/components/atoms/TheIcon3.vue +50 -50
  13. package/components/atoms/collapse/CollapseNav.vue +170 -170
  14. package/components/atoms/perPage/PerPage.vue +58 -58
  15. package/components/atoms/table/dataGrid/DataGridPagination.vue +97 -97
  16. package/components/atoms/table/dataGrid/lib/config/settingsTable.ts +94 -94
  17. package/components/atoms/table/dataGrid/lib/utils/export.ts +16 -16
  18. package/components/common/backup/storage/actions/add/Add.vue +251 -251
  19. package/components/common/backup/storage/actions/add/lib/utils.ts +62 -62
  20. package/components/common/browse/blocks/contents/filesNew/Skeleton.vue +18 -18
  21. package/components/common/diagramMain/modals/lib/config/portModal.ts +251 -251
  22. package/components/common/diagramMain/modals/lib/config/vCenterModal.ts +48 -48
  23. package/components/common/diagramMain/port/Port.vue +580 -580
  24. package/components/common/layout/theHeader/helpMenu/About.vue +79 -79
  25. package/components/common/layout/theHeader/helpMenu/aboutOld/AboutOld.vue +79 -79
  26. package/components/common/pages/backups/Backups.vue +61 -54
  27. package/components/common/pages/backups/DetailView.vue +52 -52
  28. package/components/common/pages/backups/lib/models/interfaces.ts +36 -36
  29. package/components/common/pages/backups/modals/Modals.vue +243 -243
  30. package/components/common/pages/backups/modals/createBackup/configuration/Configuration.vue +29 -29
  31. package/components/common/pages/backups/modals/createBackup/configuration/maxBandwidth/lib/config/options.ts +6 -6
  32. package/components/common/pages/backups/modals/createBackup/datastores/tableView/TableView.vue +95 -95
  33. package/components/common/pages/backups/modals/createBackup/general/General.vue +141 -141
  34. package/components/common/pages/backups/modals/createBackup/lib/config/strategyOptions.ts +12 -12
  35. package/components/common/pages/backups/modals/lib/config/restore.ts +115 -115
  36. package/components/common/pages/backups/modals/lib/models/interfaces.ts +186 -186
  37. package/components/common/pages/backups/modals/restore/disks/Disks.vue +27 -27
  38. package/components/common/pages/backups/modals/restore/disks/tableView/lib/config/table.ts +117 -117
  39. package/components/common/pages/backups/modals/restore/name/Name.vue +166 -166
  40. package/components/common/pages/backups/modals/restore/name/lib/models/interfaces.ts +6 -6
  41. package/components/common/pages/backups/modals/restore/networks/Networks.vue +67 -67
  42. package/components/common/pages/backups/modals/restore/networks/table/Table.vue +214 -214
  43. package/components/common/pages/backups/modals/restore/types/lib/config/typeOptions.ts +25 -25
  44. package/components/common/pages/backups/tools/Tools.vue +75 -75
  45. package/components/common/pages/backups/tools/lib/config/tabs.ts +36 -37
  46. package/components/common/pages/home/lib/models/interfaces.ts +48 -48
  47. package/components/common/pages/home/widgets/hosts/Hosts.vue +27 -27
  48. package/components/common/pages/home/widgets/hosts/lib/config/items.ts +23 -23
  49. package/components/common/pages/home/widgets/vms/VmsOld.vue +35 -35
  50. package/components/common/pages/home/widgets/vms/lib/config/items.ts +19 -19
  51. package/components/common/pages/scheduledTasks/lib/utils/utils.ts +84 -84
  52. package/components/common/readyToComplete/ReadyToComplete.vue +17 -17
  53. package/components/common/select/radio/RadioGroup.vue +137 -137
  54. package/components/common/spiceConsole/Drawer.vue +392 -392
  55. package/components/common/spiceConsole/SpiceConsole.vue +184 -184
  56. package/components/common/spiceConsole/lib/models/interfaces.ts +5 -5
  57. package/components/common/tools/Actions.vue +207 -207
  58. package/components/common/treeView/TreeView.vue +52 -52
  59. package/components/common/vm/actions/add/Add.vue +892 -889
  60. package/components/common/vm/actions/add/New.vue +693 -691
  61. package/components/common/vm/actions/add/Old.vue +412 -410
  62. package/components/common/vm/actions/add/folderTreeView/FolderTreeView.vue +85 -85
  63. package/components/common/vm/actions/add/folderTreeView/New.vue +40 -40
  64. package/components/common/vm/actions/add/lib/config/steps.ts +347 -347
  65. package/components/common/vm/actions/clone/Clone.vue +862 -861
  66. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/Cpu.vue +368 -368
  67. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/shares/Shares.vue +140 -140
  68. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/shares/lib/config/options.ts +28 -28
  69. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/location/Location.vue +154 -154
  70. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/location/new/table/Table.vue +99 -99
  71. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/macAddress/MacAddress.vue +119 -119
  72. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/dynamicDirectPathIo/DynamicDirectPathIo.vue +31 -31
  73. package/components/common/vm/actions/common/customizeHardware/virtualHardware/other/Other.vue +16 -16
  74. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/numberDisplays/NumberDisplays.vue +53 -53
  75. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/delay/Delay.vue +32 -32
  76. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/firmware/Firmware.vue +60 -60
  77. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/Order.vue +174 -174
  78. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/keymap/Keymap.vue +32 -32
  79. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/password/Password.vue +103 -103
  80. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/usbRedirection/UsbRedirection.vue +28 -28
  81. package/components/common/vm/actions/common/select/compatibility/Old.vue +107 -107
  82. package/components/common/vm/actions/common/select/computeResource/ComputeResource.vue +143 -143
  83. package/components/common/vm/actions/common/select/computeResource/New.vue +184 -184
  84. package/components/common/vm/actions/common/select/computeResource/treeView/TreeView.vue +131 -131
  85. package/components/common/vm/actions/common/select/createType/CreateType.vue +38 -38
  86. package/components/common/vm/actions/common/select/createType/lib/models/interfaces.ts +5 -5
  87. package/components/common/vm/actions/common/select/name/Name.vue +178 -176
  88. package/components/common/vm/actions/common/select/name/New.vue +221 -221
  89. package/components/common/vm/actions/common/select/name/Old.vue +121 -121
  90. package/components/common/vm/actions/common/select/name/lib/models/interfaces.ts +4 -4
  91. package/components/common/vm/actions/common/select/os/Old.vue +152 -152
  92. package/components/common/vm/actions/common/select/os/Os.vue +139 -139
  93. package/components/common/vm/actions/common/select/storage/new/New.vue +320 -320
  94. package/components/common/vm/actions/common/select/storage/new/lib/models/interfaces.ts +5 -5
  95. package/components/common/vm/actions/common/select/storage/new/lib/utils/utils.ts +21 -21
  96. package/components/common/vm/actions/common/select/template/old/Old.vue +50 -50
  97. package/components/common/vm/actions/editSettings/new/Skeleton.vue +88 -88
  98. package/components/common/vm/actions/register/Register.vue +284 -283
  99. package/components/common/vm/actions/register/lib/config/steps.ts +86 -86
  100. package/components/common/wizards/datastore/add/Add.vue +228 -228
  101. package/components/common/wizards/datastore/add/lib/utils.ts +93 -93
  102. package/components/common/wizards/datastore/add/steps/typeMode/lib/config/typeOptions.ts +43 -43
  103. package/components/common/wizards/vm/migrate/select/network/Network.vue +103 -103
  104. package/composables/useAppVersion.ts +21 -21
  105. package/composables/useLocal.ts +6 -6
  106. package/composables/useLocalCommon.ts +39 -39
  107. package/package.json +2 -2
  108. package/plugins/date.ts +233 -233
  109. package/plugins/panelStates.ts +70 -70
  110. package/plugins/text.ts +59 -59
  111. package/public/spice-console/lib/images/bitmap.js +203 -203
  112. package/public/spice-console/network/spicechannel.js +440 -440
  113. package/public/spice-console/run.js +210 -210
  114. package/store/main/mutations.ts +7 -7
  115. package/store/main/state.ts +7 -7
  116. package/components/common/pages/backups/BackupsOld.vue +0 -80
  117. package/components/common/pages/backups/backupsNew/BackupsNew.vue +0 -355
  118. package/components/common/pages/backups/backupsNew/contextMenuView/ContextMenuView.vue +0 -101
  119. package/components/common/pages/backups/backupsNew/contextMenuView/lib/config/contextMenuItems.ts +0 -29
  120. package/components/common/pages/backups/backupsNew/lib/models/interfaces.ts +0 -12
  121. package/components/common/pages/backups/backupsNew/lib/utils/contextMenu.ts +0 -29
  122. package/components/common/pages/backups/backupsNew/lib/utils/details.ts +0 -30
@@ -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 = selectedCpu.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 = selectedCpu.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>