bfg-common 1.3.36 → 1.3.37
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/lib/utils/sendTask.ts +79 -77
- package/package.json +1 -1
- package/store/tasks/actions.ts +1 -1
package/lib/utils/sendTask.ts
CHANGED
|
@@ -1,77 +1,79 @@
|
|
|
1
|
-
import type { UI_I_Localization } from '~/lib/models/interfaces'
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
+
}
|
package/package.json
CHANGED
package/store/tasks/actions.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
API_UI_I_Error,
|
|
3
|
+
API_UI_I_Response,
|
|
3
4
|
UI_I_CommitOptions,
|
|
4
5
|
} from '~/lib/models/store/interfaces'
|
|
5
6
|
import type {
|
|
@@ -16,7 +17,6 @@ import type {
|
|
|
16
17
|
API_UI_I_Task,
|
|
17
18
|
} from '~/lib/models/store/tasks/interfaces'
|
|
18
19
|
import type { UI_I_TasksState } from '~/store/tasks/lib/models/interfaces'
|
|
19
|
-
import type { API_UI_I_Response } from '~/lib/models/interfaces'
|
|
20
20
|
import type { UI_I_RefreshStack } from '~/store/main/lib/interfaces'
|
|
21
21
|
import { tasksConstructor } from '~/store/tasks/mappers/tasks'
|
|
22
22
|
import { recentTasks } from '~/store/tasks/mappers/recentTasks'
|