bfg-common 1.5.332 → 1.5.333

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 (38) hide show
  1. package/assets/localization/local_be.json +5 -2
  2. package/assets/localization/local_en.json +3269 -3266
  3. package/assets/localization/local_hy.json +5 -2
  4. package/assets/localization/local_kk.json +5 -2
  5. package/assets/localization/local_ru.json +8 -5
  6. package/assets/localization/local_zh.json +3266 -3263
  7. package/components/common/pages/home/widgets/WidgetsNew.vue +21 -19
  8. package/components/common/pages/home/widgets/WidgetsOld.vue +9 -7
  9. package/components/common/select/radio/RadioGroup.vue +11 -4
  10. package/components/common/select/radio/lib/models/interfaces.ts +1 -0
  11. package/components/common/vm/actions/add/New.vue +6 -1
  12. package/components/common/vm/actions/add/Old.vue +4 -1
  13. package/components/common/vm/actions/add/lib/config/steps.ts +22 -10
  14. package/components/common/vm/actions/common/customizeHardware/CustomizeHardware.vue +3 -0
  15. package/components/common/vm/actions/common/customizeHardware/CustomizeHardwareNew.vue +2 -0
  16. package/components/common/vm/actions/common/customizeHardware/CustomizeHardwareOld.vue +2 -0
  17. package/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/config/dropdownItems.ts +36 -34
  18. package/components/common/vm/actions/common/customizeHardware/vmoptions/Vmoptions.vue +3 -0
  19. package/components/common/vm/actions/common/customizeHardware/vmoptions/VmoptionsNew.vue +2 -0
  20. package/components/common/vm/actions/common/customizeHardware/vmoptions/VmoptionsOld.vue +2 -0
  21. package/components/common/vm/actions/common/customizeHardware/vmoptions/generalOptions/GeneralOptions.vue +12 -0
  22. package/components/common/vm/actions/common/customizeHardware/vmoptions/generalOptions/GeneralOptionsNew.vue +2 -1
  23. package/components/common/vm/actions/common/customizeHardware/vmoptions/generalOptions/GeneralOptionsOld.vue +4 -3
  24. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/New.vue +8 -6
  25. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/Old.vue +8 -6
  26. package/components/common/vm/actions/common/customizeHardware/vmoptions/tools/ToolsNew.vue +2 -0
  27. package/components/common/vm/actions/common/customizeHardware/vmoptions/tools/ToolsOld.vue +2 -1
  28. package/components/common/vm/actions/common/select/name/New.vue +13 -11
  29. package/components/common/vm/actions/common/select/options/Options.vue +6 -1
  30. package/components/common/vm/actions/editSettings/EditSettings.vue +3 -0
  31. package/components/common/vm/actions/editSettings/EditSettingsOld.vue +2 -0
  32. package/components/common/vm/actions/editSettings/new/New.vue +2 -0
  33. package/components/common/vmt/actions/add/Add.vue +542 -542
  34. package/components/common/vmt/actions/add/New.vue +345 -346
  35. package/components/common/vmt/actions/add/Old.vue +301 -301
  36. package/components/common/vmt/actions/add/lib/config/steps.ts +107 -107
  37. package/components/common/wizards/vm/migrate/select/type/lib/config/typeOptions.ts +16 -14
  38. package/package.json +1 -1
@@ -1,542 +1,542 @@
1
- <template>
2
- <common-vmt-actions-add-new
3
- v-if="isNewView"
4
- v-model:vmt-form="vmtForm"
5
- :title="title"
6
- :alert-messages="alertMessages"
7
- :wizard="wizard"
8
- :dynamic-steps="dynamicSteps"
9
- :new-task-form="newTaskForm"
10
- :selected-scheme="selectedScheme"
11
- :name-form-submit="nameFormSubmit"
12
- :storage-submit="storageSubmit"
13
- :customize-hardware-submit="customizeHardwareSubmit"
14
- :is-loading="isLoading"
15
- :selected-nav-item="selectedNavItem"
16
- :machine-types="machineTypes"
17
- :cpu-models="cpuModels"
18
- :max-memory="maxMemory"
19
- :max-cpus="maxCpus"
20
- :guest-os-versions="guestOsVersions"
21
- :virtual-hardware-cd-dvd-drives-local="virtualHardwareCdDvdDrivesLocal"
22
- :virtual-hardware-networks-local="virtualHardwareNetworksLocal"
23
- :virtual-hardware-hard-disks-local="virtualHardwareHardDisksLocal"
24
- :guest-os-families="guestOsFamilies"
25
- :project="props.project"
26
- :nodes="props.nodes"
27
- :files="props.files"
28
- :networks-table="props.networksTable"
29
- :datastore="props.datastore"
30
- :is-datastore-loading="props.isDatastoreLoading"
31
- :error-validation-fields="props.errorValidationFields"
32
- :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
33
- :get-datastore-table-func="props.getDatastoreTableFunc"
34
- :passthrough-devices="props.passthroughDevices"
35
- :mediated-devices="props.mediatedDevices"
36
- :ready-complete-table-info="props.readyCompleteTableInfo"
37
- @remove-error-by-title="emits('remove-error-by-title', $event)"
38
- @get-storage="emits('get-storage', $event)"
39
- @change-steps="onChangeSteps"
40
- @check-name="emits('check-name', $event)"
41
- @get-pci-devices="emits('get-pci-devices')"
42
- @change-storage="onChangeStorage"
43
- @change-boot-order="onChangeBootOrder"
44
- @change-customize-hardware="onChangeCustomizeHardware"
45
- @get-folders-or-files="emits('get-folders-or-files', $event)"
46
- @get-active-device-child="emits('get-active-device-child', $event)"
47
- @show-datastore-child="emits('show-datastore-child', $event)"
48
- @get-networks-table="emits('get-networks-table', $event)"
49
- @change-name="onChangeName"
50
- @hide="emits('hide')"
51
- @finish="onFinish"
52
- />
53
- <common-vmt-actions-add-old
54
- v-else
55
- v-model:vmt-form="vmtForm"
56
- :title="title"
57
- :wizard="wizard"
58
- :dynamic-steps="dynamicSteps"
59
- :new-task-form="newTaskForm"
60
- :selected-scheme="selectedScheme"
61
- :name-form-submit="nameFormSubmit"
62
- :storage-submit="storageSubmit"
63
- :customize-hardware-submit="customizeHardwareSubmit"
64
- :is-loading="isLoading"
65
- :selected-nav-item="selectedNavItem"
66
- :virtual-hardware-cd-dvd-drives-local="virtualHardwareCdDvdDrivesLocal"
67
- :virtual-hardware-networks-local="virtualHardwareNetworksLocal"
68
- :virtual-hardware-hard-disks-local="virtualHardwareHardDisksLocal"
69
- :max-memory="maxMemory"
70
- :max-cpus="maxCpus"
71
- :machine-types="machineTypes"
72
- :cpu-models="cpuModels"
73
- :guest-os-versions="guestOsVersions"
74
- :guest-os-families="guestOsFamilies"
75
- :project="props.project"
76
- :nodes="props.nodes"
77
- :files="props.files"
78
- :networks-table="props.networksTable"
79
- :datastore="props.datastore"
80
- :is-datastore-loading="props.isDatastoreLoading"
81
- :error-validation-fields="props.errorValidationFields"
82
- :ready-complete-table-info="props.readyCompleteTableInfo"
83
- :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
84
- :get-datastore-table-func="props.getDatastoreTableFunc"
85
- :passthrough-devices="props.passthroughDevices"
86
- :mediated-devices="props.mediatedDevices"
87
- @change-steps="onChangeSteps"
88
- @check-name="emits('check-name', $event)"
89
- @get-storage="emits('get-storage', $event)"
90
- @get-folders-or-files="emits('get-folders-or-files', $event)"
91
- @get-active-device-child="emits('get-active-device-child', $event)"
92
- @show-datastore-child="emits('show-datastore-child', $event)"
93
- @remove-error-by-title="emits('remove-error-by-title', $event)"
94
- @get-networks-table="emits('get-networks-table', $event)"
95
- @change-boot-order="onChangeBootOrder"
96
- @change-customize-hardware="onChangeCustomizeHardware"
97
- @get-pci-devices="emits('get-pci-devices')"
98
- @change-storage="onChangeStorage"
99
- @change-name="onChangeName"
100
- @hide="emits('hide')"
101
- @finish="onFinish"
102
- />
103
- </template>
104
-
105
- <script setup lang="ts">
106
- import type {
107
- UI_I_ArbitraryObject,
108
- UI_I_Localization,
109
- } from '~/lib/models/interfaces'
110
- import type {
111
- UI_I_ValidationReturn,
112
- UI_I_WizardStep,
113
- } from '~/components/atoms/wizard/lib/models/interfaces'
114
- import type { UI_I_VmtForm } from '~/components/common/vmt/actions/add/lib/models/interfaces'
115
- import type {
116
- UI_I_SendDataCpu,
117
- UI_I_SendDataMemory,
118
- UI_I_SendDataNewCdDvdDrive,
119
- UI_I_SendDataNewHardDisk,
120
- UI_I_SendDataNewNetwork,
121
- } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
122
- import type {
123
- API_UI_I_Error,
124
- UI_I_ErrorValidationField,
125
- } from '~/lib/models/store/interfaces'
126
- import type { UI_I_SendDataCustomizeHardware } from '~/components/common/vm/actions/common/customizeHardware/lib/models/interfaces'
127
- import type { UI_I_ScheduleNewTasksForm } from '~/components/common/pages/scheduledTasks/modals/lib/models/interfaces'
128
- import type { UI_T_SelectedNavItem } from '~/components/common/vm/actions/common/lib/models/types'
129
- import type { UI_T_ChangeBootOrder } from '~/components/common/vm/actions/lib/models/types'
130
- import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
131
- import type { UI_T_Project } from '~/lib/models/types'
132
- import type { UI_I_FileTreeNode } from '~/components/lib/models/interfaces'
133
- import type { UI_I_NetworkTableItem } from '~/lib/models/store/network/interfaces'
134
- import type {
135
- UI_I_DatastoreTableItem,
136
- UI_I_FolderOrFileTreePayload,
137
- } from '~/lib/models/store/storage/interfaces'
138
- import type { UI_I_TableInfoItem } from '~/components/atoms/table/info/lib/models/interfaces'
139
- import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
140
- import type {
141
- UI_I_MediatedDevice,
142
- UI_I_PciDevice,
143
- } from '~/lib/models/store/vm/interfaces'
144
- import type { UI_I_Capabilities } from '~/components/common/vm/actions/common/lib/models/interfaces'
145
- import Wizard from '~/components/atoms/wizard/lib/utils/utils'
146
- import { mapCapabilities } from '~/components/common/vm/actions/common/lib/utils/capabilities'
147
- import {
148
- dynamicSteps,
149
- stepsSchemeInitial,
150
- stepsFunc,
151
- } from '~/components/common/vmt/actions/add/lib/config/steps'
152
- import { scheduledTaskDefaultFormFunc } from '~/components/common/pages/scheduledTasks/modals/lib/config/createScheduledTask'
153
- import { capabilities } from '~/components/common/vm/actions/common/lib/config/capabilities'
154
-
155
- const props = defineProps<{
156
- project: UI_T_Project
157
- nodes: UI_I_FileTreeNode[]
158
- files: UI_I_FileTreeNode[]
159
- networksTable: UI_I_NetworkTableItem[]
160
- datastore: UI_I_DatastoreTableItem[]
161
- isDatastoreLoading: boolean
162
- errorValidationFields: UI_I_ErrorValidationField[]
163
- readyCompleteTableInfo: UI_I_TableInfoItem[]
164
- vmCpuHelpTextSecond: string
165
- finishFunc: any
166
- getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
167
- validateSendDataFunc: any
168
- passthroughDevices: UI_I_PciDevice[]
169
- mediatedDevices: UI_I_MediatedDevice[]
170
- vmtNameInWizard: string
171
- capabilities?: UI_I_Capabilities
172
- schedulerTask?: any // TODO надо interface переместить глобално
173
- }>()
174
-
175
- const emits = defineEmits<{
176
- (event: 'check-name', value: [string, (error: API_UI_I_Error) => void]): void
177
- (event: 'get-storage', value: UI_I_TablePayload): void
178
- (event: 'get-folders-or-files', value: UI_I_FolderOrFileTreePayload): void
179
- (event: 'get-active-device-child', value: UI_I_FileTreeNode): void
180
- (event: 'show-datastore-child', value: UI_I_FileTreeNode): void
181
- (event: 'remove-error-by-title', value: string): void
182
- (event: 'get-networks-table', value: UI_I_TablePayload): void
183
- (event: 'get-pci-devices'): void
184
- (event: 'hide'): void
185
- }>()
186
-
187
- const { $store }: any = useNuxtApp()
188
-
189
- const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
190
-
191
- const localization = computed<UI_I_Localization>(() => useLocal())
192
-
193
- const isScheduledTasks = computed<boolean>(
194
- () => props.schedulerTask?.isSchedulerTask
195
- )
196
-
197
- const wizard: Wizard = new Wizard(
198
- stepsFunc(localization.value, isScheduledTasks.value),
199
- stepsSchemeInitial
200
- )
201
-
202
- const selectedScheme = computed<number[]>(() => wizard.selectedScheme.value)
203
- const alertMessages = computed<string[][]>(() => wizard.alertMessages.value)
204
-
205
- const nameFormSubmit = ref<Function | null>(null)
206
- const storageSubmit = ref<Function | null>(null)
207
- const selectOptionsSubmit = ref<number>(0)
208
- const customizeHardwareSubmit = ref<Function | null>(null)
209
-
210
- const checkName = async (
211
- value: UI_I_WizardStep[]
212
- ): Promise<UI_I_ValidationReturn> => {
213
- let stepHasError = false
214
-
215
- return new Promise((resolve) => {
216
- nameFormSubmit.value = (isValid: boolean) => {
217
- if (!isValid) {
218
- stepHasError = wizard.setValidation(dynamicSteps.selectName, 'name', {
219
- fieldMessage: 'aaa',
220
- alertMessage: 'aaa',
221
- })
222
- } else if (wizard.hasMessage(dynamicSteps.selectName, 'name')) {
223
- value = wizard.removeValidation(dynamicSteps.selectName, 'name', value)
224
- }
225
-
226
- resolve({
227
- stepHasError,
228
- newValue: value,
229
- })
230
- nameFormSubmit.value = null
231
- }
232
- })
233
- }
234
- const checkStorage = async (
235
- value: UI_I_WizardStep[]
236
- ): Promise<UI_I_ValidationReturn> => {
237
- let stepHasError = false
238
-
239
- return new Promise((resolve) => {
240
- storageSubmit.value = (isValid: boolean) => {
241
- if (!isValid) {
242
- stepHasError = wizard.setValidation(
243
- dynamicSteps.selectStorage,
244
- 'storage',
245
- {
246
- fieldMessage: 'aaa',
247
- alertMessage: 'aaa',
248
- }
249
- )
250
- } else if (wizard.hasMessage(dynamicSteps.selectStorage, 'storage')) {
251
- value = wizard.removeValidation(
252
- dynamicSteps.selectStorage,
253
- 'storage',
254
- value
255
- )
256
- }
257
-
258
- resolve({
259
- stepHasError,
260
- newValue: value,
261
- })
262
- storageSubmit.value = null
263
- }
264
- })
265
- }
266
- const checkCustomizeHardware = async (
267
- value: UI_I_WizardStep[]
268
- ): Promise<UI_I_ValidationReturn> => {
269
- let stepHasError = false
270
-
271
- return new Promise((resolve) => {
272
- customizeHardwareSubmit.value = (isValid: boolean) => {
273
- if (!isValid) {
274
- stepHasError = wizard.setValidation(
275
- dynamicSteps.customizeHardware,
276
- 'customizeHardware',
277
- {
278
- fieldMessage: 'aaa',
279
- alertMessage: 'aaa',
280
- }
281
- )
282
- } else if (
283
- wizard.hasMessage(dynamicSteps.customizeHardware, 'customizeHardware')
284
- ) {
285
- value = wizard.removeValidation(
286
- dynamicSteps.customizeHardware,
287
- 'customizeHardware',
288
- value
289
- )
290
- }
291
-
292
- resolve({
293
- stepHasError,
294
- newValue: value,
295
- })
296
- storageSubmit.value = null
297
- }
298
- })
299
- }
300
- const validationFunc = async (
301
- value: UI_I_WizardStep[],
302
- currentStep: UI_I_WizardStep,
303
- nextStep: UI_I_WizardStep
304
- ): Promise<UI_I_ValidationReturn> => {
305
- let stepHasError = false
306
- let stepShouldStop = {
307
- ifOnCurrentStep: false,
308
- ifFromAnyStep: false,
309
- stoppageStepId: -1,
310
- }
311
-
312
- wizard.setLoader(true)
313
- if (
314
- wizard.isValidateForStep(
315
- dynamicSteps.selectName,
316
- currentStep.id,
317
- nextStep.id
318
- )
319
- ) {
320
- const nameValidation = await checkName(value)
321
-
322
- value = nameValidation.newValue
323
- stepHasError = stepHasError || nameValidation.stepHasError
324
- } else if (
325
- wizard.isValidateForStep(
326
- dynamicSteps.selectStorage,
327
- currentStep.id,
328
- nextStep.id
329
- )
330
- ) {
331
- const storageValidation = await checkStorage(value)
332
-
333
- value = storageValidation.newValue
334
-
335
- stepHasError = stepHasError || storageValidation.stepHasError
336
- } else if (
337
- wizard.isValidateForStep(
338
- dynamicSteps.selectOptions,
339
- currentStep.id,
340
- nextStep.id
341
- )
342
- ) {
343
- selectOptionsSubmit.value++
344
- } else if (
345
- wizard.isValidateForStep(
346
- dynamicSteps.customizeHardware,
347
- currentStep.id,
348
- nextStep.id
349
- )
350
- ) {
351
- const customizeHardwareValidation = await checkCustomizeHardware(value)
352
-
353
- value = customizeHardwareValidation.newValue
354
-
355
- stepHasError = stepHasError || customizeHardwareValidation.stepHasError
356
- }
357
- wizard.setLoader(false)
358
-
359
- return {
360
- newValue: value,
361
- stepHasError,
362
- stepShouldStop,
363
- }
364
- }
365
-
366
- const vmtForm = ref<UI_I_VmtForm>({
367
- name: '',
368
- compatibility: '',
369
- guestMachineType: null,
370
- guestOsFamily: null,
371
- guestOsVersion: null,
372
- computeResource: null,
373
- storage: null,
374
- locationPath: '',
375
- // dataCenter: null,
376
- })
377
- const customizeHardware = ref<UI_I_SendDataCustomizeHardware | null>(null)
378
- const virtualHardwareCpu = computed<UI_I_SendDataCpu | null>(
379
- () => customizeHardware.value?.virtualHardware?.cpu || null
380
- )
381
- const virtualHardwareMemory = computed<UI_I_SendDataMemory | null>(
382
- () => customizeHardware.value?.virtualHardware?.memory || null
383
- )
384
- const virtualHardwareNetworks = ref<UI_I_SendDataNewNetwork[] | null>(null)
385
- const virtualHardwareHardDisks = ref<UI_I_SendDataNewHardDisk[] | null>(null)
386
- const virtualHardwareCdDvdDrives = ref<UI_I_SendDataNewCdDvdDrive[] | null>(
387
- null
388
- )
389
- const isPowerOnByDefault = ref<boolean>(true)
390
- const selectedNavItem = ref<UI_T_SelectedNavItem>(0)
391
-
392
- const validateSendData = async (
393
- value: UI_I_WizardStep[]
394
- ): Promise<UI_I_ValidationReturn> => {
395
- wizard.setLoader(true)
396
- let stepHasError = false
397
-
398
- const data = await props.validateSendDataFunc(
399
- vmtForm.value,
400
- virtualHardwareCpu.value,
401
- virtualHardwareMemory.value,
402
- customizeHardware.value,
403
- virtualHardwareNetworks.value,
404
- virtualHardwareHardDisks.value,
405
- virtualHardwareCdDvdDrives.value,
406
- isPowerOnByDefault.value,
407
- localization.value
408
- )
409
-
410
- wizard.setLoader(false)
411
- if (data) {
412
- stepHasError = true
413
- selectedNavItem.value = data[0]
414
- }
415
-
416
- return {
417
- stepHasError,
418
- newValue: value,
419
- }
420
- }
421
-
422
- const onChangeSteps = async (value: UI_I_WizardStep[]): Promise<void> => {
423
- wizard.changeSteps(value, validationFunc, validateSendData)
424
- }
425
-
426
- const title = computed<string>(() => {
427
- const { scheduleNewTasks, scheduleTaskEdit } = localization.value.common
428
-
429
- let result = localization.value.vmt.newTemplate
430
- if (isScheduledTasks.value) {
431
- const schedulerMode = props.schedulerTask.editTask
432
- ? scheduleTaskEdit
433
- : scheduleNewTasks
434
-
435
- result = `${schedulerMode} (${localization.value.vmt.newTemplate})`
436
- }
437
-
438
- return result
439
- })
440
-
441
- // TODO move to common
442
- const newTaskForm = ref<UI_I_ScheduleNewTasksForm>(
443
- useDeepCopy(scheduledTaskDefaultFormFunc())
444
- )
445
- watch(
446
- newTaskForm,
447
- (newValue: UI_I_ScheduleNewTasksForm) => {
448
- if (isScheduledTasks.value) wizard.setDisabledNextButton(newValue.isValid)
449
- },
450
- { immediate: true, deep: true }
451
- )
452
-
453
- const isLoading = ref<boolean>(false)
454
- const onFinish = (): void => {
455
- isLoading.value = true
456
- wizard.setLoader(false)
457
- props
458
- .finishFunc(
459
- vmtForm.value,
460
- virtualHardwareCpu.value,
461
- virtualHardwareMemory.value,
462
- customizeHardware.value,
463
- virtualHardwareNetworks.value,
464
- virtualHardwareHardDisks.value,
465
- virtualHardwareCdDvdDrives.value,
466
- isPowerOnByDefault.value,
467
- localization.value,
468
- false,
469
- newTaskForm.value,
470
- props.schedulerTask
471
- )
472
- .then(() => {
473
- isLoading.value = false
474
- emits('hide')
475
- wizard.setLoader(false)
476
- })
477
- }
478
-
479
- const virtualHardwareCdDvdDrivesLocal = computed<
480
- UI_I_SendDataNewCdDvdDrive[] | null
481
- >(() => customizeHardware.value?.virtualHardware?.cdDvdDrives || null)
482
- const virtualHardwareNetworksLocal = computed<UI_I_SendDataNewNetwork[] | null>(
483
- () => customizeHardware.value?.virtualHardware?.networks || null
484
- )
485
- const virtualHardwareHardDisksLocal = computed<
486
- UI_I_SendDataNewHardDisk[] | null
487
- >(() => customizeHardware.value?.virtualHardware?.hardDisks || null)
488
-
489
- const maxCpus = ref<number>(capabilities.value.maxCpus)
490
- const maxMemory = ref<number>(capabilities.value.maxMemory)
491
- const cpuModels = ref<UI_I_OptionItem[]>(capabilities.value.cpuModels)
492
- const machineTypes = ref<UI_I_OptionItem[]>(capabilities.value.machineTypes)
493
-
494
- const guestOsVersions = ref<UI_I_ArbitraryObject<UI_I_OptionItem[]>>(
495
- capabilities.value.guestOsVersions
496
- )
497
-
498
- const guestOsFamilies = ref<UI_I_OptionItem[]>(
499
- capabilities.value.guestOsFamilies
500
- )
501
-
502
- watch(
503
- () => props.capabilities,
504
- () => {
505
- if (props.capabilities) mapCapabilities(props.capabilities)
506
- },
507
- { deep: true, immediate: true }
508
- )
509
-
510
- const onChangeCustomizeHardware = (
511
- data: UI_I_SendDataCustomizeHardware
512
- ): void => {
513
- customizeHardware.value = data
514
- }
515
-
516
- const storageIdCash = ref<string | null>(null)
517
- const onChangeStorage = (storage: UI_I_DatastoreTableItem | null): void => {
518
- if (!storage) return
519
-
520
- vmtForm.value.storage = storage
521
- storageIdCash.value = storage.id
522
- }
523
-
524
- const onChangeName = (name: string): void => {
525
- vmtForm.value.name = name
526
- }
527
-
528
- const onChangeBootOrder = (data: UI_T_ChangeBootOrder): void => {
529
- virtualHardwareHardDisks.value = data[0]
530
- virtualHardwareCdDvdDrives.value = data[1]
531
- virtualHardwareNetworks.value = data[2]
532
- }
533
-
534
- watch(
535
- () => props.vmtNameInWizard,
536
- (newValue) => {
537
- vmtForm.value.name = newValue
538
- }
539
- )
540
- </script>
541
-
542
- <style scoped lang="scss"></style>
1
+ <template>
2
+ <common-vmt-actions-add-new
3
+ v-if="isNewView"
4
+ v-model:vmt-form="vmtForm"
5
+ :title="title"
6
+ :alert-messages="alertMessages"
7
+ :wizard="wizard"
8
+ :dynamic-steps="dynamicSteps"
9
+ :new-task-form="newTaskForm"
10
+ :selected-scheme="selectedScheme"
11
+ :name-form-submit="nameFormSubmit"
12
+ :storage-submit="storageSubmit"
13
+ :customize-hardware-submit="customizeHardwareSubmit"
14
+ :is-loading="isLoading"
15
+ :selected-nav-item="selectedNavItem"
16
+ :machine-types="machineTypes"
17
+ :cpu-models="cpuModels"
18
+ :max-memory="maxMemory"
19
+ :max-cpus="maxCpus"
20
+ :guest-os-versions="guestOsVersions"
21
+ :virtual-hardware-cd-dvd-drives-local="virtualHardwareCdDvdDrivesLocal"
22
+ :virtual-hardware-networks-local="virtualHardwareNetworksLocal"
23
+ :virtual-hardware-hard-disks-local="virtualHardwareHardDisksLocal"
24
+ :guest-os-families="guestOsFamilies"
25
+ :project="props.project"
26
+ :nodes="props.nodes"
27
+ :files="props.files"
28
+ :networks-table="props.networksTable"
29
+ :datastore="props.datastore"
30
+ :is-datastore-loading="props.isDatastoreLoading"
31
+ :error-validation-fields="props.errorValidationFields"
32
+ :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
33
+ :get-datastore-table-func="props.getDatastoreTableFunc"
34
+ :passthrough-devices="props.passthroughDevices"
35
+ :mediated-devices="props.mediatedDevices"
36
+ :ready-complete-table-info="props.readyCompleteTableInfo"
37
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
38
+ @get-storage="emits('get-storage', $event)"
39
+ @change-steps="onChangeSteps"
40
+ @check-name="emits('check-name', $event)"
41
+ @get-pci-devices="emits('get-pci-devices')"
42
+ @change-storage="onChangeStorage"
43
+ @change-boot-order="onChangeBootOrder"
44
+ @change-customize-hardware="onChangeCustomizeHardware"
45
+ @get-folders-or-files="emits('get-folders-or-files', $event)"
46
+ @get-active-device-child="emits('get-active-device-child', $event)"
47
+ @show-datastore-child="emits('show-datastore-child', $event)"
48
+ @get-networks-table="emits('get-networks-table', $event)"
49
+ @change-name="onChangeName(...$event)"
50
+ @hide="emits('hide')"
51
+ @finish="onFinish"
52
+ />
53
+ <common-vmt-actions-add-old
54
+ v-else
55
+ v-model:vmt-form="vmtForm"
56
+ :title="title"
57
+ :wizard="wizard"
58
+ :dynamic-steps="dynamicSteps"
59
+ :new-task-form="newTaskForm"
60
+ :selected-scheme="selectedScheme"
61
+ :name-form-submit="nameFormSubmit"
62
+ :storage-submit="storageSubmit"
63
+ :customize-hardware-submit="customizeHardwareSubmit"
64
+ :is-loading="isLoading"
65
+ :selected-nav-item="selectedNavItem"
66
+ :virtual-hardware-cd-dvd-drives-local="virtualHardwareCdDvdDrivesLocal"
67
+ :virtual-hardware-networks-local="virtualHardwareNetworksLocal"
68
+ :virtual-hardware-hard-disks-local="virtualHardwareHardDisksLocal"
69
+ :max-memory="maxMemory"
70
+ :max-cpus="maxCpus"
71
+ :machine-types="machineTypes"
72
+ :cpu-models="cpuModels"
73
+ :guest-os-versions="guestOsVersions"
74
+ :guest-os-families="guestOsFamilies"
75
+ :project="props.project"
76
+ :nodes="props.nodes"
77
+ :files="props.files"
78
+ :networks-table="props.networksTable"
79
+ :datastore="props.datastore"
80
+ :is-datastore-loading="props.isDatastoreLoading"
81
+ :error-validation-fields="props.errorValidationFields"
82
+ :ready-complete-table-info="props.readyCompleteTableInfo"
83
+ :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
84
+ :get-datastore-table-func="props.getDatastoreTableFunc"
85
+ :passthrough-devices="props.passthroughDevices"
86
+ :mediated-devices="props.mediatedDevices"
87
+ @change-steps="onChangeSteps"
88
+ @check-name="emits('check-name', $event)"
89
+ @get-storage="emits('get-storage', $event)"
90
+ @get-folders-or-files="emits('get-folders-or-files', $event)"
91
+ @get-active-device-child="emits('get-active-device-child', $event)"
92
+ @show-datastore-child="emits('show-datastore-child', $event)"
93
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
94
+ @get-networks-table="emits('get-networks-table', $event)"
95
+ @change-boot-order="onChangeBootOrder"
96
+ @change-customize-hardware="onChangeCustomizeHardware"
97
+ @get-pci-devices="emits('get-pci-devices')"
98
+ @change-storage="onChangeStorage"
99
+ @change-name="onChangeName"
100
+ @hide="emits('hide')"
101
+ @finish="onFinish"
102
+ />
103
+ </template>
104
+
105
+ <script setup lang="ts">
106
+ import type {
107
+ UI_I_ArbitraryObject,
108
+ UI_I_Localization,
109
+ } from '~/lib/models/interfaces'
110
+ import type {
111
+ UI_I_ValidationReturn,
112
+ UI_I_WizardStep,
113
+ } from '~/components/atoms/wizard/lib/models/interfaces'
114
+ import type { UI_I_VmtForm } from '~/components/common/vmt/actions/add/lib/models/interfaces'
115
+ import type {
116
+ UI_I_SendDataCpu,
117
+ UI_I_SendDataMemory,
118
+ UI_I_SendDataNewCdDvdDrive,
119
+ UI_I_SendDataNewHardDisk,
120
+ UI_I_SendDataNewNetwork,
121
+ } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
122
+ import type {
123
+ API_UI_I_Error,
124
+ UI_I_ErrorValidationField,
125
+ } from '~/lib/models/store/interfaces'
126
+ import type { UI_I_SendDataCustomizeHardware } from '~/components/common/vm/actions/common/customizeHardware/lib/models/interfaces'
127
+ import type { UI_I_ScheduleNewTasksForm } from '~/components/common/pages/scheduledTasks/modals/lib/models/interfaces'
128
+ import type { UI_T_SelectedNavItem } from '~/components/common/vm/actions/common/lib/models/types'
129
+ import type { UI_T_ChangeBootOrder } from '~/components/common/vm/actions/lib/models/types'
130
+ import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
131
+ import type { UI_T_Project } from '~/lib/models/types'
132
+ import type { UI_I_FileTreeNode } from '~/components/lib/models/interfaces'
133
+ import type { UI_I_NetworkTableItem } from '~/lib/models/store/network/interfaces'
134
+ import type {
135
+ UI_I_DatastoreTableItem,
136
+ UI_I_FolderOrFileTreePayload,
137
+ } from '~/lib/models/store/storage/interfaces'
138
+ import type { UI_I_TableInfoItem } from '~/components/atoms/table/info/lib/models/interfaces'
139
+ import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
140
+ import type {
141
+ UI_I_MediatedDevice,
142
+ UI_I_PciDevice,
143
+ } from '~/lib/models/store/vm/interfaces'
144
+ import type { UI_I_Capabilities } from '~/components/common/vm/actions/common/lib/models/interfaces'
145
+ import Wizard from '~/components/atoms/wizard/lib/utils/utils'
146
+ import { mapCapabilities } from '~/components/common/vm/actions/common/lib/utils/capabilities'
147
+ import {
148
+ dynamicSteps,
149
+ stepsSchemeInitial,
150
+ stepsFunc,
151
+ } from '~/components/common/vmt/actions/add/lib/config/steps'
152
+ import { scheduledTaskDefaultFormFunc } from '~/components/common/pages/scheduledTasks/modals/lib/config/createScheduledTask'
153
+ import { capabilities } from '~/components/common/vm/actions/common/lib/config/capabilities'
154
+
155
+ const props = defineProps<{
156
+ project: UI_T_Project
157
+ nodes: UI_I_FileTreeNode[]
158
+ files: UI_I_FileTreeNode[]
159
+ networksTable: UI_I_NetworkTableItem[]
160
+ datastore: UI_I_DatastoreTableItem[]
161
+ isDatastoreLoading: boolean
162
+ errorValidationFields: UI_I_ErrorValidationField[]
163
+ readyCompleteTableInfo: UI_I_TableInfoItem[]
164
+ vmCpuHelpTextSecond: string
165
+ finishFunc: any
166
+ getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
167
+ validateSendDataFunc: any
168
+ passthroughDevices: UI_I_PciDevice[]
169
+ mediatedDevices: UI_I_MediatedDevice[]
170
+ vmtNameInWizard: string
171
+ capabilities?: UI_I_Capabilities
172
+ schedulerTask?: any // TODO надо interface переместить глобално
173
+ }>()
174
+
175
+ const emits = defineEmits<{
176
+ (event: 'check-name', value: [string, (error: API_UI_I_Error) => void]): void
177
+ (event: 'get-storage', value: UI_I_TablePayload): void
178
+ (event: 'get-folders-or-files', value: UI_I_FolderOrFileTreePayload): void
179
+ (event: 'get-active-device-child', value: UI_I_FileTreeNode): void
180
+ (event: 'show-datastore-child', value: UI_I_FileTreeNode): void
181
+ (event: 'remove-error-by-title', value: string): void
182
+ (event: 'get-networks-table', value: UI_I_TablePayload): void
183
+ (event: 'get-pci-devices'): void
184
+ (event: 'hide'): void
185
+ }>()
186
+
187
+ const { $store }: any = useNuxtApp()
188
+
189
+ const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
190
+
191
+ const localization = computed<UI_I_Localization>(() => useLocal())
192
+
193
+ const isScheduledTasks = computed<boolean>(
194
+ () => props.schedulerTask?.isSchedulerTask
195
+ )
196
+
197
+ const wizard: Wizard = new Wizard(
198
+ stepsFunc(localization.value, isScheduledTasks.value),
199
+ stepsSchemeInitial
200
+ )
201
+
202
+ const selectedScheme = computed<number[]>(() => wizard.selectedScheme.value)
203
+ const alertMessages = computed<string[][]>(() => wizard.alertMessages.value)
204
+
205
+ const nameFormSubmit = ref<Function | null>(null)
206
+ const storageSubmit = ref<Function | null>(null)
207
+ const selectOptionsSubmit = ref<number>(0)
208
+ const customizeHardwareSubmit = ref<Function | null>(null)
209
+
210
+ const checkName = async (
211
+ value: UI_I_WizardStep[]
212
+ ): Promise<UI_I_ValidationReturn> => {
213
+ let stepHasError = false
214
+
215
+ return new Promise((resolve) => {
216
+ nameFormSubmit.value = (isValid: boolean) => {
217
+ if (!isValid) {
218
+ stepHasError = wizard.setValidation(dynamicSteps.selectName, 'name', {
219
+ fieldMessage: 'aaa',
220
+ alertMessage: 'aaa',
221
+ })
222
+ } else if (wizard.hasMessage(dynamicSteps.selectName, 'name')) {
223
+ value = wizard.removeValidation(dynamicSteps.selectName, 'name', value)
224
+ }
225
+
226
+ resolve({
227
+ stepHasError,
228
+ newValue: value,
229
+ })
230
+ nameFormSubmit.value = null
231
+ }
232
+ })
233
+ }
234
+ const checkStorage = async (
235
+ value: UI_I_WizardStep[]
236
+ ): Promise<UI_I_ValidationReturn> => {
237
+ let stepHasError = false
238
+
239
+ return new Promise((resolve) => {
240
+ storageSubmit.value = (isValid: boolean) => {
241
+ if (!isValid) {
242
+ stepHasError = wizard.setValidation(
243
+ dynamicSteps.selectStorage,
244
+ 'storage',
245
+ {
246
+ fieldMessage: 'aaa',
247
+ alertMessage: 'aaa',
248
+ }
249
+ )
250
+ } else if (wizard.hasMessage(dynamicSteps.selectStorage, 'storage')) {
251
+ value = wizard.removeValidation(
252
+ dynamicSteps.selectStorage,
253
+ 'storage',
254
+ value
255
+ )
256
+ }
257
+
258
+ resolve({
259
+ stepHasError,
260
+ newValue: value,
261
+ })
262
+ storageSubmit.value = null
263
+ }
264
+ })
265
+ }
266
+ const checkCustomizeHardware = async (
267
+ value: UI_I_WizardStep[]
268
+ ): Promise<UI_I_ValidationReturn> => {
269
+ let stepHasError = false
270
+
271
+ return new Promise((resolve) => {
272
+ customizeHardwareSubmit.value = (isValid: boolean) => {
273
+ if (!isValid) {
274
+ stepHasError = wizard.setValidation(
275
+ dynamicSteps.customizeHardware,
276
+ 'customizeHardware',
277
+ {
278
+ fieldMessage: 'aaa',
279
+ alertMessage: 'aaa',
280
+ }
281
+ )
282
+ } else if (
283
+ wizard.hasMessage(dynamicSteps.customizeHardware, 'customizeHardware')
284
+ ) {
285
+ value = wizard.removeValidation(
286
+ dynamicSteps.customizeHardware,
287
+ 'customizeHardware',
288
+ value
289
+ )
290
+ }
291
+
292
+ resolve({
293
+ stepHasError,
294
+ newValue: value,
295
+ })
296
+ storageSubmit.value = null
297
+ }
298
+ })
299
+ }
300
+ const validationFunc = async (
301
+ value: UI_I_WizardStep[],
302
+ currentStep: UI_I_WizardStep,
303
+ nextStep: UI_I_WizardStep
304
+ ): Promise<UI_I_ValidationReturn> => {
305
+ let stepHasError = false
306
+ let stepShouldStop = {
307
+ ifOnCurrentStep: false,
308
+ ifFromAnyStep: false,
309
+ stoppageStepId: -1,
310
+ }
311
+
312
+ wizard.setLoader(true)
313
+ if (
314
+ wizard.isValidateForStep(
315
+ dynamicSteps.selectName,
316
+ currentStep.id,
317
+ nextStep.id
318
+ )
319
+ ) {
320
+ const nameValidation = await checkName(value)
321
+
322
+ value = nameValidation.newValue
323
+ stepHasError = stepHasError || nameValidation.stepHasError
324
+ } else if (
325
+ wizard.isValidateForStep(
326
+ dynamicSteps.selectStorage,
327
+ currentStep.id,
328
+ nextStep.id
329
+ )
330
+ ) {
331
+ const storageValidation = await checkStorage(value)
332
+
333
+ value = storageValidation.newValue
334
+
335
+ stepHasError = stepHasError || storageValidation.stepHasError
336
+ } else if (
337
+ wizard.isValidateForStep(
338
+ dynamicSteps.selectOptions,
339
+ currentStep.id,
340
+ nextStep.id
341
+ )
342
+ ) {
343
+ selectOptionsSubmit.value++
344
+ } else if (
345
+ wizard.isValidateForStep(
346
+ dynamicSteps.customizeHardware,
347
+ currentStep.id,
348
+ nextStep.id
349
+ )
350
+ ) {
351
+ const customizeHardwareValidation = await checkCustomizeHardware(value)
352
+
353
+ value = customizeHardwareValidation.newValue
354
+
355
+ stepHasError = stepHasError || customizeHardwareValidation.stepHasError
356
+ }
357
+ wizard.setLoader(false)
358
+
359
+ return {
360
+ newValue: value,
361
+ stepHasError,
362
+ stepShouldStop,
363
+ }
364
+ }
365
+
366
+ const vmtForm = ref<UI_I_VmtForm>({
367
+ name: '',
368
+ compatibility: '',
369
+ guestMachineType: null,
370
+ guestOsFamily: null,
371
+ guestOsVersion: null,
372
+ computeResource: null,
373
+ storage: null,
374
+ locationPath: '',
375
+ // dataCenter: null,
376
+ })
377
+ const customizeHardware = ref<UI_I_SendDataCustomizeHardware | null>(null)
378
+ const virtualHardwareCpu = computed<UI_I_SendDataCpu | null>(
379
+ () => customizeHardware.value?.virtualHardware?.cpu || null
380
+ )
381
+ const virtualHardwareMemory = computed<UI_I_SendDataMemory | null>(
382
+ () => customizeHardware.value?.virtualHardware?.memory || null
383
+ )
384
+ const virtualHardwareNetworks = ref<UI_I_SendDataNewNetwork[] | null>(null)
385
+ const virtualHardwareHardDisks = ref<UI_I_SendDataNewHardDisk[] | null>(null)
386
+ const virtualHardwareCdDvdDrives = ref<UI_I_SendDataNewCdDvdDrive[] | null>(
387
+ null
388
+ )
389
+ const isPowerOnByDefault = ref<boolean>(true)
390
+ const selectedNavItem = ref<UI_T_SelectedNavItem>(0)
391
+
392
+ const validateSendData = async (
393
+ value: UI_I_WizardStep[]
394
+ ): Promise<UI_I_ValidationReturn> => {
395
+ wizard.setLoader(true)
396
+ let stepHasError = false
397
+
398
+ const data = await props.validateSendDataFunc(
399
+ vmtForm.value,
400
+ virtualHardwareCpu.value,
401
+ virtualHardwareMemory.value,
402
+ customizeHardware.value,
403
+ virtualHardwareNetworks.value,
404
+ virtualHardwareHardDisks.value,
405
+ virtualHardwareCdDvdDrives.value,
406
+ isPowerOnByDefault.value,
407
+ localization.value
408
+ )
409
+
410
+ wizard.setLoader(false)
411
+ if (data) {
412
+ stepHasError = true
413
+ selectedNavItem.value = data[0]
414
+ }
415
+
416
+ return {
417
+ stepHasError,
418
+ newValue: value,
419
+ }
420
+ }
421
+
422
+ const onChangeSteps = async (value: UI_I_WizardStep[]): Promise<void> => {
423
+ wizard.changeSteps(value, validationFunc, validateSendData)
424
+ }
425
+
426
+ const title = computed<string>(() => {
427
+ const { scheduleNewTasks, scheduleTaskEdit } = localization.value.common
428
+
429
+ let result = localization.value.vmt.newTemplate
430
+ if (isScheduledTasks.value) {
431
+ const schedulerMode = props.schedulerTask.editTask
432
+ ? scheduleTaskEdit
433
+ : scheduleNewTasks
434
+
435
+ result = `${schedulerMode} (${localization.value.vmt.newTemplate})`
436
+ }
437
+
438
+ return result
439
+ })
440
+
441
+ // TODO move to common
442
+ const newTaskForm = ref<UI_I_ScheduleNewTasksForm>(
443
+ useDeepCopy(scheduledTaskDefaultFormFunc())
444
+ )
445
+ watch(
446
+ newTaskForm,
447
+ (newValue: UI_I_ScheduleNewTasksForm) => {
448
+ if (isScheduledTasks.value) wizard.setDisabledNextButton(newValue.isValid)
449
+ },
450
+ { immediate: true, deep: true }
451
+ )
452
+
453
+ const isLoading = ref<boolean>(false)
454
+ const onFinish = (): void => {
455
+ isLoading.value = true
456
+ wizard.setLoader(false)
457
+ props
458
+ .finishFunc(
459
+ vmtForm.value,
460
+ virtualHardwareCpu.value,
461
+ virtualHardwareMemory.value,
462
+ customizeHardware.value,
463
+ virtualHardwareNetworks.value,
464
+ virtualHardwareHardDisks.value,
465
+ virtualHardwareCdDvdDrives.value,
466
+ isPowerOnByDefault.value,
467
+ localization.value,
468
+ false,
469
+ newTaskForm.value,
470
+ props.schedulerTask
471
+ )
472
+ .then(() => {
473
+ isLoading.value = false
474
+ emits('hide')
475
+ wizard.setLoader(false)
476
+ })
477
+ }
478
+
479
+ const virtualHardwareCdDvdDrivesLocal = computed<
480
+ UI_I_SendDataNewCdDvdDrive[] | null
481
+ >(() => customizeHardware.value?.virtualHardware?.cdDvdDrives || null)
482
+ const virtualHardwareNetworksLocal = computed<UI_I_SendDataNewNetwork[] | null>(
483
+ () => customizeHardware.value?.virtualHardware?.networks || null
484
+ )
485
+ const virtualHardwareHardDisksLocal = computed<
486
+ UI_I_SendDataNewHardDisk[] | null
487
+ >(() => customizeHardware.value?.virtualHardware?.hardDisks || null)
488
+
489
+ const maxCpus = ref<number>(capabilities.value.maxCpus)
490
+ const maxMemory = ref<number>(capabilities.value.maxMemory)
491
+ const cpuModels = ref<UI_I_OptionItem[]>(capabilities.value.cpuModels)
492
+ const machineTypes = ref<UI_I_OptionItem[]>(capabilities.value.machineTypes)
493
+
494
+ const guestOsVersions = ref<UI_I_ArbitraryObject<UI_I_OptionItem[]>>(
495
+ capabilities.value.guestOsVersions
496
+ )
497
+
498
+ const guestOsFamilies = ref<UI_I_OptionItem[]>(
499
+ capabilities.value.guestOsFamilies
500
+ )
501
+
502
+ watch(
503
+ () => props.capabilities,
504
+ () => {
505
+ if (props.capabilities) mapCapabilities(props.capabilities)
506
+ },
507
+ { deep: true, immediate: true }
508
+ )
509
+
510
+ const onChangeCustomizeHardware = (
511
+ data: UI_I_SendDataCustomizeHardware
512
+ ): void => {
513
+ customizeHardware.value = data
514
+ }
515
+
516
+ const storageIdCash = ref<string | null>(null)
517
+ const onChangeStorage = (storage: UI_I_DatastoreTableItem | null): void => {
518
+ if (!storage) return
519
+
520
+ vmtForm.value.storage = storage
521
+ storageIdCash.value = storage.id
522
+ }
523
+
524
+ const onChangeName = (name: string): void => {
525
+ vmtForm.value.name = name
526
+ }
527
+
528
+ const onChangeBootOrder = (data: UI_T_ChangeBootOrder): void => {
529
+ virtualHardwareHardDisks.value = data[0]
530
+ virtualHardwareCdDvdDrives.value = data[1]
531
+ virtualHardwareNetworks.value = data[2]
532
+ }
533
+
534
+ watch(
535
+ () => props.vmtNameInWizard,
536
+ (newValue) => {
537
+ vmtForm.value.name = newValue
538
+ }
539
+ )
540
+ </script>
541
+
542
+ <style scoped lang="scss"></style>