bfg-common 1.3.326 → 1.3.328

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.
@@ -1,5 +1,6 @@
1
1
  <template>
2
2
  <div
3
+ :id="elementId"
3
4
  class="context-popup"
4
5
  :style="{
5
6
  top: currentContextMenuY,
@@ -32,6 +33,8 @@ const selectItem = (item: UI_I_ContextMenuItem): void => {
32
33
  emits('select-item', item)
33
34
  }
34
35
 
36
+ const elementId = ref<string>(`context-${useUniqueId()}`)
37
+
35
38
  const currentContextMenuY = ref<string>('')
36
39
  const currentContextMenuX = ref<string>('')
37
40
  const setCurrentPositionsPopup = (): void => {
@@ -39,7 +42,7 @@ const setCurrentPositionsPopup = (): void => {
39
42
  const contextMenuX = props.contextMenu.x
40
43
 
41
44
  const contextWrap: HTMLElement | null =
42
- document.querySelector('.context-wrap')
45
+ document.querySelector(`#${elementId.value} .context-wrap`)
43
46
  const contextW = contextWrap?.offsetWidth || 0
44
47
  const contextH = contextWrap?.offsetHeight || 0
45
48
 
@@ -18,6 +18,7 @@
18
18
  <common-wizards-datastore-add-types
19
19
  v-show="stepPosition === 0"
20
20
  v-model:type="datastoreType"
21
+ :project="props.mode"
21
22
  />
22
23
 
23
24
  <common-wizards-datastore-add-local
@@ -85,6 +86,7 @@ import { stepItemsFunc } from '~/components/common/wizards/datastore/add/lib/con
85
86
  import { constructDataReadyViewFunc } from '~/components/common/wizards/datastore/add/readyComplete/lib/config/propertiesDetails'
86
87
 
87
88
  const props = defineProps<{
89
+ // TODO refactoring to project
88
90
  mode: UI_T_WizardDatastoreMode
89
91
  finishFunc: (
90
92
  datastoreForm: UI_I_CreateDatastoreForm,
@@ -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>
@@ -1,78 +1,80 @@
1
- <template>
2
- <section class="datastore-types">
3
- <div class="header-row">
4
- <span class="datastore-types__subtitle">
5
- {{ localization.specifyDatastoreType }}
6
- </span>
7
- <div id="type-select-help-icon" class="signpost-container relative">
8
- <atoms-the-icon
9
- data-id="toggle-type-select-help-icon"
10
- fill="#0072a3"
11
- width="24px"
12
- height="24px"
13
- name="info-circle"
14
- @click="isShowTypeHelp = !isShowTypeHelp"
15
- />
16
- <atoms-tooltip-signpost
17
- v-if="isShowTypeHelp"
18
- elem-id="type-select-help-icon"
19
- @hide="isShowTypeHelp = false"
20
- >
21
- <p class="help-desc">{{ localization.datastoreTypeHelpDesc }}</p>
22
- </atoms-tooltip-signpost>
23
- </div>
24
- </div>
25
-
26
- <common-select-radio-group
27
- v-model="selectedType"
28
- :options="datastoreTypes"
29
- />
30
- </section>
31
- </template>
32
-
33
- <script lang="ts" setup>
34
- import { UI_I_Localization } from '~/lib/models/interfaces'
35
- import { UI_I_RadioOption } from '~/components/common/select/radio/lib/models/interfaces'
36
- import { datastoreTypesFunc } from '~/components/common/wizards/datastore/add/types/lib/config/typeOptions'
37
-
38
- const props = defineProps<{
39
- type: string
40
- }>()
41
- const emits = defineEmits<{
42
- (event: 'update:type', value: string): void
43
- }>()
44
- const localization = computed<UI_I_Localization>(() => useLocal())
45
-
46
- const datastoreTypes = ref<UI_I_RadioOption[]>(
47
- datastoreTypesFunc(localization.value)
48
- )
49
-
50
- const selectedType = computed<string>({
51
- get() {
52
- return props.type
53
- },
54
- set(newValue) {
55
- emits('update:type', newValue)
56
- },
57
- })
58
-
59
- const isShowTypeHelp = ref<boolean>(false)
60
- </script>
61
-
62
- <style lang="scss" scoped>
63
- .datastore-types {
64
- .signpost-container {
65
- display: flex;
66
- cursor: pointer;
67
-
68
- .help-desc-container {
69
- max-width: 350px;
70
- }
71
- }
72
- .header-row {
73
- display: flex;
74
- align-items: center;
75
- gap: 10px;
76
- }
77
- }
78
- </style>
1
+ <template>
2
+ <section class="datastore-types">
3
+ <div class="header-row">
4
+ <span class="datastore-types__subtitle">
5
+ {{ localization.specifyDatastoreType }}
6
+ </span>
7
+ <div id="type-select-help-icon" class="signpost-container relative">
8
+ <atoms-the-icon
9
+ data-id="toggle-type-select-help-icon"
10
+ fill="#0072a3"
11
+ width="24px"
12
+ height="24px"
13
+ name="info-circle"
14
+ @click="isShowTypeHelp = !isShowTypeHelp"
15
+ />
16
+ <atoms-tooltip-signpost
17
+ v-if="isShowTypeHelp"
18
+ elem-id="type-select-help-icon"
19
+ @hide="isShowTypeHelp = false"
20
+ >
21
+ <p class="help-desc">{{ localization.datastoreTypeHelpDesc }}</p>
22
+ </atoms-tooltip-signpost>
23
+ </div>
24
+ </div>
25
+
26
+ <common-select-radio-group
27
+ v-model="selectedType"
28
+ :options="datastoreTypes"
29
+ />
30
+ </section>
31
+ </template>
32
+
33
+ <script lang="ts" setup>
34
+ import { UI_I_Localization } from '~/lib/models/interfaces'
35
+ import { UI_T_Project } from '~/lib/models/types'
36
+ import { UI_I_RadioOption } from '~/components/common/select/radio/lib/models/interfaces'
37
+ import { datastoreTypesFunc } from '~/components/common/wizards/datastore/add/types/lib/config/typeOptions'
38
+
39
+ const props = defineProps<{
40
+ project: UI_T_Project
41
+ type: string
42
+ }>()
43
+ const emits = defineEmits<{
44
+ (event: 'update:type', value: string): void
45
+ }>()
46
+ const localization = computed<UI_I_Localization>(() => useLocal())
47
+
48
+ const datastoreTypes = ref<UI_I_RadioOption[]>(
49
+ datastoreTypesFunc(localization.value, props.project)
50
+ )
51
+
52
+ const selectedType = computed<string>({
53
+ get() {
54
+ return props.type
55
+ },
56
+ set(newValue) {
57
+ emits('update:type', newValue)
58
+ },
59
+ })
60
+
61
+ const isShowTypeHelp = ref<boolean>(false)
62
+ </script>
63
+
64
+ <style lang="scss" scoped>
65
+ .datastore-types {
66
+ .signpost-container {
67
+ display: flex;
68
+ cursor: pointer;
69
+
70
+ .help-desc-container {
71
+ max-width: 350px;
72
+ }
73
+ }
74
+ .header-row {
75
+ display: flex;
76
+ align-items: center;
77
+ gap: 10px;
78
+ }
79
+ }
80
+ </style>
@@ -1,42 +1,49 @@
1
- import { UI_I_Localization } from '~/lib/models/interfaces'
2
- import { UI_I_RadioOption } from '~/components/common/select/radio/lib/models/interfaces'
3
-
4
- export const datastoreTypesFunc = (
5
- localization: UI_I_Localization
6
- ): UI_I_RadioOption[] => {
7
- return [
8
- {
9
- label: localization.localStorage,
10
- value: 'local',
11
- disabled: false,
12
- description: localization.localDesc,
13
- isTooltip: false,
14
- tooltipContent: localization.localStorageHelpDesc,
15
- testId: 'datastore-type-local',
16
- },
17
- {
18
- label: localization.stormSharedStorage,
19
- value: 'shared-storm',
20
- disabled: false,
21
- description: localization.sharedStormDesc,
22
- isTooltip: false,
23
- tooltipContent: localization.stormSharedStorageHelpDesc,
24
- testId: 'datastore-type-shared-storm',
25
- },
26
- {
27
- label: localization.nfs,
28
- value: 'nfs',
29
- disabled: false,
30
- description: localization.nfsDesc,
31
- isTooltip: false,
32
- tooltipContent: localization.nfsHelpDesc,
33
- testId: 'datastore-type-nfs',
34
- },
35
- // {
36
- // label: localization.vVol,
37
- // value: 'vVol',
38
- // disabled: true,
39
- // desc: localization.vVolDesc,
40
- // },
41
- ]
42
- }
1
+ import { UI_I_Localization } from '~/lib/models/interfaces'
2
+ import { UI_T_Project } from '~/lib/models/types'
3
+ import { UI_I_RadioOption } from '~/components/common/select/radio/lib/models/interfaces'
4
+
5
+ export const datastoreTypesFunc = (
6
+ localization: UI_I_Localization,
7
+ project: UI_T_Project
8
+ ): UI_I_RadioOption[] => {
9
+ const types = [
10
+ {
11
+ label: localization.stormSharedStorage,
12
+ value: 'shared-storm',
13
+ disabled: false,
14
+ description: localization.sharedStormDesc,
15
+ isTooltip: false,
16
+ tooltipContent: localization.stormSharedStorageHelpDesc,
17
+ testId: 'datastore-type-shared-storm',
18
+ },
19
+ {
20
+ label: localization.nfs,
21
+ value: 'nfs',
22
+ disabled: false,
23
+ description: localization.nfsDesc,
24
+ isTooltip: false,
25
+ tooltipContent: localization.nfsHelpDesc,
26
+ testId: 'datastore-type-nfs',
27
+ },
28
+ // {
29
+ // label: localization.vVol,
30
+ // value: 'vVol',
31
+ // disabled: true,
32
+ // desc: localization.vVolDesc,
33
+ // },
34
+ ]
35
+
36
+ if (project === 'procurator') {
37
+ types.unshift({
38
+ label: localization.localStorage,
39
+ value: 'local',
40
+ disabled: false,
41
+ description: localization.localDesc,
42
+ isTooltip: false,
43
+ tooltipContent: localization.localStorageHelpDesc,
44
+ testId: 'datastore-type-local',
45
+ })
46
+ }
47
+
48
+ return types
49
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.3.326",
4
+ "version": "1.3.328",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",