bfg-common 1.5.548 → 1.5.550

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 (158) 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/New.vue +2 -8
  25. package/components/common/pages/backups/modals/createBackup/configuration/maxBandwidth/lib/config/options.ts +6 -6
  26. package/components/common/pages/backups/modals/createBackup/lib/config/readyToCompleteOptions.ts +69 -69
  27. package/components/common/pages/backups/modals/lib/config/restore.ts +115 -115
  28. package/components/common/pages/backups/modals/lib/models/interfaces.ts +186 -186
  29. package/components/common/pages/backups/modals/restore/Restore.vue +5 -9
  30. package/components/common/pages/backups/modals/restore/RestoreNew.vue +3 -12
  31. package/components/common/pages/backups/modals/restore/RestoreOld.vue +18 -6
  32. package/components/common/pages/backups/modals/restore/name/lib/models/interfaces.ts +6 -6
  33. package/components/common/pages/home/lib/models/interfaces.ts +48 -48
  34. package/components/common/pages/home/widgets/hosts/Hosts.vue +27 -27
  35. package/components/common/pages/home/widgets/hosts/lib/config/items.ts +23 -23
  36. package/components/common/pages/home/widgets/vms/VmsOld.vue +35 -35
  37. package/components/common/pages/home/widgets/vms/lib/config/items.ts +19 -19
  38. package/components/common/pages/scheduledTasks/lib/utils/utils.ts +84 -84
  39. package/components/common/readyToComplete/ReadyToComplete.vue +17 -17
  40. package/components/common/select/radio/RadioGroup.vue +137 -137
  41. package/components/common/spiceConsole/Drawer.vue +420 -420
  42. package/components/common/spiceConsole/SpiceConsole.vue +184 -184
  43. package/components/common/spiceConsole/lib/models/interfaces.ts +5 -5
  44. package/components/common/tools/Actions.vue +207 -207
  45. package/components/common/treeView/TreeView.vue +52 -52
  46. package/components/common/vm/actions/add/Add.vue +877 -950
  47. package/components/common/vm/actions/add/New.vue +652 -690
  48. package/components/common/vm/actions/add/Old.vue +363 -402
  49. package/components/common/vm/actions/add/lib/config/steps.ts +347 -347
  50. package/components/common/vm/actions/clone/Clone.vue +809 -809
  51. package/components/common/vm/actions/clone/new/New.vue +457 -457
  52. package/components/common/vm/actions/clone/old/Old.vue +378 -378
  53. package/components/common/vm/actions/common/customizeHardware/CustomizeHardware.vue +243 -308
  54. package/components/common/vm/actions/common/customizeHardware/CustomizeHardwareNew.vue +328 -373
  55. package/components/common/vm/actions/common/customizeHardware/CustomizeHardwareOld.vue +161 -205
  56. package/components/common/vm/actions/common/customizeHardware/virtualHardware/VirtualHardware.vue +694 -728
  57. package/components/common/vm/actions/common/customizeHardware/virtualHardware/VirtualHardwareNew.vue +512 -523
  58. package/components/common/vm/actions/common/customizeHardware/virtualHardware/VirtualHardwareOld.vue +328 -339
  59. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/Cpu.vue +348 -368
  60. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/CpuNew.vue +241 -248
  61. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/CpuOld.vue +184 -189
  62. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/shares/Shares.vue +140 -140
  63. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/shares/lib/config/options.ts +28 -28
  64. package/components/common/vm/actions/common/customizeHardware/virtualHardware/memory/Memory.vue +300 -313
  65. package/components/common/vm/actions/common/customizeHardware/virtualHardware/memory/MemoryNew.vue +158 -158
  66. package/components/common/vm/actions/common/customizeHardware/virtualHardware/memory/MemoryOld.vue +155 -155
  67. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/NewHardDisk.vue +427 -427
  68. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/location/Location.vue +154 -154
  69. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/macAddress/MacAddress.vue +119 -119
  70. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/dynamicDirectPathIo/DynamicDirectPathIo.vue +31 -31
  71. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newUsbController/NewUsbController.vue +47 -58
  72. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newUsbController/NewUsbControllerNew.vue +68 -65
  73. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newUsbController/NewUsbControllerOld.vue +64 -61
  74. package/components/common/vm/actions/common/customizeHardware/virtualHardware/other/Other.vue +16 -16
  75. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/VideoCard.vue +140 -162
  76. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/VideoCardNew.vue +6 -5
  77. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/VideoCardOld.vue +6 -5
  78. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/lib/config/options.ts +4 -4
  79. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/numberDisplays/NumberDisplays.vue +53 -53
  80. package/components/common/vm/actions/common/customizeHardware/vmoptions/Vmoptions.vue +76 -163
  81. package/components/common/vm/actions/common/customizeHardware/vmoptions/VmoptionsNew.vue +87 -138
  82. package/components/common/vm/actions/common/customizeHardware/vmoptions/VmoptionsOld.vue +71 -120
  83. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/BootOptions.vue +46 -110
  84. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/BootOptionsNew.vue +65 -85
  85. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/BootOptionsOld.vue +70 -91
  86. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/delay/Delay.vue +32 -32
  87. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/firmware/Firmware.vue +60 -60
  88. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/Order.vue +156 -174
  89. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/OrderNew.vue +109 -74
  90. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/OrderOld.vue +104 -66
  91. package/components/common/vm/actions/common/customizeHardware/vmoptions/generalOptions/GeneralOptions.vue +86 -101
  92. package/components/common/vm/actions/common/customizeHardware/vmoptions/generalOptions/GeneralOptionsNew.vue +163 -173
  93. package/components/common/vm/actions/common/customizeHardware/vmoptions/generalOptions/GeneralOptionsOld.vue +162 -170
  94. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/New.vue +142 -148
  95. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/Old.vue +135 -141
  96. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/RemoteConsoleOptions.vue +74 -178
  97. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/keymap/Keymap.vue +32 -32
  98. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/keymap/{KeymapNew.vue → New.vue} +45 -45
  99. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/keymap/{KeymapOld.vue → Old.vue} +47 -47
  100. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/password/Password.vue +102 -103
  101. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/usbRedirection/UsbRedirection.vue +28 -28
  102. package/components/common/vm/actions/common/customizeHardware/vmoptions/tools/Tools.vue +26 -49
  103. package/components/common/vm/actions/common/lib/models/interfaces.ts +189 -157
  104. package/components/common/vm/actions/common/select/compatibility/Old.vue +107 -107
  105. package/components/common/vm/actions/common/select/createType/CreateType.vue +38 -38
  106. package/components/common/vm/actions/common/select/createType/lib/models/interfaces.ts +5 -5
  107. package/components/common/vm/actions/common/select/os/Old.vue +152 -152
  108. package/components/common/vm/actions/common/select/os/Os.vue +139 -139
  109. package/components/common/vm/actions/common/select/storage/Old.vue +125 -125
  110. package/components/common/vm/actions/common/select/storage/Storage.vue +178 -178
  111. package/components/common/vm/actions/common/select/storage/new/New.vue +311 -311
  112. package/components/common/vm/actions/common/select/storage/new/lib/models/interfaces.ts +5 -5
  113. package/components/common/vm/actions/common/select/storage/new/lib/utils/utils.ts +21 -21
  114. package/components/common/vm/actions/common/select/template/old/Old.vue +50 -50
  115. package/components/common/vm/actions/editSettings/new/Skeleton.vue +88 -88
  116. package/components/common/vm/actions/lib/models/interfaces.ts +15 -40
  117. package/components/common/vm/actions/lib/utils.ts +244 -239
  118. package/components/common/vm/actions/register/Register.vue +352 -352
  119. package/components/common/vm/actions/register/lib/config/steps.ts +86 -86
  120. package/components/common/wizards/common/compatibility/Compatibility.vue +35 -35
  121. package/components/common/wizards/common/compatibility/New.vue +99 -99
  122. package/components/common/wizards/common/compatibility/Old.vue +53 -53
  123. package/components/common/wizards/common/steps/computeResource/ComputeResource.vue +86 -86
  124. package/components/common/wizards/common/steps/computeResource/New.vue +93 -93
  125. package/components/common/wizards/common/steps/computeResource/Old.vue +103 -103
  126. package/components/common/wizards/common/steps/name/Name.vue +178 -178
  127. package/components/common/wizards/common/steps/name/New.vue +221 -221
  128. package/components/common/wizards/common/steps/name/Old.vue +121 -121
  129. package/components/common/wizards/common/steps/name/lib/models/interfaces.ts +4 -4
  130. package/components/common/wizards/common/steps/name/location/Location.vue +85 -85
  131. package/components/common/wizards/common/steps/name/location/New.vue +40 -40
  132. package/components/common/wizards/datastore/add/Add.vue +228 -228
  133. package/components/common/wizards/datastore/add/lib/utils.ts +85 -85
  134. package/components/common/wizards/datastore/add/steps/typeMode/lib/config/typeOptions.ts +43 -43
  135. package/components/common/wizards/vm/migrate/select/computeResource/ComputeResource.vue +205 -205
  136. package/components/common/wizards/vm/migrate/select/network/Network.vue +103 -103
  137. package/composables/useAppVersion.ts +21 -21
  138. package/composables/useLocal.ts +6 -6
  139. package/composables/useLocalCommon.ts +39 -39
  140. package/package.json +1 -3
  141. package/plugins/console.ts +21 -21
  142. package/plugins/date.ts +233 -233
  143. package/plugins/mouse.ts +21 -21
  144. package/plugins/panelStates.ts +70 -70
  145. package/plugins/text.ts +59 -59
  146. package/public/spice-console/application/clientgui.js +854 -854
  147. package/public/spice-console/application/packetfactory.js +211 -211
  148. package/public/spice-console/application/virtualmouse.js +147 -147
  149. package/public/spice-console/lib/images/bitmap.js +203 -203
  150. package/public/spice-console/network/spicechannel.js +440 -440
  151. package/public/spice-console/process/cursorprocess.js +121 -121
  152. package/public/spice-console/process/inputprocess.js +227 -227
  153. package/public/spice-console/process/mainprocess.js +210 -210
  154. package/public/spice-console/run.js +210 -210
  155. package/store/main/mutations.ts +7 -7
  156. package/store/main/state.ts +7 -7
  157. /package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/password/{PasswordNew.vue → New.vue} +0 -0
  158. /package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/password/{PasswordOld.vue → Old.vue} +0 -0
@@ -1,368 +1,348 @@
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="model"
5
+ v-model:reservation="reservation"
6
+ v-model:reservation-type="reservationType"
7
+ v-model:limit="limit"
8
+ v-model:limit-type="limitType"
9
+ v-model:shares="shares"
10
+ v-model:shares-type="sharesType"
11
+ v-model:cpu-model="cpuModel"
12
+ v-model:passthrough-host-cpu="passthroughHostCpu"
13
+ v-model:host-model-cpu="hostModelCpu"
14
+ :cpu-models="props.cpuModels"
15
+ :is-edit="props.isEdit"
16
+ :error-validation-fields="props.errorValidationFields"
17
+ :cpu-invalid="cpuInvalid"
18
+ :vcpus-local-and-api-errors-texts="vcpusLocalAndApiErrorsTexts"
19
+ :cpu-options="cpuOptions"
20
+ :is-cpu-disabled="isCpuDisabled"
21
+ :selected-cpus="selectedCpus"
22
+ :is-disabled="isDisabled"
23
+ :enable-cpu-hot-add-disabled="enableCpuHotAddDisabled"
24
+ :max-cpu-options="maxCpuOptions"
25
+ :vm-cpu-help-text-second="vmCpuHelpTextSecond"
26
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
27
+ @remove-validation-error="onRemoveValidationError"
28
+ @max-cpu-invalid="maxCpuInvalid = $event"
29
+ @reservation-invalid="reservationInvalid = $event"
30
+ @limit-invalid="limitInvalid = $event"
31
+ @shares-invalid="sharesInvalid = $event"
32
+ />
33
+ <common-vm-actions-common-customize-hardware-virtual-hardware-cpu-old
34
+ v-else
35
+ v-model="model"
36
+ v-model:reservation="reservation"
37
+ v-model:reservation-type="reservationType"
38
+ v-model:limit="limit"
39
+ v-model:limit-type="limitType"
40
+ v-model:shares="shares"
41
+ v-model:shares-type="sharesType"
42
+ v-model:cpu-model="cpuModel"
43
+ v-model:passthrough-host-cpu="passthroughHostCpu"
44
+ v-model:host-model-cpu="hostModelCpu"
45
+ :cpu-models="props.cpuModels"
46
+ :is-edit="props.isEdit"
47
+ :error-validation-fields="props.errorValidationFields"
48
+ :cpu-invalid="cpuInvalid"
49
+ :vcpus-local-and-api-errors-texts="vcpusLocalAndApiErrorsTexts"
50
+ :cpu-options="cpuOptions"
51
+ :is-cpu-disabled="isCpuDisabled"
52
+ :selected-cpus="selectedCpus"
53
+ :is-disabled="isDisabled"
54
+ :enable-cpu-hot-add-disabled="enableCpuHotAddDisabled"
55
+ :max-cpu-options="maxCpuOptions"
56
+ :vm-cpu-help-text-second="vmCpuHelpTextSecond"
57
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
58
+ @remove-validation-error="onRemoveValidationError"
59
+ @max-cpu-invalid="maxCpuInvalid = $event"
60
+ @reservation-invalid="reservationInvalid = $event"
61
+ @limit-invalid="limitInvalid = $event"
62
+ @shares-invalid="sharesInvalid = $event"
63
+ />
64
+ </template>
65
+
66
+ <script setup lang="ts">
67
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
68
+ import type { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
69
+ import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
70
+ import type { UI_I_CreateVmData } from '~/components/common/vm/actions/common/lib/models/interfaces'
71
+ import { cpuOptionsFunc } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/lib/config/cpuOptions'
72
+
73
+ const model = defineModel<UI_I_CreateVmData>({ required: true })
74
+
75
+ const props = withDefaults(
76
+ defineProps<{
77
+ cpuModels: UI_I_OptionItem[]
78
+ isEdit: boolean
79
+ errorValidationFields: UI_I_ErrorValidationField[]
80
+ vmCpuHelpTextSecond?: string
81
+ state?: string | number
82
+ }>(),
83
+ {
84
+ state: undefined,
85
+ }
86
+ )
87
+ const emits = defineEmits<{
88
+ (event: 'invalid', value: boolean): void
89
+ (event: 'remove-error-by-title', value: string): void
90
+ }>()
91
+
92
+ const { $store, $binary }: any = useNuxtApp()
93
+ const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
94
+
95
+ const localization = computed<UI_I_Localization>(() => useLocal())
96
+
97
+ const isDisabled = computed<boolean>(() => {
98
+ return props.state === 2
99
+ })
100
+
101
+ const cpuOptions = computed<UI_I_OptionItem[]>(() =>
102
+ cpuOptionsFunc(localization.value, 1, model.value.cpu.max_vcpus)
103
+ )
104
+
105
+ // const enableCpuHotAdd = ref<boolean>(false)
106
+
107
+ const enableCpuHotAddDisabled = computed<boolean>(
108
+ // () => model.value.cpu.vcpus >= model.value.cpu.max_vcpus || isDisabled.value
109
+ () => isDisabled.value // pc-1766
110
+ )
111
+ watch(
112
+ () => model.value.cpu.hotplug,
113
+ (newValue) => {
114
+ if (newValue) {
115
+ model.value.cpu.max_vcpus = Math.max(
116
+ model.value.cpu.vcpus,
117
+ model.value.cpu.max_vcpus
118
+ )
119
+ return
120
+ }
121
+
122
+ maxCpuInvalid.value = false
123
+ model.value.cpu.max_vcpus = 1
124
+ }
125
+ )
126
+
127
+ // const selectedCpu = ref<number>(
128
+ // isDisabled.value && model.value.cpu.hotplug ? model.value.cpu.max_vcpus : 2
129
+ // )
130
+ model.value.cpu.vcpus =
131
+ isDisabled.value && model.value.cpu.hotplug ? model.value.cpu.max_vcpus : 2
132
+
133
+ const isCpuDisabled = computed<boolean>(
134
+ () => isDisabled.value && !model.value.cpu.hotplug
135
+ )
136
+ watch(
137
+ () => model.value.cpu.vcpus,
138
+ (newValue) => {
139
+ model.value.cpu.vcpus = Math.floor(+newValue)
140
+ if (
141
+ !(model.value.cpu.vcpus % model.value.cpu.core_per_socket) ||
142
+ isDisabled.value
143
+ )
144
+ return
145
+ model.value.cpu.core_per_socket = 1
146
+ }
147
+ )
148
+
149
+ const maxCpuOptions = computed<UI_I_OptionItem[]>(() =>
150
+ cpuOptionsFunc(
151
+ localization.value,
152
+ model.value.cpu.vcpus,
153
+ model.value.cpu.max_vcpus
154
+ )
155
+ )
156
+ // const selectedMaxCpu = ref<number>(1)
157
+ // watch(
158
+ // () => props.maxCpus,
159
+ // (newValue) => {
160
+ // model.value.cpu.max_vcpus = newValue
161
+ // }
162
+ // )
163
+
164
+ const selectedCpus = computed<number[]>(() =>
165
+ model.value.cpu.hotplug
166
+ ? [model.value.cpu.vcpus, model.value.cpu.max_vcpus]
167
+ : [model.value.cpu.vcpus]
168
+ )
169
+
170
+ // const selectedCorePerSocket = ref<number>(1)
171
+
172
+ const cpuErrorLocalText = computed<string>(() => {
173
+ const validValue = /^\d+(\.\d+)?$/.test(model.value.cpu.vcpus + '')
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 (model.value.cpu.vcpus < min || model.value.cpu.vcpus > 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
+ (model.value.cpu.hotplug &&
220
+ // model.value.cpu.vcpus < model.value.cpu.max_vcpus && // 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
+ if (model.value.cpu.reservation_mhz !== 1) {
234
+ const reservationInGhz = $binary.mhzToGhz(model.value.cpu.reservation_mhz)
235
+ if (reservationInGhz < 1) {
236
+ reservation.value = model.value.cpu.reservation_mhz.toString()
237
+ reservationType.value = 'mhz'
238
+ } else {
239
+ reservation.value = reservationInGhz
240
+ reservationType.value = 'ghz'
241
+ }
242
+ }
243
+ watch(
244
+ [reservation, reservationType],
245
+ () => {
246
+ model.value.cpu.reservation_mhz =
247
+ reservationType.value === 'ghz'
248
+ ? $binary.ghzToMhz(+reservation.value)
249
+ : +reservation.value
250
+ },
251
+ { deep: true, immediate: true }
252
+ )
253
+
254
+ const limit = ref<string>('Unlimited')
255
+ const limitType = ref<string>('mhz')
256
+ if (model.value.cpu.limit_mhz !== null) {
257
+ if (typeof model.value.cpu.limit_mhz === 'string')
258
+ limit.value = model.value.cpu.limit_mhz
259
+ else {
260
+ const limitInGhz = $binary.mhzToGhz(model.value.cpu.limit_mhz)
261
+ if (limitInGhz < 1) {
262
+ limit.value = model.value.cpu.limit_mhz.toString()
263
+ limitType.value = 'mhz'
264
+ } else {
265
+ limit.value = limitInGhz
266
+ limitType.value = 'ghz'
267
+ }
268
+ }
269
+ }
270
+ watch(
271
+ [limit, limitType],
272
+ () => {
273
+ model.value.cpu.limit_mhz =
274
+ limit.value === 'Unlimited'
275
+ ? limit.value
276
+ : limitType.value === 'ghz'
277
+ ? $binary.ghzToMhz(+limit.value)
278
+ : +limit.value
279
+ },
280
+ { deep: true, immediate: true }
281
+ )
282
+
283
+ const shares = ref<string>(model.value.cpu.shares + '' || '2000')
284
+ const sharesType = ref<string>(model.value.cpu.shares + '' || '2000') // TODO check
285
+ watch(
286
+ shares,
287
+ () => {
288
+ model.value.cpu.shares = +shares.value
289
+ },
290
+ { deep: true, immediate: true }
291
+ )
292
+
293
+ // const hardwareVirtualization = ref<boolean>(false)
294
+ //
295
+ // const performanceCounters = ref<boolean>(false)
296
+ //
297
+ // const schedulingAffinity = ref<string>('')
298
+ //
299
+ // const iommu = ref<boolean>(false)
300
+
301
+ // const cpuModel = ref<string>(props.cpuModels[0]?.value || '')
302
+ const cpuModel = ref<string>('') // PNCWEB-389
303
+ watch(
304
+ () => props.cpuModels,
305
+ (newValue) => {
306
+ cpuModel.value = newValue[0].value
307
+ }
308
+ )
309
+ const passthroughHostCpu = ref<boolean>(false)
310
+ const hostModelCpu = ref<boolean>(false)
311
+ if (model.value.cpu.model) {
312
+ switch (model.value.cpu.model) {
313
+ case 'host-passthrough':
314
+ passthroughHostCpu.value = true
315
+ hostModelCpu.value = false
316
+ cpuModel.value = ''
317
+ break
318
+ case 'host-model':
319
+ passthroughHostCpu.value = false
320
+ hostModelCpu.value = true
321
+ cpuModel.value = ''
322
+ break
323
+ default:
324
+ cpuModel.value =
325
+ props.cpuModels.find((model) => model.value === model.value.cpu.model)
326
+ ?.value || cpuModel.value
327
+ }
328
+ }
329
+ watch(
330
+ [cpuModel, passthroughHostCpu, hostModelCpu],
331
+ () => {
332
+ model.value.cpu.model = passthroughHostCpu.value
333
+ ? 'host-passthrough'
334
+ : hostModelCpu.value
335
+ ? 'host-model'
336
+ : cpuModel.value
337
+ },
338
+ { deep: true, immediate: true }
339
+ )
340
+
341
+ // const isShowCpuHelp = ref<boolean>(false)
342
+
343
+ const onRemoveValidationError = (): void => {
344
+ emits('remove-error-by-title', 'cpu.vcpus')
345
+ }
346
+ </script>
347
+
348
+ <style scoped lang="scss"></style>