bfg-common 1.4.174 → 1.4.176

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 (34) hide show
  1. package/assets/img/icons/icons-sprite-dark-1.svg +407 -407
  2. package/assets/img/icons/icons-sprite-dark-2.svg +343 -343
  3. package/assets/img/icons/icons-sprite-dark-3.svg +227 -227
  4. package/assets/img/icons/icons-sprite-dark-4.svg +255 -255
  5. package/assets/img/icons/icons-sprite-dark-5.svg +488 -488
  6. package/assets/img/icons/icons-sprite-dark-6.svg +83 -83
  7. package/assets/img/icons/icons-sprite-light-1.svg +407 -407
  8. package/assets/img/icons/icons-sprite-light-2.svg +343 -343
  9. package/assets/img/icons/icons-sprite-light-3.svg +227 -227
  10. package/assets/img/icons/icons-sprite-light-4.svg +255 -255
  11. package/assets/img/icons/icons-sprite-light-5.svg +488 -488
  12. package/assets/img/icons/icons-sprite-light-6.svg +83 -83
  13. package/components/atoms/modal/bySteps/BySteps.vue +253 -253
  14. package/components/atoms/stack/StackBlock.vue +185 -185
  15. package/components/common/browse/blocks/Title.vue +91 -91
  16. package/components/common/browse/blocks/info/Date.vue +21 -21
  17. package/components/common/context/lib/models/interfaces.ts +30 -30
  18. package/components/common/context/recursion/Recursion.vue +86 -86
  19. package/components/common/context/recursion/RecursionNew.vue +199 -199
  20. package/components/common/context/recursion/RecursionOld.vue +213 -213
  21. package/components/common/vm/actions/add/Add.vue +609 -609
  22. package/components/common/vm/actions/clone/Clone.vue +522 -522
  23. package/components/common/vm/actions/common/customizeHardware/virtualHardware/bus/lib/config/options.ts +20 -20
  24. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/Cpu.vue +403 -403
  25. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/Hv.vue +99 -99
  26. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/Order.vue +201 -201
  27. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/streamingMode/StreamingMode.vue +85 -85
  28. package/components/common/vm/actions/editSettings/EditSettings.vue +5 -1
  29. package/composables/productNameLocal.ts +30 -30
  30. package/lib/models/store/tasks/enums.ts +7 -0
  31. package/package.json +2 -2
  32. package/plugins/recursion.ts +311 -311
  33. package/public/spice-console/lib/images/bitmap.js +203 -203
  34. package/store/tasks/mappers/recentTasks.ts +45 -45
@@ -1,522 +1,522 @@
1
- <template>
2
- <div class="clone-vm">
3
- <atoms-wizard
4
- show
5
- :wizard="wizard"
6
- :selected-scheme="selectedScheme"
7
- :title="localization.common.cloneExistingVirtualMachine"
8
- :localization="localization"
9
- @change-steps="onChangeSteps"
10
- @hide="onHideModal"
11
- @submit="onFinish"
12
- >
13
- <template #modalBody="{ selectedStep }">
14
- <atoms-loader v-show="!vmSettings" id="loader" />
15
- <div v-if="vmSettings" class="vm-context">
16
- <common-vm-actions-common-select-name
17
- v-show="selectedStep.id === 0"
18
- :show="selectedStep.id === 0"
19
- :name-form-submit="nameFormSubmit"
20
- :project="props.project"
21
- @submit="onChangeName(...$event)"
22
- @check-name="emits('check-name', $event)"
23
- />
24
- <common-vm-actions-common-select-storage
25
- v-show="selectedStep.id === 1"
26
- :storage-submit="storageSubmit"
27
- :datastore="props.datastore"
28
- :storage="vmSettings.storage"
29
- :get-datastore-table-func="props.getDatastoreTableFunc"
30
- @submit="onChangeStorage"
31
- />
32
- <common-vm-actions-clone-select-options
33
- v-show="selectedStep.id === 2"
34
- :select-options-submit="selectOptionsSubmit"
35
- @submit="onChangeSelectOptions"
36
- />
37
- <common-vm-actions-common-customize-hardware
38
- v-show="selectedStep.id === 3"
39
- v-model:vm-name="vmName"
40
- v-model:guest-machine-type="vmSettings.guestMachineType"
41
- v-model:guest-os-family="vmSettings.guestOsFamily"
42
- v-model:guest-os-version="vmSettings.guestOsVersion"
43
- :storage="vmSettings.storage"
44
- :hard-disks-for-boot-options="virtualHardwareHardDisksLocal"
45
- :cd-dvd-drives-for-boot-options="virtualHardwareCdDvdDrivesLocal"
46
- :networks-for-boot-options="virtualHardwareNetworksLocal"
47
- :cd-dvd-drives="vmSettings.cdDvdDrives"
48
- :hard-disks="vmSettings.hardDisks"
49
- :networks="vmSettings.networks"
50
- :customize-hardware-submit="customizeHardwareSubmit"
51
- :max-cpus="vmSettings.maxCpus"
52
- :max-memory="vmSettings.maxMemory"
53
- :cpu-models="vmSettings.cpuModels"
54
- :cpu="vmSettings.cpu"
55
- :memory="vmSettings.memory"
56
- :video-card="vmSettings.videoCard"
57
- :usb-controller="vmSettings.usbController"
58
- :pci-devices="vmSettings.pciDevices"
59
- :selected-nav-item="selectedNavItem"
60
- :hard-disks-for-edit="vmSettings.hardDisks"
61
- :options="vmSettings.options"
62
- :nodes="props.nodes"
63
- :files="props.files"
64
- :networks-table="props.networksTable"
65
- :error-validation-fields="props.errorValidationFields"
66
- :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
67
- :passthrough-devices="props.passthroughDevices"
68
- :get-datastore-table-func="props.getDatastoreTableFunc"
69
- :datastore="props.datastore"
70
- :project="props.project"
71
- is-clone
72
- @change-boot-order="onChangeBootOrder"
73
- @send-data="onChangeCustomizeHardware"
74
- @get-storage="emits('get-storage', $event)"
75
- @get-folders-or-files="emits('get-folders-or-files', $event)"
76
- @get-active-device-child="emits('get-active-device-child', $event)"
77
- @show-datastore-child="emits('show-datastore-child', $event)"
78
- @get-networks-table="emits('get-networks-table', $event)"
79
- @get-pci-devices="emits('get-pci-devices')"
80
- />
81
- <common-ready-to-complete
82
- v-show="selectedStep.id === 4"
83
- :data="props.readyCompleteTableInfo"
84
- />
85
- </div>
86
- </template>
87
- </atoms-wizard>
88
- </div>
89
- </template>
90
-
91
- <script setup lang="ts">
92
- import type {
93
- UI_I_DatastoreTableItem,
94
- UI_I_FolderOrFileTreePayload,
95
- } from '~/lib/models/store/storage/interfaces'
96
- import type { UI_I_NetworkTableItem } from '~/lib/models/store/network/interfaces'
97
- import type { API_UI_I_Error } from '~/lib/models/store/interfaces'
98
- import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
99
- import type { UI_I_FileTreeNode } from '~/components/lib/models/interfaces'
100
- import type { UI_I_Localization } from '~/lib/models/interfaces'
101
- import type { UI_I_SendDataCustomizeHardware } from '~/components/common/vm/actions/common/customizeHardware/lib/models/interfaces'
102
- import type { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
103
- import type {
104
- UI_I_SendDataCpu,
105
- UI_I_SendDataMemory,
106
- UI_I_SendDataNewCdDvdDrive,
107
- UI_I_SendDataNewHardDisk,
108
- UI_I_SendDataNewNetwork,
109
- } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
110
- import type { UI_T_SelectedNavItem } from '~/components/common/vm/actions/common/lib/models/types'
111
- import type { UI_I_TableInfoItem } from '~/components/atoms/table/info/lib/models/interfaces'
112
- import type { UI_I_ConfigurePciDevicesTable } from '~/lib/models/store/host/interfaces'
113
- import type { UI_T_ChangeBootOrder } from '~/components/common/vm/actions/lib/models/types'
114
- import type { UI_T_Project } from '~/lib/models/types'
115
- import type { UI_I_VmSettings } from '~/lib/models/store/vm/interfaces'
116
- import type { UI_I_VmForm } from '~/components/common/vm/actions/clone/lib/models/interfaces'
117
- import type {
118
- UI_I_ValidationReturn,
119
- UI_I_WizardStep,
120
- } from '~/components/atoms/wizard/lib/models/interfaces'
121
- import type { UI_I_Capabilities } from '~/components/common/vm/actions/common/lib/models/interfaces'
122
- import {
123
- stepsSchemeInitial,
124
- stepsFunc,
125
- } from '~/components/common/vm/actions/clone/lib/config/steps'
126
- import Wizard from '~/components/atoms/wizard/lib/utils/utils'
127
- import { mapCapabilities } from '~/components/common/vm/actions/common/lib/utils/capabilities'
128
-
129
- const props = defineProps<{
130
- project: UI_T_Project
131
- vmSettings: UI_I_VmSettings | null
132
- nodes: UI_I_FileTreeNode[]
133
- files: UI_I_FileTreeNode[]
134
- networksTable: UI_I_NetworkTableItem[]
135
- datastore: UI_I_DatastoreTableItem[]
136
- errorValidationFields: UI_I_ErrorValidationField[]
137
- readyCompleteTableInfo: UI_I_TableInfoItem[]
138
- vmCpuHelpTextSecond: string
139
- finishFunc: any
140
- getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
141
- validateSendDataFunc: any
142
- passthroughDevices: UI_I_ConfigurePciDevicesTable | null
143
- vmNameInWizard: string
144
- capabilities?: UI_I_Capabilities
145
- }>()
146
-
147
- const emits = defineEmits<{
148
- (event: 'check-name', value: [string, (error: API_UI_I_Error) => void]): void
149
- (event: 'get-storage', value: UI_I_TablePayload): void
150
- (event: 'get-folders-or-files', value: UI_I_FolderOrFileTreePayload): void
151
- (event: 'get-active-device-child', value: UI_I_FileTreeNode): void
152
- (event: 'show-datastore-child', value: UI_I_FileTreeNode): void
153
- (event: 'remove-error-by-title', value: string): void
154
- (event: 'get-networks-table', value: UI_I_TablePayload): void
155
- (event: 'get-pci-devices'): void
156
- (event: 'hide'): void
157
- }>()
158
-
159
- const localization = computed<UI_I_Localization>(() => useLocal())
160
-
161
- watch(
162
- () => props.capabilities,
163
- () => {
164
- if (props.capabilities) mapCapabilities(props.capabilities)
165
- },
166
- { deep: true, immediate: true }
167
- )
168
-
169
- const wizard: Wizard = new Wizard(
170
- stepsFunc(localization.value),
171
- stepsSchemeInitial
172
- )
173
- const selectedScheme = computed<number[]>(() => wizard.selectedScheme.value)
174
-
175
- const onChangeSteps = async (value: UI_I_WizardStep[]): Promise<void> => {
176
- wizard.changeSteps(value, validationFunc, validateSendData)
177
- }
178
-
179
- const validationFunc = async (
180
- value: UI_I_WizardStep[],
181
- currentStep: UI_I_WizardStep,
182
- nextStep: UI_I_WizardStep
183
- ): Promise<UI_I_ValidationReturn> => {
184
- let stepHasError = false
185
- let stepShouldStop = {
186
- ifOnCurrentStep: false,
187
- ifFromAnyStep: false,
188
- stoppageStepId: -1,
189
- }
190
-
191
- wizard.setLoader(true)
192
- if (wizard.isValidateForStep(0, currentStep.id, nextStep.id)) {
193
- const nameValidation = await checkName(value)
194
-
195
- value = nameValidation.newValue
196
- stepHasError = stepHasError || nameValidation.stepHasError
197
- } else if (wizard.isValidateForStep(1, currentStep.id, nextStep.id)) {
198
- const storageValidation = await checkStorage(value)
199
-
200
- value = storageValidation.newValue
201
-
202
- stepHasError = stepHasError || storageValidation.stepHasError
203
- } else if (wizard.isValidateForStep(2, currentStep.id, nextStep.id)) {
204
- selectOptionsSubmit.value++
205
- } else if (wizard.isValidateForStep(3, currentStep.id, nextStep.id)) {
206
- const storageValidation = await checkCustomizeHardware(value)
207
-
208
- value = storageValidation.newValue
209
-
210
- stepHasError = stepHasError || storageValidation.stepHasError
211
- }
212
- wizard.setLoader(false)
213
-
214
- return {
215
- newValue: value,
216
- stepHasError,
217
- stepShouldStop,
218
- }
219
- }
220
- const checkName = async (
221
- value: UI_I_WizardStep[]
222
- ): Promise<UI_I_ValidationReturn> => {
223
- let stepHasError = false
224
-
225
- return new Promise((resolve) => {
226
- nameFormSubmit.value = (isValid: boolean) => {
227
- if (!isValid) {
228
- stepHasError = wizard.setValidation(0, 'name', {
229
- fieldMessage: 'aaa',
230
- alertMessage: 'aaa',
231
- })
232
- } else if (wizard.hasMessage(0, 'name')) {
233
- value = wizard.removeValidation(0, 'name', value)
234
- }
235
-
236
- resolve({
237
- stepHasError,
238
- newValue: value,
239
- })
240
- nameFormSubmit.value = null
241
- }
242
- })
243
- }
244
- const checkStorage = async (
245
- value: UI_I_WizardStep[]
246
- ): Promise<UI_I_ValidationReturn> => {
247
- let stepHasError = false
248
-
249
- return new Promise((resolve) => {
250
- storageSubmit.value = (isValid: boolean) => {
251
- if (!isValid) {
252
- stepHasError = wizard.setValidation(1, 'storage', {
253
- fieldMessage: 'aaa',
254
- alertMessage: 'aaa',
255
- })
256
- } else if (wizard.hasMessage(1, 'storage')) {
257
- value = wizard.removeValidation(1, 'storage', value)
258
- }
259
-
260
- resolve({
261
- stepHasError,
262
- newValue: value,
263
- })
264
- storageSubmit.value = null
265
- }
266
- })
267
- }
268
- const checkCustomizeHardware = async (
269
- value: UI_I_WizardStep[]
270
- ): Promise<UI_I_ValidationReturn> => {
271
- let stepHasError = false
272
-
273
- return new Promise((resolve) => {
274
- customizeHardwareSubmit.value = (isValid: boolean) => {
275
- if (!isValid) {
276
- stepHasError = wizard.setValidation(3, 'customizeHardware', {
277
- fieldMessage: 'aaa',
278
- alertMessage: 'aaa',
279
- })
280
- } else if (wizard.hasMessage(3, 'customizeHardware')) {
281
- value = wizard.removeValidation(3, 'customizeHardware', value)
282
- }
283
-
284
- resolve({
285
- stepHasError,
286
- newValue: value,
287
- })
288
- storageSubmit.value = null
289
- }
290
- })
291
- }
292
-
293
- const storageIdCash = ref<string | null>(null)
294
- const vmForm = ref<UI_I_VmForm>({
295
- name: '',
296
- storage: null,
297
- options: [],
298
- })
299
- const onChangeName = (name: string): void => {
300
- vmForm.value.name = name
301
- }
302
- const onChangeStorage = (storage: UI_I_DatastoreTableItem | null): void => {
303
- if (!storage) return
304
-
305
- vmForm.value.storage = storage
306
- storageIdCash.value = storage.id
307
- }
308
- const onChangeSelectOptions = (options: string[]): void => {
309
- vmForm.value.options = options
310
- }
311
- const customizeHardware = ref<UI_I_SendDataCustomizeHardware | null>(null)
312
- const onChangeCustomizeHardware = (
313
- data: UI_I_SendDataCustomizeHardware
314
- ): void => {
315
- customizeHardware.value = data
316
- }
317
-
318
- const virtualHardwareHardDisksLocal = computed<
319
- UI_I_SendDataNewHardDisk[] | null
320
- >(() => customizeHardware.value?.virtualHardware?.hardDisks || null)
321
- const virtualHardwareNetworksLocal = computed<UI_I_SendDataNewNetwork[] | null>(
322
- () => customizeHardware.value?.virtualHardware?.networks || null
323
- )
324
- const virtualHardwareCdDvdDrivesLocal = computed<
325
- UI_I_SendDataNewCdDvdDrive[] | null
326
- >(() => customizeHardware.value?.virtualHardware?.cdDvdDrives || null)
327
-
328
- const virtualHardwareCpu = computed<UI_I_SendDataCpu | null>(
329
- () => customizeHardware.value?.virtualHardware?.cpu || null
330
- )
331
- const virtualHardwareMemory = computed<UI_I_SendDataMemory | null>(
332
- () => customizeHardware.value?.virtualHardware?.memory || null
333
- )
334
- const virtualHardwareHardDisks = ref<UI_I_SendDataNewHardDisk[] | null>(null)
335
- const virtualHardwareCdDvdDrives = ref<UI_I_SendDataNewCdDvdDrive[] | null>(
336
- null
337
- )
338
- const virtualHardwareNetworks = ref<UI_I_SendDataNewNetwork[] | null>(null)
339
- const onChangeBootOrder = (data: UI_T_ChangeBootOrder): void => {
340
- virtualHardwareHardDisks.value = data[0]
341
- virtualHardwareCdDvdDrives.value = data[1]
342
- virtualHardwareNetworks.value = data[2]
343
- }
344
-
345
- const isPowerOnByDefault = ref<boolean>(true)
346
-
347
- watch(
348
- () => props.vmNameInWizard,
349
- (newValue) => {
350
- vmForm.value.name = newValue
351
- }
352
- )
353
-
354
- const validateSendData = async (
355
- value: UI_I_WizardStep[]
356
- ): Promise<UI_I_ValidationReturn> => {
357
- wizard.setLoader(true)
358
- let stepHasError = false
359
-
360
- const data = await props.validateSendDataFunc(
361
- vmForm.value,
362
- virtualHardwareCpu.value,
363
- virtualHardwareMemory.value,
364
- customizeHardware.value,
365
- virtualHardwareNetworks.value,
366
- virtualHardwareHardDisks.value,
367
- virtualHardwareCdDvdDrives.value,
368
- isPowerOnByDefault.value,
369
- localization.value
370
- )
371
-
372
- wizard.setLoader(false)
373
- if (data) {
374
- stepHasError = true
375
- selectedNavItem.value = data[0]
376
- }
377
-
378
- return {
379
- stepHasError,
380
- newValue: value,
381
- }
382
- }
383
- const onFinish = (): void => {
384
- wizard.setLoader(false)
385
- props
386
- .finishFunc(
387
- vmForm.value,
388
- virtualHardwareCpu.value,
389
- virtualHardwareMemory.value,
390
- customizeHardware.value,
391
- virtualHardwareNetworks.value,
392
- virtualHardwareHardDisks.value,
393
- virtualHardwareCdDvdDrives.value,
394
- isPowerOnByDefault.value,
395
- localization.value
396
- )
397
- .then(() => {
398
- onHideModal()
399
- wizard.setLoader(false)
400
- })
401
- }
402
-
403
- const selectedNavItem = ref<UI_T_SelectedNavItem>(0)
404
-
405
- const nameFormSubmit = ref<null | Function>(null)
406
- const storageSubmit = ref<null | Function>(null)
407
- const selectOptionsSubmit = ref<number>(0)
408
- const customizeHardwareSubmit = ref<null | Function>(null)
409
-
410
- const vmSettings = computed<UI_I_VmSettings | null>(() => props.vmSettings)
411
- const vmName = ref<string>(vmSettings.value?.name || '')
412
- watch(vmSettings, (newValue) => {
413
- vmName.value = newValue?.name || ''
414
- })
415
-
416
- const onHideModal = (): void => {
417
- emits('hide')
418
- }
419
- </script>
420
-
421
- <style scoped lang="scss">
422
- :deep(.has-solid.close-icon.clr-icon) {
423
- width: 20px;
424
- top: 0;
425
- }
426
- .vm-context {
427
- padding: 16px 15px 10px 10px;
428
- height: 100%;
429
- display: flex;
430
- flex-direction: column;
431
-
432
- .context-title-wrap {
433
- padding-bottom: 3px;
434
- border-bottom: 1px solid #a6a6a6;
435
-
436
- h4 {
437
- font-weight: 700;
438
- font-size: 13px;
439
- color: var(--vm-context-title);
440
- }
441
- p {
442
- font-weight: 400;
443
- font-size: 13px;
444
- color: var(--vm-context-sub-title);
445
- }
446
- }
447
-
448
- .finish-block {
449
- padding: 18px 24px 24px 24px;
450
-
451
- .add-hosts-ready-to-complete-mt-12 {
452
- margin-top: 12px;
453
-
454
- .add-hosts-ready-to-complete-bold {
455
- line-height: 18px;
456
- font-weight: 700;
457
- }
458
- }
459
- }
460
-
461
- .vm-hardware-version {
462
- align-self: flex-end;
463
- margin-top: auto;
464
- }
465
- }
466
-
467
- :deep(.modal .modal-dialog .modal-content .modal-footer) {
468
- flex: unset;
469
- height: unset;
470
- min-height: unset;
471
- }
472
- :deep(.wizard-modal-titlebar h3) {
473
- color: #000;
474
- font-size: 24px;
475
- font-weight: 200;
476
- line-height: 27px;
477
- margin: 0;
478
- padding: 0;
479
- }
480
- :deep(.clr-wizard-stepnav-item) {
481
- padding-left: 0;
482
- }
483
- :deep(.clr-wizard-stepnav
484
- .clr-wizard-stepnav-item
485
- button
486
- .clr-wizard-stepnav-link-title) {
487
- width: 189px;
488
- font-weight: 700;
489
- font-size: 13px;
490
- }
491
-
492
- #vm-wizard-notification {
493
- h3 {
494
- color: var(--global-font-color7);
495
- margin-top: 6px;
496
- }
497
- p {
498
- color: var(--global-font-color6);
499
- line-height: 16px;
500
- }
501
- }
502
-
503
- .power-on-by-default-wrap {
504
- display: flex;
505
- align-items: center;
506
-
507
- input {
508
- margin-right: 6px;
509
- }
510
- }
511
- </style>
512
-
513
- <style>
514
- :root {
515
- --vm-context-title: #333;
516
- --vm-context-sub-title: #000;
517
- }
518
- :root.dark-theme {
519
- --vm-context-title: #adbbc4;
520
- --vm-context-sub-title: #adbbc4;
521
- }
522
- </style>
1
+ <template>
2
+ <div class="clone-vm">
3
+ <atoms-wizard
4
+ show
5
+ :wizard="wizard"
6
+ :selected-scheme="selectedScheme"
7
+ :title="localization.common.cloneExistingVirtualMachine"
8
+ :localization="localization"
9
+ @change-steps="onChangeSteps"
10
+ @hide="onHideModal"
11
+ @submit="onFinish"
12
+ >
13
+ <template #modalBody="{ selectedStep }">
14
+ <atoms-loader v-show="!vmSettings" id="loader" />
15
+ <div v-if="vmSettings" class="vm-context">
16
+ <common-vm-actions-common-select-name
17
+ v-show="selectedStep.id === 0"
18
+ :show="selectedStep.id === 0"
19
+ :name-form-submit="nameFormSubmit"
20
+ :project="props.project"
21
+ @submit="onChangeName(...$event)"
22
+ @check-name="emits('check-name', $event)"
23
+ />
24
+ <common-vm-actions-common-select-storage
25
+ v-show="selectedStep.id === 1"
26
+ :storage-submit="storageSubmit"
27
+ :datastore="props.datastore"
28
+ :storage="vmSettings.storage"
29
+ :get-datastore-table-func="props.getDatastoreTableFunc"
30
+ @submit="onChangeStorage"
31
+ />
32
+ <common-vm-actions-clone-select-options
33
+ v-show="selectedStep.id === 2"
34
+ :select-options-submit="selectOptionsSubmit"
35
+ @submit="onChangeSelectOptions"
36
+ />
37
+ <common-vm-actions-common-customize-hardware
38
+ v-show="selectedStep.id === 3"
39
+ v-model:vm-name="vmName"
40
+ v-model:guest-machine-type="vmSettings.guestMachineType"
41
+ v-model:guest-os-family="vmSettings.guestOsFamily"
42
+ v-model:guest-os-version="vmSettings.guestOsVersion"
43
+ :storage="vmSettings.storage"
44
+ :hard-disks-for-boot-options="virtualHardwareHardDisksLocal"
45
+ :cd-dvd-drives-for-boot-options="virtualHardwareCdDvdDrivesLocal"
46
+ :networks-for-boot-options="virtualHardwareNetworksLocal"
47
+ :cd-dvd-drives="vmSettings.cdDvdDrives"
48
+ :hard-disks="vmSettings.hardDisks"
49
+ :networks="vmSettings.networks"
50
+ :customize-hardware-submit="customizeHardwareSubmit"
51
+ :max-cpus="vmSettings.maxCpus"
52
+ :max-memory="vmSettings.maxMemory"
53
+ :cpu-models="vmSettings.cpuModels"
54
+ :cpu="vmSettings.cpu"
55
+ :memory="vmSettings.memory"
56
+ :video-card="vmSettings.videoCard"
57
+ :usb-controller="vmSettings.usbController"
58
+ :pci-devices="vmSettings.pciDevices"
59
+ :selected-nav-item="selectedNavItem"
60
+ :hard-disks-for-edit="vmSettings.hardDisks"
61
+ :options="vmSettings.options"
62
+ :nodes="props.nodes"
63
+ :files="props.files"
64
+ :networks-table="props.networksTable"
65
+ :error-validation-fields="props.errorValidationFields"
66
+ :vm-cpu-help-text-second="props.vmCpuHelpTextSecond"
67
+ :passthrough-devices="props.passthroughDevices"
68
+ :get-datastore-table-func="props.getDatastoreTableFunc"
69
+ :datastore="props.datastore"
70
+ :project="props.project"
71
+ is-clone
72
+ @change-boot-order="onChangeBootOrder"
73
+ @send-data="onChangeCustomizeHardware"
74
+ @get-storage="emits('get-storage', $event)"
75
+ @get-folders-or-files="emits('get-folders-or-files', $event)"
76
+ @get-active-device-child="emits('get-active-device-child', $event)"
77
+ @show-datastore-child="emits('show-datastore-child', $event)"
78
+ @get-networks-table="emits('get-networks-table', $event)"
79
+ @get-pci-devices="emits('get-pci-devices')"
80
+ />
81
+ <common-ready-to-complete
82
+ v-show="selectedStep.id === 4"
83
+ :data="props.readyCompleteTableInfo"
84
+ />
85
+ </div>
86
+ </template>
87
+ </atoms-wizard>
88
+ </div>
89
+ </template>
90
+
91
+ <script setup lang="ts">
92
+ import type {
93
+ UI_I_DatastoreTableItem,
94
+ UI_I_FolderOrFileTreePayload,
95
+ } from '~/lib/models/store/storage/interfaces'
96
+ import type { UI_I_NetworkTableItem } from '~/lib/models/store/network/interfaces'
97
+ import type { API_UI_I_Error } from '~/lib/models/store/interfaces'
98
+ import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
99
+ import type { UI_I_FileTreeNode } from '~/components/lib/models/interfaces'
100
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
101
+ import type { UI_I_SendDataCustomizeHardware } from '~/components/common/vm/actions/common/customizeHardware/lib/models/interfaces'
102
+ import type { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
103
+ import type {
104
+ UI_I_SendDataCpu,
105
+ UI_I_SendDataMemory,
106
+ UI_I_SendDataNewCdDvdDrive,
107
+ UI_I_SendDataNewHardDisk,
108
+ UI_I_SendDataNewNetwork,
109
+ } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
110
+ import type { UI_T_SelectedNavItem } from '~/components/common/vm/actions/common/lib/models/types'
111
+ import type { UI_I_TableInfoItem } from '~/components/atoms/table/info/lib/models/interfaces'
112
+ import type { UI_I_ConfigurePciDevicesTable } from '~/lib/models/store/host/interfaces'
113
+ import type { UI_T_ChangeBootOrder } from '~/components/common/vm/actions/lib/models/types'
114
+ import type { UI_T_Project } from '~/lib/models/types'
115
+ import type { UI_I_VmSettings } from '~/lib/models/store/vm/interfaces'
116
+ import type { UI_I_VmForm } from '~/components/common/vm/actions/clone/lib/models/interfaces'
117
+ import type {
118
+ UI_I_ValidationReturn,
119
+ UI_I_WizardStep,
120
+ } from '~/components/atoms/wizard/lib/models/interfaces'
121
+ import type { UI_I_Capabilities } from '~/components/common/vm/actions/common/lib/models/interfaces'
122
+ import {
123
+ stepsSchemeInitial,
124
+ stepsFunc,
125
+ } from '~/components/common/vm/actions/clone/lib/config/steps'
126
+ import Wizard from '~/components/atoms/wizard/lib/utils/utils'
127
+ import { mapCapabilities } from '~/components/common/vm/actions/common/lib/utils/capabilities'
128
+
129
+ const props = defineProps<{
130
+ project: UI_T_Project
131
+ vmSettings: UI_I_VmSettings | null
132
+ nodes: UI_I_FileTreeNode[]
133
+ files: UI_I_FileTreeNode[]
134
+ networksTable: UI_I_NetworkTableItem[]
135
+ datastore: UI_I_DatastoreTableItem[]
136
+ errorValidationFields: UI_I_ErrorValidationField[]
137
+ readyCompleteTableInfo: UI_I_TableInfoItem[]
138
+ vmCpuHelpTextSecond: string
139
+ finishFunc: any
140
+ getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
141
+ validateSendDataFunc: any
142
+ passthroughDevices: UI_I_ConfigurePciDevicesTable | null
143
+ vmNameInWizard: string
144
+ capabilities?: UI_I_Capabilities
145
+ }>()
146
+
147
+ const emits = defineEmits<{
148
+ (event: 'check-name', value: [string, (error: API_UI_I_Error) => void]): void
149
+ (event: 'get-storage', value: UI_I_TablePayload): void
150
+ (event: 'get-folders-or-files', value: UI_I_FolderOrFileTreePayload): void
151
+ (event: 'get-active-device-child', value: UI_I_FileTreeNode): void
152
+ (event: 'show-datastore-child', value: UI_I_FileTreeNode): void
153
+ (event: 'remove-error-by-title', value: string): void
154
+ (event: 'get-networks-table', value: UI_I_TablePayload): void
155
+ (event: 'get-pci-devices'): void
156
+ (event: 'hide'): void
157
+ }>()
158
+
159
+ const localization = computed<UI_I_Localization>(() => useLocal())
160
+
161
+ watch(
162
+ () => props.capabilities,
163
+ () => {
164
+ if (props.capabilities) mapCapabilities(props.capabilities)
165
+ },
166
+ { deep: true, immediate: true }
167
+ )
168
+
169
+ const wizard: Wizard = new Wizard(
170
+ stepsFunc(localization.value),
171
+ stepsSchemeInitial
172
+ )
173
+ const selectedScheme = computed<number[]>(() => wizard.selectedScheme.value)
174
+
175
+ const onChangeSteps = async (value: UI_I_WizardStep[]): Promise<void> => {
176
+ wizard.changeSteps(value, validationFunc, validateSendData)
177
+ }
178
+
179
+ const validationFunc = async (
180
+ value: UI_I_WizardStep[],
181
+ currentStep: UI_I_WizardStep,
182
+ nextStep: UI_I_WizardStep
183
+ ): Promise<UI_I_ValidationReturn> => {
184
+ let stepHasError = false
185
+ let stepShouldStop = {
186
+ ifOnCurrentStep: false,
187
+ ifFromAnyStep: false,
188
+ stoppageStepId: -1,
189
+ }
190
+
191
+ wizard.setLoader(true)
192
+ if (wizard.isValidateForStep(0, currentStep.id, nextStep.id)) {
193
+ const nameValidation = await checkName(value)
194
+
195
+ value = nameValidation.newValue
196
+ stepHasError = stepHasError || nameValidation.stepHasError
197
+ } else if (wizard.isValidateForStep(1, currentStep.id, nextStep.id)) {
198
+ const storageValidation = await checkStorage(value)
199
+
200
+ value = storageValidation.newValue
201
+
202
+ stepHasError = stepHasError || storageValidation.stepHasError
203
+ } else if (wizard.isValidateForStep(2, currentStep.id, nextStep.id)) {
204
+ selectOptionsSubmit.value++
205
+ } else if (wizard.isValidateForStep(3, currentStep.id, nextStep.id)) {
206
+ const storageValidation = await checkCustomizeHardware(value)
207
+
208
+ value = storageValidation.newValue
209
+
210
+ stepHasError = stepHasError || storageValidation.stepHasError
211
+ }
212
+ wizard.setLoader(false)
213
+
214
+ return {
215
+ newValue: value,
216
+ stepHasError,
217
+ stepShouldStop,
218
+ }
219
+ }
220
+ const checkName = async (
221
+ value: UI_I_WizardStep[]
222
+ ): Promise<UI_I_ValidationReturn> => {
223
+ let stepHasError = false
224
+
225
+ return new Promise((resolve) => {
226
+ nameFormSubmit.value = (isValid: boolean) => {
227
+ if (!isValid) {
228
+ stepHasError = wizard.setValidation(0, 'name', {
229
+ fieldMessage: 'aaa',
230
+ alertMessage: 'aaa',
231
+ })
232
+ } else if (wizard.hasMessage(0, 'name')) {
233
+ value = wizard.removeValidation(0, 'name', value)
234
+ }
235
+
236
+ resolve({
237
+ stepHasError,
238
+ newValue: value,
239
+ })
240
+ nameFormSubmit.value = null
241
+ }
242
+ })
243
+ }
244
+ const checkStorage = async (
245
+ value: UI_I_WizardStep[]
246
+ ): Promise<UI_I_ValidationReturn> => {
247
+ let stepHasError = false
248
+
249
+ return new Promise((resolve) => {
250
+ storageSubmit.value = (isValid: boolean) => {
251
+ if (!isValid) {
252
+ stepHasError = wizard.setValidation(1, 'storage', {
253
+ fieldMessage: 'aaa',
254
+ alertMessage: 'aaa',
255
+ })
256
+ } else if (wizard.hasMessage(1, 'storage')) {
257
+ value = wizard.removeValidation(1, 'storage', value)
258
+ }
259
+
260
+ resolve({
261
+ stepHasError,
262
+ newValue: value,
263
+ })
264
+ storageSubmit.value = null
265
+ }
266
+ })
267
+ }
268
+ const checkCustomizeHardware = async (
269
+ value: UI_I_WizardStep[]
270
+ ): Promise<UI_I_ValidationReturn> => {
271
+ let stepHasError = false
272
+
273
+ return new Promise((resolve) => {
274
+ customizeHardwareSubmit.value = (isValid: boolean) => {
275
+ if (!isValid) {
276
+ stepHasError = wizard.setValidation(3, 'customizeHardware', {
277
+ fieldMessage: 'aaa',
278
+ alertMessage: 'aaa',
279
+ })
280
+ } else if (wizard.hasMessage(3, 'customizeHardware')) {
281
+ value = wizard.removeValidation(3, 'customizeHardware', value)
282
+ }
283
+
284
+ resolve({
285
+ stepHasError,
286
+ newValue: value,
287
+ })
288
+ storageSubmit.value = null
289
+ }
290
+ })
291
+ }
292
+
293
+ const storageIdCash = ref<string | null>(null)
294
+ const vmForm = ref<UI_I_VmForm>({
295
+ name: '',
296
+ storage: null,
297
+ options: [],
298
+ })
299
+ const onChangeName = (name: string): void => {
300
+ vmForm.value.name = name
301
+ }
302
+ const onChangeStorage = (storage: UI_I_DatastoreTableItem | null): void => {
303
+ if (!storage) return
304
+
305
+ vmForm.value.storage = storage
306
+ storageIdCash.value = storage.id
307
+ }
308
+ const onChangeSelectOptions = (options: string[]): void => {
309
+ vmForm.value.options = options
310
+ }
311
+ const customizeHardware = ref<UI_I_SendDataCustomizeHardware | null>(null)
312
+ const onChangeCustomizeHardware = (
313
+ data: UI_I_SendDataCustomizeHardware
314
+ ): void => {
315
+ customizeHardware.value = data
316
+ }
317
+
318
+ const virtualHardwareHardDisksLocal = computed<
319
+ UI_I_SendDataNewHardDisk[] | null
320
+ >(() => customizeHardware.value?.virtualHardware?.hardDisks || null)
321
+ const virtualHardwareNetworksLocal = computed<UI_I_SendDataNewNetwork[] | null>(
322
+ () => customizeHardware.value?.virtualHardware?.networks || null
323
+ )
324
+ const virtualHardwareCdDvdDrivesLocal = computed<
325
+ UI_I_SendDataNewCdDvdDrive[] | null
326
+ >(() => customizeHardware.value?.virtualHardware?.cdDvdDrives || null)
327
+
328
+ const virtualHardwareCpu = computed<UI_I_SendDataCpu | null>(
329
+ () => customizeHardware.value?.virtualHardware?.cpu || null
330
+ )
331
+ const virtualHardwareMemory = computed<UI_I_SendDataMemory | null>(
332
+ () => customizeHardware.value?.virtualHardware?.memory || null
333
+ )
334
+ const virtualHardwareHardDisks = ref<UI_I_SendDataNewHardDisk[] | null>(null)
335
+ const virtualHardwareCdDvdDrives = ref<UI_I_SendDataNewCdDvdDrive[] | null>(
336
+ null
337
+ )
338
+ const virtualHardwareNetworks = ref<UI_I_SendDataNewNetwork[] | null>(null)
339
+ const onChangeBootOrder = (data: UI_T_ChangeBootOrder): void => {
340
+ virtualHardwareHardDisks.value = data[0]
341
+ virtualHardwareCdDvdDrives.value = data[1]
342
+ virtualHardwareNetworks.value = data[2]
343
+ }
344
+
345
+ const isPowerOnByDefault = ref<boolean>(true)
346
+
347
+ watch(
348
+ () => props.vmNameInWizard,
349
+ (newValue) => {
350
+ vmForm.value.name = newValue
351
+ }
352
+ )
353
+
354
+ const validateSendData = async (
355
+ value: UI_I_WizardStep[]
356
+ ): Promise<UI_I_ValidationReturn> => {
357
+ wizard.setLoader(true)
358
+ let stepHasError = false
359
+
360
+ const data = await props.validateSendDataFunc(
361
+ vmForm.value,
362
+ virtualHardwareCpu.value,
363
+ virtualHardwareMemory.value,
364
+ customizeHardware.value,
365
+ virtualHardwareNetworks.value,
366
+ virtualHardwareHardDisks.value,
367
+ virtualHardwareCdDvdDrives.value,
368
+ isPowerOnByDefault.value,
369
+ localization.value
370
+ )
371
+
372
+ wizard.setLoader(false)
373
+ if (data) {
374
+ stepHasError = true
375
+ selectedNavItem.value = data[0]
376
+ }
377
+
378
+ return {
379
+ stepHasError,
380
+ newValue: value,
381
+ }
382
+ }
383
+ const onFinish = (): void => {
384
+ wizard.setLoader(false)
385
+ props
386
+ .finishFunc(
387
+ vmForm.value,
388
+ virtualHardwareCpu.value,
389
+ virtualHardwareMemory.value,
390
+ customizeHardware.value,
391
+ virtualHardwareNetworks.value,
392
+ virtualHardwareHardDisks.value,
393
+ virtualHardwareCdDvdDrives.value,
394
+ isPowerOnByDefault.value,
395
+ localization.value
396
+ )
397
+ .then(() => {
398
+ onHideModal()
399
+ wizard.setLoader(false)
400
+ })
401
+ }
402
+
403
+ const selectedNavItem = ref<UI_T_SelectedNavItem>(0)
404
+
405
+ const nameFormSubmit = ref<null | Function>(null)
406
+ const storageSubmit = ref<null | Function>(null)
407
+ const selectOptionsSubmit = ref<number>(0)
408
+ const customizeHardwareSubmit = ref<null | Function>(null)
409
+
410
+ const vmSettings = computed<UI_I_VmSettings | null>(() => props.vmSettings)
411
+ const vmName = ref<string>(vmSettings.value?.name || '')
412
+ watch(vmSettings, (newValue) => {
413
+ vmName.value = newValue?.name || ''
414
+ })
415
+
416
+ const onHideModal = (): void => {
417
+ emits('hide')
418
+ }
419
+ </script>
420
+
421
+ <style scoped lang="scss">
422
+ :deep(.has-solid.close-icon.clr-icon) {
423
+ width: 20px;
424
+ top: 0;
425
+ }
426
+ .vm-context {
427
+ padding: 16px 15px 10px 10px;
428
+ height: 100%;
429
+ display: flex;
430
+ flex-direction: column;
431
+
432
+ .context-title-wrap {
433
+ padding-bottom: 3px;
434
+ border-bottom: 1px solid #a6a6a6;
435
+
436
+ h4 {
437
+ font-weight: 700;
438
+ font-size: 13px;
439
+ color: var(--vm-context-title);
440
+ }
441
+ p {
442
+ font-weight: 400;
443
+ font-size: 13px;
444
+ color: var(--vm-context-sub-title);
445
+ }
446
+ }
447
+
448
+ .finish-block {
449
+ padding: 18px 24px 24px 24px;
450
+
451
+ .add-hosts-ready-to-complete-mt-12 {
452
+ margin-top: 12px;
453
+
454
+ .add-hosts-ready-to-complete-bold {
455
+ line-height: 18px;
456
+ font-weight: 700;
457
+ }
458
+ }
459
+ }
460
+
461
+ .vm-hardware-version {
462
+ align-self: flex-end;
463
+ margin-top: auto;
464
+ }
465
+ }
466
+
467
+ :deep(.modal .modal-dialog .modal-content .modal-footer) {
468
+ flex: unset;
469
+ height: unset;
470
+ min-height: unset;
471
+ }
472
+ :deep(.wizard-modal-titlebar h3) {
473
+ color: #000;
474
+ font-size: 24px;
475
+ font-weight: 200;
476
+ line-height: 27px;
477
+ margin: 0;
478
+ padding: 0;
479
+ }
480
+ :deep(.clr-wizard-stepnav-item) {
481
+ padding-left: 0;
482
+ }
483
+ :deep(.clr-wizard-stepnav
484
+ .clr-wizard-stepnav-item
485
+ button
486
+ .clr-wizard-stepnav-link-title) {
487
+ width: 189px;
488
+ font-weight: 700;
489
+ font-size: 13px;
490
+ }
491
+
492
+ #vm-wizard-notification {
493
+ h3 {
494
+ color: var(--global-font-color7);
495
+ margin-top: 6px;
496
+ }
497
+ p {
498
+ color: var(--global-font-color6);
499
+ line-height: 16px;
500
+ }
501
+ }
502
+
503
+ .power-on-by-default-wrap {
504
+ display: flex;
505
+ align-items: center;
506
+
507
+ input {
508
+ margin-right: 6px;
509
+ }
510
+ }
511
+ </style>
512
+
513
+ <style>
514
+ :root {
515
+ --vm-context-title: #333;
516
+ --vm-context-sub-title: #000;
517
+ }
518
+ :root.dark-theme {
519
+ --vm-context-title: #adbbc4;
520
+ --vm-context-sub-title: #adbbc4;
521
+ }
522
+ </style>