bfg-common 1.3.76 → 1.3.78

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