bfg-common 1.3.28 → 1.3.30

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