bfg-common 1.3.328 → 1.3.330

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.
@@ -105,7 +105,7 @@ const emits = defineEmits<{
105
105
  const localization = computed<UI_I_Localization>(() => useLocal())
106
106
 
107
107
  const loading = ref<boolean>(false)
108
- const datastoreType = ref<UI_T_DatastoreType>('local')
108
+ const datastoreType = ref<UI_T_DatastoreType>(props.mode === 'procurator' ? 'local' : 'shared-storm')
109
109
  const nfsVersion = ref<UI_T_NfsType>('nfs-3')
110
110
 
111
111
  const stepPosition = ref<number>(0)
@@ -1,67 +1,70 @@
1
- import { API_UI_I_Error } from '~/lib/models/store/interfaces'
2
- import {
3
- UI_I_DatastoreValidityName,
4
- UI_T_WizardDatastoreMode,
5
- } from '~/components/common/wizards/datastore/add/lib/models/types'
6
- // import {
7
- // UI_I_CreateDatastoreBodyRequest,
8
- // I_CreateStorageUuid,
9
- // } from '~/components/common/wizards/datastore/add/lib/models/interfaces'
10
-
11
- // type T_StoragePoolNameResult = {
12
- // data: I_CreateStorageUuid
13
- // msg: API_UI_I_Error
14
- // }
15
-
16
- // type T_NullableStoragePoolNameResult = {
17
- // [K in keyof T_StoragePoolNameResult]: T_StoragePoolNameResult[K] | null
18
- // }
19
-
20
- export const checkValidityName = async (
21
- name: string,
22
- _mode: UI_T_WizardDatastoreMode = 'procurator'
23
- ): Promise<UI_I_DatastoreValidityName> => {
24
-
25
- // @ts-ignore
26
- const { error } = await useMyFetch<null, API_UI_I_Error>(
27
- `/ui/ds/validate?name=${name}`,
28
- {
29
- method: 'GET',
30
- }
31
- )
32
-
33
- if (error.value && error.value.data.error_code !== 0) {
34
- const existError = error.value.data?.error_message || error.value.data
35
-
36
- return { valid: false, msg: existError }
37
- }
38
-
39
- return { valid: true, msg: null }
40
- }
41
-
42
- // export const getStoragePoolName = async <T>(
43
- // url: string,
44
- // params: T
45
- // ): Promise<T_NullableStoragePoolNameResult> => {
46
- // const { data, error } = await useMyFetch<I_CreateStorageUuid, API_UI_I_Error>(
47
- // url,
48
- // {
49
- // method: 'POST',
50
- // body: params,
51
- // }
52
- // )
53
- //
54
- // if (error.value) return { data: null, msg: error.value }
55
- //
56
- // return { data: data.value, msg: null }
57
- // }
58
-
59
- // export const createDatastore = async <T = UI_I_CreateDatastoreBodyRequest>(
60
- // params: T
61
- // ): Promise<API_UI_I_Error> => {
62
- // const { error } = await useMyFetch<any, API_UI_I_Error>('/api/v1/pn/ds', {
63
- // method: 'POST',
64
- // body: params,
65
- // })
66
- // return error.value
67
- // }
1
+ import { API_UI_I_Error } from '~/lib/models/store/interfaces'
2
+ import {
3
+ UI_I_DatastoreValidityName,
4
+ UI_T_WizardDatastoreMode,
5
+ } from '~/components/common/wizards/datastore/add/lib/models/types'
6
+ // import {
7
+ // UI_I_CreateDatastoreBodyRequest,
8
+ // I_CreateStorageUuid,
9
+ // } from '~/components/common/wizards/datastore/add/lib/models/interfaces'
10
+
11
+ // type T_StoragePoolNameResult = {
12
+ // data: I_CreateStorageUuid
13
+ // msg: API_UI_I_Error
14
+ // }
15
+
16
+ // type T_NullableStoragePoolNameResult = {
17
+ // [K in keyof T_StoragePoolNameResult]: T_StoragePoolNameResult[K] | null
18
+ // }
19
+
20
+ export const checkValidityName = async (
21
+ name: string,
22
+ mode: UI_T_WizardDatastoreMode = 'procurator'
23
+ ): Promise<UI_I_DatastoreValidityName> => {
24
+ // TODO move to projects!!!
25
+
26
+ const kind = 10 // TODO move in global space
27
+ const url =
28
+ mode === 'procurator'
29
+ ? `/ui/ds/validate?name=${name}`
30
+ : `/ui/object/validate_name?name=${name}&kind=${kind}`
31
+ // @ts-ignore
32
+ const { error } = await useMyFetch<null, API_UI_I_Error>(url, {
33
+ method: 'GET',
34
+ })
35
+
36
+ if (error.value && error.value.data.error_code !== 0) {
37
+ const existError = error.value.data?.error_message || error.value.data
38
+
39
+ return { valid: false, msg: existError }
40
+ }
41
+
42
+ return { valid: true, msg: null }
43
+ }
44
+
45
+ // export const getStoragePoolName = async <T>(
46
+ // url: string,
47
+ // params: T
48
+ // ): Promise<T_NullableStoragePoolNameResult> => {
49
+ // const { data, error } = await useMyFetch<I_CreateStorageUuid, API_UI_I_Error>(
50
+ // url,
51
+ // {
52
+ // method: 'POST',
53
+ // body: params,
54
+ // }
55
+ // )
56
+ //
57
+ // if (error.value) return { data: null, msg: error.value }
58
+ //
59
+ // return { data: data.value, msg: null }
60
+ // }
61
+
62
+ // export const createDatastore = async <T = UI_I_CreateDatastoreBodyRequest>(
63
+ // params: T
64
+ // ): Promise<API_UI_I_Error> => {
65
+ // const { error } = await useMyFetch<any, API_UI_I_Error>('/api/v1/pn/ds', {
66
+ // method: 'POST',
67
+ // body: params,
68
+ // })
69
+ // return error.value
70
+ // }
@@ -1,160 +1,160 @@
1
- <template>
2
- <div class="create-datastore-name">
3
- <atoms-alert
4
- v-show="errors.length"
5
- test-id="datastore-creat-name"
6
- status="alert-danger"
7
- :items="errors"
8
- @remove="onRemoveValidationErrors"
9
- />
10
-
11
- <div class="clr-form-control clr-row">
12
- <label for="datastore-name" class="clr-control-label clr-col-md-2">{{
13
- localization.datastoreName
14
- }}</label>
15
-
16
- <div class="clr-control-container" :class="nameErrorText && 'clr-error'">
17
- <div class="flex-align-center">
18
- <input
19
- id="datastore-name"
20
- v-model.trim="form.name.value"
21
- data-id="datastore-name-input"
22
- type="text"
23
- class="clr-input"
24
- @blur="onBlurInputName"
25
- @input="onInputName"
26
- />
27
- <atoms-the-icon class="error-icon" name="info-circle" />
28
- </div>
29
-
30
- <div class="clr-subtext ng-star-inserted">
31
- {{ nameErrorText }}
32
- </div>
33
- </div>
34
- </div>
35
- </div>
36
- </template>
37
-
38
- <script lang="ts" setup>
39
- import { UI_I_ValidationTouchResult } from '~/lib/models/plugins/validation/interfaces'
40
- import { UI_I_Localization } from '~/lib/models/interfaces'
41
- import { UI_I_FormValidationDataStore } from '~/components/common/wizards/datastore/add/sharedStorm/deviceSelection/lib/models/interfaces'
42
- import { defaultFormFunc } from '~/components/common/wizards/datastore/add/local/createName/lib/config/defaultForm'
43
- import { checkValidityName } from '~/components/common/wizards/datastore/add/lib/utils'
44
-
45
- const props = defineProps<{
46
- localCreateNameSubmit: number
47
- }>()
48
- const emits = defineEmits<{
49
- (event: 'loading', value: boolean): void
50
- (event: 'submit', value: string): void
51
- }>()
52
-
53
- const localization = computed<UI_I_Localization>(() => useLocal())
54
- const { $validation } = useNuxtApp()
55
-
56
- const validation = $validation.call({})
57
- const defaultForm: UI_I_FormValidationDataStore = defaultFormFunc(
58
- localization.value
59
- )
60
- const form = ref<UI_I_FormValidationDataStore>(useDeepCopy(defaultForm))
61
-
62
- const setForm = () => {
63
- form.value = useDeepCopy(defaultForm)
64
- validation.setForm(form)
65
- }
66
- setForm()
67
-
68
- const validForm = ref<UI_I_ValidationTouchResult | null>(null)
69
-
70
- /* Validation for Name input */
71
- const isInitNameValidation = ref<boolean>(false)
72
- const onBlurInputName = (): void => {
73
- validForm.value = validation.touch()
74
- isInitNameValidation.value = true
75
- }
76
- const onInputName = () => {
77
- validForm.value = validation.touch()
78
- }
79
- const nameErrorText = computed<string>(() => {
80
- if (!isInitNameValidation.value) return ''
81
- return validForm.value?.errors?.name?.[0] || ''
82
- })
83
- /* Validation Name input end */
84
-
85
- const errors = ref<string[]>([])
86
- const showValidationErrors = (data: string[]): void => {
87
- errors.value = data
88
- }
89
- const onRemoveValidationErrors = (): void => {
90
- errors.value = []
91
- }
92
- const submit = async (): Promise<void> => {
93
- const name = form.value.name.value
94
-
95
- if (!name) {
96
- validForm.value = validation.touch()
97
- isInitNameValidation.value = true
98
- if (nameErrorText.value) return
99
- }
100
-
101
- if (name) {
102
- emits('loading', true)
103
-
104
- const { valid, msg } = await checkValidityName(name)
105
-
106
- emits('loading', false)
107
-
108
- if (!valid) {
109
- showValidationErrors([msg])
110
- return
111
- }
112
- }
113
-
114
- onRemoveValidationErrors()
115
- emits('submit', name)
116
- }
117
- watch(
118
- () => props.localCreateNameSubmit,
119
- () => {
120
- submit()
121
- }
122
- )
123
- </script>
124
-
125
- <style lang="scss" scoped>
126
- .create-datastore-name {
127
- &__alert-info {
128
- :deep(.alert-text) {
129
- font-size: 11px;
130
- letter-spacing: normal;
131
- }
132
- }
133
- .clr-form-control {
134
- display: flex;
135
- flex-direction: row;
136
-
137
- .clr-control-container {
138
- min-height: 48px;
139
- input {
140
- width: 375px;
141
- }
142
- &.clr-error {
143
- .clr-subtext,
144
- .error-icon {
145
- display: block;
146
- }
147
- }
148
- .clr-subtext,
149
- .error-icon {
150
- display: none;
151
- }
152
- .error-icon {
153
- fill: #db2100;
154
- width: 24px;
155
- height: 24px;
156
- }
157
- }
158
- }
159
- }
160
- </style>
1
+ <template>
2
+ <div class="create-datastore-name">
3
+ <atoms-alert
4
+ v-show="errors.length"
5
+ test-id="datastore-creat-name"
6
+ status="alert-danger"
7
+ :items="errors"
8
+ @remove="onRemoveValidationErrors"
9
+ />
10
+
11
+ <div class="clr-form-control clr-row">
12
+ <label for="datastore-name" class="clr-control-label clr-col-md-2">{{
13
+ localization.datastoreName
14
+ }}</label>
15
+
16
+ <div class="clr-control-container" :class="nameErrorText && 'clr-error'">
17
+ <div class="flex-align-center">
18
+ <input
19
+ id="datastore-name"
20
+ v-model.trim="form.name.value"
21
+ data-id="datastore-name-input"
22
+ type="text"
23
+ class="clr-input"
24
+ @blur="onBlurInputName"
25
+ @input="onInputName"
26
+ />
27
+ <atoms-the-icon class="error-icon" name="info-circle" />
28
+ </div>
29
+
30
+ <div class="clr-subtext ng-star-inserted">
31
+ {{ nameErrorText }}
32
+ </div>
33
+ </div>
34
+ </div>
35
+ </div>
36
+ </template>
37
+
38
+ <script lang="ts" setup>
39
+ import { UI_I_ValidationTouchResult } from '~/lib/models/plugins/validation/interfaces'
40
+ import { UI_I_Localization } from '~/lib/models/interfaces'
41
+ import { UI_I_FormValidationDataStore } from '~/components/common/wizards/datastore/add/sharedStorm/deviceSelection/lib/models/interfaces'
42
+ import { defaultFormFunc } from '~/components/common/wizards/datastore/add/local/createName/lib/config/defaultForm'
43
+ import { checkValidityName } from '~/components/common/wizards/datastore/add/lib/utils'
44
+
45
+ const props = defineProps<{
46
+ localCreateNameSubmit: number
47
+ }>()
48
+ const emits = defineEmits<{
49
+ (event: 'loading', value: boolean): void
50
+ (event: 'submit', value: string): void
51
+ }>()
52
+
53
+ const localization = computed<UI_I_Localization>(() => useLocal())
54
+ const { $validation } = useNuxtApp()
55
+
56
+ const validation = $validation.call({})
57
+ const defaultForm: UI_I_FormValidationDataStore = defaultFormFunc(
58
+ localization.value
59
+ )
60
+ const form = ref<UI_I_FormValidationDataStore>(useDeepCopy(defaultForm))
61
+
62
+ const setForm = () => {
63
+ form.value = useDeepCopy(defaultForm)
64
+ validation.setForm(form)
65
+ }
66
+ setForm()
67
+
68
+ const validForm = ref<UI_I_ValidationTouchResult | null>(null)
69
+
70
+ /* Validation for Name input */
71
+ const isInitNameValidation = ref<boolean>(false)
72
+ const onBlurInputName = (): void => {
73
+ validForm.value = validation.touch()
74
+ isInitNameValidation.value = true
75
+ }
76
+ const onInputName = () => {
77
+ validForm.value = validation.touch()
78
+ }
79
+ const nameErrorText = computed<string>(() => {
80
+ if (!isInitNameValidation.value) return ''
81
+ return validForm.value?.errors?.name?.[0] || ''
82
+ })
83
+ /* Validation Name input end */
84
+
85
+ const errors = ref<string[]>([])
86
+ const showValidationErrors = (data: string[]): void => {
87
+ errors.value = data
88
+ }
89
+ const onRemoveValidationErrors = (): void => {
90
+ errors.value = []
91
+ }
92
+ const submit = async (): Promise<void> => {
93
+ const name = form.value.name.value
94
+
95
+ if (!name) {
96
+ validForm.value = validation.touch()
97
+ isInitNameValidation.value = true
98
+ if (nameErrorText.value) return
99
+ }
100
+
101
+ if (name) {
102
+ emits('loading', true)
103
+
104
+ const { valid, msg } = await checkValidityName(name)
105
+
106
+ emits('loading', false)
107
+
108
+ if (!valid) {
109
+ showValidationErrors([msg])
110
+ return
111
+ }
112
+ }
113
+
114
+ onRemoveValidationErrors()
115
+ emits('submit', name)
116
+ }
117
+ watch(
118
+ () => props.localCreateNameSubmit,
119
+ () => {
120
+ submit()
121
+ }
122
+ )
123
+ </script>
124
+
125
+ <style lang="scss" scoped>
126
+ .create-datastore-name {
127
+ &__alert-info {
128
+ :deep(.alert-text) {
129
+ font-size: 11px;
130
+ letter-spacing: normal;
131
+ }
132
+ }
133
+ .clr-form-control {
134
+ display: flex;
135
+ flex-direction: row;
136
+
137
+ .clr-control-container {
138
+ min-height: 48px;
139
+ input {
140
+ width: 375px;
141
+ }
142
+ &.clr-error {
143
+ .clr-subtext,
144
+ .error-icon {
145
+ display: block;
146
+ }
147
+ }
148
+ .clr-subtext,
149
+ .error-icon {
150
+ display: none;
151
+ }
152
+ .error-icon {
153
+ fill: #db2100;
154
+ width: 24px;
155
+ height: 24px;
156
+ }
157
+ }
158
+ }
159
+ }
160
+ </style>
@@ -295,7 +295,7 @@ const submit = async (): Promise<void> => {
295
295
 
296
296
  emits('loading', true)
297
297
 
298
- const { valid, msg } = await checkValidityName(name.value)
298
+ const { valid, msg } = await checkValidityName(name.value, props.mode)
299
299
 
300
300
  emits('loading', false)
301
301
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.3.328",
4
+ "version": "1.3.330",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",