bfg-common 1.5.784 → 1.5.786

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.
@@ -27,6 +27,7 @@
27
27
  <script setup lang="ts">
28
28
  import type { API_UI_I_Error } from '~/lib/models/store/interfaces'
29
29
  import type { UI_I_Localization } from '~/lib/models/interfaces'
30
+ import { validateObjectName } from '~/lib/utils/validation'
30
31
  import type { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
31
32
  import type { UI_I_NameTestIds } from '~/components/common/wizards/common/steps/name/lib/models/interfaces'
32
33
 
@@ -107,9 +108,7 @@ const submit = async (cb: Function): Promise<void> => {
107
108
  (location.value &&
108
109
  !props.allowedLocationKinds.includes(location.value.kind))
109
110
  ) {
110
- showValidationErrors([
111
- props.validationDescription,
112
- ])
111
+ showValidationErrors([props.validationDescription])
113
112
  cb(false)
114
113
  isDisabledField.value = false
115
114
  return
@@ -122,7 +121,13 @@ const submit = async (cb: Function): Promise<void> => {
122
121
  }
123
122
  // TODO use for import vms
124
123
  const checkNameIsValid = async (nameLocal: string): Promise<boolean> => {
125
- const nameRequestUrlLocal = props.nameRequestUrl.replace('{name}', nameLocal)
124
+ const nameRequestUrlLocal: string = props.nameRequestUrl.replace('{name}', nameLocal)
125
+
126
+
127
+ const { statusCode } = await validateObjectName({ url: nameRequestUrlLocal })
128
+
129
+ console.log(statusCode, 11)
130
+
126
131
  const { error } = await useMyFetch<null, API_UI_I_Error>(
127
132
  nameRequestUrlLocal,
128
133
  {
@@ -147,9 +152,7 @@ const checkNameIsValid = async (nameLocal: string): Promise<boolean> => {
147
152
  ])
148
153
  return false
149
154
  case 409: // Name exist
150
- showValidationErrors([
151
- props.nameExistValidationDescription,
152
- ])
155
+ showValidationErrors([props.nameExistValidationDescription])
153
156
  return false
154
157
  }
155
158
 
@@ -1,7 +1,8 @@
1
1
  import Wizard from '~/node_modules/bfg-uikit/components/ui/wizard/lib/utils/utils'
2
- import type { API_UI_I_Error } from '~/lib/models/store/interfaces'
2
+ // import type { API_UI_I_Error } from '~/lib/models/store/interfaces'
3
3
  import type { UI_T_Project } from '~/lib/models/types'
4
- import { UI_E_Kind } from '~/lib/models/enums'
4
+ import { UI_E_ObjectNodeKind } from '~/lib/models/enums'
5
+ import { validateObjectName } from '~/lib/utils/validation'
5
6
 
6
7
  export const checkValidityName = async ({
7
8
  name,
@@ -17,39 +18,47 @@ export const checkValidityName = async ({
17
18
  datacenterId?: string
18
19
  }): Promise<void> => {
19
20
  wizard.setLoader(true)
20
- const url = buildValidationUrl(name, project, datacenterId)
21
21
 
22
- const { error } = await useMyFetch<null, API_UI_I_Error>(url, {
23
- method: 'GET',
22
+ const { error } = await validateObjectName({
23
+ name,
24
+ project,
25
+ kind: UI_E_ObjectNodeKind.DATASTORE,
26
+ datacenterId,
24
27
  })
25
28
 
29
+ // const url = buildValidationUrl(name, project, datacenterId)
30
+ // const { error } = await useMyFetch<null, API_UI_I_Error>(url, {
31
+ // method: 'GET',
32
+ // })
33
+
26
34
  wizard.setLoader(false)
35
+ sendMessage(error)
27
36
 
28
- if (error.value && error.value.data.error_code !== 0) {
29
- const existError = error.value.data?.error_message || error.value.data
30
- sendMessage(existError)
31
- return
32
- }
33
- sendMessage('')
37
+ // if (error.value && error.value.data.error_code !== 0) {
38
+ // const existError = error.value.data?.error_message || error.value.data
39
+ // sendMessage(existError)
40
+ // return
41
+ // }
42
+ // sendMessage('')
34
43
  }
35
44
 
36
- const buildValidationUrl = (
37
- name: string,
38
- project: UI_T_Project,
39
- datacenterId?: string
40
- ): string => {
41
- if (project === 'procurator') {
42
- const params = new URLSearchParams({ name })
43
- return `/ui/ds/validate?${params.toString()}`
44
- }
45
-
46
- const params = new URLSearchParams()
47
- params.set('name', name)
48
- params.set('kind', String(UI_E_Kind.STORAGE_VALIDATION_NAME))
49
- if (datacenterId) params.set('datacenter', datacenterId)
50
-
51
- return `/ui/object/validate_name_datacenter?${params.toString()}`
52
- }
45
+ // const buildValidationUrl = (
46
+ // name: string,
47
+ // project: UI_T_Project,
48
+ // datacenterId?: string
49
+ // ): string => {
50
+ // if (project === 'procurator') {
51
+ // const params = new URLSearchParams({ name })
52
+ // return `/ui/ds/validate?${params.toString()}`
53
+ // }
54
+ //
55
+ // const params = new URLSearchParams()
56
+ // params.set('name', name)
57
+ // params.set('kind', String(UI_E_ObjectNodeKind.DATASTORE))
58
+ // if (datacenterId) params.set('datacenter', datacenterId)
59
+ //
60
+ // return `/ui/object/validate_name_datacenter?${params.toString()}`
61
+ // }
53
62
 
54
63
  export const validateNameAndGenerateDataId = (
55
64
  name: string,
@@ -1,6 +1,7 @@
1
1
  import type { UI_I_ModalPayloadSchedulerData } from '~/components/common/pages/scheduledTasks/lib/models/interfaces'
2
2
  import type { UI_T_NotificationStatus } from '~/components/atoms/alert/lib/models/types'
3
- import { UI_E_State } from '~/lib/models/enums'
3
+ import type { UI_T_Project } from '~/lib/models/types'
4
+ import { UI_E_ObjectNodeKind, UI_E_State } from '~/lib/models/enums'
4
5
 
5
6
  export interface UI_I_ItemView {
6
7
  value: number | string
@@ -96,3 +97,14 @@ export interface UI_I_ModalPayload<T = any> {
96
97
  isShow: boolean
97
98
  scheduler: UI_I_ModalPayloadSchedulerData<T>
98
99
  }
100
+
101
+ export interface UI_I_ValidateNameByParams {
102
+ name: string
103
+ project: UI_T_Project
104
+ kind?: UI_E_ObjectNodeKind
105
+ datacenterId?: string
106
+ }
107
+
108
+ export interface UI_I_ValidateNameByUrl {
109
+ url: string
110
+ }
@@ -1,40 +1,23 @@
1
1
  import type { API_UI_I_Error } from '~/lib/models/store/interfaces'
2
+ import type {
3
+ UI_I_ValidateNameByParams,
4
+ UI_I_ValidateNameByUrl,
5
+ } from '~/lib/models/interfaces'
2
6
  import type { UI_T_Project } from '~/lib/models/types'
3
7
  import { UI_E_ObjectNodeKind } from '~/lib/models/enums'
4
8
 
5
- // const onChangeName = async (name: string): Promise<void> => {
6
- //
7
- //
8
- // isLoading.value = true
9
- // const { statusCode } = await checkName(name, 'sphere', UI_E_ObjectNodeKind.DATASTORE)
10
- // isLoading.value = false
11
- //
12
- // /* TODO: сделать глобально */
13
- // switch (statusCode) {
14
- // case 200: // OK
15
- // alertErrorText.value = null
16
- // break
17
- // case 405: // Invalid kind
18
- // break
19
- // case 406: // Invalid name
20
- // break
21
- // case 409: // Name exist
22
- // alertErrorText.value =
23
- // localization.value.common.datastoreExistsTheSelectedLocation
24
- // break
25
- // }
26
- //
27
- // if (alertErrorText.value) return
28
- // onHide()
29
- // }
30
-
31
- const checkName = async (
32
- name: string,
33
- project: UI_T_Project,
34
- kind?: UI_E_ObjectNodeKind,
35
- datacenterId?: string
36
- ): Promise<{ statusCode: number; error?: string }> => {
37
- const url = buildValidationUrl(name, project, kind, datacenterId)
9
+ export const validateObjectName = async (
10
+ args: UI_I_ValidateNameByParams | UI_I_ValidateNameByUrl
11
+ ): Promise<{ statusCode: number; error: string }> => {
12
+ const url =
13
+ 'url' in args
14
+ ? args.url
15
+ : buildValidationUrl(
16
+ args.name,
17
+ args.project,
18
+ args.kind,
19
+ args.datacenterId
20
+ )
38
21
  console.log(url, 'checkName URL')
39
22
 
40
23
  const { error } = await useMyFetch<null, API_UI_I_Error>(url, {
@@ -44,6 +27,7 @@ const checkName = async (
44
27
  if (!error.value) {
45
28
  return {
46
29
  statusCode: 200,
30
+ error: '',
47
31
  }
48
32
  }
49
33
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.5.784",
4
+ "version": "1.5.786",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",