bfg-common 1.5.485 → 1.5.487

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 (31) hide show
  1. package/assets/localization/local_be.json +2 -1
  2. package/assets/localization/local_en.json +2 -1
  3. package/assets/localization/local_hy.json +2 -1
  4. package/assets/localization/local_kk.json +2 -1
  5. package/assets/localization/local_ru.json +2 -1
  6. package/assets/localization/local_zh.json +2 -1
  7. package/assets/scss/common/theme.scss +2 -2
  8. package/components/atoms/window/Window.vue +460 -460
  9. package/components/common/layout/theHeader/feedback/new/New.vue +2 -2
  10. package/components/common/layout/theHeader/feedback/new/description/Description.vue +3 -3
  11. package/components/common/layout/theHeader/feedback/new/tabs/Tabs.vue +4 -2
  12. package/components/common/layout/theHeader/feedback/new/tabs/lib/config/tabs.ts +3 -2
  13. package/components/common/layout/theHeader/feedback/new/tabs/lib/models/interfaces.ts +5 -0
  14. package/components/common/layout/theHeader/helpMenu/aboutNew/AboutNew.vue +96 -95
  15. package/components/common/layout/theHeader/userMenu/modals/changePassword/ChangePasswordNew.vue +1 -2
  16. package/components/common/layout/theHeader/userMenu/modals/preferences/PreferencesNew.vue +9 -0
  17. package/components/common/layout/theHeader/userMenu/modals/preferences/view/ViewNew.vue +6 -2
  18. package/components/common/monitor/advanced/tools/chartOptionsModal/ChartOptionsModalNew.vue +1 -0
  19. package/components/common/monitor/overview/OverviewNew.vue +4 -1
  20. package/components/common/monitor/overview/filters/customIntervalModal/CustomIntervalModal.vue +0 -2
  21. package/components/common/monitor/overview/filters/customIntervalModal/customIntervalModalNew/CustomIntervalModalNew.vue +6 -6
  22. package/components/common/pages/backups/modals/Modals.vue +1 -1
  23. package/components/common/pages/tasks/table/Table.vue +8 -9
  24. package/components/common/vm/actions/add/Add.vue +877 -850
  25. package/components/common/vm/actions/add/New.vue +8 -2
  26. package/components/common/vm/actions/add/Old.vue +8 -2
  27. package/components/common/vm/actions/add/lib/config/steps.ts +14 -3
  28. package/components/common/vm/actions/common/select/name/Name.vue +3 -0
  29. package/components/common/vm/actions/common/select/name/Old.vue +131 -124
  30. package/components/common/vmt/actions/add/Add.vue +549 -548
  31. package/package.json +1 -1
@@ -1,548 +1,549 @@
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_ValidationReturn,
108
- UI_I_WizardStep,
109
- } from '~/node_modules/bfg-uikit/components/ui/wizard/lib/models/interfaces'
110
- import Wizard from '~/node_modules/bfg-uikit/components/ui/wizard/lib/utils/utils'
111
- import type {
112
- UI_I_ArbitraryObject,
113
- UI_I_Localization,
114
- } from '~/lib/models/interfaces'
115
- import type { UI_I_VmtForm } from '~/components/common/vmt/actions/add/lib/models/interfaces'
116
- import type {
117
- UI_I_SendDataCpu,
118
- UI_I_SendDataMemory,
119
- UI_I_SendDataNewCdDvdDrive,
120
- UI_I_SendDataNewHardDisk,
121
- UI_I_SendDataNewNetwork,
122
- } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
123
- import type {
124
- API_UI_I_Error,
125
- UI_I_ErrorValidationField,
126
- } from '~/lib/models/store/interfaces'
127
- import type { UI_I_SendDataCustomizeHardware } from '~/components/common/vm/actions/common/customizeHardware/lib/models/interfaces'
128
- import type { UI_I_ScheduleNewTasksForm } from '~/components/common/pages/scheduledTasks/modals/lib/models/interfaces'
129
- import type { UI_T_SelectedNavItem } from '~/components/common/vm/actions/common/lib/models/types'
130
- import type { UI_T_ChangeBootOrder } from '~/components/common/vm/actions/lib/models/types'
131
- import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
132
- import type { UI_T_Project } from '~/lib/models/types'
133
- import type { UI_I_FileTreeNode } from '~/components/lib/models/interfaces'
134
- import type { UI_I_NetworkTableItem } from '~/lib/models/store/network/interfaces'
135
- import type {
136
- UI_I_DatastoreTableItem,
137
- UI_I_FolderOrFileTreePayload,
138
- } from '~/lib/models/store/storage/interfaces'
139
- import type { UI_I_TableInfoItem } from '~/components/atoms/table/info/lib/models/interfaces'
140
- import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
141
- import type {
142
- UI_I_MediatedDevice,
143
- UI_I_PciDevice,
144
- } from '~/lib/models/store/vm/interfaces'
145
- import type { UI_I_Capabilities } from '~/components/common/vm/actions/common/lib/models/interfaces'
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 = withDefaults(
156
- defineProps<{
157
- project: UI_T_Project
158
- nodes: UI_I_FileTreeNode[]
159
- files: UI_I_FileTreeNode[]
160
- networksTable: UI_I_NetworkTableItem[]
161
- datastore: UI_I_DatastoreTableItem[]
162
- isDatastoreLoading: boolean
163
- errorValidationFields: UI_I_ErrorValidationField[]
164
- readyCompleteTableInfo: UI_I_TableInfoItem[]
165
- vmCpuHelpTextSecond: string
166
- finishFunc: any
167
- getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
168
- validateSendDataFunc: any
169
- passthroughDevices: UI_I_PciDevice[]
170
- mediatedDevices: UI_I_MediatedDevice[]
171
- vmtNameInWizard: string
172
- capabilities?: UI_I_Capabilities
173
- schedulerTask?: any // TODO надо interface переместить глобално
174
- }>(),
175
- {
176
- capabilities: undefined,
177
- schedulerTask: undefined,
178
- }
179
- )
180
-
181
- const emits = defineEmits<{
182
- (event: 'check-name', value: [string, (error: API_UI_I_Error) => void]): void
183
- (event: 'get-storage', value: UI_I_TablePayload): void
184
- (event: 'get-folders-or-files', value: UI_I_FolderOrFileTreePayload): void
185
- (event: 'get-active-device-child', value: UI_I_FileTreeNode): void
186
- (event: 'show-datastore-child', value: UI_I_FileTreeNode): void
187
- (event: 'remove-error-by-title', value: string): void
188
- (event: 'get-networks-table', value: UI_I_TablePayload): void
189
- (event: 'get-pci-devices'): void
190
- (event: 'hide'): void
191
- }>()
192
-
193
- const { $store }: any = useNuxtApp()
194
-
195
- const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
196
-
197
- const localization = computed<UI_I_Localization>(() => useLocal())
198
-
199
- const isScheduledTasks = computed<boolean>(
200
- () => props.schedulerTask?.isSchedulerTask
201
- )
202
-
203
- const wizard: Wizard = new Wizard(
204
- stepsFunc(localization.value, isScheduledTasks.value),
205
- stepsSchemeInitial
206
- )
207
-
208
- const selectedScheme = computed<number[]>(() => wizard.selectedScheme.value)
209
- const alertMessages = computed<string[][]>(() => wizard.alertMessages.value)
210
-
211
- const nameFormSubmit = ref<Function | null>(null)
212
- const storageSubmit = ref<Function | null>(null)
213
- const selectOptionsSubmit = ref<number>(0)
214
- const customizeHardwareSubmit = ref<Function | null>(null)
215
-
216
- const checkName = async (
217
- value: UI_I_WizardStep[]
218
- ): Promise<UI_I_ValidationReturn> => {
219
- let stepHasError = false
220
-
221
- return new Promise((resolve) => {
222
- nameFormSubmit.value = (isValid: boolean) => {
223
- if (!isValid) {
224
- stepHasError = wizard.setValidation(dynamicSteps.selectName, 'name', {
225
- fieldMessage: 'aaa',
226
- alertMessage: 'aaa',
227
- })
228
- } else if (wizard.hasMessage(dynamicSteps.selectName, 'name')) {
229
- value = wizard.removeValidation(dynamicSteps.selectName, 'name', value)
230
- }
231
-
232
- resolve({
233
- stepHasError,
234
- newValue: value,
235
- })
236
- nameFormSubmit.value = null
237
- }
238
- })
239
- }
240
- const checkStorage = async (
241
- value: UI_I_WizardStep[]
242
- ): Promise<UI_I_ValidationReturn> => {
243
- let stepHasError = false
244
-
245
- return new Promise((resolve) => {
246
- storageSubmit.value = (isValid: boolean) => {
247
- if (!isValid) {
248
- stepHasError = wizard.setValidation(
249
- dynamicSteps.selectStorage,
250
- 'storage',
251
- {
252
- fieldMessage: 'aaa',
253
- alertMessage: 'aaa',
254
- }
255
- )
256
- } else if (wizard.hasMessage(dynamicSteps.selectStorage, 'storage')) {
257
- value = wizard.removeValidation(
258
- dynamicSteps.selectStorage,
259
- 'storage',
260
- value
261
- )
262
- }
263
-
264
- resolve({
265
- stepHasError,
266
- newValue: value,
267
- })
268
- storageSubmit.value = null
269
- }
270
- })
271
- }
272
- const checkCustomizeHardware = async (
273
- value: UI_I_WizardStep[]
274
- ): Promise<UI_I_ValidationReturn> => {
275
- let stepHasError = false
276
-
277
- return new Promise((resolve) => {
278
- customizeHardwareSubmit.value = (isValid: boolean) => {
279
- if (!isValid) {
280
- stepHasError = wizard.setValidation(
281
- dynamicSteps.customizeHardware,
282
- 'customizeHardware',
283
- {
284
- fieldMessage: 'aaa',
285
- alertMessage: 'aaa',
286
- }
287
- )
288
- } else if (
289
- wizard.hasMessage(dynamicSteps.customizeHardware, 'customizeHardware')
290
- ) {
291
- value = wizard.removeValidation(
292
- dynamicSteps.customizeHardware,
293
- 'customizeHardware',
294
- value
295
- )
296
- }
297
-
298
- resolve({
299
- stepHasError,
300
- newValue: value,
301
- })
302
- storageSubmit.value = null
303
- }
304
- })
305
- }
306
- const validationFunc = async (
307
- value: UI_I_WizardStep[],
308
- currentStep: UI_I_WizardStep,
309
- nextStep: UI_I_WizardStep
310
- ): Promise<UI_I_ValidationReturn> => {
311
- let stepHasError = false
312
- let stepShouldStop = {
313
- ifOnCurrentStep: false,
314
- ifFromAnyStep: false,
315
- stoppageStepId: -1,
316
- }
317
-
318
- wizard.setLoader(true)
319
- if (
320
- wizard.isValidateForStep(
321
- dynamicSteps.selectName,
322
- currentStep.id,
323
- nextStep.id
324
- )
325
- ) {
326
- const nameValidation = await checkName(value)
327
-
328
- value = nameValidation.newValue
329
- stepHasError = stepHasError || nameValidation.stepHasError
330
- } else if (
331
- wizard.isValidateForStep(
332
- dynamicSteps.selectStorage,
333
- currentStep.id,
334
- nextStep.id
335
- )
336
- ) {
337
- const storageValidation = await checkStorage(value)
338
-
339
- value = storageValidation.newValue
340
-
341
- stepHasError = stepHasError || storageValidation.stepHasError
342
- } else if (
343
- wizard.isValidateForStep(
344
- dynamicSteps.selectOptions,
345
- currentStep.id,
346
- nextStep.id
347
- )
348
- ) {
349
- selectOptionsSubmit.value++
350
- } else if (
351
- wizard.isValidateForStep(
352
- dynamicSteps.customizeHardware,
353
- currentStep.id,
354
- nextStep.id
355
- )
356
- ) {
357
- const customizeHardwareValidation = await checkCustomizeHardware(value)
358
-
359
- value = customizeHardwareValidation.newValue
360
-
361
- stepHasError = stepHasError || customizeHardwareValidation.stepHasError
362
- }
363
- wizard.setLoader(false)
364
-
365
- return {
366
- newValue: value,
367
- stepHasError,
368
- stepShouldStop,
369
- }
370
- }
371
-
372
- const vmtForm = ref<UI_I_VmtForm>({
373
- name: '',
374
- compatibility: '',
375
- guestMachineType: null,
376
- guestOsFamily: null,
377
- guestOsVersion: null,
378
- computeResource: null,
379
- storage: null,
380
- locationPath: '',
381
- // dataCenter: null,
382
- })
383
- const customizeHardware = ref<UI_I_SendDataCustomizeHardware | null>(null)
384
- const virtualHardwareCpu = computed<UI_I_SendDataCpu | null>(
385
- () => customizeHardware.value?.virtualHardware?.cpu || null
386
- )
387
- const virtualHardwareMemory = computed<UI_I_SendDataMemory | null>(
388
- () => customizeHardware.value?.virtualHardware?.memory || null
389
- )
390
- const virtualHardwareNetworks = ref<UI_I_SendDataNewNetwork[] | null>(null)
391
- const virtualHardwareHardDisks = ref<UI_I_SendDataNewHardDisk[] | null>(null)
392
- const virtualHardwareCdDvdDrives = ref<UI_I_SendDataNewCdDvdDrive[] | null>(
393
- null
394
- )
395
- const isPowerOnByDefault = ref<boolean>(true)
396
- const selectedNavItem = ref<UI_T_SelectedNavItem>(0)
397
-
398
- const validateSendData = async (
399
- value: UI_I_WizardStep[]
400
- ): Promise<UI_I_ValidationReturn> => {
401
- wizard.setLoader(true)
402
- let stepHasError = false
403
-
404
- const data = await props.validateSendDataFunc(
405
- vmtForm.value,
406
- virtualHardwareCpu.value,
407
- virtualHardwareMemory.value,
408
- customizeHardware.value,
409
- virtualHardwareNetworks.value,
410
- virtualHardwareHardDisks.value,
411
- virtualHardwareCdDvdDrives.value,
412
- isPowerOnByDefault.value,
413
- localization.value
414
- )
415
-
416
- wizard.setLoader(false)
417
- if (data) {
418
- stepHasError = true
419
- selectedNavItem.value = data[0]
420
- }
421
-
422
- return {
423
- stepHasError,
424
- newValue: value,
425
- }
426
- }
427
-
428
- const onChangeSteps = async (value: UI_I_WizardStep[]): Promise<void> => {
429
- wizard.changeSteps(value, validationFunc, validateSendData)
430
- }
431
-
432
- const title = computed<string>(() => {
433
- const { scheduleNewTasks, scheduleTaskEdit } = localization.value.common
434
-
435
- let result = localization.value.vmt.newTemplate
436
- if (isScheduledTasks.value) {
437
- const schedulerMode = props.schedulerTask.editTask
438
- ? scheduleTaskEdit
439
- : scheduleNewTasks
440
-
441
- result = `${schedulerMode} (${localization.value.vmt.newTemplate})`
442
- }
443
-
444
- return result
445
- })
446
-
447
- // TODO move to common
448
- const newTaskForm = ref<UI_I_ScheduleNewTasksForm>(
449
- useDeepCopy(scheduledTaskDefaultFormFunc())
450
- )
451
- watch(
452
- newTaskForm,
453
- (newValue: UI_I_ScheduleNewTasksForm) => {
454
- if (isScheduledTasks.value) wizard.setDisabledNextButton(newValue.isValid)
455
- },
456
- { immediate: true, deep: true }
457
- )
458
-
459
- const isLoading = ref<boolean>(false)
460
- const onFinish = (): void => {
461
- isLoading.value = true
462
- wizard.setLoader(false)
463
- props
464
- .finishFunc(
465
- vmtForm.value,
466
- virtualHardwareCpu.value,
467
- virtualHardwareMemory.value,
468
- customizeHardware.value,
469
- virtualHardwareNetworks.value,
470
- virtualHardwareHardDisks.value,
471
- virtualHardwareCdDvdDrives.value,
472
- isPowerOnByDefault.value,
473
- localization.value,
474
- false,
475
- newTaskForm.value,
476
- props.schedulerTask
477
- )
478
- .then(() => {
479
- isLoading.value = false
480
- emits('hide')
481
- wizard.setLoader(false)
482
- })
483
- }
484
-
485
- const virtualHardwareCdDvdDrivesLocal = computed<
486
- UI_I_SendDataNewCdDvdDrive[] | null
487
- >(() => customizeHardware.value?.virtualHardware?.cdDvdDrives || null)
488
- const virtualHardwareNetworksLocal = computed<UI_I_SendDataNewNetwork[] | null>(
489
- () => customizeHardware.value?.virtualHardware?.networks || null
490
- )
491
- const virtualHardwareHardDisksLocal = computed<
492
- UI_I_SendDataNewHardDisk[] | null
493
- >(() => customizeHardware.value?.virtualHardware?.hardDisks || null)
494
-
495
- const maxCpus = ref<number>(capabilities.value.maxCpus)
496
- const maxMemory = ref<number>(capabilities.value.maxMemory)
497
- const cpuModels = ref<UI_I_OptionItem[]>(capabilities.value.cpuModels)
498
- const machineTypes = ref<UI_I_OptionItem[]>(capabilities.value.machineTypes)
499
-
500
- const guestOsVersions = ref<UI_I_ArbitraryObject<UI_I_OptionItem[]>>(
501
- capabilities.value.guestOsVersions
502
- )
503
-
504
- const guestOsFamilies = ref<UI_I_OptionItem[]>(
505
- capabilities.value.guestOsFamilies
506
- )
507
-
508
- watch(
509
- () => props.capabilities,
510
- () => {
511
- if (props.capabilities) mapCapabilities(props.capabilities)
512
- },
513
- { deep: true, immediate: true }
514
- )
515
-
516
- const onChangeCustomizeHardware = (
517
- data: UI_I_SendDataCustomizeHardware
518
- ): void => {
519
- customizeHardware.value = data
520
- }
521
-
522
- const storageIdCash = ref<string | null>(null)
523
- const onChangeStorage = (storage: UI_I_DatastoreTableItem | null): void => {
524
- if (!storage) return
525
-
526
- vmtForm.value.storage = storage
527
- storageIdCash.value = storage.id
528
- }
529
-
530
- const onChangeName = (name: string): void => {
531
- vmtForm.value.name = name
532
- }
533
-
534
- const onChangeBootOrder = (data: UI_T_ChangeBootOrder): void => {
535
- virtualHardwareHardDisks.value = data[0]
536
- virtualHardwareCdDvdDrives.value = data[1]
537
- virtualHardwareNetworks.value = data[2]
538
- }
539
-
540
- watch(
541
- () => props.vmtNameInWizard,
542
- (newValue) => {
543
- vmtForm.value.name = newValue
544
- }
545
- )
546
- </script>
547
-
548
- <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
+ // TODO use just add-vm component
107
+ import type {
108
+ UI_I_ValidationReturn,
109
+ UI_I_WizardStep,
110
+ } from '~/node_modules/bfg-uikit/components/ui/wizard/lib/models/interfaces'
111
+ import Wizard from '~/node_modules/bfg-uikit/components/ui/wizard/lib/utils/utils'
112
+ import type {
113
+ UI_I_ArbitraryObject,
114
+ UI_I_Localization,
115
+ } from '~/lib/models/interfaces'
116
+ import type { UI_I_VmtForm } from '~/components/common/vmt/actions/add/lib/models/interfaces'
117
+ import type {
118
+ UI_I_SendDataCpu,
119
+ UI_I_SendDataMemory,
120
+ UI_I_SendDataNewCdDvdDrive,
121
+ UI_I_SendDataNewHardDisk,
122
+ UI_I_SendDataNewNetwork,
123
+ } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
124
+ import type {
125
+ API_UI_I_Error,
126
+ UI_I_ErrorValidationField,
127
+ } from '~/lib/models/store/interfaces'
128
+ import type { UI_I_SendDataCustomizeHardware } from '~/components/common/vm/actions/common/customizeHardware/lib/models/interfaces'
129
+ import type { UI_I_ScheduleNewTasksForm } from '~/components/common/pages/scheduledTasks/modals/lib/models/interfaces'
130
+ import type { UI_T_SelectedNavItem } from '~/components/common/vm/actions/common/lib/models/types'
131
+ import type { UI_T_ChangeBootOrder } from '~/components/common/vm/actions/lib/models/types'
132
+ import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
133
+ import type { UI_T_Project } from '~/lib/models/types'
134
+ import type { UI_I_FileTreeNode } from '~/components/lib/models/interfaces'
135
+ import type { UI_I_NetworkTableItem } from '~/lib/models/store/network/interfaces'
136
+ import type {
137
+ UI_I_DatastoreTableItem,
138
+ UI_I_FolderOrFileTreePayload,
139
+ } from '~/lib/models/store/storage/interfaces'
140
+ import type { UI_I_TableInfoItem } from '~/components/atoms/table/info/lib/models/interfaces'
141
+ import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
142
+ import type {
143
+ UI_I_MediatedDevice,
144
+ UI_I_PciDevice,
145
+ } from '~/lib/models/store/vm/interfaces'
146
+ import type { UI_I_Capabilities } from '~/components/common/vm/actions/common/lib/models/interfaces'
147
+ import { mapCapabilities } from '~/components/common/vm/actions/common/lib/utils/capabilities'
148
+ import {
149
+ dynamicSteps,
150
+ stepsSchemeInitial,
151
+ stepsFunc,
152
+ } from '~/components/common/vmt/actions/add/lib/config/steps'
153
+ import { scheduledTaskDefaultFormFunc } from '~/components/common/pages/scheduledTasks/modals/lib/config/createScheduledTask'
154
+ import { capabilities } from '~/components/common/vm/actions/common/lib/config/capabilities'
155
+
156
+ const props = withDefaults(
157
+ defineProps<{
158
+ project: UI_T_Project
159
+ nodes: UI_I_FileTreeNode[]
160
+ files: UI_I_FileTreeNode[]
161
+ networksTable: UI_I_NetworkTableItem[]
162
+ datastore: UI_I_DatastoreTableItem[]
163
+ isDatastoreLoading: boolean
164
+ errorValidationFields: UI_I_ErrorValidationField[]
165
+ readyCompleteTableInfo: UI_I_TableInfoItem[]
166
+ vmCpuHelpTextSecond: string
167
+ finishFunc: any
168
+ getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
169
+ validateSendDataFunc: any
170
+ passthroughDevices: UI_I_PciDevice[]
171
+ mediatedDevices: UI_I_MediatedDevice[]
172
+ vmtNameInWizard: string
173
+ capabilities?: UI_I_Capabilities
174
+ schedulerTask?: any // TODO надо interface переместить глобално
175
+ }>(),
176
+ {
177
+ capabilities: undefined,
178
+ schedulerTask: undefined,
179
+ }
180
+ )
181
+
182
+ const emits = defineEmits<{
183
+ (event: 'check-name', value: [string, (error: API_UI_I_Error) => void]): void
184
+ (event: 'get-storage', value: UI_I_TablePayload): void
185
+ (event: 'get-folders-or-files', value: UI_I_FolderOrFileTreePayload): void
186
+ (event: 'get-active-device-child', value: UI_I_FileTreeNode): void
187
+ (event: 'show-datastore-child', value: UI_I_FileTreeNode): void
188
+ (event: 'remove-error-by-title', value: string): void
189
+ (event: 'get-networks-table', value: UI_I_TablePayload): void
190
+ (event: 'get-pci-devices'): void
191
+ (event: 'hide'): void
192
+ }>()
193
+
194
+ const { $store }: any = useNuxtApp()
195
+
196
+ const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
197
+
198
+ const localization = computed<UI_I_Localization>(() => useLocal())
199
+
200
+ const isScheduledTasks = computed<boolean>(
201
+ () => props.schedulerTask?.isSchedulerTask
202
+ )
203
+
204
+ const wizard: Wizard = new Wizard(
205
+ stepsFunc(localization.value, isScheduledTasks.value),
206
+ stepsSchemeInitial
207
+ )
208
+
209
+ const selectedScheme = computed<number[]>(() => wizard.selectedScheme.value)
210
+ const alertMessages = computed<string[][]>(() => wizard.alertMessages.value)
211
+
212
+ const nameFormSubmit = ref<Function | null>(null)
213
+ const storageSubmit = ref<Function | null>(null)
214
+ const selectOptionsSubmit = ref<number>(0)
215
+ const customizeHardwareSubmit = ref<Function | null>(null)
216
+
217
+ const checkName = async (
218
+ value: UI_I_WizardStep[]
219
+ ): Promise<UI_I_ValidationReturn> => {
220
+ let stepHasError = false
221
+
222
+ return new Promise((resolve) => {
223
+ nameFormSubmit.value = (isValid: boolean) => {
224
+ if (!isValid) {
225
+ stepHasError = wizard.setValidation(dynamicSteps.selectName, 'name', {
226
+ fieldMessage: 'aaa',
227
+ alertMessage: 'aaa',
228
+ })
229
+ } else if (wizard.hasMessage(dynamicSteps.selectName, 'name')) {
230
+ value = wizard.removeValidation(dynamicSteps.selectName, 'name', value)
231
+ }
232
+
233
+ resolve({
234
+ stepHasError,
235
+ newValue: value,
236
+ })
237
+ nameFormSubmit.value = null
238
+ }
239
+ })
240
+ }
241
+ const checkStorage = async (
242
+ value: UI_I_WizardStep[]
243
+ ): Promise<UI_I_ValidationReturn> => {
244
+ let stepHasError = false
245
+
246
+ return new Promise((resolve) => {
247
+ storageSubmit.value = (isValid: boolean) => {
248
+ if (!isValid) {
249
+ stepHasError = wizard.setValidation(
250
+ dynamicSteps.selectStorage,
251
+ 'storage',
252
+ {
253
+ fieldMessage: 'aaa',
254
+ alertMessage: 'aaa',
255
+ }
256
+ )
257
+ } else if (wizard.hasMessage(dynamicSteps.selectStorage, 'storage')) {
258
+ value = wizard.removeValidation(
259
+ dynamicSteps.selectStorage,
260
+ 'storage',
261
+ value
262
+ )
263
+ }
264
+
265
+ resolve({
266
+ stepHasError,
267
+ newValue: value,
268
+ })
269
+ storageSubmit.value = null
270
+ }
271
+ })
272
+ }
273
+ const checkCustomizeHardware = async (
274
+ value: UI_I_WizardStep[]
275
+ ): Promise<UI_I_ValidationReturn> => {
276
+ let stepHasError = false
277
+
278
+ return new Promise((resolve) => {
279
+ customizeHardwareSubmit.value = (isValid: boolean) => {
280
+ if (!isValid) {
281
+ stepHasError = wizard.setValidation(
282
+ dynamicSteps.customizeHardware,
283
+ 'customizeHardware',
284
+ {
285
+ fieldMessage: 'aaa',
286
+ alertMessage: 'aaa',
287
+ }
288
+ )
289
+ } else if (
290
+ wizard.hasMessage(dynamicSteps.customizeHardware, 'customizeHardware')
291
+ ) {
292
+ value = wizard.removeValidation(
293
+ dynamicSteps.customizeHardware,
294
+ 'customizeHardware',
295
+ value
296
+ )
297
+ }
298
+
299
+ resolve({
300
+ stepHasError,
301
+ newValue: value,
302
+ })
303
+ storageSubmit.value = null
304
+ }
305
+ })
306
+ }
307
+ const validationFunc = async (
308
+ value: UI_I_WizardStep[],
309
+ currentStep: UI_I_WizardStep,
310
+ nextStep: UI_I_WizardStep
311
+ ): Promise<UI_I_ValidationReturn> => {
312
+ let stepHasError = false
313
+ let stepShouldStop = {
314
+ ifOnCurrentStep: false,
315
+ ifFromAnyStep: false,
316
+ stoppageStepId: -1,
317
+ }
318
+
319
+ wizard.setLoader(true)
320
+ if (
321
+ wizard.isValidateForStep(
322
+ dynamicSteps.selectName,
323
+ currentStep.id,
324
+ nextStep.id
325
+ )
326
+ ) {
327
+ const nameValidation = await checkName(value)
328
+
329
+ value = nameValidation.newValue
330
+ stepHasError = stepHasError || nameValidation.stepHasError
331
+ } else if (
332
+ wizard.isValidateForStep(
333
+ dynamicSteps.selectStorage,
334
+ currentStep.id,
335
+ nextStep.id
336
+ )
337
+ ) {
338
+ const storageValidation = await checkStorage(value)
339
+
340
+ value = storageValidation.newValue
341
+
342
+ stepHasError = stepHasError || storageValidation.stepHasError
343
+ } else if (
344
+ wizard.isValidateForStep(
345
+ dynamicSteps.selectOptions,
346
+ currentStep.id,
347
+ nextStep.id
348
+ )
349
+ ) {
350
+ selectOptionsSubmit.value++
351
+ } else if (
352
+ wizard.isValidateForStep(
353
+ dynamicSteps.customizeHardware,
354
+ currentStep.id,
355
+ nextStep.id
356
+ )
357
+ ) {
358
+ const customizeHardwareValidation = await checkCustomizeHardware(value)
359
+
360
+ value = customizeHardwareValidation.newValue
361
+
362
+ stepHasError = stepHasError || customizeHardwareValidation.stepHasError
363
+ }
364
+ wizard.setLoader(false)
365
+
366
+ return {
367
+ newValue: value,
368
+ stepHasError,
369
+ stepShouldStop,
370
+ }
371
+ }
372
+
373
+ const vmtForm = ref<UI_I_VmtForm>({
374
+ name: '',
375
+ compatibility: '',
376
+ guestMachineType: null,
377
+ guestOsFamily: null,
378
+ guestOsVersion: null,
379
+ computeResource: null,
380
+ storage: null,
381
+ locationPath: '',
382
+ // dataCenter: null,
383
+ })
384
+ const customizeHardware = ref<UI_I_SendDataCustomizeHardware | null>(null)
385
+ const virtualHardwareCpu = computed<UI_I_SendDataCpu | null>(
386
+ () => customizeHardware.value?.virtualHardware?.cpu || null
387
+ )
388
+ const virtualHardwareMemory = computed<UI_I_SendDataMemory | null>(
389
+ () => customizeHardware.value?.virtualHardware?.memory || null
390
+ )
391
+ const virtualHardwareNetworks = ref<UI_I_SendDataNewNetwork[] | null>(null)
392
+ const virtualHardwareHardDisks = ref<UI_I_SendDataNewHardDisk[] | null>(null)
393
+ const virtualHardwareCdDvdDrives = ref<UI_I_SendDataNewCdDvdDrive[] | null>(
394
+ null
395
+ )
396
+ const isPowerOnByDefault = ref<boolean>(true)
397
+ const selectedNavItem = ref<UI_T_SelectedNavItem>(0)
398
+
399
+ const validateSendData = async (
400
+ value: UI_I_WizardStep[]
401
+ ): Promise<UI_I_ValidationReturn> => {
402
+ wizard.setLoader(true)
403
+ let stepHasError = false
404
+
405
+ const data = await props.validateSendDataFunc(
406
+ vmtForm.value,
407
+ virtualHardwareCpu.value,
408
+ virtualHardwareMemory.value,
409
+ customizeHardware.value,
410
+ virtualHardwareNetworks.value,
411
+ virtualHardwareHardDisks.value,
412
+ virtualHardwareCdDvdDrives.value,
413
+ isPowerOnByDefault.value,
414
+ localization.value
415
+ )
416
+
417
+ wizard.setLoader(false)
418
+ if (data) {
419
+ stepHasError = true
420
+ selectedNavItem.value = data[0]
421
+ }
422
+
423
+ return {
424
+ stepHasError,
425
+ newValue: value,
426
+ }
427
+ }
428
+
429
+ const onChangeSteps = async (value: UI_I_WizardStep[]): Promise<void> => {
430
+ wizard.changeSteps(value, validationFunc, validateSendData)
431
+ }
432
+
433
+ const title = computed<string>(() => {
434
+ const { scheduleNewTasks, scheduleTaskEdit } = localization.value.common
435
+
436
+ let result = localization.value.vmt.newTemplate
437
+ if (isScheduledTasks.value) {
438
+ const schedulerMode = props.schedulerTask.editTask
439
+ ? scheduleTaskEdit
440
+ : scheduleNewTasks
441
+
442
+ result = `${schedulerMode} (${localization.value.vmt.newTemplate})`
443
+ }
444
+
445
+ return result
446
+ })
447
+
448
+ // TODO move to common
449
+ const newTaskForm = ref<UI_I_ScheduleNewTasksForm>(
450
+ useDeepCopy(scheduledTaskDefaultFormFunc())
451
+ )
452
+ watch(
453
+ newTaskForm,
454
+ (newValue: UI_I_ScheduleNewTasksForm) => {
455
+ if (isScheduledTasks.value) wizard.setDisabledNextButton(newValue.isValid)
456
+ },
457
+ { immediate: true, deep: true }
458
+ )
459
+
460
+ const isLoading = ref<boolean>(false)
461
+ const onFinish = (): void => {
462
+ isLoading.value = true
463
+ wizard.setLoader(false)
464
+ props
465
+ .finishFunc(
466
+ vmtForm.value,
467
+ virtualHardwareCpu.value,
468
+ virtualHardwareMemory.value,
469
+ customizeHardware.value,
470
+ virtualHardwareNetworks.value,
471
+ virtualHardwareHardDisks.value,
472
+ virtualHardwareCdDvdDrives.value,
473
+ isPowerOnByDefault.value,
474
+ localization.value,
475
+ false,
476
+ newTaskForm.value,
477
+ props.schedulerTask
478
+ )
479
+ .then(() => {
480
+ isLoading.value = false
481
+ emits('hide')
482
+ wizard.setLoader(false)
483
+ })
484
+ }
485
+
486
+ const virtualHardwareCdDvdDrivesLocal = computed<
487
+ UI_I_SendDataNewCdDvdDrive[] | null
488
+ >(() => customizeHardware.value?.virtualHardware?.cdDvdDrives || null)
489
+ const virtualHardwareNetworksLocal = computed<UI_I_SendDataNewNetwork[] | null>(
490
+ () => customizeHardware.value?.virtualHardware?.networks || null
491
+ )
492
+ const virtualHardwareHardDisksLocal = computed<
493
+ UI_I_SendDataNewHardDisk[] | null
494
+ >(() => customizeHardware.value?.virtualHardware?.hardDisks || null)
495
+
496
+ const maxCpus = ref<number>(capabilities.value.maxCpus)
497
+ const maxMemory = ref<number>(capabilities.value.maxMemory)
498
+ const cpuModels = ref<UI_I_OptionItem[]>(capabilities.value.cpuModels)
499
+ const machineTypes = ref<UI_I_OptionItem[]>(capabilities.value.machineTypes)
500
+
501
+ const guestOsVersions = ref<UI_I_ArbitraryObject<UI_I_OptionItem[]>>(
502
+ capabilities.value.guestOsVersions
503
+ )
504
+
505
+ const guestOsFamilies = ref<UI_I_OptionItem[]>(
506
+ capabilities.value.guestOsFamilies
507
+ )
508
+
509
+ watch(
510
+ () => props.capabilities,
511
+ () => {
512
+ if (props.capabilities) mapCapabilities(props.capabilities)
513
+ },
514
+ { deep: true, immediate: true }
515
+ )
516
+
517
+ const onChangeCustomizeHardware = (
518
+ data: UI_I_SendDataCustomizeHardware
519
+ ): void => {
520
+ customizeHardware.value = data
521
+ }
522
+
523
+ const storageIdCash = ref<string | null>(null)
524
+ const onChangeStorage = (storage: UI_I_DatastoreTableItem | null): void => {
525
+ if (!storage) return
526
+
527
+ vmtForm.value.storage = storage
528
+ storageIdCash.value = storage.id
529
+ }
530
+
531
+ const onChangeName = (name: string): void => {
532
+ vmtForm.value.name = name
533
+ }
534
+
535
+ const onChangeBootOrder = (data: UI_T_ChangeBootOrder): void => {
536
+ virtualHardwareHardDisks.value = data[0]
537
+ virtualHardwareCdDvdDrives.value = data[1]
538
+ virtualHardwareNetworks.value = data[2]
539
+ }
540
+
541
+ watch(
542
+ () => props.vmtNameInWizard,
543
+ (newValue) => {
544
+ vmtForm.value.name = newValue
545
+ }
546
+ )
547
+ </script>
548
+
549
+ <style scoped lang="scss"></style>