bfg-common 1.3.39 → 1.3.41
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.
- package/assets/scss/common/icons/icons-2.scss +222 -222
- package/components/atoms/switch/Switch.vue +107 -107
- package/components/common/browse/blocks/Title.vue +66 -66
- package/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/Table.vue +137 -137
- package/components/common/pages/Tasks.vue +120 -120
- package/components/common/recursionTree/RecursionTree.vue +203 -203
- package/components/common/resource/lib/utils.ts +44 -44
- package/components/common/vm/actions/clone/Clone.vue +518 -518
- package/composables/useAppVersion.ts +21 -0
- package/composables/useEnvLanguage.ts +20 -0
- package/composables/useLocal.ts +38 -38
- package/layouts/auth.vue +31 -0
- package/lib/models/composables/useAppVersion/interfaces.ts +5 -0
- package/lib/models/store/tasks/interfaces.ts +108 -108
- package/lib/models/table/interfaces.ts +38 -38
- package/lib/utils/sendTask.ts +79 -79
- package/minify.js +146 -146
- package/package.json +1 -1
- package/public/spice-console/application/codec.js +257 -257
- package/public/spice-console/lib/rasterEngine.js +907 -907
- package/public/spice-console/network/spicechannel.js +369 -369
- package/store/main/lib/interfaces.ts +9 -9
- package/store/tasks/actions.ts +133 -133
- package/store/tasks/getters.ts +25 -25
- package/store/tasks/lib/models/interfaces.ts +18 -18
- package/store/tasks/mappers/tasks.ts +42 -42
- package/store/tasks/mutations.ts +58 -58
- package/store/tasks/state.ts +16 -16
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { UI_I_UseAppVersionReturnType } from '~/lib/models/composables/useAppVersion/interfaces'
|
|
2
|
+
|
|
3
|
+
export function useAppVersion(): UI_I_UseAppVersionReturnType {
|
|
4
|
+
const config = useRuntimeConfig()
|
|
5
|
+
const version = config.public.APP_VERSION
|
|
6
|
+
|
|
7
|
+
const regexHasDot = /\./
|
|
8
|
+
const regexHasDotAndB = /\..*b/
|
|
9
|
+
const regexHasDotAndD = /\..*d/
|
|
10
|
+
|
|
11
|
+
const isBeta = regexHasDotAndB.test(version)
|
|
12
|
+
const isDev =
|
|
13
|
+
regexHasDotAndD.test(version) ||
|
|
14
|
+
(!regexHasDot.test(version) && version.length < 8)
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
version,
|
|
18
|
+
isBeta,
|
|
19
|
+
isDev,
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function useEnvLanguage(): string {
|
|
2
|
+
const { $store }: any = useNuxtApp()
|
|
3
|
+
|
|
4
|
+
let localizationCode = 'en_US'
|
|
5
|
+
const langFromLocalStorage =
|
|
6
|
+
useLocalStorage('lang') || $store.getters['main/getInterfaceLang'] // Из $store для Сферы, но думаю нужно сделать одинаково из localStorage
|
|
7
|
+
if (langFromLocalStorage) {
|
|
8
|
+
if (
|
|
9
|
+
langFromLocalStorage === 'en_US' ||
|
|
10
|
+
langFromLocalStorage === 'ru_RU' ||
|
|
11
|
+
langFromLocalStorage === 'hy_AM'
|
|
12
|
+
) {
|
|
13
|
+
localizationCode = langFromLocalStorage
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
localizationCode = localizationCode.slice(0, 2).toUpperCase()
|
|
18
|
+
|
|
19
|
+
return localizationCode
|
|
20
|
+
}
|
package/composables/useLocal.ts
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import localRu from '~/assets/localization/local_ru.json'
|
|
2
|
-
import localEn from '~/assets/localization/local_en.json'
|
|
3
|
-
import localHy from '~/assets/localization/local_hy.json'
|
|
4
|
-
import localZh from '~/assets/localization/local_zh.json'
|
|
5
|
-
import localKk from '~/assets/localization/local_kk.json'
|
|
6
|
-
import localBe from '~/assets/localization/local_be.json'
|
|
7
|
-
const locals = {
|
|
8
|
-
localRu,
|
|
9
|
-
localEn,
|
|
10
|
-
localHy,
|
|
11
|
-
localZh,
|
|
12
|
-
localKk,
|
|
13
|
-
localBe,
|
|
14
|
-
}
|
|
15
|
-
export const useLocal = () => {
|
|
16
|
-
const config = useRuntimeConfig()
|
|
17
|
-
|
|
18
|
-
const code: string = config?.public?.LOCALIZATION_CODE?.toLowerCase() || 'ru'
|
|
19
|
-
|
|
20
|
-
document.getElementsByTagName('html')[0].setAttribute('lang', code)
|
|
21
|
-
|
|
22
|
-
switch (code) {
|
|
23
|
-
case 'ru':
|
|
24
|
-
return locals.localRu
|
|
25
|
-
case 'en':
|
|
26
|
-
return locals.localEn
|
|
27
|
-
case 'hy':
|
|
28
|
-
return locals.localHy
|
|
29
|
-
case 'zh':
|
|
30
|
-
return locals.localZh
|
|
31
|
-
case 'kk':
|
|
32
|
-
return locals.localKk
|
|
33
|
-
case 'be':
|
|
34
|
-
return locals.localBe
|
|
35
|
-
default:
|
|
36
|
-
return locals.localRu
|
|
37
|
-
}
|
|
38
|
-
}
|
|
1
|
+
import localRu from '~/assets/localization/local_ru.json'
|
|
2
|
+
import localEn from '~/assets/localization/local_en.json'
|
|
3
|
+
import localHy from '~/assets/localization/local_hy.json'
|
|
4
|
+
import localZh from '~/assets/localization/local_zh.json'
|
|
5
|
+
import localKk from '~/assets/localization/local_kk.json'
|
|
6
|
+
import localBe from '~/assets/localization/local_be.json'
|
|
7
|
+
const locals = {
|
|
8
|
+
localRu,
|
|
9
|
+
localEn,
|
|
10
|
+
localHy,
|
|
11
|
+
localZh,
|
|
12
|
+
localKk,
|
|
13
|
+
localBe,
|
|
14
|
+
}
|
|
15
|
+
export const useLocal = () => {
|
|
16
|
+
const config = useRuntimeConfig()
|
|
17
|
+
|
|
18
|
+
const code: string = config?.public?.LOCALIZATION_CODE?.toLowerCase() || 'ru'
|
|
19
|
+
|
|
20
|
+
document.getElementsByTagName('html')[0].setAttribute('lang', code)
|
|
21
|
+
|
|
22
|
+
switch (code) {
|
|
23
|
+
case 'ru':
|
|
24
|
+
return locals.localRu
|
|
25
|
+
case 'en':
|
|
26
|
+
return locals.localEn
|
|
27
|
+
case 'hy':
|
|
28
|
+
return locals.localHy
|
|
29
|
+
case 'zh':
|
|
30
|
+
return locals.localZh
|
|
31
|
+
case 'kk':
|
|
32
|
+
return locals.localKk
|
|
33
|
+
case 'be':
|
|
34
|
+
return locals.localBe
|
|
35
|
+
default:
|
|
36
|
+
return locals.localRu
|
|
37
|
+
}
|
|
38
|
+
}
|
package/layouts/auth.vue
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<Head>
|
|
4
|
+
<Title>{{ companyName }}® | {{ localization.login }}</Title>
|
|
5
|
+
</Head>
|
|
6
|
+
|
|
7
|
+
<slot />
|
|
8
|
+
|
|
9
|
+
<templates-auth-the-footer />
|
|
10
|
+
|
|
11
|
+
<atoms-loader-pre-loader :show="isShowPreLoader" />
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script setup lang="ts">
|
|
16
|
+
import type { UI_I_Localization } from '~/lib/models/interfaces'
|
|
17
|
+
|
|
18
|
+
const config = useRuntimeConfig()
|
|
19
|
+
|
|
20
|
+
const companyName = computed<string>(() => {
|
|
21
|
+
return config.public[`TRADEMARK_${useEnvLanguage()}`]
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
const localization = computed<UI_I_Localization>(() => useLocal())
|
|
25
|
+
|
|
26
|
+
const isShowPreLoader = ref<boolean>(true)
|
|
27
|
+
|
|
28
|
+
onMounted(() => {
|
|
29
|
+
isShowPreLoader.value = false
|
|
30
|
+
})
|
|
31
|
+
</script>
|
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
import type { UI_I_LoadingPayload } from '~/lib/models/store/interfaces'
|
|
2
|
-
import type {
|
|
3
|
-
UI_T_TasksStateLoading,
|
|
4
|
-
UI_T_TaskStatus,
|
|
5
|
-
} from '~/lib/models/store/tasks/types'
|
|
6
|
-
import type { API_UI_I_DataTable } from '~/lib/models/table/interfaces'
|
|
7
|
-
|
|
8
|
-
export interface UI_I_TasksLoadingPayload
|
|
9
|
-
extends UI_I_LoadingPayload<UI_T_TasksStateLoading> {}
|
|
10
|
-
|
|
11
|
-
export interface UI_I_RTaskQuery {
|
|
12
|
-
last: number
|
|
13
|
-
sortBy?: string
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface API_UI_I_RecentTaskItem<T, E = any> {
|
|
17
|
-
args: string // base64
|
|
18
|
-
completion: number
|
|
19
|
-
creation_time: number
|
|
20
|
-
details: string
|
|
21
|
-
error: string
|
|
22
|
-
id: string
|
|
23
|
-
initiator: string
|
|
24
|
-
method: string
|
|
25
|
-
mod_revision: number
|
|
26
|
-
server: string
|
|
27
|
-
start_time: number
|
|
28
|
-
status: UI_T_TaskStatus
|
|
29
|
-
target: string
|
|
30
|
-
target_type: T
|
|
31
|
-
task_name: string
|
|
32
|
-
zone: string
|
|
33
|
-
extra: E // Динамические данные зависит от того что нужно на фронте
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface UI_I_RecentTaskItem<T, E = any> {
|
|
37
|
-
completion: string
|
|
38
|
-
queuedFor: number
|
|
39
|
-
execution: number
|
|
40
|
-
details: string
|
|
41
|
-
error: string
|
|
42
|
-
initiator: string
|
|
43
|
-
server: string
|
|
44
|
-
startTime: string
|
|
45
|
-
status: UI_T_TaskStatus
|
|
46
|
-
statusIcon: string
|
|
47
|
-
statusText: string
|
|
48
|
-
target: string
|
|
49
|
-
targetType: T
|
|
50
|
-
taskName: string
|
|
51
|
-
id: string
|
|
52
|
-
zone: string
|
|
53
|
-
extra: E
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface API_UI_I_RecentTask<T, I = API_UI_I_RecentTaskItem<T>> {
|
|
57
|
-
items: I[]
|
|
58
|
-
last: number
|
|
59
|
-
}
|
|
60
|
-
export interface UI_I_RawRecentTask<T> extends API_UI_I_RecentTask<T> {}
|
|
61
|
-
export interface UI_I_RecentTask<T>
|
|
62
|
-
extends API_UI_I_RecentTask<UI_I_RecentTaskItem<T>> {}
|
|
63
|
-
export interface UI_I_RawRecentTaskItem<T, E = any>
|
|
64
|
-
extends API_UI_I_RecentTaskItem<T, E> {}
|
|
65
|
-
|
|
66
|
-
export interface API_UI_I_TaskItem<T, E = any> {
|
|
67
|
-
completion: number
|
|
68
|
-
creation_time: number
|
|
69
|
-
details: string
|
|
70
|
-
error: string
|
|
71
|
-
id: string
|
|
72
|
-
initiator: string
|
|
73
|
-
method: string
|
|
74
|
-
mod_revision: number
|
|
75
|
-
server: string
|
|
76
|
-
start_time: number
|
|
77
|
-
status: UI_T_TaskStatus
|
|
78
|
-
target: string
|
|
79
|
-
target_type: T
|
|
80
|
-
task_name: string
|
|
81
|
-
zone: string
|
|
82
|
-
extra: E // Динамические данные зависит от того что нужно на фронте
|
|
83
|
-
args?: string // base64
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export interface UI_I_TaskItem<T> {
|
|
87
|
-
relatedEvents: any
|
|
88
|
-
completion: number | string
|
|
89
|
-
queuedFor: number
|
|
90
|
-
execution: number
|
|
91
|
-
details: string
|
|
92
|
-
error: string
|
|
93
|
-
initiator: string
|
|
94
|
-
server: string
|
|
95
|
-
startTime: number | string
|
|
96
|
-
statusIcon: string
|
|
97
|
-
statusText: string
|
|
98
|
-
status: UI_T_TaskStatus
|
|
99
|
-
target: string
|
|
100
|
-
targetType: T
|
|
101
|
-
taskName: string
|
|
102
|
-
id: string
|
|
103
|
-
zone: string
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export interface API_UI_I_Task<T>
|
|
107
|
-
extends API_UI_I_DataTable<API_UI_I_TaskItem<T>[]> {}
|
|
108
|
-
export interface UI_I_Task<T> extends API_UI_I_DataTable<UI_I_TaskItem<T>[]> {}
|
|
1
|
+
import type { UI_I_LoadingPayload } from '~/lib/models/store/interfaces'
|
|
2
|
+
import type {
|
|
3
|
+
UI_T_TasksStateLoading,
|
|
4
|
+
UI_T_TaskStatus,
|
|
5
|
+
} from '~/lib/models/store/tasks/types'
|
|
6
|
+
import type { API_UI_I_DataTable } from '~/lib/models/table/interfaces'
|
|
7
|
+
|
|
8
|
+
export interface UI_I_TasksLoadingPayload
|
|
9
|
+
extends UI_I_LoadingPayload<UI_T_TasksStateLoading> {}
|
|
10
|
+
|
|
11
|
+
export interface UI_I_RTaskQuery {
|
|
12
|
+
last: number
|
|
13
|
+
sortBy?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface API_UI_I_RecentTaskItem<T, E = any> {
|
|
17
|
+
args: string // base64
|
|
18
|
+
completion: number
|
|
19
|
+
creation_time: number
|
|
20
|
+
details: string
|
|
21
|
+
error: string
|
|
22
|
+
id: string
|
|
23
|
+
initiator: string
|
|
24
|
+
method: string
|
|
25
|
+
mod_revision: number
|
|
26
|
+
server: string
|
|
27
|
+
start_time: number
|
|
28
|
+
status: UI_T_TaskStatus
|
|
29
|
+
target: string
|
|
30
|
+
target_type: T
|
|
31
|
+
task_name: string
|
|
32
|
+
zone: string
|
|
33
|
+
extra: E // Динамические данные зависит от того что нужно на фронте
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface UI_I_RecentTaskItem<T, E = any> {
|
|
37
|
+
completion: string
|
|
38
|
+
queuedFor: number
|
|
39
|
+
execution: number
|
|
40
|
+
details: string
|
|
41
|
+
error: string
|
|
42
|
+
initiator: string
|
|
43
|
+
server: string
|
|
44
|
+
startTime: string
|
|
45
|
+
status: UI_T_TaskStatus
|
|
46
|
+
statusIcon: string
|
|
47
|
+
statusText: string
|
|
48
|
+
target: string
|
|
49
|
+
targetType: T
|
|
50
|
+
taskName: string
|
|
51
|
+
id: string
|
|
52
|
+
zone: string
|
|
53
|
+
extra: E
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface API_UI_I_RecentTask<T, I = API_UI_I_RecentTaskItem<T>> {
|
|
57
|
+
items: I[]
|
|
58
|
+
last: number
|
|
59
|
+
}
|
|
60
|
+
export interface UI_I_RawRecentTask<T> extends API_UI_I_RecentTask<T> {}
|
|
61
|
+
export interface UI_I_RecentTask<T>
|
|
62
|
+
extends API_UI_I_RecentTask<UI_I_RecentTaskItem<T>> {}
|
|
63
|
+
export interface UI_I_RawRecentTaskItem<T, E = any>
|
|
64
|
+
extends API_UI_I_RecentTaskItem<T, E> {}
|
|
65
|
+
|
|
66
|
+
export interface API_UI_I_TaskItem<T, E = any> {
|
|
67
|
+
completion: number
|
|
68
|
+
creation_time: number
|
|
69
|
+
details: string
|
|
70
|
+
error: string
|
|
71
|
+
id: string
|
|
72
|
+
initiator: string
|
|
73
|
+
method: string
|
|
74
|
+
mod_revision: number
|
|
75
|
+
server: string
|
|
76
|
+
start_time: number
|
|
77
|
+
status: UI_T_TaskStatus
|
|
78
|
+
target: string
|
|
79
|
+
target_type: T
|
|
80
|
+
task_name: string
|
|
81
|
+
zone: string
|
|
82
|
+
extra: E // Динамические данные зависит от того что нужно на фронте
|
|
83
|
+
args?: string // base64
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface UI_I_TaskItem<T> {
|
|
87
|
+
relatedEvents: any
|
|
88
|
+
completion: number | string
|
|
89
|
+
queuedFor: number
|
|
90
|
+
execution: number
|
|
91
|
+
details: string
|
|
92
|
+
error: string
|
|
93
|
+
initiator: string
|
|
94
|
+
server: string
|
|
95
|
+
startTime: number | string
|
|
96
|
+
statusIcon: string
|
|
97
|
+
statusText: string
|
|
98
|
+
status: UI_T_TaskStatus
|
|
99
|
+
target: string
|
|
100
|
+
targetType: T
|
|
101
|
+
taskName: string
|
|
102
|
+
id: string
|
|
103
|
+
zone: string
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface API_UI_I_Task<T>
|
|
107
|
+
extends API_UI_I_DataTable<API_UI_I_TaskItem<T>[]> {}
|
|
108
|
+
export interface UI_I_Task<T> extends API_UI_I_DataTable<UI_I_TaskItem<T>[]> {}
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import type { UI_T_Schema } from '~/lib/models/table/types'
|
|
2
|
-
|
|
3
|
-
export interface API_UI_I_DataTable<T> {
|
|
4
|
-
total_items: number
|
|
5
|
-
total_pages: number
|
|
6
|
-
items: T
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface UI_I_TableQuery {
|
|
10
|
-
page: number
|
|
11
|
-
page_size: number
|
|
12
|
-
sortBy?: string
|
|
13
|
-
filter?: string
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface UI_I_TableQueryWidthSchema extends UI_I_TableQuery {
|
|
17
|
-
schema: UI_T_Schema
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface UI_I_Pagination {
|
|
21
|
-
page: number
|
|
22
|
-
pageSize: number
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface UI_I_DataTableQuery extends UI_I_Pagination {
|
|
26
|
-
sortBy?: string
|
|
27
|
-
filter?: string
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface UI_I_SchemaTablePayload {
|
|
31
|
-
schema: UI_T_Schema
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface UI_I_TablePayload extends UI_I_SchemaTablePayload {
|
|
35
|
-
pagination: UI_I_Pagination
|
|
36
|
-
type: any
|
|
37
|
-
sortBy: string | null
|
|
38
|
-
}
|
|
1
|
+
import type { UI_T_Schema } from '~/lib/models/table/types'
|
|
2
|
+
|
|
3
|
+
export interface API_UI_I_DataTable<T> {
|
|
4
|
+
total_items: number
|
|
5
|
+
total_pages: number
|
|
6
|
+
items: T
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface UI_I_TableQuery {
|
|
10
|
+
page: number
|
|
11
|
+
page_size: number
|
|
12
|
+
sortBy?: string
|
|
13
|
+
filter?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface UI_I_TableQueryWidthSchema extends UI_I_TableQuery {
|
|
17
|
+
schema: UI_T_Schema
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface UI_I_Pagination {
|
|
21
|
+
page: number
|
|
22
|
+
pageSize: number
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface UI_I_DataTableQuery extends UI_I_Pagination {
|
|
26
|
+
sortBy?: string
|
|
27
|
+
filter?: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface UI_I_SchemaTablePayload {
|
|
31
|
+
schema: UI_T_Schema
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface UI_I_TablePayload extends UI_I_SchemaTablePayload {
|
|
35
|
+
pagination: UI_I_Pagination
|
|
36
|
+
type: any
|
|
37
|
+
sortBy: string | null
|
|
38
|
+
}
|
package/lib/utils/sendTask.ts
CHANGED
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
import type { UI_I_Localization } from '~/lib/models/interfaces'
|
|
2
|
-
import type {
|
|
3
|
-
API_UI_I_Error,
|
|
4
|
-
UI_I_RequestBody,
|
|
5
|
-
} from '~/lib/models/store/interfaces'
|
|
6
|
-
import type {
|
|
7
|
-
UI_I_NotifyBodyMessage,
|
|
8
|
-
UI_I_SendTaskParams,
|
|
9
|
-
} from '~/lib/models/interfaces'
|
|
10
|
-
import { base64 } from './base64'
|
|
11
|
-
|
|
12
|
-
const localization = computed<UI_I_Localization>(() => useLocal())
|
|
13
|
-
|
|
14
|
-
const showNotification = (message: UI_I_NotifyBodyMessage): void => {
|
|
15
|
-
const { title, desc, status } = message
|
|
16
|
-
const { $store } = useNuxtApp()
|
|
17
|
-
|
|
18
|
-
// @ts-ignore
|
|
19
|
-
$store.dispatch('main/A_SHOW_NOTIFICATION', {
|
|
20
|
-
status,
|
|
21
|
-
messages: [
|
|
22
|
-
{
|
|
23
|
-
title,
|
|
24
|
-
descriptions: [desc],
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
|
-
headline: '',
|
|
28
|
-
timeout: status === 'success' ? 3000 : '',
|
|
29
|
-
})
|
|
30
|
-
}
|
|
31
|
-
const msgError: UI_I_NotifyBodyMessage = {
|
|
32
|
-
status: 'error',
|
|
33
|
-
title: localization.value.error,
|
|
34
|
-
desc: '',
|
|
35
|
-
}
|
|
36
|
-
const handleErrors = (error: Ref<API_UI_I_Error>): void => {
|
|
37
|
-
if (error.value.data?.error_message) {
|
|
38
|
-
msgError.desc = error.value.data?.error_message
|
|
39
|
-
showNotification(msgError)
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export const handleRequest = async (
|
|
44
|
-
url: string,
|
|
45
|
-
body: UI_I_RequestBody
|
|
46
|
-
): Promise<boolean> => {
|
|
47
|
-
// @ts-ignore
|
|
48
|
-
const { error } = await useMyFetch<never, API_UI_I_Error>(url, {
|
|
49
|
-
method: 'POST',
|
|
50
|
-
key: Date.now().toString(),
|
|
51
|
-
body,
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
if (error.value && error.value.data.error_code !== 0) {
|
|
55
|
-
handleErrors(error)
|
|
56
|
-
return false
|
|
57
|
-
}
|
|
58
|
-
return true
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export async function sendTask({
|
|
62
|
-
method,
|
|
63
|
-
target,
|
|
64
|
-
args,
|
|
65
|
-
}: UI_I_SendTaskParams): Promise<void> {
|
|
66
|
-
const { $store } = useNuxtApp()
|
|
67
|
-
|
|
68
|
-
const argsToBase64 = args ? base64.encode(args) : ''
|
|
69
|
-
const hasProcess = await handleRequest('/ui/tasks', {
|
|
70
|
-
method,
|
|
71
|
-
params: {
|
|
72
|
-
target,
|
|
73
|
-
args: argsToBase64,
|
|
74
|
-
},
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
// @ts-ignore
|
|
78
|
-
$store.dispatch('tasks/A_SET_PROCESS', hasProcess)
|
|
79
|
-
}
|
|
1
|
+
import type { UI_I_Localization } from '~/lib/models/interfaces'
|
|
2
|
+
import type {
|
|
3
|
+
API_UI_I_Error,
|
|
4
|
+
UI_I_RequestBody,
|
|
5
|
+
} from '~/lib/models/store/interfaces'
|
|
6
|
+
import type {
|
|
7
|
+
UI_I_NotifyBodyMessage,
|
|
8
|
+
UI_I_SendTaskParams,
|
|
9
|
+
} from '~/lib/models/interfaces'
|
|
10
|
+
import { base64 } from './base64'
|
|
11
|
+
|
|
12
|
+
const localization = computed<UI_I_Localization>(() => useLocal())
|
|
13
|
+
|
|
14
|
+
const showNotification = (message: UI_I_NotifyBodyMessage): void => {
|
|
15
|
+
const { title, desc, status } = message
|
|
16
|
+
const { $store } = useNuxtApp()
|
|
17
|
+
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
$store.dispatch('main/A_SHOW_NOTIFICATION', {
|
|
20
|
+
status,
|
|
21
|
+
messages: [
|
|
22
|
+
{
|
|
23
|
+
title,
|
|
24
|
+
descriptions: [desc],
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
headline: '',
|
|
28
|
+
timeout: status === 'success' ? 3000 : '',
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
const msgError: UI_I_NotifyBodyMessage = {
|
|
32
|
+
status: 'error',
|
|
33
|
+
title: localization.value.error,
|
|
34
|
+
desc: '',
|
|
35
|
+
}
|
|
36
|
+
const handleErrors = (error: Ref<API_UI_I_Error>): void => {
|
|
37
|
+
if (error.value.data?.error_message) {
|
|
38
|
+
msgError.desc = error.value.data?.error_message
|
|
39
|
+
showNotification(msgError)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const handleRequest = async (
|
|
44
|
+
url: string,
|
|
45
|
+
body: UI_I_RequestBody
|
|
46
|
+
): Promise<boolean> => {
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
const { error } = await useMyFetch<never, API_UI_I_Error>(url, {
|
|
49
|
+
method: 'POST',
|
|
50
|
+
key: Date.now().toString(),
|
|
51
|
+
body,
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
if (error.value && error.value.data.error_code !== 0) {
|
|
55
|
+
handleErrors(error)
|
|
56
|
+
return false
|
|
57
|
+
}
|
|
58
|
+
return true
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export async function sendTask({
|
|
62
|
+
method,
|
|
63
|
+
target,
|
|
64
|
+
args,
|
|
65
|
+
}: UI_I_SendTaskParams): Promise<void> {
|
|
66
|
+
const { $store } = useNuxtApp()
|
|
67
|
+
|
|
68
|
+
const argsToBase64 = args ? base64.encode(args) : ''
|
|
69
|
+
const hasProcess = await handleRequest('/ui/tasks', {
|
|
70
|
+
method,
|
|
71
|
+
params: {
|
|
72
|
+
target,
|
|
73
|
+
args: argsToBase64,
|
|
74
|
+
},
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
// @ts-ignore
|
|
78
|
+
$store.dispatch('tasks/A_SET_PROCESS', hasProcess)
|
|
79
|
+
}
|