bfg-common 1.3.467 → 1.3.468

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 (109) hide show
  1. package/assets/scss/common/normalize.scss +340 -340
  2. package/components/atoms/TheIcon2.vue +1353 -1353
  3. package/components/atoms/loader/Loader.vue +30 -30
  4. package/components/atoms/loader/PreLoader.vue +38 -38
  5. package/components/atoms/switch/Switch.vue +111 -111
  6. package/components/atoms/table/compact/Compact.vue +526 -526
  7. package/components/common/adapterManager/ui/table/Header.vue +93 -93
  8. package/components/common/adapterManager/ui/table/Table.vue +162 -162
  9. package/components/common/context/Context.vue +99 -99
  10. package/components/common/layout/theHeader/LanguageSwitch.vue +102 -0
  11. package/components/common/layout/theHeader/TheHeader.vue +91 -0
  12. package/components/common/layout/theHeader/TheHeaderNew.vue +229 -0
  13. package/components/common/layout/theHeader/TheHeaderOld.vue +241 -0
  14. package/components/common/layout/theHeader/feedback/Feedback.vue +104 -0
  15. package/components/common/layout/theHeader/feedback/FeedbackNew.vue +63 -0
  16. package/components/common/layout/theHeader/feedback/FeedbackOld.vue +73 -0
  17. package/components/common/layout/theHeader/helpMenu/About.vue +110 -0
  18. package/components/common/layout/theHeader/helpMenu/HelpMenu.vue +45 -0
  19. package/components/common/layout/theHeader/helpMenu/helpMenuNew/HelpMenuNew.vue +112 -0
  20. package/components/common/layout/theHeader/helpMenu/helpMenuNew/lib/config/dropMenu.ts +25 -0
  21. package/components/common/layout/theHeader/helpMenu/helpMenuOld/HelpMenuOld.vue +69 -0
  22. package/components/common/layout/theHeader/helpMenu/helpMenuOld/lib/config/dropMenu.ts +22 -0
  23. package/components/common/layout/theHeader/helpMenu/helpMenuOld/lib/models/types.ts +1 -0
  24. package/components/common/layout/theHeader/lib/models/types.ts +5 -0
  25. package/components/common/layout/theHeader/modals/Reconnect.vue +98 -0
  26. package/components/common/layout/theHeader/modals/RedirectLogin.vue +60 -0
  27. package/components/common/layout/theHeader/userMenu/UserMenu.vue +95 -0
  28. package/components/common/layout/theHeader/userMenu/lib/models/interfaces.ts +32 -0
  29. package/components/common/layout/theHeader/userMenu/modals/changePassword/ChangePassword.vue +210 -0
  30. package/components/common/layout/theHeader/userMenu/modals/changePassword/lib/config/form.ts +31 -0
  31. package/components/common/layout/theHeader/userMenu/modals/changePassword/lib/models/interfaces.ts +12 -0
  32. package/components/common/layout/theHeader/userMenu/modals/preferences/Inventory.vue +43 -0
  33. package/components/common/layout/theHeader/userMenu/modals/preferences/Preferences.vue +119 -0
  34. package/components/common/layout/theHeader/userMenu/modals/preferences/View.vue +113 -0
  35. package/components/common/layout/theHeader/userMenu/modals/preferences/changeLanguage/ChangeLanguage.vue +148 -0
  36. package/components/common/layout/theHeader/userMenu/modals/preferences/changeLanguage/lib/config/lang.ts +10 -0
  37. package/components/common/layout/theHeader/userMenu/modals/preferences/changeLanguage/lib/config/radioOptions.ts +22 -0
  38. package/components/common/layout/theHeader/userMenu/modals/preferences/changeLanguage/lib/models/enums.ts +9 -0
  39. package/components/common/layout/theHeader/userMenu/modals/preferences/changeLanguage/lib/models/interfaces.ts +11 -0
  40. package/components/common/layout/theHeader/userMenu/modals/preferences/changeLanguage/lib/models/types.ts +1 -0
  41. package/components/common/layout/theHeader/userMenu/modals/preferences/defaultConsole/DefaultConsole.vue +66 -0
  42. package/components/common/layout/theHeader/userMenu/modals/preferences/defaultConsole/lib/config/consoleOptions.ts +30 -0
  43. package/components/common/layout/theHeader/userMenu/modals/preferences/defaultConsole/lib/models/interfaces.ts +5 -0
  44. package/components/common/layout/theHeader/userMenu/modals/preferences/lib/config/preferencesTabs.ts +68 -0
  45. package/components/common/layout/theHeader/userMenu/modals/preferences/lib/models/types.ts +1 -0
  46. package/components/common/layout/theHeader/userMenu/modals/preferences/timeFormat/TimeFormat.vue +67 -0
  47. package/components/common/layout/theHeader/userMenu/modals/preferences/timeFormat/lib/config/formatOptions.ts +27 -0
  48. package/components/common/layout/theHeader/userMenu/modals/preferences/timeFormat/lib/models/types.ts +1 -0
  49. package/components/common/layout/theHeader/userMenu/userMenuNew/UserMenuNew.vue +114 -0
  50. package/components/common/layout/theHeader/userMenu/userMenuNew/lib/config/dropMenu.ts +28 -0
  51. package/components/common/layout/theHeader/userMenu/userMenuOld/UserMenuOld.vue +36 -0
  52. package/components/common/layout/theHeader/userMenu/userMenuOld/lib/config/dropMenu.ts +36 -0
  53. package/components/common/layout/theHeader/userMenu/userMenuOld/lib/models/types.ts +5 -0
  54. package/components/common/lib/config/states.ts +160 -160
  55. package/components/common/mainNavigationPanel/MainNavigationPanel.vue +142 -142
  56. package/components/common/mainNavigationPanel/MainNavigationPanelNew.vue +248 -248
  57. package/components/common/mainNavigationPanel/MainNavigationPanelOld.vue +288 -288
  58. package/components/common/readyToComplete/ReadyToComplete.vue +15 -15
  59. package/components/common/resource/progressBlock/ProgressBlock.vue +142 -142
  60. package/components/common/split/horizontal/Horizontal.vue +70 -70
  61. package/components/common/vm/actions/clone/Clone.vue +511 -511
  62. package/components/common/vm/actions/common/customizeHardware/CustomizeHardware.vue +273 -273
  63. package/components/common/vm/actions/common/customizeHardware/virtualHardware/VirtualHardware.vue +697 -697
  64. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/Cpu.vue +400 -400
  65. package/components/common/vm/actions/common/customizeHardware/virtualHardware/memory/Memory.vue +329 -329
  66. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/NewNetwork.vue +305 -305
  67. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/NewPciDevice.vue +168 -168
  68. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newUsbController/NewUsbController.vue +82 -82
  69. package/components/common/vm/actions/common/customizeHardware/virtualHardware/other/Other.vue +32 -32
  70. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/VideoCard.vue +182 -182
  71. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/BootOptions.vue +114 -114
  72. package/components/common/vm/actions/common/customizeHardware/vmoptions/generalOptions/GeneralOptions.vue +192 -192
  73. package/components/common/vm/actions/common/customizeHardware/vmoptions/tools/Tools.vue +72 -72
  74. package/components/common/vm/actions/common/select/computeResource/ComputeResource.vue +164 -164
  75. package/components/common/vm/actions/common/select/name/Name.vue +235 -235
  76. package/components/common/vm/actions/common/select/storage/Storage.vue +198 -198
  77. package/components/common/vm/actions/editSettings/EditSettings.vue +316 -316
  78. package/components/common/weekSelect/lib/config/options.ts +10 -10
  79. package/components/common/wizards/datastore/add/Add.vue +436 -436
  80. package/components/common/wizards/datastore/add/lib/config/stepItems.ts +191 -191
  81. package/components/common/wizards/datastore/add/lib/models/interfaces.ts +38 -38
  82. package/components/common/wizards/datastore/add/lib/utils.ts +70 -70
  83. package/components/common/wizards/datastore/add/local/createName/CreateName.vue +160 -160
  84. package/components/common/wizards/datastore/add/nfs/Nfs.vue +112 -112
  85. package/components/common/wizards/datastore/add/nfs/accessibility/Accessibility.vue +104 -104
  86. package/components/common/wizards/datastore/add/nfs/accessibility/tablesView/lib/config/compatibleTable.ts +62 -62
  87. package/components/common/wizards/datastore/add/nfs/accessibility/tablesView/lib/config/hostsTableItems.ts +53 -53
  88. package/components/common/wizards/datastore/add/readyComplete/ReadyComplete.vue +86 -86
  89. package/components/common/wizards/datastore/add/readyComplete/lib/config/propertiesDetails.ts +184 -184
  90. package/components/common/wizards/datastore/add/sharedStorm/deviceSelection/DeviceSelection.vue +459 -459
  91. package/components/common/wizards/datastore/add/types/Types.vue +80 -80
  92. package/components/common/wizards/datastore/add/types/lib/config/typeOptions.ts +49 -49
  93. package/composables/useAppVersion.ts +22 -22
  94. package/composables/useEnvLanguage.ts +20 -20
  95. package/lib/utils/sendTask.ts +73 -73
  96. package/minify.js +146 -146
  97. package/package.json +2 -1
  98. package/plugins/spice-console/spice.console.ts +147 -147
  99. package/public/spice-console/application/codec.js +263 -263
  100. package/public/spice-console/lib/rasterEngine.js +907 -907
  101. package/public/spice-console/network/spicechannel.js +375 -375
  102. package/store/main/lib/interfaces.ts +9 -9
  103. package/store/tasks/actions.ts +133 -133
  104. package/store/tasks/getters.ts +25 -25
  105. package/store/tasks/lib/models/interfaces.ts +18 -18
  106. package/store/tasks/mutations.ts +58 -58
  107. package/store/tasks/state.ts +16 -16
  108. /package/components/{layout → common/layout}/theHeader/lib/models/enums.ts +0 -0
  109. /package/components/{layout → common/layout}/theHeader/lib/utils/localization.ts +0 -0
@@ -1,436 +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
- :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>
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>