bfg-common 1.4.227 → 1.4.229

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