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,459 +1,459 @@
1
- <template>
2
- <div class="device-selection">
3
- <atoms-alert
4
- v-show="errors.length"
5
- test-id="device-selection-errors"
6
- status="alert-danger"
7
- :items="errors"
8
- @remove="onCloseAlertDanger"
9
- />
10
-
11
- <div class="clr-form-control clr-row">
12
- <label for="" class="clr-control-label clr-col-md-2">{{
13
- localization.name
14
- }}</label>
15
-
16
- <div
17
- class="clr-control-container"
18
- :class="formErrors.errors?.name?.length && 'clr-error'"
19
- >
20
- <div class="flex-align-center">
21
- <input
22
- id="device-selection-input"
23
- v-model="form.name.value"
24
- data-id="device-selection-input"
25
- type="text"
26
- class="clr-input"
27
- @blur="initValidation"
28
- @input="onInput"
29
- />
30
- <atoms-the-icon class="error-icon" name="info-circle" />
31
- </div>
32
-
33
- <div class="clr-subtext ng-star-inserted">
34
- {{ formErrors?.errors?.name?.[0] || '' }}
35
- </div>
36
- </div>
37
- </div>
38
-
39
- <atoms-alert
40
- v-show="alertInfo"
41
- test-id="device-selection-info"
42
- class="device-selection__alert-info"
43
- status="alert-info"
44
- :items="[localization.nameAndDeviceSelectionAlertInfo]"
45
- @remove="onHideAlertInfo"
46
- />
47
-
48
- <div
49
- v-if="props.mode === 'sphere' && !props.hostId"
50
- class="clr-form-control clr-row"
51
- >
52
- <label class="clr-control-label clr-col-12 clr-col-md-2">{{
53
- localization.selectHost
54
- }}</label>
55
-
56
- <div>
57
- <div class="clr-select-wrapper">
58
- <select
59
- id="device-host-select"
60
- v-model="selectedHost"
61
- data-id="device-host-select"
62
- class="dropdown-toggle"
63
- @change="onSelectHost"
64
- >
65
- <option
66
- v-for="(item, index) in hostOptions"
67
- :key="index"
68
- :value="item.value"
69
- :disabled="item.disabled"
70
- >
71
- {{ item.text }}
72
- </option>
73
- </select>
74
- </div>
75
- <div class="clr-subtext">
76
- {{ localization.selectHostToViewAccessible }}
77
- </div>
78
- </div>
79
- </div>
80
-
81
- <div class="device-selection__disk-list">
82
- <common-wizards-datastore-add-shared-storm-device-selection-host-table
83
- v-model:selected="selectedLunDisk"
84
- :data-table="dataTable?.items || []"
85
- :total-items="dataTable?.total_items || 0"
86
- :total-pages="dataTable?.total_pages || 1"
87
- :pagination="pagination"
88
- :loading="loading"
89
- :is-main-filter="props.isMainFilter"
90
- @pagination="updatePagination"
91
- @sort="sortTable"
92
- @main-filter="emits('main-filter', $event)"
93
- />
94
- </div>
95
- </div>
96
- </template>
97
-
98
- <script lang="ts" setup>
99
- import { UI_I_ValidationTouchResult } from '~/lib/models/plugins/validation/interfaces'
100
- // import { UI_I_SchemaTablePayload } from '~/lib/models/store/interfaces'
101
- import { UI_I_Localization } from '~/lib/models/interfaces'
102
- import {
103
- API_UI_I_DataTable,
104
- UI_I_Pagination,
105
- UI_I_DataTableQuery,
106
- } from '~/lib/models/table/interfaces'
107
- import {
108
- UI_I_CreateStorageLunDiskItem,
109
- UI_I_DeviceSelectionSendData,
110
- UI_I_FormValidationDataStore,
111
- UI_I_LunDiskSpherePayload,
112
- UI_I_SelectHostOptions,
113
- } from '~/components/common/wizards/datastore/add/sharedStorm/deviceSelection/lib/models/interfaces'
114
- // import { Ui_T_HostSelectedType } from '~/components/common/wizards/datastore/add/sharedStorm/deviceSelection/lib/models/types'
115
- import {
116
- UI_T_DatastoreType,
117
- UI_T_WizardDatastoreMode,
118
- } from '~/components/common/wizards/datastore/add/lib/models/types'
119
- import { defaultFormFunc } from '~/components/common/wizards/datastore/add/sharedStorm/deviceSelection/lib/config/defaultForm'
120
- import { hostsOptionsFunc } from '~/components/common/wizards/datastore/add/sharedStorm/deviceSelection/lib/config/selectOptions'
121
- import { checkValidityName } from '~/components/common/wizards/datastore/add/lib/utils'
122
-
123
- const props = defineProps<{
124
- mode: UI_T_WizardDatastoreMode
125
- deviceSelectionSubmit: number
126
- lunDisk: UI_I_CreateStorageLunDiskItem[]
127
- stepPosition: number
128
- datastoreType: UI_T_DatastoreType
129
- datacenterHosts?: UI_I_SelectHostOptions[] | undefined
130
- isMainFilter?: boolean
131
- hostId?: string
132
- }>()
133
- const emits = defineEmits<{
134
- (event: 'loading', value: boolean): void
135
- (event: 'submit', value: UI_I_DeviceSelectionSendData): void
136
- (
137
- event: 'update:lun-disk',
138
- value: UI_I_CreateStorageLunDiskItem[] | null
139
- ): void
140
- (event: 'main-filter', value: string): void
141
- }>()
142
-
143
- const localization = computed<UI_I_Localization>(() => useLocal())
144
- const { $store } = useNuxtApp()
145
- const { $validation } = useNuxtApp()
146
-
147
- const isInitDatastoreNameValidation = ref<boolean>(false)
148
- const initValidation = (): void => {
149
- isInitDatastoreNameValidation.value = true
150
- const valid = validation.touch()
151
- if (!valid.isValid) {
152
- showValidationErrors(valid)
153
- }
154
- }
155
- const onInput = (): void => {
156
- const valid = validation.touch()
157
-
158
- if (!isInitDatastoreNameValidation.value) return
159
-
160
- valid.isValid ? removeInputValidation() : showValidationErrors(valid)
161
- }
162
-
163
- const validation = $validation.call({})
164
- const defaultForm: UI_I_FormValidationDataStore = defaultFormFunc(
165
- localization.value
166
- )
167
- const form = ref<UI_I_FormValidationDataStore>(useDeepCopy(defaultForm))
168
-
169
- const setForm = (): void => {
170
- form.value = useDeepCopy(defaultForm)
171
- validation.setForm(form)
172
- }
173
- setForm()
174
-
175
- const alertInfo = ref<boolean>(true)
176
- const onHideAlertInfo = (): void => {
177
- alertInfo.value = false
178
- }
179
-
180
- const errors = ref<string[]>([])
181
- const formErrors = ref<UI_I_ValidationTouchResult[]>([])
182
-
183
- /* Lun disk table */
184
-
185
- const pagination = ref<UI_I_Pagination>({
186
- page: 1,
187
- pageSize: 35,
188
- })
189
- const sort = ref<string | null>(null)
190
-
191
- const selectedLunDisk = ref<number[]>([])
192
-
193
- watch(
194
- selectedLunDisk,
195
- (newValue: number[] | null) => {
196
- if (newValue === null || !dataTable.value) return null
197
-
198
- const lunDisk = dataTable.value.items.filter((_: any, key: number) =>
199
- newValue.includes(key)
200
- )
201
-
202
- emits('update:lun-disk', lunDisk)
203
- },
204
- { deep: true }
205
- )
206
-
207
- const updatePagination = (event: UI_I_Pagination): void => {
208
- pagination.value = event
209
- }
210
- const sortTable = (event: string): void => {
211
- sort.value = event
212
- initLunDisksDataTable()
213
- }
214
-
215
- const loading = computed<boolean>(() =>
216
- $store.getters['storage/getLoading']('datastoreHosts')
217
- )
218
- const dataTable = computed<API_UI_I_DataTable<
219
- UI_I_CreateStorageLunDiskItem[]
220
- > | null>(() => {
221
- // if (props.mode === 'procurator')
222
- return $store.getters['storage/getNewDatastoreHosts']
223
-
224
- // if (props.datastoreType === 'local') return []
225
- //
226
- // if (props.datastoreType === 'shared-storm') return []
227
- //
228
- // if (props.datastoreType === 'nfs') return []
229
- })
230
-
231
- /* Select host */
232
- // const hostData = ref<UI_I_SelectHostOptions[] | null>(null)
233
- const selectedHost = ref<string>(props.hostId || '')
234
- const hostOptions = computed<UI_I_SelectHostOptions[]>(() =>
235
- hostsOptionsFunc(localization.value, props.datacenterHosts)
236
- ) // <!-- TODO Нам сейчас он не нужен. Мы монтируем nfs только на один хост ( procurator )-->
237
-
238
- const onSelectHost = (): void => {
239
- if (props.datastoreType !== 'shared-storm') return
240
-
241
- initLunDisksForSphere(selectedHost.value)
242
- }
243
-
244
- const showValidationErrors = (
245
- data: UI_I_ValidationTouchResult[],
246
- errorText = '',
247
- alert = false
248
- ): void => {
249
- if (alert) errors.value = [errorText]
250
- formErrors.value = data
251
- }
252
-
253
- const resetValidation = (): void => {
254
- errors.value = []
255
- formErrors.value = []
256
- }
257
- const removeInputValidation = (): void => {
258
- formErrors.value = []
259
- }
260
- const onCloseAlertDanger = (): void => {
261
- errors.value = []
262
- }
263
- const validatePropertiesForSphere = (): boolean => {
264
- if (props.datastoreType === 'local') {
265
- return !selectedHost.value
266
- }
267
-
268
- if (props.datastoreType === 'shared-storm') {
269
- return !selectedHost.value || !selectedLunDisk.value.length
270
- }
271
-
272
- return false
273
- }
274
- const validationTextForSphere = (): string => {
275
- if (props.datastoreType === 'local') {
276
- return 'selectHostToContinueAlert'
277
- }
278
-
279
- if (props.datastoreType === 'shared-storm') {
280
- return !selectedHost.value
281
- ? 'selectHostToContinueAlert'
282
- : 'selectDiskToContinueAlert'
283
- }
284
-
285
- return ''
286
- }
287
-
288
- const collectDataForReview = (
289
- name: string,
290
- mode: UI_T_WizardDatastoreMode
291
- ): UI_I_DeviceSelectionSendData => {
292
- const data: UI_I_DeviceSelectionSendData = {
293
- name,
294
- }
295
-
296
- if (mode === 'procurator') {
297
- data.lunDisk = props.lunDisk.map((lun) => {
298
- return { name: lun.name, capacity: lun.capacity_mb }
299
- })
300
- }
301
-
302
- if (mode === 'sphere') {
303
- if (props.datastoreType === 'local') {
304
- data.host = selectedHost.value
305
- }
306
-
307
- if (props.datastoreType === 'shared-storm') {
308
- data.host = selectedHost.value
309
- data.lunDisk = props.lunDisk.map((lun) => {
310
- return { name: lun.name, capacity: lun.capacity_mb }
311
- })
312
- }
313
- }
314
-
315
- return data
316
- }
317
-
318
- const submit = async (): Promise<void> => {
319
- const name = form.value.name.value
320
- const { mode } = props
321
-
322
- const valid = validation.touch()
323
- const isShowAlertDanger =
324
- mode === 'procurator'
325
- ? !selectedLunDisk.value.length
326
- : validatePropertiesForSphere()
327
-
328
- if (!valid.isValid || isShowAlertDanger) {
329
- const isModeSphere = mode === 'sphere' && props.datastoreType === 'local'
330
-
331
- const errorText =
332
- localization.value[
333
- isModeSphere ? 'selectHostToContinueAlert' : validationTextForSphere()
334
- ]
335
-
336
- showValidationErrors(valid, errorText, isShowAlertDanger)
337
- return
338
- }
339
-
340
- if (!isShowAlertDanger) {
341
- emits('loading', true)
342
-
343
- const { valid: validName, msg } = await checkValidityName(name, props.mode)
344
-
345
- emits('loading', false)
346
-
347
- if (!validName) {
348
- showValidationErrors(valid, msg, true)
349
- return
350
- }
351
- }
352
-
353
- resetValidation()
354
-
355
- const eventData = collectDataForReview(name, mode)
356
- emits('submit', eventData)
357
- }
358
-
359
- watch(
360
- () => props.deviceSelectionSubmit,
361
- () => {
362
- submit()
363
- }
364
- )
365
-
366
- // const initHostData = async (): Promise<void> => {
367
- // hostData.value = await $store.dispatch('storage/A_GET_DATACENTER_HOSTS', {
368
- // schema: 'short',
369
- // } as UI_I_SchemaTablePayload)
370
- // }
371
- const initLunDisksForSphere = async (host: string): Promise<void> => {
372
- await $store.dispatch('storage/A_GET_DISKS_LIST', {
373
- host,
374
- ...pagination.value,
375
- sortBy: sort.value,
376
- } as UI_I_LunDiskSpherePayload)
377
- }
378
- if (props.hostId) {
379
- initLunDisksForSphere(props.hostId)
380
- }
381
- const initLunDisksDataTable = async (): Promise<void> => {
382
- await $store.dispatch('storage/A_GET_LUN_DISK_LIST', {
383
- ...pagination.value,
384
- sortBy: sort.value,
385
- } as UI_I_DataTableQuery)
386
- }
387
-
388
- watch(
389
- () => props.stepPosition,
390
- () => {
391
- const { stepPosition, datastoreType, mode } = props
392
- // const hostsDataForProcurator =
393
- // $store.getters['storage/getNewDatastoreHosts']
394
-
395
- // if (
396
- // mode === 'sphere' &&
397
- // stepPosition === 1 &&
398
- // datastoreType === 'local' &&
399
- // !hostData.value
400
- // ) {
401
- // initHostData()
402
- // }
403
- if (
404
- mode === 'procurator' &&
405
- stepPosition === 1 &&
406
- datastoreType === 'shared-storm'
407
- ) {
408
- initLunDisksDataTable()
409
- }
410
- }
411
- )
412
- </script>
413
-
414
- <style lang="scss" scoped>
415
- .device-selection {
416
- display: flex;
417
- flex-direction: column;
418
- height: inherit;
419
- overflow-y: auto;
420
- overflow-x: hidden;
421
- &__alert-info {
422
- :deep(.alert-text) {
423
- font-size: 11px;
424
- letter-spacing: normal;
425
- }
426
- }
427
- .dropdown-toggle {
428
- min-width: 160px;
429
- }
430
- .clr-form-control {
431
- display: flex;
432
- flex-direction: row;
433
-
434
- .clr-control-container {
435
- min-height: 48px;
436
- &.clr-error {
437
- .clr-subtext,
438
- .error-icon {
439
- display: block;
440
- }
441
- }
442
- .clr-subtext,
443
- .error-icon {
444
- display: none;
445
- }
446
- .error-icon {
447
- fill: #db2100;
448
- width: 24px;
449
- height: 24px;
450
- }
451
- }
452
- }
453
- &__disk-list {
454
- display: flex;
455
- flex-direction: column;
456
- height: 100%;
457
- }
458
- }
459
- </style>
1
+ <template>
2
+ <div class="device-selection">
3
+ <atoms-alert
4
+ v-show="errors.length"
5
+ test-id="device-selection-errors"
6
+ status="alert-danger"
7
+ :items="errors"
8
+ @remove="onCloseAlertDanger"
9
+ />
10
+
11
+ <div class="clr-form-control clr-row">
12
+ <label for="" class="clr-control-label clr-col-md-2">{{
13
+ localization.name
14
+ }}</label>
15
+
16
+ <div
17
+ class="clr-control-container"
18
+ :class="formErrors.errors?.name?.length && 'clr-error'"
19
+ >
20
+ <div class="flex-align-center">
21
+ <input
22
+ id="device-selection-input"
23
+ v-model="form.name.value"
24
+ data-id="device-selection-input"
25
+ type="text"
26
+ class="clr-input"
27
+ @blur="initValidation"
28
+ @input="onInput"
29
+ />
30
+ <atoms-the-icon class="error-icon" name="info-circle" />
31
+ </div>
32
+
33
+ <div class="clr-subtext ng-star-inserted">
34
+ {{ formErrors?.errors?.name?.[0] || '' }}
35
+ </div>
36
+ </div>
37
+ </div>
38
+
39
+ <atoms-alert
40
+ v-show="alertInfo"
41
+ test-id="device-selection-info"
42
+ class="device-selection__alert-info"
43
+ status="alert-info"
44
+ :items="[localization.nameAndDeviceSelectionAlertInfo]"
45
+ @remove="onHideAlertInfo"
46
+ />
47
+
48
+ <div
49
+ v-if="props.mode === 'sphere' && !props.hostId"
50
+ class="clr-form-control clr-row"
51
+ >
52
+ <label class="clr-control-label clr-col-12 clr-col-md-2">{{
53
+ localization.selectHost
54
+ }}</label>
55
+
56
+ <div>
57
+ <div class="clr-select-wrapper">
58
+ <select
59
+ id="device-host-select"
60
+ v-model="selectedHost"
61
+ data-id="device-host-select"
62
+ class="dropdown-toggle"
63
+ @change="onSelectHost"
64
+ >
65
+ <option
66
+ v-for="(item, index) in hostOptions"
67
+ :key="index"
68
+ :value="item.value"
69
+ :disabled="item.disabled"
70
+ >
71
+ {{ item.text }}
72
+ </option>
73
+ </select>
74
+ </div>
75
+ <div class="clr-subtext">
76
+ {{ localization.selectHostToViewAccessible }}
77
+ </div>
78
+ </div>
79
+ </div>
80
+
81
+ <div class="device-selection__disk-list">
82
+ <common-wizards-datastore-add-shared-storm-device-selection-host-table
83
+ v-model:selected="selectedLunDisk"
84
+ :data-table="dataTable?.items || []"
85
+ :total-items="dataTable?.total_items || 0"
86
+ :total-pages="dataTable?.total_pages || 1"
87
+ :pagination="pagination"
88
+ :loading="loading"
89
+ :is-main-filter="props.isMainFilter"
90
+ @pagination="updatePagination"
91
+ @sort="sortTable"
92
+ @main-filter="emits('main-filter', $event)"
93
+ />
94
+ </div>
95
+ </div>
96
+ </template>
97
+
98
+ <script lang="ts" setup>
99
+ import { UI_I_ValidationTouchResult } from '~/lib/models/plugins/validation/interfaces'
100
+ // import { UI_I_SchemaTablePayload } from '~/lib/models/store/interfaces'
101
+ import { UI_I_Localization } from '~/lib/models/interfaces'
102
+ import {
103
+ API_UI_I_DataTable,
104
+ UI_I_Pagination,
105
+ UI_I_DataTableQuery,
106
+ } from '~/lib/models/table/interfaces'
107
+ import {
108
+ UI_I_CreateStorageLunDiskItem,
109
+ UI_I_DeviceSelectionSendData,
110
+ UI_I_FormValidationDataStore,
111
+ UI_I_LunDiskSpherePayload,
112
+ UI_I_SelectHostOptions,
113
+ } from '~/components/common/wizards/datastore/add/sharedStorm/deviceSelection/lib/models/interfaces'
114
+ // import { Ui_T_HostSelectedType } from '~/components/common/wizards/datastore/add/sharedStorm/deviceSelection/lib/models/types'
115
+ import {
116
+ UI_T_DatastoreType,
117
+ UI_T_WizardDatastoreMode,
118
+ } from '~/components/common/wizards/datastore/add/lib/models/types'
119
+ import { defaultFormFunc } from '~/components/common/wizards/datastore/add/sharedStorm/deviceSelection/lib/config/defaultForm'
120
+ import { hostsOptionsFunc } from '~/components/common/wizards/datastore/add/sharedStorm/deviceSelection/lib/config/selectOptions'
121
+ import { checkValidityName } from '~/components/common/wizards/datastore/add/lib/utils'
122
+
123
+ const props = defineProps<{
124
+ mode: UI_T_WizardDatastoreMode
125
+ deviceSelectionSubmit: number
126
+ lunDisk: UI_I_CreateStorageLunDiskItem[]
127
+ stepPosition: number
128
+ datastoreType: UI_T_DatastoreType
129
+ datacenterHosts?: UI_I_SelectHostOptions[] | undefined
130
+ isMainFilter?: boolean
131
+ hostId?: string
132
+ }>()
133
+ const emits = defineEmits<{
134
+ (event: 'loading', value: boolean): void
135
+ (event: 'submit', value: UI_I_DeviceSelectionSendData): void
136
+ (
137
+ event: 'update:lun-disk',
138
+ value: UI_I_CreateStorageLunDiskItem[] | null
139
+ ): void
140
+ (event: 'main-filter', value: string): void
141
+ }>()
142
+
143
+ const localization = computed<UI_I_Localization>(() => useLocal())
144
+ const { $store } = useNuxtApp()
145
+ const { $validation } = useNuxtApp()
146
+
147
+ const isInitDatastoreNameValidation = ref<boolean>(false)
148
+ const initValidation = (): void => {
149
+ isInitDatastoreNameValidation.value = true
150
+ const valid = validation.touch()
151
+ if (!valid.isValid) {
152
+ showValidationErrors(valid)
153
+ }
154
+ }
155
+ const onInput = (): void => {
156
+ const valid = validation.touch()
157
+
158
+ if (!isInitDatastoreNameValidation.value) return
159
+
160
+ valid.isValid ? removeInputValidation() : showValidationErrors(valid)
161
+ }
162
+
163
+ const validation = $validation.call({})
164
+ const defaultForm: UI_I_FormValidationDataStore = defaultFormFunc(
165
+ localization.value
166
+ )
167
+ const form = ref<UI_I_FormValidationDataStore>(useDeepCopy(defaultForm))
168
+
169
+ const setForm = (): void => {
170
+ form.value = useDeepCopy(defaultForm)
171
+ validation.setForm(form)
172
+ }
173
+ setForm()
174
+
175
+ const alertInfo = ref<boolean>(true)
176
+ const onHideAlertInfo = (): void => {
177
+ alertInfo.value = false
178
+ }
179
+
180
+ const errors = ref<string[]>([])
181
+ const formErrors = ref<UI_I_ValidationTouchResult[]>([])
182
+
183
+ /* Lun disk table */
184
+
185
+ const pagination = ref<UI_I_Pagination>({
186
+ page: 1,
187
+ pageSize: 35,
188
+ })
189
+ const sort = ref<string | null>(null)
190
+
191
+ const selectedLunDisk = ref<number[]>([])
192
+
193
+ watch(
194
+ selectedLunDisk,
195
+ (newValue: number[] | null) => {
196
+ if (newValue === null || !dataTable.value) return null
197
+
198
+ const lunDisk = dataTable.value.items.filter((_: any, key: number) =>
199
+ newValue.includes(key)
200
+ )
201
+
202
+ emits('update:lun-disk', lunDisk)
203
+ },
204
+ { deep: true }
205
+ )
206
+
207
+ const updatePagination = (event: UI_I_Pagination): void => {
208
+ pagination.value = event
209
+ }
210
+ const sortTable = (event: string): void => {
211
+ sort.value = event
212
+ initLunDisksDataTable()
213
+ }
214
+
215
+ const loading = computed<boolean>(() =>
216
+ $store.getters['storage/getLoading']('datastoreHosts')
217
+ )
218
+ const dataTable = computed<API_UI_I_DataTable<
219
+ UI_I_CreateStorageLunDiskItem[]
220
+ > | null>(() => {
221
+ // if (props.mode === 'procurator')
222
+ return $store.getters['storage/getNewDatastoreHosts']
223
+
224
+ // if (props.datastoreType === 'local') return []
225
+ //
226
+ // if (props.datastoreType === 'shared-storm') return []
227
+ //
228
+ // if (props.datastoreType === 'nfs') return []
229
+ })
230
+
231
+ /* Select host */
232
+ // const hostData = ref<UI_I_SelectHostOptions[] | null>(null)
233
+ const selectedHost = ref<string>(props.hostId || '')
234
+ const hostOptions = computed<UI_I_SelectHostOptions[]>(() =>
235
+ hostsOptionsFunc(localization.value, props.datacenterHosts)
236
+ ) // <!-- TODO Нам сейчас он не нужен. Мы монтируем nfs только на один хост ( procurator )-->
237
+
238
+ const onSelectHost = (): void => {
239
+ if (props.datastoreType !== 'shared-storm') return
240
+
241
+ initLunDisksForSphere(selectedHost.value)
242
+ }
243
+
244
+ const showValidationErrors = (
245
+ data: UI_I_ValidationTouchResult[],
246
+ errorText = '',
247
+ alert = false
248
+ ): void => {
249
+ if (alert) errors.value = [errorText]
250
+ formErrors.value = data
251
+ }
252
+
253
+ const resetValidation = (): void => {
254
+ errors.value = []
255
+ formErrors.value = []
256
+ }
257
+ const removeInputValidation = (): void => {
258
+ formErrors.value = []
259
+ }
260
+ const onCloseAlertDanger = (): void => {
261
+ errors.value = []
262
+ }
263
+ const validatePropertiesForSphere = (): boolean => {
264
+ if (props.datastoreType === 'local') {
265
+ return !selectedHost.value
266
+ }
267
+
268
+ if (props.datastoreType === 'shared-storm') {
269
+ return !selectedHost.value || !selectedLunDisk.value.length
270
+ }
271
+
272
+ return false
273
+ }
274
+ const validationTextForSphere = (): string => {
275
+ if (props.datastoreType === 'local') {
276
+ return 'selectHostToContinueAlert'
277
+ }
278
+
279
+ if (props.datastoreType === 'shared-storm') {
280
+ return !selectedHost.value
281
+ ? 'selectHostToContinueAlert'
282
+ : 'selectDiskToContinueAlert'
283
+ }
284
+
285
+ return ''
286
+ }
287
+
288
+ const collectDataForReview = (
289
+ name: string,
290
+ mode: UI_T_WizardDatastoreMode
291
+ ): UI_I_DeviceSelectionSendData => {
292
+ const data: UI_I_DeviceSelectionSendData = {
293
+ name,
294
+ }
295
+
296
+ if (mode === 'procurator') {
297
+ data.lunDisk = props.lunDisk.map((lun) => {
298
+ return { name: lun.name, capacity: lun.capacity_mb }
299
+ })
300
+ }
301
+
302
+ if (mode === 'sphere') {
303
+ if (props.datastoreType === 'local') {
304
+ data.host = selectedHost.value
305
+ }
306
+
307
+ if (props.datastoreType === 'shared-storm') {
308
+ data.host = selectedHost.value
309
+ data.lunDisk = props.lunDisk.map((lun) => {
310
+ return { name: lun.name, capacity: lun.capacity_mb }
311
+ })
312
+ }
313
+ }
314
+
315
+ return data
316
+ }
317
+
318
+ const submit = async (): Promise<void> => {
319
+ const name = form.value.name.value
320
+ const { mode } = props
321
+
322
+ const valid = validation.touch()
323
+ const isShowAlertDanger =
324
+ mode === 'procurator'
325
+ ? !selectedLunDisk.value.length
326
+ : validatePropertiesForSphere()
327
+
328
+ if (!valid.isValid || isShowAlertDanger) {
329
+ const isModeSphere = mode === 'sphere' && props.datastoreType === 'local'
330
+
331
+ const errorText =
332
+ localization.value[
333
+ isModeSphere ? 'selectHostToContinueAlert' : validationTextForSphere()
334
+ ]
335
+
336
+ showValidationErrors(valid, errorText, isShowAlertDanger)
337
+ return
338
+ }
339
+
340
+ if (!isShowAlertDanger) {
341
+ emits('loading', true)
342
+
343
+ const { valid: validName, msg } = await checkValidityName(name, props.mode)
344
+
345
+ emits('loading', false)
346
+
347
+ if (!validName) {
348
+ showValidationErrors(valid, msg, true)
349
+ return
350
+ }
351
+ }
352
+
353
+ resetValidation()
354
+
355
+ const eventData = collectDataForReview(name, mode)
356
+ emits('submit', eventData)
357
+ }
358
+
359
+ watch(
360
+ () => props.deviceSelectionSubmit,
361
+ () => {
362
+ submit()
363
+ }
364
+ )
365
+
366
+ // const initHostData = async (): Promise<void> => {
367
+ // hostData.value = await $store.dispatch('storage/A_GET_DATACENTER_HOSTS', {
368
+ // schema: 'short',
369
+ // } as UI_I_SchemaTablePayload)
370
+ // }
371
+ const initLunDisksForSphere = async (host: string): Promise<void> => {
372
+ await $store.dispatch('storage/A_GET_DISKS_LIST', {
373
+ host,
374
+ ...pagination.value,
375
+ sortBy: sort.value,
376
+ } as UI_I_LunDiskSpherePayload)
377
+ }
378
+ if (props.hostId) {
379
+ initLunDisksForSphere(props.hostId)
380
+ }
381
+ const initLunDisksDataTable = async (): Promise<void> => {
382
+ await $store.dispatch('storage/A_GET_LUN_DISK_LIST', {
383
+ ...pagination.value,
384
+ sortBy: sort.value,
385
+ } as UI_I_DataTableQuery)
386
+ }
387
+
388
+ watch(
389
+ () => props.stepPosition,
390
+ () => {
391
+ const { stepPosition, datastoreType, mode } = props
392
+ // const hostsDataForProcurator =
393
+ // $store.getters['storage/getNewDatastoreHosts']
394
+
395
+ // if (
396
+ // mode === 'sphere' &&
397
+ // stepPosition === 1 &&
398
+ // datastoreType === 'local' &&
399
+ // !hostData.value
400
+ // ) {
401
+ // initHostData()
402
+ // }
403
+ if (
404
+ mode === 'procurator' &&
405
+ stepPosition === 1 &&
406
+ datastoreType === 'shared-storm'
407
+ ) {
408
+ initLunDisksDataTable()
409
+ }
410
+ }
411
+ )
412
+ </script>
413
+
414
+ <style lang="scss" scoped>
415
+ .device-selection {
416
+ display: flex;
417
+ flex-direction: column;
418
+ height: inherit;
419
+ overflow-y: auto;
420
+ overflow-x: hidden;
421
+ &__alert-info {
422
+ :deep(.alert-text) {
423
+ font-size: 11px;
424
+ letter-spacing: normal;
425
+ }
426
+ }
427
+ .dropdown-toggle {
428
+ min-width: 160px;
429
+ }
430
+ .clr-form-control {
431
+ display: flex;
432
+ flex-direction: row;
433
+
434
+ .clr-control-container {
435
+ min-height: 48px;
436
+ &.clr-error {
437
+ .clr-subtext,
438
+ .error-icon {
439
+ display: block;
440
+ }
441
+ }
442
+ .clr-subtext,
443
+ .error-icon {
444
+ display: none;
445
+ }
446
+ .error-icon {
447
+ fill: #db2100;
448
+ width: 24px;
449
+ height: 24px;
450
+ }
451
+ }
452
+ }
453
+ &__disk-list {
454
+ display: flex;
455
+ flex-direction: column;
456
+ height: 100%;
457
+ }
458
+ }
459
+ </style>