bfg-common 1.3.349 → 1.3.350

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 (49) hide show
  1. package/components/atoms/TheIcon.vue +1081 -1602
  2. package/components/atoms/switch/Switch.vue +111 -111
  3. package/components/atoms/table/compact/Compact.vue +526 -526
  4. package/components/common/adapterManager/ui/table/Header.vue +93 -93
  5. package/components/common/adapterManager/ui/table/Table.vue +162 -162
  6. package/components/common/context/Context.vue +99 -99
  7. package/components/common/lib/config/states.ts +126 -126
  8. package/components/common/resource/progressBlock/ProgressBlock.vue +142 -142
  9. package/components/common/vm/actions/add/Add.vue +602 -602
  10. package/components/common/vm/actions/clone/Clone.vue +518 -518
  11. package/components/common/vm/actions/common/customizeHardware/CustomizeHardware.vue +273 -273
  12. package/components/common/vm/actions/common/customizeHardware/virtualHardware/VirtualHardware.vue +697 -697
  13. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/NewNetwork.vue +299 -299
  14. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/NewPciDevice.vue +165 -165
  15. package/components/common/vm/actions/common/select/computeResource/ComputeResource.vue +164 -164
  16. package/components/common/vm/actions/common/select/name/Name.vue +235 -235
  17. package/components/common/vm/actions/common/select/storage/Storage.vue +198 -198
  18. package/components/common/vm/actions/editSettings/EditSettings.vue +313 -313
  19. package/components/common/weekSelect/lib/config/options.ts +10 -10
  20. package/components/common/wizards/datastore/add/Add.vue +436 -434
  21. package/components/common/wizards/datastore/add/lib/config/stepItems.ts +191 -191
  22. package/components/common/wizards/datastore/add/lib/models/interfaces.ts +38 -38
  23. package/components/common/wizards/datastore/add/lib/utils.ts +70 -70
  24. package/components/common/wizards/datastore/add/local/createName/CreateName.vue +160 -160
  25. package/components/common/wizards/datastore/add/nfs/Nfs.vue +112 -112
  26. package/components/common/wizards/datastore/add/nfs/accessibility/Accessibility.vue +104 -104
  27. package/components/common/wizards/datastore/add/nfs/accessibility/tablesView/lib/config/compatibleTable.ts +62 -62
  28. package/components/common/wizards/datastore/add/nfs/accessibility/tablesView/lib/config/hostsTableItems.ts +53 -53
  29. package/components/common/wizards/datastore/add/readyComplete/ReadyComplete.vue +86 -86
  30. package/components/common/wizards/datastore/add/readyComplete/lib/config/propertiesDetails.ts +184 -184
  31. package/components/common/wizards/datastore/add/sharedStorm/SharedStorm.vue +2 -0
  32. package/components/common/wizards/datastore/add/sharedStorm/deviceSelection/DeviceSelection.vue +459 -452
  33. package/components/common/wizards/datastore/add/types/Types.vue +80 -80
  34. package/components/common/wizards/datastore/add/types/lib/config/typeOptions.ts +49 -49
  35. package/composables/useAppVersion.ts +21 -21
  36. package/composables/useEnvLanguage.ts +20 -20
  37. package/lib/utils/sendTask.ts +72 -72
  38. package/minify.js +146 -146
  39. package/package.json +1 -1
  40. package/public/spice-console/application/codec.js +257 -257
  41. package/public/spice-console/lib/rasterEngine.js +907 -907
  42. package/public/spice-console/network/spicechannel.js +369 -369
  43. package/store/main/lib/interfaces.ts +9 -9
  44. package/store/tasks/actions.ts +133 -133
  45. package/store/tasks/getters.ts +25 -25
  46. package/store/tasks/lib/models/interfaces.ts +18 -18
  47. package/store/tasks/mutations.ts +58 -58
  48. package/store/tasks/state.ts +16 -16
  49. package/components/atoms/TheIconOld.vue +0 -2444
@@ -1,434 +1,436 @@
1
- <template>
2
- <div class="new-datastore">
3
- <atoms-modal-by-steps
4
- test-id="add-datastore-wizard"
5
- :show="true"
6
- :title="localization.newDatastore"
7
- :step-items="stepItems"
8
- :step-position="stepPosition"
9
- :loading="loading"
10
- @finish="onAddDatastore"
11
- @next="onNextStep"
12
- @back="back"
13
- @change-step="onChangeStep"
14
- @hide="onHideModal"
15
- >
16
- <template #modalBody>
17
- <div class="new-datastore__body">
18
- <common-wizards-datastore-add-types
19
- v-show="stepPosition === 0"
20
- v-model:type="datastoreType"
21
- :project="props.mode"
22
- />
23
-
24
- <common-wizards-datastore-add-local
25
- v-show="datastoreType === 'local' && !isShowCompleteBlock"
26
- :mode="props.mode"
27
- :step-position="stepPosition"
28
- :datastore-type="datastoreType"
29
- :local-create-name-submit="localCreateNameSubmit"
30
- :datacenter-hosts="props.datacenterHosts"
31
- :is-main-filter="props.isMainFilter"
32
- @loading="(e) => (loading = e)"
33
- @submit="onSaveNameAndNextLocal"
34
- @main-filter="emits('main-filter', $event)"
35
- />
36
-
37
- <common-wizards-datastore-add-shared-storm
38
- v-show="datastoreType === 'shared-storm' && !isShowCompleteBlock"
39
- :mode="props.mode"
40
- :step-position="stepPosition"
41
- :datastore-type="datastoreType"
42
- :device-selection-submit="deviceSelectionSubmit"
43
- :datacenter-hosts="props.datacenterHosts"
44
- :is-main-filter="props.isMainFilter"
45
- @loading="(e) => (loading = e)"
46
- @submit="onSaveAndNextSharedStorm"
47
- @main-filter="emits('main-filter', $event)"
48
- />
49
-
50
- <common-wizards-datastore-add-nfs
51
- v-show="datastoreType === 'nfs' && !isShowCompleteBlock"
52
- :mode="props.mode"
53
- :step-position="stepPosition"
54
- :datastore-type="datastoreType"
55
- :nfs-configuration-submit="nfsConfigurationSubmit"
56
- :host-accessibility-submit="hostAccessibilitySubmit"
57
- :hosts="props.nfsHosts"
58
- @loading="(e) => (loading = e)"
59
- @change-nfs-version="updateNfsVersion"
60
- @submit="saveChangesAndNextNfs"
61
- />
62
-
63
- <common-wizards-datastore-add-ready-complete
64
- v-show="isShowCompleteBlock"
65
- :data-ready-view="dataReadyView"
66
- />
67
- </div>
68
- </template>
69
- </atoms-modal-by-steps>
70
- </div>
71
- </template>
72
-
73
- <script setup lang="ts">
74
- import { UI_I_Localization } from '~/lib/models/interfaces'
75
- import { UI_I_VerticalStepItem } from '~/components/atoms/lib/models/interfaces'
76
- import {
77
- UI_T_DatastoreType,
78
- UI_T_NfsType,
79
- UI_T_WizardDatastoreMode,
80
- } from '~/components/common/wizards/datastore/add/lib/models/types'
81
- import { UI_I_CreateDatastoreForm } from '~/components/common/wizards/datastore/add/lib/models/interfaces'
82
- import {
83
- UI_I_LunDisk,
84
- UI_I_SelectHostOptions,
85
- } from '~/components/common/wizards/datastore/add/sharedStorm/deviceSelection/lib/models/interfaces'
86
- import { stepItemsFunc } from '~/components/common/wizards/datastore/add/lib/config/stepItems'
87
- import { constructDataReadyViewFunc } from '~/components/common/wizards/datastore/add/readyComplete/lib/config/propertiesDetails'
88
-
89
- const props = defineProps<{
90
- // TODO refactoring to project
91
- mode: UI_T_WizardDatastoreMode
92
- finishFunc: (
93
- datastoreForm: UI_I_CreateDatastoreForm,
94
- datastoreType: UI_T_DatastoreType,
95
- version: UI_T_NfsType
96
- ) => Promise<void>
97
- datacenterHosts?: UI_I_SelectHostOptions[]
98
- nfsHosts?: any
99
- isMainFilter?: boolean
100
- }>()
101
- const emits = defineEmits<{
102
- (event: 'hide'): void
103
- (event: 'global-refresh'): void
104
- (event: 'main-filter', value: string): void
105
- }>()
106
-
107
- const localization = computed<UI_I_Localization>(() => useLocal())
108
-
109
- const loading = ref<boolean>(false)
110
- const datastoreType = ref<UI_T_DatastoreType>(
111
- props.mode === 'procurator' ? 'local' : 'shared-storm'
112
- )
113
- const nfsVersion = ref<UI_T_NfsType>('nfs-3')
114
-
115
- const stepPosition = ref<number>(0)
116
- const dataReadyView = ref<any>([])
117
-
118
- const datastoreForm = ref<UI_I_CreateDatastoreForm>({
119
- local: {
120
- name: '',
121
- hosts: [],
122
- type_code: 1,
123
- },
124
- sharedStorm: {
125
- name: '',
126
- dev_names: [],
127
- hosts: [],
128
- pool_name: '',
129
- type_code: 2,
130
- },
131
- nfs: {
132
- name: '',
133
- server: '',
134
- folder: '',
135
- readonly: false,
136
- version: nfsVersion.value,
137
- type_code: 4,
138
- hosts: [],
139
- },
140
- })
141
-
142
- const stepItems = computed<UI_I_VerticalStepItem[]>(() =>
143
- stepItemsFunc(localization.value, datastoreType.value, props.mode)
144
- )
145
-
146
- let cashStep = -1
147
- const onNextStep = (force = false): void => {
148
- const isValid = checkSubmit(force)
149
-
150
- if (!isValid) {
151
- return
152
- }
153
-
154
- const isDisabled = stepItems.value[cashStep]?.disabled
155
- if (cashStep !== -1 && !isDisabled) {
156
- stepPosition.value = cashStep
157
- cashStep = -1
158
- return
159
- }
160
-
161
- stepItems.value[stepPosition.value].complete = true
162
- stepItems.value[stepPosition.value + 1].disabled = false
163
- stepPosition.value++
164
- }
165
-
166
- const back = (): void => {
167
- stepPosition.value--
168
- }
169
-
170
- const onChangeStep = (key: number): void => {
171
- if (key < stepPosition.value) {
172
- stepPosition.value = key
173
- return
174
- }
175
-
176
- const isValid = checkSubmit()
177
-
178
- if (!isValid) {
179
- cashStep = key
180
- return
181
- }
182
-
183
- stepPosition.value = key
184
- }
185
- const onHideModal = (): void => {
186
- emits('hide')
187
- }
188
-
189
- const updateNfsVersion = (event: UI_T_NfsType): void => {
190
- nfsVersion.value = event
191
- const { name, server, folder, hosts } = datastoreForm.value.nfs
192
- saveChangesAndNextNfs({ name, server, folder, hosts }, false)
193
- }
194
-
195
- const localCreateNameSubmit = ref<number>(0)
196
-
197
- const nfsConfigurationSubmit = ref<number>(0)
198
- const hostAccessibilitySubmit = ref<number>(0)
199
-
200
- const deviceSelectionSubmit = ref<number>(0)
201
-
202
- const checkSubmit = (force = false): boolean => {
203
- if (datastoreType.value === 'local') {
204
- if (stepPosition.value === 1 && !force) {
205
- localCreateNameSubmit.value++
206
- return false
207
- }
208
- }
209
-
210
- if (datastoreType.value === 'shared-storm') {
211
- if (stepPosition.value === 1 && !force) {
212
- deviceSelectionSubmit.value++
213
- return false
214
- }
215
- }
216
-
217
- if (datastoreType.value === 'nfs') {
218
- if (stepPosition.value === 2 && !force) {
219
- nfsConfigurationSubmit.value++
220
- return false
221
- }
222
-
223
- if (props.mode === 'sphere' && stepPosition.value === 3 && !force) {
224
- hostAccessibilitySubmit.value++
225
- return false
226
- }
227
- // if (
228
- // ((stepPosition.value === 4 && nfsVersion.value === 'nfs-4.1') ||
229
- // (stepPosition.value === 3 && nfsVersion.value === 'nfs-3')) &&
230
- // !force
231
- // ) {
232
- // hostAccessibilitySubmit.value++
233
- // return false
234
- // }
235
- }
236
-
237
- return true
238
- }
239
-
240
- const isWizardModeForSphere = computed<boolean>(() => props.mode === 'sphere')
241
-
242
- const onSaveNameAndNextLocal = (event: any): void => {
243
- const { local } = datastoreForm.value
244
-
245
- if (isWizardModeForSphere.value) {
246
- local.name = event.name
247
- local.hosts.push(event.host)
248
- }
249
-
250
- if (!isWizardModeForSphere.value) {
251
- local.name = event
252
- }
253
-
254
- dataReadyView.value = constructDataReadyViewFunc(
255
- localization.value,
256
- 'local',
257
- event,
258
- isWizardModeForSphere.value
259
- )
260
-
261
- onNextStep(true)
262
- }
263
-
264
- const onSaveAndNextSharedStorm = (event: any): void => {
265
- const { sharedStorm } = datastoreForm.value
266
- sharedStorm.name = event.name
267
- sharedStorm.dev_names = event.lunDisk.map((lun: UI_I_LunDisk) => lun.name)
268
- sharedStorm.hosts = [event.host]
269
-
270
- dataReadyView.value = constructDataReadyViewFunc(
271
- localization.value,
272
- 'shared-storm',
273
- event,
274
- isWizardModeForSphere.value
275
- )
276
-
277
- onNextStep(true)
278
- }
279
- const saveChangesAndNextNfs = (event: any, next = true): void => {
280
- const { nfs } = datastoreForm.value
281
- nfs.name = event.name
282
- nfs.folder = event.folder
283
- nfs.server = event.server
284
- nfs.hosts = event.hosts
285
-
286
- // TODO refactoring
287
- const hostsNames = props.nfsHosts
288
- ? props.nfsHosts.items
289
- .filter((host) => event.hosts.includes(host.id))
290
- .map((host) => host.host)
291
- : []
292
-
293
- dataReadyView.value = constructDataReadyViewFunc(
294
- localization.value,
295
- 'nfs',
296
- {
297
- ...event,
298
- hosts: hostsNames,
299
- version: nfsVersion.value,
300
- },
301
- isWizardModeForSphere.value
302
- )
303
-
304
- next && onNextStep(true)
305
- }
306
-
307
- const isShowCompleteBlock = computed<boolean>(() => {
308
- // TODO refactoring
309
- const localStep = datastoreType.value === 'local' && stepPosition.value === 2
310
-
311
- const sharesStep =
312
- datastoreType.value === 'shared-storm' &&
313
- (props.mode === 'procurator'
314
- ? stepPosition.value === 3
315
- : stepPosition.value === 2)
316
-
317
- let nfsFirst
318
- if (props.mode === 'procurator') {
319
- nfsFirst =
320
- datastoreType.value === 'nfs' &&
321
- nfsVersion.value === 'nfs-3' &&
322
- stepPosition.value === 3
323
- } else {
324
- nfsFirst =
325
- datastoreType.value === 'nfs' &&
326
- nfsVersion.value === 'nfs-3' &&
327
- stepPosition.value === 4
328
- }
329
-
330
- let nfsSecond
331
- if (props.mode === 'procurator') {
332
- nfsSecond =
333
- datastoreType.value === 'nfs' &&
334
- nfsVersion.value === 'nfs-4.1' &&
335
- stepPosition.value === 3
336
- } else {
337
- nfsSecond =
338
- datastoreType.value === 'nfs' &&
339
- nfsVersion.value === 'nfs-4.1' &&
340
- stepPosition.value === 4
341
- }
342
-
343
- return localStep || sharesStep || nfsFirst || nfsSecond
344
- })
345
-
346
- const onAddDatastore = async (): Promise<void> => {
347
- loading.value = true
348
-
349
- props
350
- .finishFunc(datastoreForm.value, datastoreType.value, nfsVersion.value)
351
- .then(() => {
352
- emits('global-refresh')
353
- loading.value = false
354
- onHideModal()
355
- })
356
- }
357
-
358
- // const createDatastoreFromLocal = async (): Promise<API_UI_I_Error> => {
359
- // const { local } = datastoreForm.value
360
- //
361
- // return await createDatastore<Omit<UI_I_CreateDatastoreBodyRequest, 'pool_name'>>(
362
- // local
363
- // )
364
- // }
365
- // const createDatastoreFromSharedStorm = async (): Promise<API_UI_I_Error> => {
366
- // const {
367
- // sharedStorm: { dev_names: disks, ...sendData },
368
- // } = datastoreForm.value
369
- //
370
- // const { data, msg } = await getStoragePoolName<{ dev_names: string[] }>(
371
- // '/psm/api/v1/storage/lvm/create',
372
- // { dev_names: disks }
373
- // )
374
- //
375
- // if (!data && msg) return msg
376
- //
377
- // sendData.pool_name = data?.pool_name || ''
378
- //
379
- // return await createDatastore(sendData)
380
- // }
381
-
382
- // const createDatastoreFromNfs = async (): Promise<API_UI_I_Error> => {
383
- // const {
384
- // nfs: { server, folder, readonly, name, type_code: type },
385
- // } = datastoreForm.value
386
- //
387
- // const sendDataOne = {
388
- // server,
389
- // folder,
390
- // readonly,
391
- // version: nfsVersion.value === 'nfs-4.1' ? 4.1 : 3.0,
392
- // }
393
- //
394
- // const { data, msg } = await getStoragePoolName<UI_I_NfsPoolNameForm>(
395
- // '/psm/api/v1/storage/cnfs',
396
- // sendDataOne
397
- // )
398
- //
399
- // if (!data && msg) return msg
400
- //
401
- // const sendDataTwo = {
402
- // name,
403
- // type_code: type,
404
- // pool_name: data?.pool_name || '',
405
- // }
406
- //
407
- // return await createDatastore(sendDataTwo)
408
- // }
409
- </script>
410
-
411
- <style scoped lang="scss">
412
- @import '~/assets/scss/common/mixins.scss';
413
-
414
- .new-datastore {
415
- &__body {
416
- @include flex($dir: column);
417
- height: 100%;
418
- padding-left: 24px;
419
- }
420
- }
421
-
422
- .finish-block {
423
- padding: 18px 24px 24px 24px;
424
-
425
- .add-hosts-ready-to-complete-mt-12 {
426
- margin-top: 12px;
427
-
428
- .add-hosts-ready-to-complete-bold {
429
- line-height: 18px;
430
- font-weight: 700;
431
- }
432
- }
433
- }
434
- </style>
1
+ <template>
2
+ <div class="new-datastore">
3
+ <atoms-modal-by-steps
4
+ test-id="add-datastore-wizard"
5
+ :show="true"
6
+ :title="localization.newDatastore"
7
+ :step-items="stepItems"
8
+ :step-position="stepPosition"
9
+ :loading="loading"
10
+ @finish="onAddDatastore"
11
+ @next="onNextStep"
12
+ @back="back"
13
+ @change-step="onChangeStep"
14
+ @hide="onHideModal"
15
+ >
16
+ <template #modalBody>
17
+ <div class="new-datastore__body">
18
+ <common-wizards-datastore-add-types
19
+ v-show="stepPosition === 0"
20
+ v-model:type="datastoreType"
21
+ :project="props.mode"
22
+ />
23
+
24
+ <common-wizards-datastore-add-local
25
+ v-show="datastoreType === 'local' && !isShowCompleteBlock"
26
+ :mode="props.mode"
27
+ :step-position="stepPosition"
28
+ :datastore-type="datastoreType"
29
+ :local-create-name-submit="localCreateNameSubmit"
30
+ :datacenter-hosts="props.datacenterHosts"
31
+ :is-main-filter="props.isMainFilter"
32
+ @loading="(e) => (loading = e)"
33
+ @submit="onSaveNameAndNextLocal"
34
+ @main-filter="emits('main-filter', $event)"
35
+ />
36
+
37
+ <common-wizards-datastore-add-shared-storm
38
+ v-show="datastoreType === 'shared-storm' && !isShowCompleteBlock"
39
+ :mode="props.mode"
40
+ :step-position="stepPosition"
41
+ :datastore-type="datastoreType"
42
+ :device-selection-submit="deviceSelectionSubmit"
43
+ :datacenter-hosts="props.datacenterHosts"
44
+ :is-main-filter="props.isMainFilter"
45
+ :host-id="props.hostId"
46
+ @loading="(e) => (loading = e)"
47
+ @submit="onSaveAndNextSharedStorm"
48
+ @main-filter="emits('main-filter', $event)"
49
+ />
50
+
51
+ <common-wizards-datastore-add-nfs
52
+ v-show="datastoreType === 'nfs' && !isShowCompleteBlock"
53
+ :mode="props.mode"
54
+ :step-position="stepPosition"
55
+ :datastore-type="datastoreType"
56
+ :nfs-configuration-submit="nfsConfigurationSubmit"
57
+ :host-accessibility-submit="hostAccessibilitySubmit"
58
+ :hosts="props.nfsHosts"
59
+ @loading="(e) => (loading = e)"
60
+ @change-nfs-version="updateNfsVersion"
61
+ @submit="saveChangesAndNextNfs"
62
+ />
63
+
64
+ <common-wizards-datastore-add-ready-complete
65
+ v-show="isShowCompleteBlock"
66
+ :data-ready-view="dataReadyView"
67
+ />
68
+ </div>
69
+ </template>
70
+ </atoms-modal-by-steps>
71
+ </div>
72
+ </template>
73
+
74
+ <script setup lang="ts">
75
+ import { UI_I_Localization } from '~/lib/models/interfaces'
76
+ import { UI_I_VerticalStepItem } from '~/components/atoms/lib/models/interfaces'
77
+ import {
78
+ UI_T_DatastoreType,
79
+ UI_T_NfsType,
80
+ UI_T_WizardDatastoreMode,
81
+ } from '~/components/common/wizards/datastore/add/lib/models/types'
82
+ import { UI_I_CreateDatastoreForm } from '~/components/common/wizards/datastore/add/lib/models/interfaces'
83
+ import {
84
+ UI_I_LunDisk,
85
+ UI_I_SelectHostOptions,
86
+ } from '~/components/common/wizards/datastore/add/sharedStorm/deviceSelection/lib/models/interfaces'
87
+ import { stepItemsFunc } from '~/components/common/wizards/datastore/add/lib/config/stepItems'
88
+ import { constructDataReadyViewFunc } from '~/components/common/wizards/datastore/add/readyComplete/lib/config/propertiesDetails'
89
+
90
+ const props = defineProps<{
91
+ // TODO refactoring to project
92
+ mode: UI_T_WizardDatastoreMode
93
+ finishFunc: (
94
+ datastoreForm: UI_I_CreateDatastoreForm,
95
+ datastoreType: UI_T_DatastoreType,
96
+ version: UI_T_NfsType
97
+ ) => Promise<void>
98
+ datacenterHosts?: UI_I_SelectHostOptions[]
99
+ nfsHosts?: any
100
+ isMainFilter?: boolean
101
+ hostId?: string
102
+ }>()
103
+ const emits = defineEmits<{
104
+ (event: 'hide'): void
105
+ (event: 'global-refresh'): void
106
+ (event: 'main-filter', value: string): void
107
+ }>()
108
+
109
+ const localization = computed<UI_I_Localization>(() => useLocal())
110
+
111
+ const loading = ref<boolean>(false)
112
+ const datastoreType = ref<UI_T_DatastoreType>(
113
+ props.mode === 'procurator' ? 'local' : 'shared-storm'
114
+ )
115
+ const nfsVersion = ref<UI_T_NfsType>('nfs-3')
116
+
117
+ const stepPosition = ref<number>(0)
118
+ const dataReadyView = ref<any>([])
119
+
120
+ const datastoreForm = ref<UI_I_CreateDatastoreForm>({
121
+ local: {
122
+ name: '',
123
+ hosts: [],
124
+ type_code: 1,
125
+ },
126
+ sharedStorm: {
127
+ name: '',
128
+ dev_names: [],
129
+ hosts: [],
130
+ pool_name: '',
131
+ type_code: 2,
132
+ },
133
+ nfs: {
134
+ name: '',
135
+ server: '',
136
+ folder: '',
137
+ readonly: false,
138
+ version: nfsVersion.value,
139
+ type_code: 4,
140
+ hosts: [],
141
+ },
142
+ })
143
+
144
+ const stepItems = computed<UI_I_VerticalStepItem[]>(() =>
145
+ stepItemsFunc(localization.value, datastoreType.value, props.mode)
146
+ )
147
+
148
+ let cashStep = -1
149
+ const onNextStep = (force = false): void => {
150
+ const isValid = checkSubmit(force)
151
+
152
+ if (!isValid) {
153
+ return
154
+ }
155
+
156
+ const isDisabled = stepItems.value[cashStep]?.disabled
157
+ if (cashStep !== -1 && !isDisabled) {
158
+ stepPosition.value = cashStep
159
+ cashStep = -1
160
+ return
161
+ }
162
+
163
+ stepItems.value[stepPosition.value].complete = true
164
+ stepItems.value[stepPosition.value + 1].disabled = false
165
+ stepPosition.value++
166
+ }
167
+
168
+ const back = (): void => {
169
+ stepPosition.value--
170
+ }
171
+
172
+ const onChangeStep = (key: number): void => {
173
+ if (key < stepPosition.value) {
174
+ stepPosition.value = key
175
+ return
176
+ }
177
+
178
+ const isValid = checkSubmit()
179
+
180
+ if (!isValid) {
181
+ cashStep = key
182
+ return
183
+ }
184
+
185
+ stepPosition.value = key
186
+ }
187
+ const onHideModal = (): void => {
188
+ emits('hide')
189
+ }
190
+
191
+ const updateNfsVersion = (event: UI_T_NfsType): void => {
192
+ nfsVersion.value = event
193
+ const { name, server, folder, hosts } = datastoreForm.value.nfs
194
+ saveChangesAndNextNfs({ name, server, folder, hosts }, false)
195
+ }
196
+
197
+ const localCreateNameSubmit = ref<number>(0)
198
+
199
+ const nfsConfigurationSubmit = ref<number>(0)
200
+ const hostAccessibilitySubmit = ref<number>(0)
201
+
202
+ const deviceSelectionSubmit = ref<number>(0)
203
+
204
+ const checkSubmit = (force = false): boolean => {
205
+ if (datastoreType.value === 'local') {
206
+ if (stepPosition.value === 1 && !force) {
207
+ localCreateNameSubmit.value++
208
+ return false
209
+ }
210
+ }
211
+
212
+ if (datastoreType.value === 'shared-storm') {
213
+ if (stepPosition.value === 1 && !force) {
214
+ deviceSelectionSubmit.value++
215
+ return false
216
+ }
217
+ }
218
+
219
+ if (datastoreType.value === 'nfs') {
220
+ if (stepPosition.value === 2 && !force) {
221
+ nfsConfigurationSubmit.value++
222
+ return false
223
+ }
224
+
225
+ if (props.mode === 'sphere' && stepPosition.value === 3 && !force) {
226
+ hostAccessibilitySubmit.value++
227
+ return false
228
+ }
229
+ // if (
230
+ // ((stepPosition.value === 4 && nfsVersion.value === 'nfs-4.1') ||
231
+ // (stepPosition.value === 3 && nfsVersion.value === 'nfs-3')) &&
232
+ // !force
233
+ // ) {
234
+ // hostAccessibilitySubmit.value++
235
+ // return false
236
+ // }
237
+ }
238
+
239
+ return true
240
+ }
241
+
242
+ const isWizardModeForSphere = computed<boolean>(() => props.mode === 'sphere')
243
+
244
+ const onSaveNameAndNextLocal = (event: any): void => {
245
+ const { local } = datastoreForm.value
246
+
247
+ if (isWizardModeForSphere.value) {
248
+ local.name = event.name
249
+ local.hosts.push(event.host)
250
+ }
251
+
252
+ if (!isWizardModeForSphere.value) {
253
+ local.name = event
254
+ }
255
+
256
+ dataReadyView.value = constructDataReadyViewFunc(
257
+ localization.value,
258
+ 'local',
259
+ event,
260
+ isWizardModeForSphere.value
261
+ )
262
+
263
+ onNextStep(true)
264
+ }
265
+
266
+ const onSaveAndNextSharedStorm = (event: any): void => {
267
+ const { sharedStorm } = datastoreForm.value
268
+ sharedStorm.name = event.name
269
+ sharedStorm.dev_names = event.lunDisk.map((lun: UI_I_LunDisk) => lun.name)
270
+ sharedStorm.hosts = [event.host]
271
+
272
+ dataReadyView.value = constructDataReadyViewFunc(
273
+ localization.value,
274
+ 'shared-storm',
275
+ event,
276
+ isWizardModeForSphere.value
277
+ )
278
+
279
+ onNextStep(true)
280
+ }
281
+ const saveChangesAndNextNfs = (event: any, next = true): void => {
282
+ const { nfs } = datastoreForm.value
283
+ nfs.name = event.name
284
+ nfs.folder = event.folder
285
+ nfs.server = event.server
286
+ nfs.hosts = event.hosts
287
+
288
+ // TODO refactoring
289
+ const hostsNames = props.nfsHosts
290
+ ? props.nfsHosts.items
291
+ .filter((host) => event.hosts.includes(host.id))
292
+ .map((host) => host.host)
293
+ : []
294
+
295
+ dataReadyView.value = constructDataReadyViewFunc(
296
+ localization.value,
297
+ 'nfs',
298
+ {
299
+ ...event,
300
+ hosts: hostsNames,
301
+ version: nfsVersion.value,
302
+ },
303
+ isWizardModeForSphere.value
304
+ )
305
+
306
+ next && onNextStep(true)
307
+ }
308
+
309
+ const isShowCompleteBlock = computed<boolean>(() => {
310
+ // TODO refactoring
311
+ const localStep = datastoreType.value === 'local' && stepPosition.value === 2
312
+
313
+ const sharesStep =
314
+ datastoreType.value === 'shared-storm' &&
315
+ (props.mode === 'procurator'
316
+ ? stepPosition.value === 3
317
+ : stepPosition.value === 2)
318
+
319
+ let nfsFirst
320
+ if (props.mode === 'procurator') {
321
+ nfsFirst =
322
+ datastoreType.value === 'nfs' &&
323
+ nfsVersion.value === 'nfs-3' &&
324
+ stepPosition.value === 3
325
+ } else {
326
+ nfsFirst =
327
+ datastoreType.value === 'nfs' &&
328
+ nfsVersion.value === 'nfs-3' &&
329
+ stepPosition.value === 4
330
+ }
331
+
332
+ let nfsSecond
333
+ if (props.mode === 'procurator') {
334
+ nfsSecond =
335
+ datastoreType.value === 'nfs' &&
336
+ nfsVersion.value === 'nfs-4.1' &&
337
+ stepPosition.value === 3
338
+ } else {
339
+ nfsSecond =
340
+ datastoreType.value === 'nfs' &&
341
+ nfsVersion.value === 'nfs-4.1' &&
342
+ stepPosition.value === 4
343
+ }
344
+
345
+ return localStep || sharesStep || nfsFirst || nfsSecond
346
+ })
347
+
348
+ const onAddDatastore = async (): Promise<void> => {
349
+ loading.value = true
350
+
351
+ props
352
+ .finishFunc(datastoreForm.value, datastoreType.value, nfsVersion.value)
353
+ .then(() => {
354
+ emits('global-refresh')
355
+ loading.value = false
356
+ onHideModal()
357
+ })
358
+ }
359
+
360
+ // const createDatastoreFromLocal = async (): Promise<API_UI_I_Error> => {
361
+ // const { local } = datastoreForm.value
362
+ //
363
+ // return await createDatastore<Omit<UI_I_CreateDatastoreBodyRequest, 'pool_name'>>(
364
+ // local
365
+ // )
366
+ // }
367
+ // const createDatastoreFromSharedStorm = async (): Promise<API_UI_I_Error> => {
368
+ // const {
369
+ // sharedStorm: { dev_names: disks, ...sendData },
370
+ // } = datastoreForm.value
371
+ //
372
+ // const { data, msg } = await getStoragePoolName<{ dev_names: string[] }>(
373
+ // '/psm/api/v1/storage/lvm/create',
374
+ // { dev_names: disks }
375
+ // )
376
+ //
377
+ // if (!data && msg) return msg
378
+ //
379
+ // sendData.pool_name = data?.pool_name || ''
380
+ //
381
+ // return await createDatastore(sendData)
382
+ // }
383
+
384
+ // const createDatastoreFromNfs = async (): Promise<API_UI_I_Error> => {
385
+ // const {
386
+ // nfs: { server, folder, readonly, name, type_code: type },
387
+ // } = datastoreForm.value
388
+ //
389
+ // const sendDataOne = {
390
+ // server,
391
+ // folder,
392
+ // readonly,
393
+ // version: nfsVersion.value === 'nfs-4.1' ? 4.1 : 3.0,
394
+ // }
395
+ //
396
+ // const { data, msg } = await getStoragePoolName<UI_I_NfsPoolNameForm>(
397
+ // '/psm/api/v1/storage/cnfs',
398
+ // sendDataOne
399
+ // )
400
+ //
401
+ // if (!data && msg) return msg
402
+ //
403
+ // const sendDataTwo = {
404
+ // name,
405
+ // type_code: type,
406
+ // pool_name: data?.pool_name || '',
407
+ // }
408
+ //
409
+ // return await createDatastore(sendDataTwo)
410
+ // }
411
+ </script>
412
+
413
+ <style scoped lang="scss">
414
+ @import '~/assets/scss/common/mixins.scss';
415
+
416
+ .new-datastore {
417
+ &__body {
418
+ @include flex($dir: column);
419
+ height: 100%;
420
+ padding-left: 24px;
421
+ }
422
+ }
423
+
424
+ .finish-block {
425
+ padding: 18px 24px 24px 24px;
426
+
427
+ .add-hosts-ready-to-complete-mt-12 {
428
+ margin-top: 12px;
429
+
430
+ .add-hosts-ready-to-complete-bold {
431
+ line-height: 18px;
432
+ font-weight: 700;
433
+ }
434
+ }
435
+ }
436
+ </style>