bfg-common 1.5.689 → 1.5.691

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 (126) hide show
  1. package/CODE_STYLE.md +109 -109
  2. package/assets/img/icons/icons-sprite-dark-3.svg +227 -227
  3. package/assets/img/icons/icons-sprite-dark-5.svg +488 -488
  4. package/assets/img/icons/icons-sprite-light-3.svg +227 -227
  5. package/assets/img/icons/icons-sprite-light-5.svg +488 -488
  6. package/assets/localization/local_be.json +4 -0
  7. package/assets/localization/local_en.json +4 -0
  8. package/assets/localization/local_hy.json +4 -0
  9. package/assets/localization/local_kk.json +4 -0
  10. package/assets/localization/local_ru.json +4 -0
  11. package/assets/localization/local_zh.json +4 -0
  12. package/components/atoms/TheIcon3.vue +50 -50
  13. package/components/atoms/collapse/CollapseNav.vue +170 -170
  14. package/components/atoms/perPage/PerPage.vue +58 -58
  15. package/components/atoms/switch/Switch.vue +103 -103
  16. package/components/atoms/table/dataGrid/DataGrid.vue +1718 -1718
  17. package/components/atoms/table/dataGrid/DataGridPagination.vue +97 -97
  18. package/components/atoms/table/dataGrid/lib/config/settingsTable.ts +94 -94
  19. package/components/atoms/table/dataGrid/lib/utils/export.ts +16 -16
  20. package/components/common/backup/storage/actions/add/lib/utils.ts +51 -51
  21. package/components/common/browse/blocks/contents/filesNew/Skeleton.vue +18 -18
  22. package/components/common/diagramMain/modals/lib/config/vCenterModal.ts +48 -48
  23. package/components/common/diagramMain/port/Port.vue +580 -580
  24. package/components/common/layout/theHeader/TheHeaderNew.vue +315 -315
  25. package/components/common/layout/theHeader/TheHeaderOld.vue +262 -262
  26. package/components/common/layout/theHeader/helpMenu/About.vue +79 -79
  27. package/components/common/layout/theHeader/helpMenu/aboutOld/AboutOld.vue +79 -79
  28. package/components/common/layout/theHeader/userMenu/modals/preferences/PreferencesNew.vue +13 -0
  29. package/components/common/layout/theHeader/userMenu/modals/preferences/PreferencesOld.vue +144 -144
  30. package/components/common/layout/theHeader/userMenu/modals/preferences/changeLanguage/ChangeLanguage.vue +8 -15
  31. package/components/common/layout/theHeader/userMenu/modals/preferences/changeLanguage/{ChangeLanguageNew.vue → New.vue} +1 -2
  32. package/components/common/layout/theHeader/userMenu/modals/preferences/changeLanguage/{ChangeLanguageOld.vue → Old.vue} +0 -2
  33. package/components/common/layout/theHeader/userMenu/modals/preferences/defaultConsole/DefaultConsole.vue +8 -7
  34. package/components/common/layout/theHeader/userMenu/modals/preferences/defaultConsole/{DefaultConsoleNew.vue → New.vue} +3 -3
  35. package/components/common/layout/theHeader/userMenu/modals/preferences/defaultConsole/{DefaultConsoleOld.vue → Old.vue} +2 -2
  36. package/components/common/layout/theHeader/userMenu/modals/preferences/inventory/Inventory.vue +7 -8
  37. package/components/common/layout/theHeader/userMenu/modals/preferences/inventory/{InventoryNew.vue → New.vue} +3 -2
  38. package/components/common/layout/theHeader/userMenu/modals/preferences/inventory/{InventoryOld.vue → Old.vue} +2 -2
  39. package/components/common/layout/theHeader/userMenu/modals/preferences/lib/models/types.ts +7 -7
  40. package/components/common/layout/theHeader/userMenu/modals/preferences/security/New.vue +277 -12
  41. package/components/common/layout/theHeader/userMenu/modals/preferences/security/Old.vue +184 -216
  42. package/components/common/layout/theHeader/userMenu/modals/preferences/security/Security.vue +90 -31
  43. package/components/common/layout/theHeader/userMenu/modals/preferences/timeFormat/{TimeFormatNew.vue → New.vue} +3 -3
  44. package/components/common/layout/theHeader/userMenu/modals/preferences/timeFormat/{TimeFormatOld.vue → Old.vue} +2 -2
  45. package/components/common/layout/theHeader/userMenu/modals/preferences/timeFormat/TimeFormat.vue +8 -8
  46. package/components/common/layout/theHeader/userMenu/modals/preferences/view/{ViewNew.vue → New.vue} +12 -3
  47. package/components/common/layout/theHeader/userMenu/modals/preferences/view/{ViewOld.vue → Old.vue} +2 -2
  48. package/components/common/layout/theHeader/userMenu/modals/preferences/view/View.vue +8 -7
  49. package/components/common/pages/backups/DetailView.vue +52 -52
  50. package/components/common/pages/backups/lib/models/interfaces.ts +36 -36
  51. package/components/common/pages/backups/modals/Modals.vue +243 -243
  52. package/components/common/pages/backups/modals/createBackup/configuration/maxBandwidth/lib/config/options.ts +6 -6
  53. package/components/common/pages/backups/modals/createBackup/lib/config/readyToCompleteOptions.ts +69 -69
  54. package/components/common/pages/backups/modals/lib/config/restore.ts +115 -115
  55. package/components/common/pages/backups/modals/lib/models/interfaces.ts +186 -186
  56. package/components/common/pages/backups/modals/restore/name/lib/models/interfaces.ts +6 -6
  57. package/components/common/pages/home/lib/models/interfaces.ts +48 -48
  58. package/components/common/pages/home/widgets/hosts/Hosts.vue +27 -27
  59. package/components/common/pages/home/widgets/hosts/lib/config/items.ts +23 -23
  60. package/components/common/pages/home/widgets/vms/VmsOld.vue +35 -35
  61. package/components/common/pages/home/widgets/vms/lib/config/items.ts +19 -19
  62. package/components/common/pages/scheduledTasks/lib/utils/utils.ts +84 -84
  63. package/components/common/qr/Qr.vue +69 -57
  64. package/components/common/readyToComplete/ReadyToComplete.vue +17 -17
  65. package/components/common/select/radio/RadioGroup.vue +137 -137
  66. package/components/common/spiceConsole/Drawer.vue +420 -420
  67. package/components/common/spiceConsole/SpiceConsole.vue +184 -184
  68. package/components/common/spiceConsole/lib/models/interfaces.ts +5 -5
  69. package/components/common/tools/Actions.vue +207 -207
  70. package/components/common/treeView/TreeView.vue +52 -52
  71. package/components/common/vm/actions/clone/lib/config/steps.ts +295 -295
  72. package/components/common/vm/actions/clone/new/New.vue +438 -438
  73. package/components/common/vm/actions/common/customizeHardware/virtualHardware/VirtualHardware.vue +706 -706
  74. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/shares/lib/config/options.ts +28 -28
  75. package/components/common/vm/actions/common/customizeHardware/virtualHardware/memory/Memory.vue +283 -283
  76. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/NewHardDisk.vue +489 -489
  77. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/NewPciDevice.vue +253 -253
  78. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/Order.vue +156 -156
  79. package/components/common/vm/actions/common/select/compatibility/Old.vue +107 -107
  80. package/components/common/vm/actions/common/select/createType/lib/models/interfaces.ts +5 -5
  81. package/components/common/vm/actions/common/select/options/New.vue +264 -264
  82. package/components/common/vm/actions/common/select/options/Old.vue +109 -109
  83. package/components/common/vm/actions/common/select/options/Options.vue +58 -58
  84. package/components/common/vm/actions/common/select/storage/Old.vue +125 -125
  85. package/components/common/vm/actions/common/select/storage/new/New.vue +311 -311
  86. package/components/common/vm/actions/common/select/storage/new/lib/models/interfaces.ts +5 -5
  87. package/components/common/vm/actions/common/select/storage/new/lib/utils/utils.ts +21 -21
  88. package/components/common/vm/actions/common/select/template/old/Old.vue +50 -50
  89. package/components/common/vm/actions/editSettings/new/Skeleton.vue +88 -88
  90. package/components/common/wizards/common/compatibility/Compatibility.vue +35 -35
  91. package/components/common/wizards/common/steps/computeResource/New.vue +93 -93
  92. package/components/common/wizards/common/steps/name/Name.vue +178 -178
  93. package/components/common/wizards/common/steps/name/New.vue +221 -221
  94. package/components/common/wizards/common/steps/name/Old.vue +121 -121
  95. package/components/common/wizards/common/steps/name/lib/models/interfaces.ts +4 -4
  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/nameAndDevice/NameAndDeviceNew.vue +232 -232
  100. package/components/common/wizards/datastore/add/steps/nameAndDevice/NameAndDeviceOld.vue +231 -231
  101. package/components/common/wizards/datastore/add/steps/nameAndDevice/advancedOptions/AdvancedOptions.vue +43 -43
  102. package/components/common/wizards/datastore/add/steps/nameAndDevice/advancedOptions/New.vue +101 -101
  103. package/components/common/wizards/datastore/add/steps/nameAndDevice/advancedOptions/Old.vue +101 -101
  104. package/components/common/wizards/datastore/add/steps/typeMode/lib/config/typeOptions.ts +43 -43
  105. package/composables/useAppVersion.ts +21 -21
  106. package/composables/useEnvLanguage.ts +22 -22
  107. package/composables/useLocal.ts +6 -6
  108. package/composables/useLocalCommon.ts +39 -39
  109. package/package.json +2 -2
  110. package/plugins/console.ts +21 -21
  111. package/plugins/mouse.ts +21 -21
  112. package/plugins/panelStates.ts +70 -70
  113. package/plugins/text.ts +59 -59
  114. package/public/spice-console/application/clientgui.js +854 -854
  115. package/public/spice-console/application/packetfactory.js +211 -211
  116. package/public/spice-console/application/virtualmouse.js +147 -147
  117. package/public/spice-console/lib/images/bitmap.js +203 -203
  118. package/public/spice-console/network/spicechannel.js +440 -440
  119. package/public/spice-console/process/cursorprocess.js +128 -128
  120. package/public/spice-console/process/inputprocess.js +227 -227
  121. package/public/spice-console/process/mainprocess.js +212 -212
  122. package/public/spice-console/run.js +210 -210
  123. package/store/main/mutations.ts +7 -7
  124. package/store/main/state.ts +7 -7
  125. package/store/tasks/mappers/recentTasks.ts +123 -123
  126. package/store/tasks/mutations.ts +82 -82
@@ -1,489 +1,489 @@
1
- <template>
2
- <component
3
- :is="currentComponent"
4
- v-model:delete-files-from-datastore="deleteFilesFromDatastore"
5
- v-model:size="sizeLocal"
6
- v-model:hard-disk-type="hardDiskType"
7
- v-model:disk-provisioning="provisionType"
8
- v-model:sharing="sharingLocal"
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
- v-model:source="source"
16
- :is-removable="isRemovable"
17
- :label="label"
18
- :hard-disk-invalid="hardDiskInvalid"
19
- :error-text="hardDiskLocalAndApiErrorsTexts"
20
- :hard-disk-type-error-local-text="hardDiskTypeErrorLocalText"
21
- :is-disabled-size="isDisabledSize"
22
- :is-disabled-provisioning="isDisabledProvisioning"
23
- :is-disabled-sharing="isDisabledSharing"
24
- :is-disabled-limit-iops="isDisabledLimitIops"
25
- :is-disabled-mode="isDisabledMode"
26
- :is-disabled-cache="isDisabledCache"
27
- :is-disabled-bus="isDisabledBus"
28
- :hard-disk-type-options="hardDiskTypeOptions"
29
- :max-hard-disk="maxHardDisk"
30
- :location="location"
31
- :is-running="isRunning"
32
- :is-new-hard-disk="isNewHardDisk"
33
- :is-edit="props.isEdit"
34
- :datastore="props.datastore"
35
- :is-datastore-loading="props.isDatastoreLoading"
36
- :get-datastore-table-func="props.getDatastoreTableFunc"
37
- :error-validation-fields="props.errorValidationFields"
38
- :index="props.index"
39
- :type="props.type"
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
- </template>
49
-
50
- <script setup lang="ts">
51
- import type { UI_I_DatastoreTableItem } from '~/lib/models/store/storage/interfaces'
52
- // import type {
53
- // UI_I_SendDataNewHardDisk,
54
- // UI_I_SendDataNewHardDiskStorage,
55
- // } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
56
- import type { UI_T_HardDiskType } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/types'
57
- import type { UI_I_Localization } from '~/lib/models/interfaces'
58
- import type { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
59
- import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
60
- import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
61
- import type { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
62
- import { binaryOptionsFunc } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/config/binaryOptions'
63
-
64
- const size = defineModel<number>('size', { required: true })
65
- const initialSize = size.value
66
- // const provisionType = ref<string>('thick')
67
- const provisionType = defineModel<string>('provisionType', { required: true })
68
- // const sharing = ref<string>('')
69
- const sharing = defineModel<boolean>('sharing', { required: true })
70
- // const sharingLocal = ref<string>(sharing.value ? 'yes' : '')
71
- const sharingLocal = computed<string>({
72
- set(newValue) {
73
- sharing.value = newValue === 'yes'
74
- },
75
- get() {
76
- return sharing.value ? 'yes' : ''
77
- },
78
- })
79
- // const shares = ref<number>(0)
80
- const shares = defineModel<number>('shares', { required: true })
81
-
82
- // const limitIops = ref<number>(16)
83
- const limitIops = defineModel<number>('limitIops', { required: true })
84
- const limitIopsType = ref<string>('unlimited') // ??
85
- const limitIopsInvalid = ref<boolean>(false) // ??
86
-
87
- // const diskMode = ref<string>('dependent')
88
- const diskMode = defineModel<string>('diskMode', { required: true })
89
-
90
- // const cache = ref<string>('none')
91
- const cache = defineModel<string>('cache', { required: true })
92
-
93
- // const bus = ref<string>('ide')
94
- const bus = defineModel<string>('bus', { required: true })
95
-
96
- // const readOnly = ref<boolean>(false)
97
- const readOnly = defineModel<boolean>('readOnly', { required: true })
98
-
99
- // const discard = ref<string>('')
100
- const discard = defineModel<string>('discard', { required: true })
101
-
102
- // const io = ref<string>('')
103
- const io = defineModel<string>('io', { required: true })
104
-
105
- // const target = ref<string>('')
106
- const target = defineModel<string>('target', { required: true })
107
-
108
- const source = defineModel<string>('source', { required: true })
109
-
110
- const storage = defineModel<any>('storage', { required: true })
111
-
112
- const remove = defineModel<boolean>('remove', { required: true })
113
- const detach = defineModel<boolean>('detach', { required: true })
114
-
115
- const props = withDefaults(
116
- defineProps<{
117
- mainStorage: UI_I_DatastoreTableItem | null
118
- mainStorageFree: number
119
- // hardDisk: UI_I_SendDataNewHardDisk
120
- type: UI_T_HardDiskType
121
- index: number
122
- errorValidationFields: UI_I_ErrorValidationField[]
123
- getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
124
- datastore: UI_I_DatastoreTableItem[]
125
- isDatastoreLoading: boolean
126
- isEdit: boolean
127
- state?: string | number
128
- guestMachineType?: UI_I_OptionItem | null
129
- computeResource?: UI_I_TreeNode | null
130
- }>(),
131
- {
132
- state: undefined,
133
- guestMachineType: undefined,
134
- computeResource: undefined,
135
- }
136
- )
137
- const emits = defineEmits<{
138
- // (event: 'send-data', value: UI_I_SendDataNewHardDisk): void
139
- (event: 'invalid', value: boolean): void
140
- (event: 'remove'): void
141
- (event: 'roll-back'): void
142
- (event: 'remove-error-by-title', value: string): void
143
- }>()
144
-
145
- watch(
146
- () => props.type,
147
- (newValue) => {
148
- detach.value = newValue === 'removed'
149
- }
150
- )
151
-
152
- const { $store, $binary }: any = useNuxtApp()
153
- const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
154
- const currentComponent = computed(() =>
155
- isNewView.value
156
- ? defineAsyncComponent(() => import('./New.vue'))
157
- : defineAsyncComponent(() => import('./Old.vue'))
158
- )
159
-
160
- const localization = computed<UI_I_Localization>(() => useLocal())
161
-
162
- const isRunning = computed<boolean>(() => {
163
- return props.state === 2
164
- })
165
-
166
- const isRemovable = computed<boolean>(() => {
167
- return (
168
- !props.isEdit ||
169
- !isRunning.value ||
170
- (isRunning.value && bus.value === 'virtio')
171
- )
172
- })
173
-
174
- const typeError = computed<string>(() => `disk_devices[${props.index}].size`)
175
-
176
- const apiErrorLocal = computed<string>(() => {
177
- return (
178
- props.errorValidationFields?.find(
179
- (message) => message.field === typeError.value
180
- )?.error_message || ''
181
- )
182
- })
183
-
184
- // PC-1796
185
- // const isNotNewHardDisk = computed<boolean>(
186
- // () => props.type === 'edit' || props.type === 'removed'
187
- // )
188
- const isNewHardDisk = computed<boolean>(
189
- () => props.type !== 'edit' && props.type !== 'removed'
190
- )
191
- const label = computed<string>(() => {
192
- // if (props.type === 'edit' || props.type === 'removed')
193
- if (!isNewHardDisk.value)
194
- return `${localization.value.common.hardDisk} ${props.index + 1}`
195
-
196
- return `${localization.value.common.newHardDisk} *`
197
- })
198
-
199
- const maxHardDisk = computed<number>(() => {
200
- // // const hardDiskSizeMb = $binary.gbToMb(props.hardDisk.size)
201
- //
202
- // if (props.type === 'exist') return initialSize
203
- //
204
- // if (!storageLocal.value) return 0
205
- // const free = (storageLocal.value.capacity.free_mb ||
206
- // storageLocal.value.free) as number // TODO fix
207
- //
208
- // if (props.type === 'edit') return free + initialSize
209
- //
210
- // return free
211
- if (props.type === 'exist') return initialSize
212
-
213
- if (!storageLocal.value) return 0
214
-
215
- return props.mainStorageFree + size.value
216
- })
217
- const hardDiskTypeErrorLocalText = computed<string>(() => {
218
- if (size.value > maxHardDisk.value) {
219
- return localization.value.common.diskCapacitySpecifiedGreater
220
- }
221
-
222
- if (size.value <= 0) {
223
- return localization.value.common.diskCapacityCannotZero
224
- }
225
-
226
- return ''
227
- })
228
-
229
- const hardDiskLocalAndApiErrorsTexts = computed<string>(() => {
230
- const localError = hardDiskTypeErrorLocalText.value
231
- const apiError = apiErrorLocal.value
232
-
233
- let result = ''
234
- if (localError && !apiError) result = localError
235
- if (!localError && apiError) result = apiError
236
- if (localError && apiError) result = localError + ', ' + apiError
237
- if (!localError && apiError) result = apiError
238
-
239
- return result
240
- })
241
-
242
- const deleteFilesFromDatastore = ref<boolean>(false)
243
- watch(deleteFilesFromDatastore, (newValue) => {
244
- remove.value = props.type === 'removed' && newValue
245
- })
246
-
247
- const hardDiskType = ref<string>(size.value < 1024 ? 'mb' : 'gb')
248
- watch(hardDiskType, (newValue) => {
249
- size.value = $binary.universalFromTo(sizeLocal.value, newValue, 'mb')
250
- })
251
- const hardDiskTypeOptions = ref<UI_I_OptionItem[]>(
252
- binaryOptionsFunc(localization.value)
253
- )
254
-
255
- const sizeLocal = ref<number>(
256
- size.value < 1024 ? size.value : $binary.mbToGb(size.value)
257
- )
258
- watch(sizeLocal, (newValue) => {
259
- if (hardDiskType.value === 'mb') {
260
- size.value = newValue
261
- }
262
-
263
- size.value = $binary.universalFromTo(newValue, hardDiskType.value, 'mb')
264
- })
265
- // const sizeInMb = computed<number>(() => {
266
- // if (hardDiskType.value === 'mb') {
267
- // return size.value
268
- // }
269
- //
270
- // return $binary.universalFromTo(size.value, hardDiskType.value, 'mb')
271
- // })
272
- const onValidateSize = (): void => {
273
- if (props.type !== 'edit') return
274
- if (size.value < initialSize) {
275
- sizeLocal.value = $binary.universalFromTo(
276
- initialSize,
277
- 'mb',
278
- hardDiskType.value
279
- )
280
- }
281
- }
282
-
283
- const isDisabledSize = computed<boolean>(() => {
284
- if (isNewHardDisk.value) return false
285
- return (
286
- props.type === 'exist' ||
287
- (props.type === 'edit' && readOnly.value)
288
- // (isRunning.value && provisionType.value === 'thick')
289
- )
290
- })
291
- const isDisabledProvisioning = computed<boolean>(() => {
292
- if (isNewHardDisk.value) return false
293
- return props.isEdit || isRunning.value
294
- })
295
- const isDisabledSharing = computed<boolean>(() => {
296
- return isRunning.value && !isNewHardDisk.value
297
- })
298
- const isDisabledLimitIops = computed<boolean>(() => {
299
- return isRunning.value && !isNewHardDisk.value
300
- })
301
- const isDisabledMode = computed<boolean>(() => {
302
- return isRunning.value && !isNewHardDisk.value
303
- })
304
- const isDisabledCache = computed<boolean>(() => {
305
- if (isNewHardDisk.value) return false
306
- return props.isEdit || isRunning.value
307
- })
308
- const isDisabledBus = computed<boolean>(() => {
309
- return !isNewHardDisk.value && isRunning.value
310
- })
311
-
312
- const location = ref<UI_I_DatastoreTableItem | null>(props.mainStorage || null)
313
- const storageLocal = ref<UI_I_DatastoreTableItem | null>(props.mainStorage)
314
- watch(
315
- () => props.mainStorage,
316
- (newValue) => {
317
- location.value = newValue
318
- storageLocal.value = newValue
319
-
320
- storage.value = {
321
- id: newValue?.id || '',
322
- name: newValue?.name || '',
323
- type: newValue?.type_text || '',
324
- pool: newValue?.pool_name || '',
325
- user: '',
326
- endpoint: '',
327
- password: '',
328
- protocol: '',
329
- options: '',
330
- }
331
- },
332
- {
333
- immediate: true,
334
- deep: true,
335
- }
336
- )
337
- const onChangeStorage = (item: UI_I_DatastoreTableItem): void => {
338
- storageLocal.value = item
339
-
340
- storage.value = {
341
- id: item?.id || '',
342
- name: item?.name || '',
343
- type: item?.type_text || '',
344
- pool: item?.pool_name || '',
345
- user: '',
346
- endpoint: '',
347
- password: '',
348
- protocol: '',
349
- options: '',
350
- }
351
- }
352
-
353
- // const diskProvisioning = ref<string>('thick')
354
- // const sharing = ref<string>('')
355
- // const shares = ref<number>(0)
356
- //
357
- // const limitIops = ref<number>(16)
358
- // const limitIopsType = ref<string>('unlimited')
359
- // const limitIopsInvalid = ref<boolean>(false)
360
- //
361
- // const diskMode = ref<string>('dependent')
362
- //
363
- // const cache = ref<string>('none')
364
- //
365
- // const bus = ref<string>('ide')
366
- //
367
- // const readOnly = ref<boolean>(false)
368
- //
369
- // const discard = ref<string>('')
370
- //
371
- // const io = ref<string>('')
372
- //
373
- // const target = ref<string>('')
374
-
375
- // watch(
376
- // [
377
- // sizeInMb,
378
- // storage,
379
- // diskProvisioning,
380
- // sharing,
381
- // limitIops,
382
- // limitIopsType,
383
- // diskMode,
384
- // cache,
385
- // bus,
386
- // deleteFilesFromDatastore,
387
- // (): void => props.type,
388
- // ],
389
- // () => {
390
- // const limitIopsLocal =
391
- // limitIopsType.value === 'unlimited' ? 0 : limitIops.value
392
- // const storageLocal: UI_I_SendDataNewHardDiskStorage = {
393
- // id: storage.value?.id || '',
394
- // name: storage.value?.name || '',
395
- // type: storage.value?.type_text || '',
396
- // pool: storage.value?.pool_name || '',
397
- // user: '',
398
- // endpoint: '',
399
- // password: '',
400
- // protocol: '',
401
- // options: '',
402
- // }
403
- //
404
- // emits('send-data', {
405
- // create: props.hardDisk.create,
406
- // attach: props.hardDisk.attach,
407
- // source: props.hardDisk.source,
408
- // size: Math.ceil(sizeInMb.value),
409
- // bus: bus.value,
410
- // target: target.value,
411
- // storage: storageLocal,
412
- // device_type: 'disk',
413
- // provision_type: diskProvisioning.value,
414
- // disk_mode: diskMode.value,
415
- // sharing: sharing.value === 'yes',
416
- // read_only: readOnly.value,
417
- // shares: shares.value,
418
- // cache: cache.value,
419
- // io: io.value,
420
- // limit_iops: limitIopsLocal,
421
- // discard: discard.value,
422
- // capacity: Math.ceil(sizeInMb.value),
423
- // boot_order: props.hardDisk.boot_order,
424
- // detach: props.type === 'removed',
425
- // remove: props.type === 'removed' && deleteFilesFromDatastore.value, // Проверяем если удалили диск и указали Delete files from datastore
426
- // })
427
- // },
428
- // { immediate: true }
429
- // )
430
-
431
- // Добавляем данные для редактирования
432
- // watch(
433
- // () => props.hardDisk,
434
- // (newValue) => {
435
- // // TODO refactoring
436
- // if (props.type === 'exist') {
437
- // diskProvisioning.value = newValue.provision_type || 'thick'
438
- // return
439
- // }
440
- // // if (props.type !== 'edit') return
441
- // if (props.type !== 'edit' && props.type !== 'clone') return
442
- //
443
- // const sizeInGb = $binary.mbToGb(newValue.size)
444
- // if (sizeInGb < 1) {
445
- // size.value = newValue.size
446
- // hardDiskType.value = 'mb'
447
- // } else {
448
- // size.value = sizeInGb
449
- // hardDiskType.value = 'gb'
450
- // }
451
- // diskProvisioning.value = newValue.provision_type || 'thick'
452
- // sharing.value = newValue.sharing ? 'yes' : ''
453
- // shares.value = newValue.shares || 0
454
- // // limitIopsType.value = newValue.io === 'native' ? 'unlimited' : 'custom'
455
- // limitIopsType.value = newValue.limit_iops === 0 ? 'unlimited' : 'custom'
456
- // limitIops.value = newValue.limit_iops || 16
457
- // diskMode.value = newValue.disk_mode || 'dependent'
458
- // cache.value = newValue.cache || 'none'
459
- // bus.value = newValue.bus || 'ide'
460
- // readOnly.value = newValue.read_only || false
461
- // discard.value = newValue.discard || ''
462
- // io.value = newValue.io || ''
463
- // target.value = newValue.target || ''
464
- // },
465
- // { immediate: true }
466
- // )
467
- watch(
468
- isRunning,
469
- (newValue) => {
470
- if (newValue && props.type === 'new') {
471
- bus.value = 'virtio'
472
- }
473
- },
474
- { immediate: true }
475
- )
476
-
477
- const hardDiskInvalid = computed<boolean>(() => {
478
- return !!hardDiskTypeErrorLocalText.value || limitIopsInvalid.value
479
- })
480
- watch(
481
- hardDiskInvalid,
482
- (newValue) => {
483
- emits('invalid', newValue)
484
- },
485
- { immediate: true }
486
- )
487
- </script>
488
-
489
- <style scoped lang="scss"></style>
1
+ <template>
2
+ <component
3
+ :is="currentComponent"
4
+ v-model:delete-files-from-datastore="deleteFilesFromDatastore"
5
+ v-model:size="sizeLocal"
6
+ v-model:hard-disk-type="hardDiskType"
7
+ v-model:disk-provisioning="provisionType"
8
+ v-model:sharing="sharingLocal"
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
+ v-model:source="source"
16
+ :is-removable="isRemovable"
17
+ :label="label"
18
+ :hard-disk-invalid="hardDiskInvalid"
19
+ :error-text="hardDiskLocalAndApiErrorsTexts"
20
+ :hard-disk-type-error-local-text="hardDiskTypeErrorLocalText"
21
+ :is-disabled-size="isDisabledSize"
22
+ :is-disabled-provisioning="isDisabledProvisioning"
23
+ :is-disabled-sharing="isDisabledSharing"
24
+ :is-disabled-limit-iops="isDisabledLimitIops"
25
+ :is-disabled-mode="isDisabledMode"
26
+ :is-disabled-cache="isDisabledCache"
27
+ :is-disabled-bus="isDisabledBus"
28
+ :hard-disk-type-options="hardDiskTypeOptions"
29
+ :max-hard-disk="maxHardDisk"
30
+ :location="location"
31
+ :is-running="isRunning"
32
+ :is-new-hard-disk="isNewHardDisk"
33
+ :is-edit="props.isEdit"
34
+ :datastore="props.datastore"
35
+ :is-datastore-loading="props.isDatastoreLoading"
36
+ :get-datastore-table-func="props.getDatastoreTableFunc"
37
+ :error-validation-fields="props.errorValidationFields"
38
+ :index="props.index"
39
+ :type="props.type"
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
+ </template>
49
+
50
+ <script setup lang="ts">
51
+ import type { UI_I_DatastoreTableItem } from '~/lib/models/store/storage/interfaces'
52
+ // import type {
53
+ // UI_I_SendDataNewHardDisk,
54
+ // UI_I_SendDataNewHardDiskStorage,
55
+ // } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
56
+ import type { UI_T_HardDiskType } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/types'
57
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
58
+ import type { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
59
+ import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
60
+ import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
61
+ import type { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
62
+ import { binaryOptionsFunc } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/config/binaryOptions'
63
+
64
+ const size = defineModel<number>('size', { required: true })
65
+ const initialSize = size.value
66
+ // const provisionType = ref<string>('thick')
67
+ const provisionType = defineModel<string>('provisionType', { required: true })
68
+ // const sharing = ref<string>('')
69
+ const sharing = defineModel<boolean>('sharing', { required: true })
70
+ // const sharingLocal = ref<string>(sharing.value ? 'yes' : '')
71
+ const sharingLocal = computed<string>({
72
+ set(newValue) {
73
+ sharing.value = newValue === 'yes'
74
+ },
75
+ get() {
76
+ return sharing.value ? 'yes' : ''
77
+ },
78
+ })
79
+ // const shares = ref<number>(0)
80
+ const shares = defineModel<number>('shares', { required: true })
81
+
82
+ // const limitIops = ref<number>(16)
83
+ const limitIops = defineModel<number>('limitIops', { required: true })
84
+ const limitIopsType = ref<string>('unlimited') // ??
85
+ const limitIopsInvalid = ref<boolean>(false) // ??
86
+
87
+ // const diskMode = ref<string>('dependent')
88
+ const diskMode = defineModel<string>('diskMode', { required: true })
89
+
90
+ // const cache = ref<string>('none')
91
+ const cache = defineModel<string>('cache', { required: true })
92
+
93
+ // const bus = ref<string>('ide')
94
+ const bus = defineModel<string>('bus', { required: true })
95
+
96
+ // const readOnly = ref<boolean>(false)
97
+ const readOnly = defineModel<boolean>('readOnly', { required: true })
98
+
99
+ // const discard = ref<string>('')
100
+ const discard = defineModel<string>('discard', { required: true })
101
+
102
+ // const io = ref<string>('')
103
+ const io = defineModel<string>('io', { required: true })
104
+
105
+ // const target = ref<string>('')
106
+ const target = defineModel<string>('target', { required: true })
107
+
108
+ const source = defineModel<string>('source', { required: true })
109
+
110
+ const storage = defineModel<any>('storage', { required: true })
111
+
112
+ const remove = defineModel<boolean>('remove', { required: true })
113
+ const detach = defineModel<boolean>('detach', { required: true })
114
+
115
+ const props = withDefaults(
116
+ defineProps<{
117
+ mainStorage: UI_I_DatastoreTableItem | null
118
+ mainStorageFree: number
119
+ // hardDisk: UI_I_SendDataNewHardDisk
120
+ type: UI_T_HardDiskType
121
+ index: number
122
+ errorValidationFields: UI_I_ErrorValidationField[]
123
+ getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
124
+ datastore: UI_I_DatastoreTableItem[]
125
+ isDatastoreLoading: boolean
126
+ isEdit: boolean
127
+ state?: string | number
128
+ guestMachineType?: UI_I_OptionItem | null
129
+ computeResource?: UI_I_TreeNode | null
130
+ }>(),
131
+ {
132
+ state: undefined,
133
+ guestMachineType: undefined,
134
+ computeResource: undefined,
135
+ }
136
+ )
137
+ const emits = defineEmits<{
138
+ // (event: 'send-data', value: UI_I_SendDataNewHardDisk): void
139
+ (event: 'invalid', value: boolean): void
140
+ (event: 'remove'): void
141
+ (event: 'roll-back'): void
142
+ (event: 'remove-error-by-title', value: string): void
143
+ }>()
144
+
145
+ watch(
146
+ () => props.type,
147
+ (newValue) => {
148
+ detach.value = newValue === 'removed'
149
+ }
150
+ )
151
+
152
+ const { $store, $binary }: any = useNuxtApp()
153
+ const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
154
+ const currentComponent = computed(() =>
155
+ isNewView.value
156
+ ? defineAsyncComponent(() => import('./New.vue'))
157
+ : defineAsyncComponent(() => import('./Old.vue'))
158
+ )
159
+
160
+ const localization = computed<UI_I_Localization>(() => useLocal())
161
+
162
+ const isRunning = computed<boolean>(() => {
163
+ return props.state === 2
164
+ })
165
+
166
+ const isRemovable = computed<boolean>(() => {
167
+ return (
168
+ !props.isEdit ||
169
+ !isRunning.value ||
170
+ (isRunning.value && bus.value === 'virtio')
171
+ )
172
+ })
173
+
174
+ const typeError = computed<string>(() => `disk_devices[${props.index}].size`)
175
+
176
+ const apiErrorLocal = computed<string>(() => {
177
+ return (
178
+ props.errorValidationFields?.find(
179
+ (message) => message.field === typeError.value
180
+ )?.error_message || ''
181
+ )
182
+ })
183
+
184
+ // PC-1796
185
+ // const isNotNewHardDisk = computed<boolean>(
186
+ // () => props.type === 'edit' || props.type === 'removed'
187
+ // )
188
+ const isNewHardDisk = computed<boolean>(
189
+ () => props.type !== 'edit' && props.type !== 'removed'
190
+ )
191
+ const label = computed<string>(() => {
192
+ // if (props.type === 'edit' || props.type === 'removed')
193
+ if (!isNewHardDisk.value)
194
+ return `${localization.value.common.hardDisk} ${props.index + 1}`
195
+
196
+ return `${localization.value.common.newHardDisk} *`
197
+ })
198
+
199
+ const maxHardDisk = computed<number>(() => {
200
+ // // const hardDiskSizeMb = $binary.gbToMb(props.hardDisk.size)
201
+ //
202
+ // if (props.type === 'exist') return initialSize
203
+ //
204
+ // if (!storageLocal.value) return 0
205
+ // const free = (storageLocal.value.capacity.free_mb ||
206
+ // storageLocal.value.free) as number // TODO fix
207
+ //
208
+ // if (props.type === 'edit') return free + initialSize
209
+ //
210
+ // return free
211
+ if (props.type === 'exist') return initialSize
212
+
213
+ if (!storageLocal.value) return 0
214
+
215
+ return props.mainStorageFree + size.value
216
+ })
217
+ const hardDiskTypeErrorLocalText = computed<string>(() => {
218
+ if (size.value > maxHardDisk.value) {
219
+ return localization.value.common.diskCapacitySpecifiedGreater
220
+ }
221
+
222
+ if (size.value <= 0) {
223
+ return localization.value.common.diskCapacityCannotZero
224
+ }
225
+
226
+ return ''
227
+ })
228
+
229
+ const hardDiskLocalAndApiErrorsTexts = computed<string>(() => {
230
+ const localError = hardDiskTypeErrorLocalText.value
231
+ const apiError = apiErrorLocal.value
232
+
233
+ let result = ''
234
+ if (localError && !apiError) result = localError
235
+ if (!localError && apiError) result = apiError
236
+ if (localError && apiError) result = localError + ', ' + apiError
237
+ if (!localError && apiError) result = apiError
238
+
239
+ return result
240
+ })
241
+
242
+ const deleteFilesFromDatastore = ref<boolean>(false)
243
+ watch(deleteFilesFromDatastore, (newValue) => {
244
+ remove.value = props.type === 'removed' && newValue
245
+ })
246
+
247
+ const hardDiskType = ref<string>(size.value < 1024 ? 'mb' : 'gb')
248
+ watch(hardDiskType, (newValue) => {
249
+ size.value = $binary.universalFromTo(sizeLocal.value, newValue, 'mb')
250
+ })
251
+ const hardDiskTypeOptions = ref<UI_I_OptionItem[]>(
252
+ binaryOptionsFunc(localization.value)
253
+ )
254
+
255
+ const sizeLocal = ref<number>(
256
+ size.value < 1024 ? size.value : $binary.mbToGb(size.value)
257
+ )
258
+ watch(sizeLocal, (newValue) => {
259
+ if (hardDiskType.value === 'mb') {
260
+ size.value = newValue
261
+ }
262
+
263
+ size.value = $binary.universalFromTo(newValue, hardDiskType.value, 'mb')
264
+ })
265
+ // const sizeInMb = computed<number>(() => {
266
+ // if (hardDiskType.value === 'mb') {
267
+ // return size.value
268
+ // }
269
+ //
270
+ // return $binary.universalFromTo(size.value, hardDiskType.value, 'mb')
271
+ // })
272
+ const onValidateSize = (): void => {
273
+ if (props.type !== 'edit') return
274
+ if (size.value < initialSize) {
275
+ sizeLocal.value = $binary.universalFromTo(
276
+ initialSize,
277
+ 'mb',
278
+ hardDiskType.value
279
+ )
280
+ }
281
+ }
282
+
283
+ const isDisabledSize = computed<boolean>(() => {
284
+ if (isNewHardDisk.value) return false
285
+ return (
286
+ props.type === 'exist' ||
287
+ (props.type === 'edit' && readOnly.value)
288
+ // (isRunning.value && provisionType.value === 'thick')
289
+ )
290
+ })
291
+ const isDisabledProvisioning = computed<boolean>(() => {
292
+ if (isNewHardDisk.value) return false
293
+ return props.isEdit || isRunning.value
294
+ })
295
+ const isDisabledSharing = computed<boolean>(() => {
296
+ return isRunning.value && !isNewHardDisk.value
297
+ })
298
+ const isDisabledLimitIops = computed<boolean>(() => {
299
+ return isRunning.value && !isNewHardDisk.value
300
+ })
301
+ const isDisabledMode = computed<boolean>(() => {
302
+ return isRunning.value && !isNewHardDisk.value
303
+ })
304
+ const isDisabledCache = computed<boolean>(() => {
305
+ if (isNewHardDisk.value) return false
306
+ return props.isEdit || isRunning.value
307
+ })
308
+ const isDisabledBus = computed<boolean>(() => {
309
+ return !isNewHardDisk.value && isRunning.value
310
+ })
311
+
312
+ const location = ref<UI_I_DatastoreTableItem | null>(props.mainStorage || null)
313
+ const storageLocal = ref<UI_I_DatastoreTableItem | null>(props.mainStorage)
314
+ watch(
315
+ () => props.mainStorage,
316
+ (newValue) => {
317
+ location.value = newValue
318
+ storageLocal.value = newValue
319
+
320
+ storage.value = {
321
+ id: newValue?.id || '',
322
+ name: newValue?.name || '',
323
+ type: newValue?.type_text || '',
324
+ pool: newValue?.pool_name || '',
325
+ user: '',
326
+ endpoint: '',
327
+ password: '',
328
+ protocol: '',
329
+ options: '',
330
+ }
331
+ },
332
+ {
333
+ immediate: true,
334
+ deep: true,
335
+ }
336
+ )
337
+ const onChangeStorage = (item: UI_I_DatastoreTableItem): void => {
338
+ storageLocal.value = item
339
+
340
+ storage.value = {
341
+ id: item?.id || '',
342
+ name: item?.name || '',
343
+ type: item?.type_text || '',
344
+ pool: item?.pool_name || '',
345
+ user: '',
346
+ endpoint: '',
347
+ password: '',
348
+ protocol: '',
349
+ options: '',
350
+ }
351
+ }
352
+
353
+ // const diskProvisioning = ref<string>('thick')
354
+ // const sharing = ref<string>('')
355
+ // const shares = ref<number>(0)
356
+ //
357
+ // const limitIops = ref<number>(16)
358
+ // const limitIopsType = ref<string>('unlimited')
359
+ // const limitIopsInvalid = ref<boolean>(false)
360
+ //
361
+ // const diskMode = ref<string>('dependent')
362
+ //
363
+ // const cache = ref<string>('none')
364
+ //
365
+ // const bus = ref<string>('ide')
366
+ //
367
+ // const readOnly = ref<boolean>(false)
368
+ //
369
+ // const discard = ref<string>('')
370
+ //
371
+ // const io = ref<string>('')
372
+ //
373
+ // const target = ref<string>('')
374
+
375
+ // watch(
376
+ // [
377
+ // sizeInMb,
378
+ // storage,
379
+ // diskProvisioning,
380
+ // sharing,
381
+ // limitIops,
382
+ // limitIopsType,
383
+ // diskMode,
384
+ // cache,
385
+ // bus,
386
+ // deleteFilesFromDatastore,
387
+ // (): void => props.type,
388
+ // ],
389
+ // () => {
390
+ // const limitIopsLocal =
391
+ // limitIopsType.value === 'unlimited' ? 0 : limitIops.value
392
+ // const storageLocal: UI_I_SendDataNewHardDiskStorage = {
393
+ // id: storage.value?.id || '',
394
+ // name: storage.value?.name || '',
395
+ // type: storage.value?.type_text || '',
396
+ // pool: storage.value?.pool_name || '',
397
+ // user: '',
398
+ // endpoint: '',
399
+ // password: '',
400
+ // protocol: '',
401
+ // options: '',
402
+ // }
403
+ //
404
+ // emits('send-data', {
405
+ // create: props.hardDisk.create,
406
+ // attach: props.hardDisk.attach,
407
+ // source: props.hardDisk.source,
408
+ // size: Math.ceil(sizeInMb.value),
409
+ // bus: bus.value,
410
+ // target: target.value,
411
+ // storage: storageLocal,
412
+ // device_type: 'disk',
413
+ // provision_type: diskProvisioning.value,
414
+ // disk_mode: diskMode.value,
415
+ // sharing: sharing.value === 'yes',
416
+ // read_only: readOnly.value,
417
+ // shares: shares.value,
418
+ // cache: cache.value,
419
+ // io: io.value,
420
+ // limit_iops: limitIopsLocal,
421
+ // discard: discard.value,
422
+ // capacity: Math.ceil(sizeInMb.value),
423
+ // boot_order: props.hardDisk.boot_order,
424
+ // detach: props.type === 'removed',
425
+ // remove: props.type === 'removed' && deleteFilesFromDatastore.value, // Проверяем если удалили диск и указали Delete files from datastore
426
+ // })
427
+ // },
428
+ // { immediate: true }
429
+ // )
430
+
431
+ // Добавляем данные для редактирования
432
+ // watch(
433
+ // () => props.hardDisk,
434
+ // (newValue) => {
435
+ // // TODO refactoring
436
+ // if (props.type === 'exist') {
437
+ // diskProvisioning.value = newValue.provision_type || 'thick'
438
+ // return
439
+ // }
440
+ // // if (props.type !== 'edit') return
441
+ // if (props.type !== 'edit' && props.type !== 'clone') return
442
+ //
443
+ // const sizeInGb = $binary.mbToGb(newValue.size)
444
+ // if (sizeInGb < 1) {
445
+ // size.value = newValue.size
446
+ // hardDiskType.value = 'mb'
447
+ // } else {
448
+ // size.value = sizeInGb
449
+ // hardDiskType.value = 'gb'
450
+ // }
451
+ // diskProvisioning.value = newValue.provision_type || 'thick'
452
+ // sharing.value = newValue.sharing ? 'yes' : ''
453
+ // shares.value = newValue.shares || 0
454
+ // // limitIopsType.value = newValue.io === 'native' ? 'unlimited' : 'custom'
455
+ // limitIopsType.value = newValue.limit_iops === 0 ? 'unlimited' : 'custom'
456
+ // limitIops.value = newValue.limit_iops || 16
457
+ // diskMode.value = newValue.disk_mode || 'dependent'
458
+ // cache.value = newValue.cache || 'none'
459
+ // bus.value = newValue.bus || 'ide'
460
+ // readOnly.value = newValue.read_only || false
461
+ // discard.value = newValue.discard || ''
462
+ // io.value = newValue.io || ''
463
+ // target.value = newValue.target || ''
464
+ // },
465
+ // { immediate: true }
466
+ // )
467
+ watch(
468
+ isRunning,
469
+ (newValue) => {
470
+ if (newValue && props.type === 'new') {
471
+ bus.value = 'virtio'
472
+ }
473
+ },
474
+ { immediate: true }
475
+ )
476
+
477
+ const hardDiskInvalid = computed<boolean>(() => {
478
+ return !!hardDiskTypeErrorLocalText.value || limitIopsInvalid.value
479
+ })
480
+ watch(
481
+ hardDiskInvalid,
482
+ (newValue) => {
483
+ emits('invalid', newValue)
484
+ },
485
+ { immediate: true }
486
+ )
487
+ </script>
488
+
489
+ <style scoped lang="scss"></style>