bfg-common 1.5.534 → 1.5.535

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 (133) 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_ru.json +1 -1
  7. package/components/atoms/TheIcon3.vue +50 -50
  8. package/components/atoms/collapse/CollapseNav.vue +170 -170
  9. package/components/atoms/perPage/PerPage.vue +58 -58
  10. package/components/atoms/table/dataGrid/DataGrid.vue +1718 -1718
  11. package/components/atoms/table/dataGrid/DataGridPagination.vue +97 -97
  12. package/components/atoms/table/dataGrid/lib/config/settingsTable.ts +94 -94
  13. package/components/atoms/table/dataGrid/lib/utils/export.ts +16 -16
  14. package/components/common/backup/storage/actions/add/Add.vue +251 -251
  15. package/components/common/backup/storage/actions/add/lib/utils.ts +51 -51
  16. package/components/common/browse/blocks/contents/filesNew/Skeleton.vue +18 -18
  17. package/components/common/browse/blocks/lib/models/types.ts +1 -1
  18. package/components/common/browse/lib/models/interfaces.ts +5 -5
  19. package/components/common/diagramMain/network/Contents.vue +497 -497
  20. package/components/common/layout/theHeader/helpMenu/About.vue +79 -79
  21. package/components/common/layout/theHeader/helpMenu/aboutOld/AboutOld.vue +79 -79
  22. package/components/common/pages/backups/DetailView.vue +52 -52
  23. package/components/common/pages/backups/lib/models/interfaces.ts +36 -36
  24. package/components/common/pages/backups/modals/Modals.vue +243 -243
  25. package/components/common/pages/backups/modals/createBackup/CreateBackup.vue +195 -195
  26. package/components/common/pages/backups/modals/createBackup/configuration/maxBandwidth/lib/config/options.ts +6 -6
  27. package/components/common/pages/backups/modals/createBackup/lib/config/readyToCompleteOptions.ts +69 -69
  28. package/components/common/pages/backups/modals/lib/config/restore.ts +115 -115
  29. package/components/common/pages/backups/modals/lib/models/interfaces.ts +186 -186
  30. package/components/common/pages/backups/modals/restore/disks/Disks.vue +27 -27
  31. package/components/common/pages/backups/modals/restore/disks/tableView/lib/config/table.ts +117 -117
  32. package/components/common/pages/backups/modals/restore/name/Name.vue +166 -166
  33. package/components/common/pages/backups/modals/restore/name/lib/models/interfaces.ts +6 -6
  34. package/components/common/pages/backups/modals/restore/networks/Networks.vue +70 -67
  35. package/components/common/pages/backups/modals/restore/networks/table/Table.vue +214 -214
  36. package/components/common/pages/backups/modals/restore/types/lib/config/typeOptions.ts +25 -25
  37. package/components/common/pages/home/lib/models/interfaces.ts +48 -48
  38. package/components/common/pages/home/widgets/hosts/Hosts.vue +27 -27
  39. package/components/common/pages/home/widgets/hosts/lib/config/items.ts +23 -23
  40. package/components/common/pages/home/widgets/vms/VmsOld.vue +35 -35
  41. package/components/common/pages/home/widgets/vms/lib/config/items.ts +19 -19
  42. package/components/common/pages/scheduledTasks/lib/utils/utils.ts +84 -84
  43. package/components/common/readyToComplete/ReadyToComplete.vue +17 -17
  44. package/components/common/select/radio/RadioGroup.vue +137 -137
  45. package/components/common/spiceConsole/Drawer.vue +420 -420
  46. package/components/common/spiceConsole/SpiceConsole.vue +184 -184
  47. package/components/common/spiceConsole/lib/models/interfaces.ts +5 -5
  48. package/components/common/tools/Actions.vue +207 -207
  49. package/components/common/treeView/TreeView.vue +52 -52
  50. package/components/common/vm/actions/add/Add.vue +945 -895
  51. package/components/common/vm/actions/add/New.vue +689 -695
  52. package/components/common/vm/actions/add/Old.vue +400 -414
  53. package/components/common/vm/actions/add/lib/config/steps.ts +347 -347
  54. package/components/common/vm/actions/clone/Clone.vue +806 -754
  55. package/components/common/vm/actions/clone/{cloneNew/CloneNew.vue → new/New.vue} +454 -434
  56. package/components/common/vm/actions/clone/{cloneOld/CloneOld.vue → old/Old.vue} +375 -382
  57. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/Cpu.vue +368 -368
  58. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/shares/Shares.vue +140 -140
  59. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/shares/lib/config/options.ts +28 -28
  60. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/NewHardDisk.vue +427 -427
  61. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/location/Location.vue +154 -154
  62. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/location/new/table/Table.vue +99 -93
  63. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/macAddress/MacAddress.vue +119 -119
  64. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/dynamicDirectPathIo/DynamicDirectPathIo.vue +31 -31
  65. package/components/common/vm/actions/common/customizeHardware/virtualHardware/other/Other.vue +16 -16
  66. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/numberDisplays/NumberDisplays.vue +53 -53
  67. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/delay/Delay.vue +32 -32
  68. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/firmware/Firmware.vue +60 -60
  69. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/Order.vue +174 -174
  70. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/keymap/Keymap.vue +32 -32
  71. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/password/Password.vue +103 -103
  72. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/usbRedirection/UsbRedirection.vue +28 -28
  73. package/components/common/vm/actions/common/select/compatibility/Old.vue +107 -107
  74. package/components/common/vm/actions/common/select/createType/CreateType.vue +38 -38
  75. package/components/common/vm/actions/common/select/createType/lib/models/interfaces.ts +5 -5
  76. package/components/common/vm/actions/common/select/os/Old.vue +152 -152
  77. package/components/common/vm/actions/common/select/os/Os.vue +139 -139
  78. package/components/common/vm/actions/common/select/storage/new/lib/models/interfaces.ts +5 -5
  79. package/components/common/vm/actions/common/select/storage/new/lib/utils/utils.ts +21 -21
  80. package/components/common/vm/actions/common/select/template/old/Old.vue +50 -50
  81. package/components/common/vm/actions/editSettings/new/Skeleton.vue +88 -88
  82. package/components/common/vm/actions/register/Register.vue +352 -285
  83. package/components/common/vm/actions/register/lib/config/steps.ts +86 -86
  84. package/components/common/wizards/common/steps/computeResource/ComputeResource.vue +85 -95
  85. package/components/common/wizards/common/steps/computeResource/New.vue +92 -88
  86. package/components/common/wizards/common/steps/computeResource/Old.vue +102 -81
  87. package/components/common/wizards/common/steps/computeResource/compatibility/Compatibility.vue +31 -0
  88. package/components/common/wizards/common/steps/computeResource/compatibility/New.vue +98 -0
  89. package/components/common/wizards/{vm/common/validation/compatibility/Compatibility.vue → common/steps/computeResource/compatibility/Old.vue} +54 -62
  90. package/components/common/wizards/common/steps/computeResource/compatibility/lib/models/enums.ts +6 -0
  91. package/components/common/wizards/common/steps/name/Name.vue +178 -178
  92. package/components/common/wizards/common/steps/name/New.vue +221 -221
  93. package/components/common/wizards/common/steps/name/Old.vue +121 -121
  94. package/components/common/wizards/common/steps/name/lib/models/interfaces.ts +4 -4
  95. package/components/common/wizards/common/steps/name/location/Location.vue +85 -85
  96. package/components/common/wizards/common/steps/name/location/New.vue +40 -40
  97. package/components/common/wizards/datastore/add/Add.vue +228 -228
  98. package/components/common/wizards/datastore/add/lib/utils.ts +85 -85
  99. package/components/common/wizards/datastore/add/steps/typeMode/lib/config/typeOptions.ts +43 -43
  100. package/components/common/wizards/vm/migrate/select/computeResource/ComputeResource.vue +6 -6
  101. package/components/common/wizards/vm/migrate/select/network/Network.vue +103 -103
  102. package/components/common/wizards/vm/migrate/select/storage/Storage.vue +3 -3
  103. package/composables/useAppVersion.ts +21 -21
  104. package/composables/useLocal.ts +6 -6
  105. package/composables/useLocalCommon.ts +39 -39
  106. package/package.json +2 -2
  107. package/plugins/console.ts +21 -21
  108. package/plugins/date.ts +233 -233
  109. package/plugins/mouse.ts +21 -21
  110. package/plugins/panelStates.ts +70 -70
  111. package/plugins/text.ts +59 -59
  112. package/public/spice-console/application/clientgui.js +854 -854
  113. package/public/spice-console/application/packetfactory.js +211 -211
  114. package/public/spice-console/application/virtualmouse.js +147 -147
  115. package/public/spice-console/lib/images/bitmap.js +203 -203
  116. package/public/spice-console/network/spicechannel.js +440 -440
  117. package/public/spice-console/process/cursorprocess.js +121 -121
  118. package/public/spice-console/process/inputprocess.js +227 -227
  119. package/public/spice-console/process/mainprocess.js +210 -210
  120. package/public/spice-console/run.js +210 -210
  121. package/store/main/mutations.ts +7 -7
  122. package/store/main/state.ts +7 -7
  123. package/components/common/vm/actions/common/select/computeResource/ComputeResource.vue +0 -143
  124. package/components/common/vm/actions/common/select/computeResource/New.vue +0 -184
  125. package/components/common/vm/actions/common/select/computeResource/Old.vue +0 -99
  126. package/components/common/vm/actions/common/select/computeResource/lib/ComputeResource.spec.ts +0 -479
  127. package/components/common/vm/actions/common/select/computeResource/treeView/New.vue +0 -51
  128. package/components/common/vm/actions/common/select/computeResource/treeView/Old.vue +0 -51
  129. package/components/common/vm/actions/common/select/computeResource/treeView/TreeView.vue +0 -131
  130. package/components/common/wizards/common/compatibility/Compatibility.vue +0 -13
  131. package/components/common/wizards/common/compatibility/New.vue +0 -10
  132. package/components/common/wizards/common/compatibility/Old.vue +0 -10
  133. package/components/common/wizards/vm/common/validation/lib/models/enums.ts +0 -5
@@ -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>