bfg-common 1.3.348 → 1.3.349

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