bfg-common 1.3.409 → 1.3.411

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