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,427 +1,427 @@
1
- <template>
2
- <common-vm-actions-common-customize-hardware-virtual-hardware-new-hard-disk-new
3
- v-if="isNewView"
4
- v-model:delete-files-from-datastore="deleteFilesFromDatastore"
5
- v-model:size="size"
6
- v-model:hard-disk-type="hardDiskType"
7
- v-model:disk-provisioning="diskProvisioning"
8
- v-model:sharing="sharing"
9
- v-model:limit-iops="limitIops"
10
- v-model:limit-iops-type="limitIopsType"
11
- v-model:limit-iops-invalid="limitIopsInvalid"
12
- v-model:disk-mode="diskMode"
13
- v-model:cache="cache"
14
- v-model:bus="bus"
15
- :is-removable="isRemovable"
16
- :label="label"
17
- :hard-disk-invalid="hardDiskInvalid"
18
- :error-text="hardDiskLocalAndApiErrorsTexts"
19
- :hard-disk-type-error-local-text="hardDiskTypeErrorLocalText"
20
- :is-disabled-size="isDisabledSize"
21
- :is-disabled-provisioning="isDisabledProvisioning"
22
- :is-disabled-sharing="isDisabledSharing"
23
- :is-disabled-limit-iops="isDisabledLimitIops"
24
- :is-disabled-mode="isDisabledMode"
25
- :is-disabled-cache="isDisabledCache"
26
- :is-disabled-bus="isDisabledBus"
27
- :hard-disk-type-options="hardDiskTypeOptions"
28
- :max-hard-disk="maxHardDisk"
29
- :location="location"
30
- :is-running="isRunning"
31
- :is-new-hard-disk="isNewHardDisk"
32
- :is-edit="props.isEdit"
33
- :datastore="props.datastore"
34
- :is-datastore-loading="props.isDatastoreLoading"
35
- :get-datastore-table-func="props.getDatastoreTableFunc"
36
- :error-validation-fields="props.errorValidationFields"
37
- :index="props.index"
38
- :type="props.type"
39
- :hard-disk="props.hardDisk"
40
- :guest-machine-type="props.guestMachineType"
41
- :compute-resource="props.computeResource"
42
- @remove="emits('remove')"
43
- @roll-back="emits('roll-back')"
44
- @validate-size="onValidateSize"
45
- @change-storage="onChangeStorage"
46
- @remove-error-by-title="emits('remove-error-by-title', $event)"
47
- />
48
- <common-vm-actions-common-customize-hardware-virtual-hardware-new-hard-disk-old
49
- v-else
50
- v-model:delete-files-from-datastore="deleteFilesFromDatastore"
51
- v-model:size="size"
52
- v-model:hard-disk-type="hardDiskType"
53
- v-model:disk-provisioning="diskProvisioning"
54
- v-model:sharing="sharing"
55
- v-model:limit-iops="limitIops"
56
- v-model:limit-iops-type="limitIopsType"
57
- v-model:limit-iops-invalid="limitIopsInvalid"
58
- v-model:disk-mode="diskMode"
59
- v-model:cache="cache"
60
- v-model:bus="bus"
61
- :is-removable="isRemovable"
62
- :label="label"
63
- :hard-disk-invalid="hardDiskInvalid"
64
- :error-text="hardDiskLocalAndApiErrorsTexts"
65
- :hard-disk-type-error-local-text="hardDiskTypeErrorLocalText"
66
- :is-disabled-size="isDisabledSize"
67
- :is-disabled-provisioning="isDisabledProvisioning"
68
- :is-disabled-sharing="isDisabledSharing"
69
- :is-disabled-limit-iops="isDisabledLimitIops"
70
- :is-disabled-mode="isDisabledMode"
71
- :is-disabled-cache="isDisabledCache"
72
- :is-disabled-bus="isDisabledBus"
73
- :hard-disk-type-options="hardDiskTypeOptions"
74
- :max-hard-disk="maxHardDisk"
75
- :location="location"
76
- :is-running="isRunning"
77
- :is-new-hard-disk="isNewHardDisk"
78
- :is-edit="props.isEdit"
79
- :datastore="props.datastore"
80
- :is-datastore-loading="props.isDatastoreLoading"
81
- :get-datastore-table-func="props.getDatastoreTableFunc"
82
- :error-validation-fields="props.errorValidationFields"
83
- :index="props.index"
84
- :type="props.type"
85
- :hard-disk="props.hardDisk"
86
- :guest-machine-type="props.guestMachineType"
87
- :compute-resource="props.computeResource"
88
- :disabled="false"
89
- @remove="emits('remove')"
90
- @roll-back="emits('roll-back')"
91
- @validate-size="onValidateSize"
92
- @change-storage="onChangeStorage"
93
- @remove-error-by-title="emits('remove-error-by-title', $event)"
94
- />
95
- </template>
96
-
97
- <script setup lang="ts">
98
- import type { UI_I_DatastoreTableItem } from '~/lib/models/store/storage/interfaces'
99
- import type {
100
- UI_I_SendDataNewHardDisk,
101
- UI_I_SendDataNewHardDiskStorage,
102
- } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
103
- import type { UI_T_HardDiskType } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/types'
104
- import type { UI_I_Localization } from '~/lib/models/interfaces'
105
- import type { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
106
- import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
107
- import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
108
- import type { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
109
- import { binaryOptionsFunc } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/config/binaryOptions'
110
-
111
- const props = withDefaults(
112
- defineProps<{
113
- storage: UI_I_DatastoreTableItem | null
114
- hardDisk: UI_I_SendDataNewHardDisk
115
- type: UI_T_HardDiskType
116
- index: number
117
- errorValidationFields: UI_I_ErrorValidationField[]
118
- getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
119
- datastore: UI_I_DatastoreTableItem[]
120
- isDatastoreLoading: boolean
121
- isEdit: boolean
122
- state?: string | number
123
- guestMachineType?: UI_I_OptionItem | null
124
- computeResource?: UI_I_TreeNode | null
125
- }>(),
126
- {
127
- state: undefined,
128
- guestMachineType: undefined,
129
- computeResource: undefined,
130
- }
131
- )
132
- const emits = defineEmits<{
133
- (event: 'send-data', value: UI_I_SendDataNewHardDisk): void
134
- (event: 'invalid', value: boolean): void
135
- (event: 'remove'): void
136
- (event: 'roll-back'): void
137
- (event: 'remove-error-by-title', value: string): void
138
- }>()
139
-
140
- const { $store, $binary }: any = useNuxtApp()
141
- const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
142
-
143
- const localization = computed<UI_I_Localization>(() => useLocal())
144
-
145
- const isRunning = computed<boolean>(() => {
146
- return props.state === 2
147
- })
148
-
149
- const isRemovable = computed<boolean>(() => {
150
- return (
151
- !props.isEdit ||
152
- !isRunning.value ||
153
- (isRunning.value && bus.value === 'virtio')
154
- )
155
- })
156
-
157
- const typeError = computed<string>(() => `disk_devices[${props.index}].size`)
158
-
159
- const apiErrorLocal = computed<string>(() => {
160
- return (
161
- props.errorValidationFields?.find(
162
- (message) => message.field === typeError.value
163
- )?.error_message || ''
164
- )
165
- })
166
-
167
- // PC-1796
168
- // const isNotNewHardDisk = computed<boolean>(
169
- // () => props.type === 'edit' || props.type === 'removed'
170
- // )
171
- const isNewHardDisk = computed<boolean>(
172
- () => props.type !== 'edit' && props.type !== 'removed'
173
- )
174
- const label = computed<string>(() => {
175
- // if (props.type === 'edit' || props.type === 'removed')
176
- if (!isNewHardDisk.value)
177
- return `${localization.value.common.hardDisk} ${props.index + 1}`
178
-
179
- return `${localization.value.common.newHardDisk} *`
180
- })
181
-
182
- const maxHardDisk = computed<number>(() => {
183
- const hardDiskSizeMb = $binary.gbToMb(props.hardDisk.size)
184
-
185
- if (props.type === 'exist') return hardDiskSizeMb
186
-
187
- if (!storage.value) return 0
188
- const free = storage.value.capacity.free_mb || storage.value.capacity // TODO fix
189
-
190
- if (props.isEdit) return free + hardDiskSizeMb
191
-
192
- return free
193
- })
194
- const hardDiskTypeErrorLocalText = computed<string>(() => {
195
- if (+sizeInMb.value > maxHardDisk.value) {
196
- return localization.value.common.diskCapacitySpecifiedGreater
197
- }
198
-
199
- if (+sizeInMb.value <= 0) {
200
- return localization.value.common.diskCapacityCannotZero
201
- }
202
-
203
- return ''
204
- })
205
-
206
- const hardDiskLocalAndApiErrorsTexts = computed<string>(() => {
207
- const localError = hardDiskTypeErrorLocalText.value
208
- const apiError = apiErrorLocal.value
209
-
210
- let result = ''
211
- if (localError && !apiError) result = localError
212
- if (!localError && apiError) result = apiError
213
- if (localError && apiError) result = localError + ', ' + apiError
214
- if (!localError && apiError) result = apiError
215
-
216
- return result
217
- })
218
-
219
- const deleteFilesFromDatastore = ref<boolean>(false)
220
-
221
- const hardDiskType = ref<string>('gb')
222
- const hardDiskTypeOptions = ref<UI_I_OptionItem[]>(
223
- binaryOptionsFunc(localization.value)
224
- )
225
-
226
- const size = ref<number>(props.hardDisk.size) // Изначально всегда приходит в gb
227
- const sizeInMb = computed<number>(() => {
228
- if (hardDiskType.value === 'mb') {
229
- return size.value
230
- }
231
-
232
- return $binary.universalFromTo(size.value, hardDiskType.value, 'mb')
233
- })
234
- const onValidateSize = (): void => {
235
- if (props.type !== 'edit') return
236
- if (sizeInMb.value < props.hardDisk.size) {
237
- size.value = $binary.universalFromTo(
238
- props.hardDisk.size,
239
- 'mb',
240
- hardDiskType.value
241
- )
242
- }
243
- }
244
-
245
- const isDisabledSize = computed<boolean>(() => {
246
- if (isNewHardDisk.value) return false
247
- return (
248
- props.type === 'exist' ||
249
- (props.type === 'edit' && readOnly.value) ||
250
- (isRunning.value && diskProvisioning.value === 'thick')
251
- )
252
- })
253
- const isDisabledProvisioning = computed<boolean>(() => {
254
- if (isNewHardDisk.value) return false
255
- return props.isEdit || isRunning.value
256
- })
257
- const isDisabledSharing = computed<boolean>(() => {
258
- return isRunning.value && !isNewHardDisk.value
259
- })
260
- const isDisabledLimitIops = computed<boolean>(() => {
261
- return isRunning.value && !isNewHardDisk.value
262
- })
263
- const isDisabledMode = computed<boolean>(() => {
264
- return isRunning.value && !isNewHardDisk.value
265
- })
266
- const isDisabledCache = computed<boolean>(() => {
267
- if (isNewHardDisk.value) return false
268
- return props.isEdit || isRunning.value
269
- })
270
- const isDisabledBus = computed<boolean>(() => {
271
- return !isNewHardDisk.value && isRunning.value
272
- })
273
-
274
- const location = ref<UI_I_DatastoreTableItem | null>(props.storage || null)
275
- const storage = ref<UI_I_DatastoreTableItem | null>(props.storage)
276
- watch(
277
- () => props.storage,
278
- (newValue) => {
279
- location.value = newValue
280
- storage.value = newValue
281
- },
282
- {
283
- immediate: true,
284
- deep: true,
285
- }
286
- )
287
- const onChangeStorage = (item: UI_I_DatastoreTableItem): void => {
288
- storage.value = item
289
- }
290
-
291
- const diskProvisioning = ref<string>('thick')
292
- const sharing = ref<string>('')
293
- const shares = ref<number>(0)
294
-
295
- const limitIops = ref<number>(16)
296
- const limitIopsType = ref<string>('unlimited')
297
- const limitIopsInvalid = ref<boolean>(false)
298
-
299
- const diskMode = ref<string>('dependent')
300
-
301
- const cache = ref<string>('none')
302
-
303
- const bus = ref<string>('ide')
304
-
305
- const readOnly = ref<boolean>(false)
306
-
307
- const discard = ref<string>('')
308
-
309
- const io = ref<string>('')
310
-
311
- const target = ref<string>('')
312
-
313
- watch(
314
- [
315
- sizeInMb,
316
- storage,
317
- diskProvisioning,
318
- sharing,
319
- limitIops,
320
- limitIopsType,
321
- diskMode,
322
- cache,
323
- bus,
324
- deleteFilesFromDatastore,
325
- (): void => props.type,
326
- ],
327
- () => {
328
- const limitIopsLocal =
329
- limitIopsType.value === 'unlimited' ? 0 : limitIops.value
330
- const storageLocal: UI_I_SendDataNewHardDiskStorage = {
331
- id: storage.value?.id || '',
332
- name: storage.value?.name || '',
333
- type: storage.value?.type_text || '',
334
- pool: storage.value?.pool_name || '',
335
- user: '',
336
- endpoint: '',
337
- password: '',
338
- protocol: '',
339
- options: '',
340
- }
341
-
342
- emits('send-data', {
343
- create: props.hardDisk.create,
344
- attach: props.hardDisk.attach,
345
- source: props.hardDisk.source,
346
- size: Math.ceil(sizeInMb.value),
347
- bus: bus.value,
348
- target: target.value,
349
- storage: storageLocal,
350
- device_type: 'disk',
351
- provision_type: diskProvisioning.value,
352
- disk_mode: diskMode.value,
353
- sharing: sharing.value === 'yes',
354
- read_only: readOnly.value,
355
- shares: shares.value,
356
- cache: cache.value,
357
- io: io.value,
358
- limit_iops: limitIopsLocal,
359
- discard: discard.value,
360
- capacity: Math.ceil(sizeInMb.value),
361
- boot_order: props.hardDisk.boot_order,
362
- detach: props.type === 'removed',
363
- remove: props.type === 'removed' && deleteFilesFromDatastore.value, // Проверяем если удалили диск и указали Delete files from datastore
364
- })
365
- },
366
- { immediate: true }
367
- )
368
-
369
- // Добавляем данные для редактирования
370
- watch(
371
- () => props.hardDisk,
372
- (newValue) => {
373
- // TODO refactoring
374
- if (props.type === 'exist') {
375
- diskProvisioning.value = newValue.provision_type || 'thick'
376
- return
377
- }
378
- // if (props.type !== 'edit') return
379
- if (props.type !== 'edit' && props.type !== 'clone') return
380
-
381
- const sizeInGb = $binary.mbToGb(newValue.size)
382
- if (sizeInGb < 1) {
383
- size.value = newValue.size
384
- hardDiskType.value = 'mb'
385
- } else {
386
- size.value = sizeInGb
387
- hardDiskType.value = 'gb'
388
- }
389
- diskProvisioning.value = newValue.provision_type || 'thick'
390
- sharing.value = newValue.sharing ? 'yes' : ''
391
- shares.value = newValue.shares || 0
392
- // limitIopsType.value = newValue.io === 'native' ? 'unlimited' : 'custom'
393
- limitIopsType.value = newValue.limit_iops === 0 ? 'unlimited' : 'custom'
394
- limitIops.value = newValue.limit_iops || 16
395
- diskMode.value = newValue.disk_mode || 'dependent'
396
- cache.value = newValue.cache || 'none'
397
- bus.value = newValue.bus || 'ide'
398
- readOnly.value = newValue.read_only || false
399
- discard.value = newValue.discard || ''
400
- io.value = newValue.io || ''
401
- target.value = newValue.target || ''
402
- },
403
- { immediate: true }
404
- )
405
- watch(
406
- isRunning,
407
- (newValue) => {
408
- if (newValue && props.type === 'new') {
409
- bus.value = 'virtio'
410
- }
411
- },
412
- { immediate: true }
413
- )
414
-
415
- const hardDiskInvalid = computed<boolean>(() => {
416
- return !!hardDiskTypeErrorLocalText.value || limitIopsInvalid.value
417
- })
418
- watch(
419
- hardDiskInvalid,
420
- (newValue) => {
421
- emits('invalid', newValue)
422
- },
423
- { immediate: true }
424
- )
425
- </script>
426
-
427
- <style scoped lang="scss"></style>
1
+ <template>
2
+ <common-vm-actions-common-customize-hardware-virtual-hardware-new-hard-disk-new
3
+ v-if="isNewView"
4
+ v-model:delete-files-from-datastore="deleteFilesFromDatastore"
5
+ v-model:size="size"
6
+ v-model:hard-disk-type="hardDiskType"
7
+ v-model:disk-provisioning="diskProvisioning"
8
+ v-model:sharing="sharing"
9
+ v-model:limit-iops="limitIops"
10
+ v-model:limit-iops-type="limitIopsType"
11
+ v-model:limit-iops-invalid="limitIopsInvalid"
12
+ v-model:disk-mode="diskMode"
13
+ v-model:cache="cache"
14
+ v-model:bus="bus"
15
+ :is-removable="isRemovable"
16
+ :label="label"
17
+ :hard-disk-invalid="hardDiskInvalid"
18
+ :error-text="hardDiskLocalAndApiErrorsTexts"
19
+ :hard-disk-type-error-local-text="hardDiskTypeErrorLocalText"
20
+ :is-disabled-size="isDisabledSize"
21
+ :is-disabled-provisioning="isDisabledProvisioning"
22
+ :is-disabled-sharing="isDisabledSharing"
23
+ :is-disabled-limit-iops="isDisabledLimitIops"
24
+ :is-disabled-mode="isDisabledMode"
25
+ :is-disabled-cache="isDisabledCache"
26
+ :is-disabled-bus="isDisabledBus"
27
+ :hard-disk-type-options="hardDiskTypeOptions"
28
+ :max-hard-disk="maxHardDisk"
29
+ :location="location"
30
+ :is-running="isRunning"
31
+ :is-new-hard-disk="isNewHardDisk"
32
+ :is-edit="props.isEdit"
33
+ :datastore="props.datastore"
34
+ :is-datastore-loading="props.isDatastoreLoading"
35
+ :get-datastore-table-func="props.getDatastoreTableFunc"
36
+ :error-validation-fields="props.errorValidationFields"
37
+ :index="props.index"
38
+ :type="props.type"
39
+ :hard-disk="props.hardDisk"
40
+ :guest-machine-type="props.guestMachineType"
41
+ :compute-resource="props.computeResource"
42
+ @remove="emits('remove')"
43
+ @roll-back="emits('roll-back')"
44
+ @validate-size="onValidateSize"
45
+ @change-storage="onChangeStorage"
46
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
47
+ />
48
+ <common-vm-actions-common-customize-hardware-virtual-hardware-new-hard-disk-old
49
+ v-else
50
+ v-model:delete-files-from-datastore="deleteFilesFromDatastore"
51
+ v-model:size="size"
52
+ v-model:hard-disk-type="hardDiskType"
53
+ v-model:disk-provisioning="diskProvisioning"
54
+ v-model:sharing="sharing"
55
+ v-model:limit-iops="limitIops"
56
+ v-model:limit-iops-type="limitIopsType"
57
+ v-model:limit-iops-invalid="limitIopsInvalid"
58
+ v-model:disk-mode="diskMode"
59
+ v-model:cache="cache"
60
+ v-model:bus="bus"
61
+ :is-removable="isRemovable"
62
+ :label="label"
63
+ :hard-disk-invalid="hardDiskInvalid"
64
+ :error-text="hardDiskLocalAndApiErrorsTexts"
65
+ :hard-disk-type-error-local-text="hardDiskTypeErrorLocalText"
66
+ :is-disabled-size="isDisabledSize"
67
+ :is-disabled-provisioning="isDisabledProvisioning"
68
+ :is-disabled-sharing="isDisabledSharing"
69
+ :is-disabled-limit-iops="isDisabledLimitIops"
70
+ :is-disabled-mode="isDisabledMode"
71
+ :is-disabled-cache="isDisabledCache"
72
+ :is-disabled-bus="isDisabledBus"
73
+ :hard-disk-type-options="hardDiskTypeOptions"
74
+ :max-hard-disk="maxHardDisk"
75
+ :location="location"
76
+ :is-running="isRunning"
77
+ :is-new-hard-disk="isNewHardDisk"
78
+ :is-edit="props.isEdit"
79
+ :datastore="props.datastore"
80
+ :is-datastore-loading="props.isDatastoreLoading"
81
+ :get-datastore-table-func="props.getDatastoreTableFunc"
82
+ :error-validation-fields="props.errorValidationFields"
83
+ :index="props.index"
84
+ :type="props.type"
85
+ :hard-disk="props.hardDisk"
86
+ :guest-machine-type="props.guestMachineType"
87
+ :compute-resource="props.computeResource"
88
+ :disabled="false"
89
+ @remove="emits('remove')"
90
+ @roll-back="emits('roll-back')"
91
+ @validate-size="onValidateSize"
92
+ @change-storage="onChangeStorage"
93
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
94
+ />
95
+ </template>
96
+
97
+ <script setup lang="ts">
98
+ import type { UI_I_DatastoreTableItem } from '~/lib/models/store/storage/interfaces'
99
+ import type {
100
+ UI_I_SendDataNewHardDisk,
101
+ UI_I_SendDataNewHardDiskStorage,
102
+ } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
103
+ import type { UI_T_HardDiskType } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/types'
104
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
105
+ import type { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
106
+ import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
107
+ import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
108
+ import type { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
109
+ import { binaryOptionsFunc } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/config/binaryOptions'
110
+
111
+ const props = withDefaults(
112
+ defineProps<{
113
+ storage: UI_I_DatastoreTableItem | null
114
+ hardDisk: UI_I_SendDataNewHardDisk
115
+ type: UI_T_HardDiskType
116
+ index: number
117
+ errorValidationFields: UI_I_ErrorValidationField[]
118
+ getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
119
+ datastore: UI_I_DatastoreTableItem[]
120
+ isDatastoreLoading: boolean
121
+ isEdit: boolean
122
+ state?: string | number
123
+ guestMachineType?: UI_I_OptionItem | null
124
+ computeResource?: UI_I_TreeNode | null
125
+ }>(),
126
+ {
127
+ state: undefined,
128
+ guestMachineType: undefined,
129
+ computeResource: undefined,
130
+ }
131
+ )
132
+ const emits = defineEmits<{
133
+ (event: 'send-data', value: UI_I_SendDataNewHardDisk): void
134
+ (event: 'invalid', value: boolean): void
135
+ (event: 'remove'): void
136
+ (event: 'roll-back'): void
137
+ (event: 'remove-error-by-title', value: string): void
138
+ }>()
139
+
140
+ const { $store, $binary }: any = useNuxtApp()
141
+ const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
142
+
143
+ const localization = computed<UI_I_Localization>(() => useLocal())
144
+
145
+ const isRunning = computed<boolean>(() => {
146
+ return props.state === 2
147
+ })
148
+
149
+ const isRemovable = computed<boolean>(() => {
150
+ return (
151
+ !props.isEdit ||
152
+ !isRunning.value ||
153
+ (isRunning.value && bus.value === 'virtio')
154
+ )
155
+ })
156
+
157
+ const typeError = computed<string>(() => `disk_devices[${props.index}].size`)
158
+
159
+ const apiErrorLocal = computed<string>(() => {
160
+ return (
161
+ props.errorValidationFields?.find(
162
+ (message) => message.field === typeError.value
163
+ )?.error_message || ''
164
+ )
165
+ })
166
+
167
+ // PC-1796
168
+ // const isNotNewHardDisk = computed<boolean>(
169
+ // () => props.type === 'edit' || props.type === 'removed'
170
+ // )
171
+ const isNewHardDisk = computed<boolean>(
172
+ () => props.type !== 'edit' && props.type !== 'removed'
173
+ )
174
+ const label = computed<string>(() => {
175
+ // if (props.type === 'edit' || props.type === 'removed')
176
+ if (!isNewHardDisk.value)
177
+ return `${localization.value.common.hardDisk} ${props.index + 1}`
178
+
179
+ return `${localization.value.common.newHardDisk} *`
180
+ })
181
+
182
+ const maxHardDisk = computed<number>(() => {
183
+ const hardDiskSizeMb = $binary.gbToMb(props.hardDisk.size)
184
+
185
+ if (props.type === 'exist') return hardDiskSizeMb
186
+
187
+ if (!storage.value) return 0
188
+ const free = storage.value.capacity.free_mb || storage.value.capacity // TODO fix
189
+
190
+ if (props.isEdit) return free + hardDiskSizeMb
191
+
192
+ return free
193
+ })
194
+ const hardDiskTypeErrorLocalText = computed<string>(() => {
195
+ if (+sizeInMb.value > maxHardDisk.value) {
196
+ return localization.value.common.diskCapacitySpecifiedGreater
197
+ }
198
+
199
+ if (+sizeInMb.value <= 0) {
200
+ return localization.value.common.diskCapacityCannotZero
201
+ }
202
+
203
+ return ''
204
+ })
205
+
206
+ const hardDiskLocalAndApiErrorsTexts = computed<string>(() => {
207
+ const localError = hardDiskTypeErrorLocalText.value
208
+ const apiError = apiErrorLocal.value
209
+
210
+ let result = ''
211
+ if (localError && !apiError) result = localError
212
+ if (!localError && apiError) result = apiError
213
+ if (localError && apiError) result = localError + ', ' + apiError
214
+ if (!localError && apiError) result = apiError
215
+
216
+ return result
217
+ })
218
+
219
+ const deleteFilesFromDatastore = ref<boolean>(false)
220
+
221
+ const hardDiskType = ref<string>('gb')
222
+ const hardDiskTypeOptions = ref<UI_I_OptionItem[]>(
223
+ binaryOptionsFunc(localization.value)
224
+ )
225
+
226
+ const size = ref<number>(props.hardDisk.size) // Изначально всегда приходит в gb
227
+ const sizeInMb = computed<number>(() => {
228
+ if (hardDiskType.value === 'mb') {
229
+ return size.value
230
+ }
231
+
232
+ return $binary.universalFromTo(size.value, hardDiskType.value, 'mb')
233
+ })
234
+ const onValidateSize = (): void => {
235
+ if (props.type !== 'edit') return
236
+ if (sizeInMb.value < props.hardDisk.size) {
237
+ size.value = $binary.universalFromTo(
238
+ props.hardDisk.size,
239
+ 'mb',
240
+ hardDiskType.value
241
+ )
242
+ }
243
+ }
244
+
245
+ const isDisabledSize = computed<boolean>(() => {
246
+ if (isNewHardDisk.value) return false
247
+ return (
248
+ props.type === 'exist' ||
249
+ (props.type === 'edit' && readOnly.value) ||
250
+ (isRunning.value && diskProvisioning.value === 'thick')
251
+ )
252
+ })
253
+ const isDisabledProvisioning = computed<boolean>(() => {
254
+ if (isNewHardDisk.value) return false
255
+ return props.isEdit || isRunning.value
256
+ })
257
+ const isDisabledSharing = computed<boolean>(() => {
258
+ return isRunning.value && !isNewHardDisk.value
259
+ })
260
+ const isDisabledLimitIops = computed<boolean>(() => {
261
+ return isRunning.value && !isNewHardDisk.value
262
+ })
263
+ const isDisabledMode = computed<boolean>(() => {
264
+ return isRunning.value && !isNewHardDisk.value
265
+ })
266
+ const isDisabledCache = computed<boolean>(() => {
267
+ if (isNewHardDisk.value) return false
268
+ return props.isEdit || isRunning.value
269
+ })
270
+ const isDisabledBus = computed<boolean>(() => {
271
+ return !isNewHardDisk.value && isRunning.value
272
+ })
273
+
274
+ const location = ref<UI_I_DatastoreTableItem | null>(props.storage || null)
275
+ const storage = ref<UI_I_DatastoreTableItem | null>(props.storage)
276
+ watch(
277
+ () => props.storage,
278
+ (newValue) => {
279
+ location.value = newValue
280
+ storage.value = newValue
281
+ },
282
+ {
283
+ immediate: true,
284
+ deep: true,
285
+ }
286
+ )
287
+ const onChangeStorage = (item: UI_I_DatastoreTableItem): void => {
288
+ storage.value = item
289
+ }
290
+
291
+ const diskProvisioning = ref<string>('thick')
292
+ const sharing = ref<string>('')
293
+ const shares = ref<number>(0)
294
+
295
+ const limitIops = ref<number>(16)
296
+ const limitIopsType = ref<string>('unlimited')
297
+ const limitIopsInvalid = ref<boolean>(false)
298
+
299
+ const diskMode = ref<string>('dependent')
300
+
301
+ const cache = ref<string>('none')
302
+
303
+ const bus = ref<string>('ide')
304
+
305
+ const readOnly = ref<boolean>(false)
306
+
307
+ const discard = ref<string>('')
308
+
309
+ const io = ref<string>('')
310
+
311
+ const target = ref<string>('')
312
+
313
+ watch(
314
+ [
315
+ sizeInMb,
316
+ storage,
317
+ diskProvisioning,
318
+ sharing,
319
+ limitIops,
320
+ limitIopsType,
321
+ diskMode,
322
+ cache,
323
+ bus,
324
+ deleteFilesFromDatastore,
325
+ (): void => props.type,
326
+ ],
327
+ () => {
328
+ const limitIopsLocal =
329
+ limitIopsType.value === 'unlimited' ? 0 : limitIops.value
330
+ const storageLocal: UI_I_SendDataNewHardDiskStorage = {
331
+ id: storage.value?.id || '',
332
+ name: storage.value?.name || '',
333
+ type: storage.value?.type_text || '',
334
+ pool: storage.value?.pool_name || '',
335
+ user: '',
336
+ endpoint: '',
337
+ password: '',
338
+ protocol: '',
339
+ options: '',
340
+ }
341
+
342
+ emits('send-data', {
343
+ create: props.hardDisk.create,
344
+ attach: props.hardDisk.attach,
345
+ source: props.hardDisk.source,
346
+ size: Math.ceil(sizeInMb.value),
347
+ bus: bus.value,
348
+ target: target.value,
349
+ storage: storageLocal,
350
+ device_type: 'disk',
351
+ provision_type: diskProvisioning.value,
352
+ disk_mode: diskMode.value,
353
+ sharing: sharing.value === 'yes',
354
+ read_only: readOnly.value,
355
+ shares: shares.value,
356
+ cache: cache.value,
357
+ io: io.value,
358
+ limit_iops: limitIopsLocal,
359
+ discard: discard.value,
360
+ capacity: Math.ceil(sizeInMb.value),
361
+ boot_order: props.hardDisk.boot_order,
362
+ detach: props.type === 'removed',
363
+ remove: props.type === 'removed' && deleteFilesFromDatastore.value, // Проверяем если удалили диск и указали Delete files from datastore
364
+ })
365
+ },
366
+ { immediate: true }
367
+ )
368
+
369
+ // Добавляем данные для редактирования
370
+ watch(
371
+ () => props.hardDisk,
372
+ (newValue) => {
373
+ // TODO refactoring
374
+ if (props.type === 'exist') {
375
+ diskProvisioning.value = newValue.provision_type || 'thick'
376
+ return
377
+ }
378
+ // if (props.type !== 'edit') return
379
+ if (props.type !== 'edit' && props.type !== 'clone') return
380
+
381
+ const sizeInGb = $binary.mbToGb(newValue.size)
382
+ if (sizeInGb < 1) {
383
+ size.value = newValue.size
384
+ hardDiskType.value = 'mb'
385
+ } else {
386
+ size.value = sizeInGb
387
+ hardDiskType.value = 'gb'
388
+ }
389
+ diskProvisioning.value = newValue.provision_type || 'thick'
390
+ sharing.value = newValue.sharing ? 'yes' : ''
391
+ shares.value = newValue.shares || 0
392
+ // limitIopsType.value = newValue.io === 'native' ? 'unlimited' : 'custom'
393
+ limitIopsType.value = newValue.limit_iops === 0 ? 'unlimited' : 'custom'
394
+ limitIops.value = newValue.limit_iops || 16
395
+ diskMode.value = newValue.disk_mode || 'dependent'
396
+ cache.value = newValue.cache || 'none'
397
+ bus.value = newValue.bus || 'ide'
398
+ readOnly.value = newValue.read_only || false
399
+ discard.value = newValue.discard || ''
400
+ io.value = newValue.io || ''
401
+ target.value = newValue.target || ''
402
+ },
403
+ { immediate: true }
404
+ )
405
+ watch(
406
+ isRunning,
407
+ (newValue) => {
408
+ if (newValue && props.type === 'new') {
409
+ bus.value = 'virtio'
410
+ }
411
+ },
412
+ { immediate: true }
413
+ )
414
+
415
+ const hardDiskInvalid = computed<boolean>(() => {
416
+ return !!hardDiskTypeErrorLocalText.value || limitIopsInvalid.value
417
+ })
418
+ watch(
419
+ hardDiskInvalid,
420
+ (newValue) => {
421
+ emits('invalid', newValue)
422
+ },
423
+ { immediate: true }
424
+ )
425
+ </script>
426
+
427
+ <style scoped lang="scss"></style>