bfg-common 1.4.71 → 1.4.73

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 (24) hide show
  1. package/components/common/vm/actions/clone/Clone.vue +522 -511
  2. package/components/common/vm/actions/common/customizeHardware/virtualHardware/bus/Bus.vue +13 -15
  3. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/CdDvdDrive.vue +1 -1
  4. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/CpuHotPlug.vue +1 -1
  5. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/CpuModel.vue +2 -2
  6. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/Hv.vue +1 -1
  7. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/Iommu.vue +1 -1
  8. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/Pc.vue +1 -1
  9. package/components/common/vm/actions/common/customizeHardware/virtualHardware/memory/MemoryHotPlug.vue +1 -1
  10. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/NewHardDisk.vue +1 -1
  11. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/Graphics.vue +1 -1
  12. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/Menu.vue +1 -1
  13. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/Secure.vue +1 -1
  14. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/Order.vue +1 -1
  15. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/CopyPaste.vue +1 -1
  16. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/FileTransfer.vue +1 -1
  17. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/FolderSharing.vue +1 -1
  18. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/PlaybackCompression.vue +1 -1
  19. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/PowerControl.vue +1 -1
  20. package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/password/Password.vue +1 -1
  21. package/components/common/vm/actions/common/customizeHardware/vmoptions/tools/Tools.vue +1 -1
  22. package/components/common/vm/actions/common/select/lib/models/interfaces.ts +0 -1
  23. package/components/common/vm/actions/editSettings/EditSettings.vue +327 -316
  24. package/package.json +1 -1
@@ -1,511 +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 {
122
- stepsSchemeInitial,
123
- stepsFunc,
124
- } from '~/components/common/vm/actions/clone/lib/config/steps'
125
- import Wizard from '~/components/atoms/wizard/lib/utils/utils'
126
-
127
- const props = defineProps<{
128
- project: UI_T_Project
129
- vmSettings: UI_I_VmSettings | null
130
- nodes: UI_I_FileTreeNode[]
131
- files: UI_I_FileTreeNode[]
132
- networksTable: UI_I_NetworkTableItem[]
133
- datastore: UI_I_DatastoreTableItem[]
134
- errorValidationFields: UI_I_ErrorValidationField[]
135
- readyCompleteTableInfo: UI_I_TableInfoItem[]
136
- vmCpuHelpTextSecond: string
137
- finishFunc: any
138
- getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
139
- validateSendDataFunc: any
140
- passthroughDevices: UI_I_ConfigurePciDevicesTable | null
141
- vmNameInWizard: string
142
- }>()
143
-
144
- const emits = defineEmits<{
145
- (event: 'check-name', value: [string, (error: API_UI_I_Error) => void]): void
146
- (event: 'get-storage', value: UI_I_TablePayload): void
147
- (event: 'get-folders-or-files', value: UI_I_FolderOrFileTreePayload): void
148
- (event: 'get-active-device-child', value: UI_I_FileTreeNode): void
149
- (event: 'show-datastore-child', value: UI_I_FileTreeNode): void
150
- (event: 'remove-error-by-title', value: string): void
151
- (event: 'get-networks-table', value: UI_I_TablePayload): void
152
- (event: 'get-pci-devices'): void
153
- (event: 'hide'): void
154
- }>()
155
-
156
- const localization = computed<UI_I_Localization>(() => useLocal())
157
-
158
- const wizard: Wizard = new Wizard(
159
- stepsFunc(localization.value),
160
- stepsSchemeInitial
161
- )
162
- const selectedScheme = computed<number[]>(() => wizard.selectedScheme.value)
163
-
164
- const onChangeSteps = async (value: UI_I_WizardStep[]): Promise<void> => {
165
- wizard.changeSteps(value, validationFunc, validateSendData)
166
- }
167
-
168
- const validationFunc = async (
169
- value: UI_I_WizardStep[],
170
- currentStep: UI_I_WizardStep,
171
- nextStep: UI_I_WizardStep
172
- ): Promise<UI_I_ValidationReturn> => {
173
- let stepHasError = false
174
- let stepShouldStop = {
175
- ifOnCurrentStep: false,
176
- ifFromAnyStep: false,
177
- stoppageStepId: -1,
178
- }
179
-
180
- wizard.setLoader(true)
181
- if (wizard.isValidateForStep(0, currentStep.id, nextStep.id)) {
182
- const nameValidation = await checkName(value)
183
-
184
- value = nameValidation.newValue
185
- stepHasError = stepHasError || nameValidation.stepHasError
186
- } else if (wizard.isValidateForStep(1, currentStep.id, nextStep.id)) {
187
- const storageValidation = await checkStorage(value)
188
-
189
- value = storageValidation.newValue
190
-
191
- stepHasError = stepHasError || storageValidation.stepHasError
192
- } else if (wizard.isValidateForStep(2, currentStep.id, nextStep.id)) {
193
- selectOptionsSubmit.value++
194
- } else if (wizard.isValidateForStep(3, currentStep.id, nextStep.id)) {
195
- const storageValidation = await checkCustomizeHardware(value)
196
-
197
- value = storageValidation.newValue
198
-
199
- stepHasError = stepHasError || storageValidation.stepHasError
200
- }
201
- wizard.setLoader(false)
202
-
203
- return {
204
- newValue: value,
205
- stepHasError,
206
- stepShouldStop,
207
- }
208
- }
209
- const checkName = async (
210
- value: UI_I_WizardStep[]
211
- ): Promise<UI_I_ValidationReturn> => {
212
- let stepHasError = false
213
-
214
- return new Promise((resolve) => {
215
- nameFormSubmit.value = (isValid: boolean) => {
216
- if (!isValid) {
217
- stepHasError = wizard.setValidation(0, 'name', {
218
- fieldMessage: 'aaa',
219
- alertMessage: 'aaa',
220
- })
221
- } else if (wizard.hasMessage(0, 'name')) {
222
- value = wizard.removeValidation(0, 'name', value)
223
- }
224
-
225
- resolve({
226
- stepHasError,
227
- newValue: value,
228
- })
229
- nameFormSubmit.value = null
230
- }
231
- })
232
- }
233
- const checkStorage = async (
234
- value: UI_I_WizardStep[]
235
- ): Promise<UI_I_ValidationReturn> => {
236
- let stepHasError = false
237
-
238
- return new Promise((resolve) => {
239
- storageSubmit.value = (isValid: boolean) => {
240
- if (!isValid) {
241
- stepHasError = wizard.setValidation(1, 'storage', {
242
- fieldMessage: 'aaa',
243
- alertMessage: 'aaa',
244
- })
245
- } else if (wizard.hasMessage(1, 'storage')) {
246
- value = wizard.removeValidation(1, 'storage', value)
247
- }
248
-
249
- resolve({
250
- stepHasError,
251
- newValue: value,
252
- })
253
- storageSubmit.value = null
254
- }
255
- })
256
- }
257
- const checkCustomizeHardware = async (
258
- value: UI_I_WizardStep[]
259
- ): Promise<UI_I_ValidationReturn> => {
260
- let stepHasError = false
261
-
262
- return new Promise((resolve) => {
263
- customizeHardwareSubmit.value = (isValid: boolean) => {
264
- if (!isValid) {
265
- stepHasError = wizard.setValidation(3, 'customizeHardware', {
266
- fieldMessage: 'aaa',
267
- alertMessage: 'aaa',
268
- })
269
- } else if (wizard.hasMessage(3, 'customizeHardware')) {
270
- value = wizard.removeValidation(3, 'customizeHardware', value)
271
- }
272
-
273
- resolve({
274
- stepHasError,
275
- newValue: value,
276
- })
277
- storageSubmit.value = null
278
- }
279
- })
280
- }
281
-
282
- const storageIdCash = ref<string | null>(null)
283
- const vmForm = ref<UI_I_VmForm>({
284
- name: '',
285
- storage: null,
286
- options: [],
287
- })
288
- const onChangeName = (name: string): void => {
289
- vmForm.value.name = name
290
- }
291
- const onChangeStorage = (storage: UI_I_DatastoreTableItem | null): void => {
292
- if (!storage) return
293
-
294
- vmForm.value.storage = storage
295
- storageIdCash.value = storage.id
296
- }
297
- const onChangeSelectOptions = (options: string[]): void => {
298
- vmForm.value.options = options
299
- }
300
- const customizeHardware = ref<UI_I_SendDataCustomizeHardware | null>(null)
301
- const onChangeCustomizeHardware = (
302
- data: UI_I_SendDataCustomizeHardware
303
- ): void => {
304
- customizeHardware.value = data
305
- }
306
-
307
- const virtualHardwareHardDisksLocal = computed<
308
- UI_I_SendDataNewHardDisk[] | null
309
- >(() => customizeHardware.value?.virtualHardware?.hardDisks || null)
310
- const virtualHardwareNetworksLocal = computed<UI_I_SendDataNewNetwork[] | null>(
311
- () => customizeHardware.value?.virtualHardware?.networks || null
312
- )
313
- const virtualHardwareCdDvdDrivesLocal = computed<
314
- UI_I_SendDataNewCdDvdDrive[] | null
315
- >(() => customizeHardware.value?.virtualHardware?.cdDvdDrives || null)
316
-
317
- const virtualHardwareCpu = computed<UI_I_SendDataCpu | null>(
318
- () => customizeHardware.value?.virtualHardware?.cpu || null
319
- )
320
- const virtualHardwareMemory = computed<UI_I_SendDataMemory | null>(
321
- () => customizeHardware.value?.virtualHardware?.memory || null
322
- )
323
- const virtualHardwareHardDisks = ref<UI_I_SendDataNewHardDisk[] | null>(null)
324
- const virtualHardwareCdDvdDrives = ref<UI_I_SendDataNewCdDvdDrive[] | null>(
325
- null
326
- )
327
- const virtualHardwareNetworks = ref<UI_I_SendDataNewNetwork[] | null>(null)
328
- const onChangeBootOrder = (data: UI_T_ChangeBootOrder): void => {
329
- virtualHardwareHardDisks.value = data[0]
330
- virtualHardwareCdDvdDrives.value = data[1]
331
- virtualHardwareNetworks.value = data[2]
332
- }
333
-
334
- const isPowerOnByDefault = ref<boolean>(true)
335
-
336
- watch(
337
- () => props.vmNameInWizard,
338
- (newValue) => {
339
- vmForm.value.name = newValue
340
- }
341
- )
342
-
343
- const validateSendData = async (
344
- value: UI_I_WizardStep[]
345
- ): Promise<UI_I_ValidationReturn> => {
346
- wizard.setLoader(true)
347
- let stepHasError = false
348
-
349
- const data = await props.validateSendDataFunc(
350
- vmForm.value,
351
- virtualHardwareCpu.value,
352
- virtualHardwareMemory.value,
353
- customizeHardware.value,
354
- virtualHardwareNetworks.value,
355
- virtualHardwareHardDisks.value,
356
- virtualHardwareCdDvdDrives.value,
357
- isPowerOnByDefault.value,
358
- localization.value
359
- )
360
-
361
- wizard.setLoader(false)
362
- if (data) {
363
- stepHasError = true
364
- selectedNavItem.value = data[0]
365
- }
366
-
367
- return {
368
- stepHasError,
369
- newValue: value,
370
- }
371
- }
372
- const onFinish = (): void => {
373
- wizard.setLoader(false)
374
- props
375
- .finishFunc(
376
- vmForm.value,
377
- virtualHardwareCpu.value,
378
- virtualHardwareMemory.value,
379
- customizeHardware.value,
380
- virtualHardwareNetworks.value,
381
- virtualHardwareHardDisks.value,
382
- virtualHardwareCdDvdDrives.value,
383
- isPowerOnByDefault.value,
384
- localization.value
385
- )
386
- .then(() => {
387
- onHideModal()
388
- wizard.setLoader(false)
389
- })
390
- }
391
-
392
- const selectedNavItem = ref<UI_T_SelectedNavItem>(0)
393
-
394
- const nameFormSubmit = ref<null | Function>(null)
395
- const storageSubmit = ref<null | Function>(null)
396
- const selectOptionsSubmit = ref<number>(0)
397
- const customizeHardwareSubmit = ref<null | Function>(null)
398
-
399
- const vmSettings = computed<UI_I_VmSettings | null>(() => props.vmSettings)
400
- const vmName = ref<string>(vmSettings.value?.name || '')
401
- watch(vmSettings, (newValue) => {
402
- vmName.value = newValue?.name || ''
403
- })
404
-
405
- const onHideModal = (): void => {
406
- emits('hide')
407
- }
408
- </script>
409
-
410
- <style scoped lang="scss">
411
- :deep(.has-solid.close-icon.clr-icon) {
412
- width: 20px;
413
- top: 0;
414
- }
415
- .vm-context {
416
- padding: 16px 15px 10px 10px;
417
- height: 100%;
418
- display: flex;
419
- flex-direction: column;
420
-
421
- .context-title-wrap {
422
- padding-bottom: 3px;
423
- border-bottom: 1px solid #a6a6a6;
424
-
425
- h4 {
426
- font-weight: 700;
427
- font-size: 13px;
428
- color: var(--vm-context-title);
429
- }
430
- p {
431
- font-weight: 400;
432
- font-size: 13px;
433
- color: var(--vm-context-sub-title);
434
- }
435
- }
436
-
437
- .finish-block {
438
- padding: 18px 24px 24px 24px;
439
-
440
- .add-hosts-ready-to-complete-mt-12 {
441
- margin-top: 12px;
442
-
443
- .add-hosts-ready-to-complete-bold {
444
- line-height: 18px;
445
- font-weight: 700;
446
- }
447
- }
448
- }
449
-
450
- .vm-hardware-version {
451
- align-self: flex-end;
452
- margin-top: auto;
453
- }
454
- }
455
-
456
- :deep(.modal .modal-dialog .modal-content .modal-footer) {
457
- flex: unset;
458
- height: unset;
459
- min-height: unset;
460
- }
461
- :deep(.wizard-modal-titlebar h3) {
462
- color: #000;
463
- font-size: 24px;
464
- font-weight: 200;
465
- line-height: 27px;
466
- margin: 0;
467
- padding: 0;
468
- }
469
- :deep(.clr-wizard-stepnav-item) {
470
- padding-left: 0;
471
- }
472
- :deep(.clr-wizard-stepnav
473
- .clr-wizard-stepnav-item
474
- button
475
- .clr-wizard-stepnav-link-title) {
476
- width: 189px;
477
- font-weight: 700;
478
- font-size: 13px;
479
- }
480
-
481
- #vm-wizard-notification {
482
- h3 {
483
- color: var(--global-font-color7);
484
- margin-top: 6px;
485
- }
486
- p {
487
- color: var(--global-font-color6);
488
- line-height: 16px;
489
- }
490
- }
491
-
492
- .power-on-by-default-wrap {
493
- display: flex;
494
- align-items: center;
495
-
496
- input {
497
- margin-right: 6px;
498
- }
499
- }
500
- </style>
501
-
502
- <style>
503
- :root {
504
- --vm-context-title: #333;
505
- --vm-context-sub-title: #000;
506
- }
507
- :root.dark-theme {
508
- --vm-context-title: #adbbc4;
509
- --vm-context-sub-title: #adbbc4;
510
- }
511
- </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>