bfg-common 1.5.630 → 1.5.632
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/localization/local_be.json +4 -0
- package/assets/localization/local_en.json +4 -0
- package/assets/localization/local_hy.json +4 -0
- package/assets/localization/local_kk.json +4 -0
- package/assets/localization/local_ru.json +4 -0
- package/assets/localization/local_zh.json +4 -0
- package/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/lib/config/utils.ts +1 -2
- package/lib/models/interfaces.ts +1 -0
- package/lib/models/store/tasks/interfaces.ts +9 -0
- package/lib/models/store/tasks/types.ts +7 -1
- package/package.json +1 -1
- package/store/tasks/actions.ts +165 -144
- package/store/tasks/mappers/recentTasks.ts +118 -94
- package/store/tasks/mutations.ts +82 -64
|
@@ -3691,5 +3691,9 @@
|
|
|
3691
3691
|
"lastCreateSubtitle": "Праверце падрабязнасці перад рэгістрацыяй віртуальнай машыны.",
|
|
3692
3692
|
"registerVmSelectFile": "Рэгістрацыя ВМ — Выбар файла",
|
|
3693
3693
|
"nameAlreadyExistsDescription": "Запіс з такой назвай ужо існуе."
|
|
3694
|
+
},
|
|
3695
|
+
"files": {
|
|
3696
|
+
"deleteFileDescription": "Вы ўпэўнены, што хочаце выдаліць «{0}»?",
|
|
3697
|
+
"deleteFilesDescription": "Вы ўпэўнены, што хочаце выдаліць {0} файлаў?"
|
|
3694
3698
|
}
|
|
3695
3699
|
}
|
|
@@ -3695,5 +3695,9 @@
|
|
|
3695
3695
|
"lastCreateSubtitle": "Review the details before the virtual machine is registered.",
|
|
3696
3696
|
"registerVmSelectFile": "Register VM - Select File",
|
|
3697
3697
|
"nameAlreadyExistsDescription": "A record with this name already exists."
|
|
3698
|
+
},
|
|
3699
|
+
"files": {
|
|
3700
|
+
"deleteFileDescription": "Are you sure you want to delete “{0}”?",
|
|
3701
|
+
"deleteFilesDescription": "Are you sure you want to delete {0} files?"
|
|
3698
3702
|
}
|
|
3699
3703
|
}
|
|
@@ -3696,5 +3696,9 @@
|
|
|
3696
3696
|
"lastCreateSubtitle": "Ստուգեք մանրամասները՝ մինչ վիրտուալ մեքենայի գրանցումը։",
|
|
3697
3697
|
"registerVmSelectFile": "Գրանցել VM — Ընտրել ֆայլ",
|
|
3698
3698
|
"nameAlreadyExistsDescription": "Այս անունով գրառում արդեն գոյություն ունի։"
|
|
3699
|
+
},
|
|
3700
|
+
"files": {
|
|
3701
|
+
"deleteFileDescription": "Վստա՞հ եք, որ ցանկանում եք ջնջել «{0}»-ը։",
|
|
3702
|
+
"deleteFilesDescription": "Վստա՞հ եք, որ ցանկանում եք ջնջել {0} ֆայլ։"
|
|
3699
3703
|
}
|
|
3700
3704
|
}
|
|
@@ -3694,5 +3694,9 @@
|
|
|
3694
3694
|
"lastCreateSubtitle": "Виртуалды машинаны тіркемес бұрын мәліметтерді тексеріңіз.",
|
|
3695
3695
|
"registerVmSelectFile": "VM тіркеу — Файл таңдау",
|
|
3696
3696
|
"nameAlreadyExistsDescription": "Бұл атаумен жазба бұрыннан бар."
|
|
3697
|
+
},
|
|
3698
|
+
"files": {
|
|
3699
|
+
"deleteFileDescription": "«{0}» файлын жоюға сенімдісіз бе?",
|
|
3700
|
+
"deleteFilesDescription": "{0} файлды жоюға сенімдісіз бе?"
|
|
3697
3701
|
}
|
|
3698
3702
|
}
|
|
@@ -3694,5 +3694,9 @@
|
|
|
3694
3694
|
"lastCreateSubtitle": "Проверьте данные перед регистрацией виртуальной машины.",
|
|
3695
3695
|
"registerVmSelectFile": "Зарегистрировать ВМ — Выбор файла",
|
|
3696
3696
|
"nameAlreadyExistsDescription": "Запись с таким именем уже существует."
|
|
3697
|
+
},
|
|
3698
|
+
"files": {
|
|
3699
|
+
"deleteFileDescription": "Вы уверены, что хотите удалить «{0}»?",
|
|
3700
|
+
"deleteFilesDescription": "Вы уверены, что хотите удалить {0} файлов?"
|
|
3697
3701
|
}
|
|
3698
3702
|
}
|
|
@@ -3692,5 +3692,9 @@
|
|
|
3692
3692
|
"lastCreateSubtitle": "在注册虚拟机之前请先检查详细信息。",
|
|
3693
3693
|
"registerVmSelectFile": "注册虚拟机 — 选择文件",
|
|
3694
3694
|
"nameAlreadyExistsDescription": "已存在同名记录。"
|
|
3695
|
+
},
|
|
3696
|
+
"files": {
|
|
3697
|
+
"deleteFileDescription": "您确定要删除“{0}”吗?",
|
|
3698
|
+
"deleteFilesDescription": "您确定要删除 {0} 个文件吗?"
|
|
3695
3699
|
}
|
|
3696
3700
|
}
|
package/lib/models/interfaces.ts
CHANGED
|
@@ -57,6 +57,7 @@ export interface UI_I_Localization {
|
|
|
57
57
|
identityProvider: UI_I_ArbitraryObject<string>
|
|
58
58
|
sphereAvailability: UI_I_ArbitraryObject<string>
|
|
59
59
|
registerVm: UI_I_ArbitraryObject<string>
|
|
60
|
+
files: UI_I_ArbitraryObject<string>
|
|
60
61
|
}
|
|
61
62
|
export interface UI_I_SendTaskParams {
|
|
62
63
|
method: string
|
|
@@ -33,6 +33,10 @@ export interface API_UI_I_RecentTaskItem<T, E = any> {
|
|
|
33
33
|
args: string // base64
|
|
34
34
|
completion: number
|
|
35
35
|
creation_time: number
|
|
36
|
+
progress: {
|
|
37
|
+
percent: number
|
|
38
|
+
message: string
|
|
39
|
+
}
|
|
36
40
|
details: string
|
|
37
41
|
error: string
|
|
38
42
|
id: string
|
|
@@ -76,6 +80,11 @@ export interface UI_I_RecentTaskItem<T, E = any> {
|
|
|
76
80
|
id: string
|
|
77
81
|
zone: string
|
|
78
82
|
extra: E
|
|
83
|
+
progress: {
|
|
84
|
+
percent: number
|
|
85
|
+
message: string
|
|
86
|
+
}
|
|
87
|
+
isCanceled: boolean
|
|
79
88
|
}
|
|
80
89
|
|
|
81
90
|
export interface API_UI_I_RecentTask<T, I = API_UI_I_RecentTaskItem<T>> {
|
package/package.json
CHANGED
package/store/tasks/actions.ts
CHANGED
|
@@ -1,144 +1,165 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
API_UI_I_Error,
|
|
3
|
-
API_UI_I_Response,
|
|
4
|
-
UI_I_CommitOptions,
|
|
5
|
-
} from '~/lib/models/store/interfaces'
|
|
6
|
-
import type {
|
|
7
|
-
UI_I_DataTableQuery,
|
|
8
|
-
UI_I_TableQuery,
|
|
9
|
-
} from '~/lib/models/table/interfaces'
|
|
10
|
-
import type { UI_I_Options } from '~/lib/models/composables/useMyFetch/interfaces'
|
|
11
|
-
import type {
|
|
12
|
-
API_UI_I_RecentTask,
|
|
13
|
-
UI_I_RTaskQuery,
|
|
14
|
-
UI_I_TasksLoadingPayload,
|
|
15
|
-
UI_I_RawRecentTask,
|
|
16
|
-
UI_I_RecentTask,
|
|
17
|
-
API_UI_I_Task,
|
|
18
|
-
} from '~/lib/models/store/tasks/interfaces'
|
|
19
|
-
import type { UI_I_TasksState } from '~/store/tasks/lib/models/interfaces'
|
|
20
|
-
import type { UI_I_RefreshStack } from '~/store/main/lib/interfaces'
|
|
21
|
-
import { tasksConstructor } from '~/store/tasks/mappers/tasks'
|
|
22
|
-
import { recentTasks } from '~/store/tasks/mappers/recentTasks'
|
|
23
|
-
|
|
24
|
-
export default {
|
|
25
|
-
async A_GET_TASKS(
|
|
26
|
-
context: {
|
|
27
|
-
commit: <T>(arg0: string, arg1: T) => void
|
|
28
|
-
state: UI_I_TasksState
|
|
29
|
-
dispatch: <T>(arg0: string, arg1: T, arg2: UI_I_CommitOptions) => void
|
|
30
|
-
},
|
|
31
|
-
payload: UI_I_DataTableQuery
|
|
32
|
-
): Promise<API_UI_I_Error | void> {
|
|
33
|
-
const { page, pageSize, sortBy, filter } = payload
|
|
34
|
-
|
|
35
|
-
const query: UI_I_TableQuery = {
|
|
36
|
-
page_size: pageSize,
|
|
37
|
-
page,
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (sortBy) query.sortBy = sortBy
|
|
41
|
-
if (filter) query.filter = filter
|
|
42
|
-
|
|
43
|
-
const queryJson: string = JSON.stringify({ type: 'tasks', ...query })
|
|
44
|
-
const lastQuery: string = context.state.taskQuery || ''
|
|
45
|
-
|
|
46
|
-
if (queryJson === lastQuery) {
|
|
47
|
-
// Снимаем с паузы сам запрос, для глобального обновления
|
|
48
|
-
context.dispatch<string>('main/A_CONTINUE_GLOBAL_REFRESH', queryJson, {
|
|
49
|
-
root: true,
|
|
50
|
-
})
|
|
51
|
-
return
|
|
52
|
-
}
|
|
53
|
-
context.commit('M_SET_TASKS_LAST_QUERY', queryJson)
|
|
54
|
-
|
|
55
|
-
const url = '/ui/tasks'
|
|
56
|
-
const options: UI_I_Options = {
|
|
57
|
-
query,
|
|
58
|
-
method: 'GET',
|
|
59
|
-
key: Date.now().toString(),
|
|
60
|
-
onRequest() {
|
|
61
|
-
context.commit<UI_I_TasksLoadingPayload>('M_SET_LOADING', {
|
|
62
|
-
prop: 'tasks',
|
|
63
|
-
value: true,
|
|
64
|
-
})
|
|
65
|
-
},
|
|
66
|
-
onResponse({ response }: API_UI_I_Response<API_UI_I_Task<string>>) {
|
|
67
|
-
const tasks = tasksConstructor(response._data)
|
|
68
|
-
|
|
69
|
-
context.commit('M_SET_TASKS_LIST', tasks)
|
|
70
|
-
context.commit<UI_I_TasksLoadingPayload>('M_SET_LOADING', {
|
|
71
|
-
prop: 'tasks',
|
|
72
|
-
value: false,
|
|
73
|
-
})
|
|
74
|
-
},
|
|
75
|
-
}
|
|
76
|
-
const { error } = await useMyFetch<API_UI_I_Task<string>, API_UI_I_Error>(
|
|
77
|
-
url,
|
|
78
|
-
options
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
if (error.value?.data?.error_code)
|
|
82
|
-
throw new Error(error.value.data.error_message)
|
|
83
|
-
|
|
84
|
-
context.dispatch<UI_I_RefreshStack>(
|
|
85
|
-
'main/A_ADD_IN_GLOBAL_REFRESH',
|
|
86
|
-
{ key: queryJson, url, options },
|
|
87
|
-
{ root: true }
|
|
88
|
-
)
|
|
89
|
-
},
|
|
90
|
-
async A_GET_RECENT_TASKS(
|
|
91
|
-
context: {
|
|
92
|
-
commit: <T>(arg0: string, arg1: T) => void
|
|
93
|
-
state: UI_I_TasksState
|
|
94
|
-
},
|
|
95
|
-
payload: string
|
|
96
|
-
): Promise<void> {
|
|
97
|
-
const query: UI_I_RTaskQuery = {
|
|
98
|
-
last: context.state.recentTaskList?.last || 0,
|
|
99
|
-
}
|
|
100
|
-
if (payload) query.sortBy = payload
|
|
101
|
-
|
|
102
|
-
// Создаем контроллер для возможности отмены
|
|
103
|
-
const abortController = new AbortController()
|
|
104
|
-
context.commit('M_SET_ABORT_CONTROLLER', abortController)
|
|
105
|
-
|
|
106
|
-
const { data, error } = await useMyFetch<
|
|
107
|
-
API_UI_I_RecentTask<string>,
|
|
108
|
-
API_UI_I_Error
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
//
|
|
129
|
-
//
|
|
130
|
-
//
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
1
|
+
import type {
|
|
2
|
+
API_UI_I_Error,
|
|
3
|
+
API_UI_I_Response,
|
|
4
|
+
UI_I_CommitOptions,
|
|
5
|
+
} from '~/lib/models/store/interfaces'
|
|
6
|
+
import type {
|
|
7
|
+
UI_I_DataTableQuery,
|
|
8
|
+
UI_I_TableQuery,
|
|
9
|
+
} from '~/lib/models/table/interfaces'
|
|
10
|
+
import type { UI_I_Options } from '~/lib/models/composables/useMyFetch/interfaces'
|
|
11
|
+
import type {
|
|
12
|
+
API_UI_I_RecentTask,
|
|
13
|
+
UI_I_RTaskQuery,
|
|
14
|
+
UI_I_TasksLoadingPayload,
|
|
15
|
+
UI_I_RawRecentTask,
|
|
16
|
+
UI_I_RecentTask,
|
|
17
|
+
API_UI_I_Task,
|
|
18
|
+
} from '~/lib/models/store/tasks/interfaces'
|
|
19
|
+
import type { UI_I_TasksState } from '~/store/tasks/lib/models/interfaces'
|
|
20
|
+
import type { UI_I_RefreshStack } from '~/store/main/lib/interfaces'
|
|
21
|
+
import { tasksConstructor } from '~/store/tasks/mappers/tasks'
|
|
22
|
+
import { recentTasks } from '~/store/tasks/mappers/recentTasks'
|
|
23
|
+
|
|
24
|
+
export default {
|
|
25
|
+
async A_GET_TASKS(
|
|
26
|
+
context: {
|
|
27
|
+
commit: <T>(arg0: string, arg1: T) => void
|
|
28
|
+
state: UI_I_TasksState
|
|
29
|
+
dispatch: <T>(arg0: string, arg1: T, arg2: UI_I_CommitOptions) => void
|
|
30
|
+
},
|
|
31
|
+
payload: UI_I_DataTableQuery
|
|
32
|
+
): Promise<API_UI_I_Error | void> {
|
|
33
|
+
const { page, pageSize, sortBy, filter } = payload
|
|
34
|
+
|
|
35
|
+
const query: UI_I_TableQuery = {
|
|
36
|
+
page_size: pageSize,
|
|
37
|
+
page,
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (sortBy) query.sortBy = sortBy
|
|
41
|
+
if (filter) query.filter = filter
|
|
42
|
+
|
|
43
|
+
const queryJson: string = JSON.stringify({ type: 'tasks', ...query })
|
|
44
|
+
const lastQuery: string = context.state.taskQuery || ''
|
|
45
|
+
|
|
46
|
+
if (queryJson === lastQuery) {
|
|
47
|
+
// Снимаем с паузы сам запрос, для глобального обновления
|
|
48
|
+
context.dispatch<string>('main/A_CONTINUE_GLOBAL_REFRESH', queryJson, {
|
|
49
|
+
root: true,
|
|
50
|
+
})
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
context.commit('M_SET_TASKS_LAST_QUERY', queryJson)
|
|
54
|
+
|
|
55
|
+
const url = '/ui/tasks'
|
|
56
|
+
const options: UI_I_Options = {
|
|
57
|
+
query,
|
|
58
|
+
method: 'GET',
|
|
59
|
+
key: Date.now().toString(),
|
|
60
|
+
onRequest() {
|
|
61
|
+
context.commit<UI_I_TasksLoadingPayload>('M_SET_LOADING', {
|
|
62
|
+
prop: 'tasks',
|
|
63
|
+
value: true,
|
|
64
|
+
})
|
|
65
|
+
},
|
|
66
|
+
onResponse({ response }: API_UI_I_Response<API_UI_I_Task<string>>) {
|
|
67
|
+
const tasks = tasksConstructor(response._data)
|
|
68
|
+
|
|
69
|
+
context.commit('M_SET_TASKS_LIST', tasks)
|
|
70
|
+
context.commit<UI_I_TasksLoadingPayload>('M_SET_LOADING', {
|
|
71
|
+
prop: 'tasks',
|
|
72
|
+
value: false,
|
|
73
|
+
})
|
|
74
|
+
},
|
|
75
|
+
}
|
|
76
|
+
const { error } = await useMyFetch<API_UI_I_Task<string>, API_UI_I_Error>(
|
|
77
|
+
url,
|
|
78
|
+
options
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
if (error.value?.data?.error_code)
|
|
82
|
+
throw new Error(error.value.data.error_message)
|
|
83
|
+
|
|
84
|
+
context.dispatch<UI_I_RefreshStack>(
|
|
85
|
+
'main/A_ADD_IN_GLOBAL_REFRESH',
|
|
86
|
+
{ key: queryJson, url, options },
|
|
87
|
+
{ root: true }
|
|
88
|
+
)
|
|
89
|
+
},
|
|
90
|
+
async A_GET_RECENT_TASKS(
|
|
91
|
+
context: {
|
|
92
|
+
commit: <T>(arg0: string, arg1: T) => void
|
|
93
|
+
state: UI_I_TasksState
|
|
94
|
+
},
|
|
95
|
+
payload: string
|
|
96
|
+
): Promise<void> {
|
|
97
|
+
const query: UI_I_RTaskQuery = {
|
|
98
|
+
last: context.state.recentTaskList?.last || 0,
|
|
99
|
+
}
|
|
100
|
+
if (payload) query.sortBy = payload
|
|
101
|
+
|
|
102
|
+
// Создаем контроллер для возможности отмены
|
|
103
|
+
const abortController = new AbortController()
|
|
104
|
+
context.commit('M_SET_ABORT_CONTROLLER', abortController)
|
|
105
|
+
|
|
106
|
+
const { data, error } = await useMyFetch<
|
|
107
|
+
API_UI_I_RecentTask<string>,
|
|
108
|
+
API_UI_I_Error
|
|
109
|
+
// >('/ui/tasks/watch', {
|
|
110
|
+
>('/ui/rtasks', {
|
|
111
|
+
query,
|
|
112
|
+
method: 'GET',
|
|
113
|
+
initialCache: false,
|
|
114
|
+
signal: abortController.signal,
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
if (error.value?.data?.error_code)
|
|
118
|
+
throw new Error(error.value.data.error_message)
|
|
119
|
+
|
|
120
|
+
context.commit<UI_I_RecentTask<string>>(
|
|
121
|
+
'M_SET_RECENT_TASKS_LIST',
|
|
122
|
+
recentTasks(data.value)
|
|
123
|
+
)
|
|
124
|
+
context.commit<UI_I_RawRecentTask<string>>(
|
|
125
|
+
'M_SET_UPDATED_RECENT_TASKS_LIST',
|
|
126
|
+
data.value
|
|
127
|
+
)
|
|
128
|
+
// context.commit<I_TasksLoadingPayload>('M_SET_LOADING', {
|
|
129
|
+
// prop: 'recentTasks',
|
|
130
|
+
// value: false,
|
|
131
|
+
// })
|
|
132
|
+
},
|
|
133
|
+
A_CANCEL_RECENT_TASKS(context: { commit: (arg0: string) => void }): void {
|
|
134
|
+
context.commit('M_CANCEL_RECENT_TASKS')
|
|
135
|
+
},
|
|
136
|
+
async M_HIDE_CANCEL_RECENT_TASK_BY_ID(
|
|
137
|
+
context: {
|
|
138
|
+
commit: (arg0: string, arg1: string) => void
|
|
139
|
+
},
|
|
140
|
+
payload: string
|
|
141
|
+
): Promise<void> {
|
|
142
|
+
// Скрываем кнопку cancel
|
|
143
|
+
context.commit(
|
|
144
|
+
'A_HIDE_CANCEL_RECENT_TASK_BY_ID',
|
|
145
|
+
payload
|
|
146
|
+
)
|
|
147
|
+
const { error } = await useMyFetch<
|
|
148
|
+
API_UI_I_RecentTask<string>,
|
|
149
|
+
API_UI_I_Error
|
|
150
|
+
>(`/ui/tasks/${payload}/cancel`, {
|
|
151
|
+
method: 'POST',
|
|
152
|
+
initialCache: false,
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
if (error.value?.data?.error_code)
|
|
156
|
+
throw new Error(error.value.data.error_message)
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
// Вызывается в useMyFetch когда получаем первый ответ от запроса с url tasks
|
|
160
|
+
// и default.vue когда срабатывает watch на recentTasks
|
|
161
|
+
// Нужно для того чтобы не обрабатывали те таски которые были сделаны перед загрузкой страницы
|
|
162
|
+
A_SET_FIRST_TASK(context: { commit: (arg0: string) => void }): void {
|
|
163
|
+
context.commit('M_SET_FIRST_TASK')
|
|
164
|
+
},
|
|
165
|
+
}
|
|
@@ -1,94 +1,118 @@
|
|
|
1
|
-
import {
|
|
2
|
-
UI_E_RecentTaskStatus,
|
|
3
|
-
UI_E_IconNameByRecentTaskStatus,
|
|
4
|
-
} from '~/lib/models/store/tasks/enums'
|
|
5
|
-
import type {
|
|
6
|
-
API_UI_I_RecentTask,
|
|
7
|
-
UI_I_RecentTask,
|
|
8
|
-
UI_T_TaskStatusDetails,
|
|
9
|
-
} from '~/lib/models/store/tasks/interfaces'
|
|
10
|
-
import { base64 } from '~/lib/utils/base64'
|
|
11
|
-
import {
|
|
12
|
-
UI_E_RecentTaskStatusIcon,
|
|
13
|
-
UI_E_RecentTaskStatusIconNewView,
|
|
14
|
-
} from '~/store/tasks/lib/models/enums'
|
|
15
|
-
|
|
16
|
-
export const recentTasks = (
|
|
17
|
-
data: API_UI_I_RecentTask<string>
|
|
18
|
-
): UI_I_RecentTask<string> => {
|
|
19
|
-
const { $store }: any = useNuxtApp()
|
|
20
|
-
|
|
21
|
-
const isNewView = $store.getters['main/getIsNewView']
|
|
22
|
-
|
|
23
|
-
const items =
|
|
24
|
-
data.items
|
|
25
|
-
?.sort((a, b) => {
|
|
26
|
-
return b.start_time - a.start_time
|
|
27
|
-
})
|
|
28
|
-
.map((task) => {
|
|
29
|
-
let args: any = {}
|
|
30
|
-
try {
|
|
31
|
-
args = base64.decode(task.args)
|
|
32
|
-
} catch (error) {
|
|
33
|
-
args = {}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let completion: string = task.completion + '' || '--'
|
|
37
|
-
let execution: string | number = Math.abs(
|
|
38
|
-
task.start_time - task.completion
|
|
39
|
-
)
|
|
40
|
-
let queuedFor: number = task.start_time - task.creation_time
|
|
41
|
-
let startTime: string = task.start_time + '' || '--'
|
|
42
|
-
// Обрабатываем данные когда задачка в ожидании
|
|
43
|
-
if (task.status === 0) {
|
|
44
|
-
completion = '--'
|
|
45
|
-
execution = '--'
|
|
46
|
-
queuedFor = 0
|
|
47
|
-
startTime = Date.now() / 1000 + ''
|
|
48
|
-
// Обрабатываем данные когда задачка в работе
|
|
49
|
-
} else if (task.status === 1) {
|
|
50
|
-
completion = '--'
|
|
51
|
-
execution = '--'
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const { upd_operations } = task.extra
|
|
55
|
-
const operations: UI_T_TaskStatusDetails[] =
|
|
56
|
-
upd_operations?.operations?.map(
|
|
57
|
-
(operation: UI_T_TaskStatusDetails) => {
|
|
58
|
-
return {
|
|
59
|
-
...operation,
|
|
60
|
-
iconClassName: isNewView
|
|
61
|
-
? UI_E_RecentTaskStatusIconNewView[operation.status]
|
|
62
|
-
: UI_E_RecentTaskStatusIcon[operation.status],
|
|
63
|
-
testId: operation.operation_type.replaceAll(' ', '-'),
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
) || []
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
1
|
+
import {
|
|
2
|
+
UI_E_RecentTaskStatus,
|
|
3
|
+
UI_E_IconNameByRecentTaskStatus,
|
|
4
|
+
} from '~/lib/models/store/tasks/enums'
|
|
5
|
+
import type {
|
|
6
|
+
API_UI_I_RecentTask,
|
|
7
|
+
UI_I_RecentTask,
|
|
8
|
+
UI_T_TaskStatusDetails,
|
|
9
|
+
} from '~/lib/models/store/tasks/interfaces'
|
|
10
|
+
import { base64 } from '~/lib/utils/base64'
|
|
11
|
+
import {
|
|
12
|
+
UI_E_RecentTaskStatusIcon,
|
|
13
|
+
UI_E_RecentTaskStatusIconNewView,
|
|
14
|
+
} from '~/store/tasks/lib/models/enums'
|
|
15
|
+
|
|
16
|
+
export const recentTasks = (
|
|
17
|
+
data: API_UI_I_RecentTask<string>
|
|
18
|
+
): UI_I_RecentTask<string> => {
|
|
19
|
+
const { $store }: any = useNuxtApp()
|
|
20
|
+
|
|
21
|
+
const isNewView = $store.getters['main/getIsNewView']
|
|
22
|
+
|
|
23
|
+
const items =
|
|
24
|
+
data.items
|
|
25
|
+
?.sort((a, b) => {
|
|
26
|
+
return b.start_time - a.start_time
|
|
27
|
+
})
|
|
28
|
+
.map((task) => {
|
|
29
|
+
let args: any = {}
|
|
30
|
+
try {
|
|
31
|
+
args = base64.decode(task.args)
|
|
32
|
+
} catch (error) {
|
|
33
|
+
args = {}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let completion: string = task.completion + '' || '--'
|
|
37
|
+
let execution: string | number = Math.abs(
|
|
38
|
+
task.start_time - task.completion
|
|
39
|
+
)
|
|
40
|
+
let queuedFor: number = task.start_time - task.creation_time
|
|
41
|
+
let startTime: string = task.start_time + '' || '--'
|
|
42
|
+
// Обрабатываем данные когда задачка в ожидании
|
|
43
|
+
if (task.status === 0) {
|
|
44
|
+
completion = '--'
|
|
45
|
+
execution = '--'
|
|
46
|
+
queuedFor = 0
|
|
47
|
+
startTime = Date.now() / 1000 + ''
|
|
48
|
+
// Обрабатываем данные когда задачка в работе
|
|
49
|
+
} else if (task.status === 1) {
|
|
50
|
+
completion = '--'
|
|
51
|
+
execution = '--'
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const { upd_operations } = task.extra
|
|
55
|
+
const operations: UI_T_TaskStatusDetails[] =
|
|
56
|
+
upd_operations?.operations?.map(
|
|
57
|
+
(operation: UI_T_TaskStatusDetails) => {
|
|
58
|
+
return {
|
|
59
|
+
...operation,
|
|
60
|
+
iconClassName: isNewView
|
|
61
|
+
? UI_E_RecentTaskStatusIconNewView[operation.status]
|
|
62
|
+
: UI_E_RecentTaskStatusIcon[operation.status],
|
|
63
|
+
testId: operation.operation_type.replaceAll(' ', '-'),
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
) || []
|
|
67
|
+
|
|
68
|
+
// TODO
|
|
69
|
+
let statusIcon = 'help-icon'
|
|
70
|
+
switch (task.status) {
|
|
71
|
+
case 0:
|
|
72
|
+
statusIcon = 'help-icon'
|
|
73
|
+
break
|
|
74
|
+
case 1:
|
|
75
|
+
statusIcon = 'green-play'
|
|
76
|
+
break
|
|
77
|
+
case 2:
|
|
78
|
+
statusIcon = 'success-circle'
|
|
79
|
+
break
|
|
80
|
+
case 3:
|
|
81
|
+
case 4:
|
|
82
|
+
statusIcon = 'error-outline'
|
|
83
|
+
break
|
|
84
|
+
case 5:
|
|
85
|
+
statusIcon = 'warning-outline'
|
|
86
|
+
break
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
args,
|
|
91
|
+
completion,
|
|
92
|
+
execution,
|
|
93
|
+
queuedFor,
|
|
94
|
+
startTime,
|
|
95
|
+
statusIcon,
|
|
96
|
+
progress: task.progress,
|
|
97
|
+
details: task.details,
|
|
98
|
+
error: task.error,
|
|
99
|
+
initiator: task.initiator,
|
|
100
|
+
server: task.server,
|
|
101
|
+
// statusIcon: UI_E_IconNameByRecentTaskStatus[task.status],
|
|
102
|
+
statusText: task.error || UI_E_RecentTaskStatus[task.status],
|
|
103
|
+
status: task.status,
|
|
104
|
+
statusDetails: operations,
|
|
105
|
+
target: task.target,
|
|
106
|
+
targetType: task.target_type,
|
|
107
|
+
taskName: task.task_name,
|
|
108
|
+
id: task.id,
|
|
109
|
+
zone: task.zone,
|
|
110
|
+
extra: task.extra,
|
|
111
|
+
isCanceled: task.status === 4
|
|
112
|
+
}
|
|
113
|
+
}) || []
|
|
114
|
+
return {
|
|
115
|
+
items,
|
|
116
|
+
last: data.last,
|
|
117
|
+
}
|
|
118
|
+
}
|
package/store/tasks/mutations.ts
CHANGED
|
@@ -1,64 +1,82 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
UI_I_RawRecentTask,
|
|
3
|
-
UI_I_TasksLoadingPayload,
|
|
4
|
-
UI_I_RecentTask,
|
|
5
|
-
UI_I_Task,
|
|
6
|
-
} from '~/lib/models/store/tasks/interfaces'
|
|
7
|
-
import type { UI_I_TasksState } from '~/store/tasks/lib/models/interfaces'
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
M_SET_RECENT_TASKS_LIST(
|
|
11
|
-
state: UI_I_TasksState,
|
|
12
|
-
payload: UI_I_RecentTask<string>
|
|
13
|
-
): void {
|
|
14
|
-
if (state.recentTaskList) {
|
|
15
|
-
state.recentTaskList.last = payload.last
|
|
16
|
-
|
|
17
|
-
// Заменяем которые уже имеются и удаляем их из payload.items
|
|
18
|
-
state.recentTaskList.items = state.recentTaskList.items.map((task) => {
|
|
19
|
-
let changedTask = null
|
|
20
|
-
payload.items = payload.items.filter((task2) => {
|
|
21
|
-
if (task2.id === task.id) changedTask = task2
|
|
22
|
-
return task2.id !== task.id
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
return changedTask || task
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
// Делаем слияние новых и старых tasks
|
|
29
|
-
state.recentTaskList.items = [
|
|
30
|
-
...payload.items,
|
|
31
|
-
...state.recentTaskList.items,
|
|
32
|
-
]
|
|
33
|
-
return
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
state.recentTaskList = payload
|
|
37
|
-
},
|
|
38
|
-
M_SET_ABORT_CONTROLLER(
|
|
39
|
-
state
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
state.abortController
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
state.
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
state
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
state
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
1
|
+
import type {
|
|
2
|
+
UI_I_RawRecentTask,
|
|
3
|
+
UI_I_TasksLoadingPayload,
|
|
4
|
+
UI_I_RecentTask,
|
|
5
|
+
UI_I_Task,
|
|
6
|
+
} from '~/lib/models/store/tasks/interfaces'
|
|
7
|
+
import type { UI_I_TasksState } from '~/store/tasks/lib/models/interfaces'
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
M_SET_RECENT_TASKS_LIST(
|
|
11
|
+
state: UI_I_TasksState,
|
|
12
|
+
payload: UI_I_RecentTask<string>
|
|
13
|
+
): void {
|
|
14
|
+
if (state.recentTaskList) {
|
|
15
|
+
state.recentTaskList.last = payload.last
|
|
16
|
+
|
|
17
|
+
// Заменяем которые уже имеются и удаляем их из payload.items
|
|
18
|
+
state.recentTaskList.items = state.recentTaskList.items.map((task) => {
|
|
19
|
+
let changedTask = null
|
|
20
|
+
payload.items = payload.items.filter((task2) => {
|
|
21
|
+
if (task2.id === task.id) changedTask = task2
|
|
22
|
+
return task2.id !== task.id
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
return changedTask || task
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
// Делаем слияние новых и старых tasks
|
|
29
|
+
state.recentTaskList.items = [
|
|
30
|
+
...payload.items,
|
|
31
|
+
...state.recentTaskList.items,
|
|
32
|
+
]
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
state.recentTaskList = payload
|
|
37
|
+
},
|
|
38
|
+
M_SET_ABORT_CONTROLLER(
|
|
39
|
+
state: UI_I_TasksState,
|
|
40
|
+
payload: AbortController
|
|
41
|
+
): void {
|
|
42
|
+
state.abortController = payload
|
|
43
|
+
},
|
|
44
|
+
M_CANCEL_RECENT_TASKS(state: UI_I_TasksState): void {
|
|
45
|
+
state.abortController && state.abortController.abort()
|
|
46
|
+
},
|
|
47
|
+
M_HIDE_CANCEL_RECENT_TASK_BY_ID(
|
|
48
|
+
state: UI_I_TasksState,
|
|
49
|
+
payload: string
|
|
50
|
+
): void {
|
|
51
|
+
if (!state.recentTaskList) return
|
|
52
|
+
state.recentTaskList.items = state.recentTaskList.items.map((task) => {
|
|
53
|
+
if (task.id === payload) {
|
|
54
|
+
task.isCanceled = true
|
|
55
|
+
}
|
|
56
|
+
return task
|
|
57
|
+
})
|
|
58
|
+
},
|
|
59
|
+
M_SET_TASKS_LAST_QUERY(state: UI_I_TasksState, payload: string): void {
|
|
60
|
+
state.taskLastRequestType = payload
|
|
61
|
+
},
|
|
62
|
+
M_SET_TASKS_LIST(state: UI_I_TasksState, payload: UI_I_Task<string>): void {
|
|
63
|
+
state.taskList = payload
|
|
64
|
+
},
|
|
65
|
+
M_SET_UPDATED_RECENT_TASKS_LIST(
|
|
66
|
+
state: UI_I_TasksState,
|
|
67
|
+
payload: UI_I_RawRecentTask<string>
|
|
68
|
+
): void {
|
|
69
|
+
state.updatedTaskList = payload.items
|
|
70
|
+
},
|
|
71
|
+
M_SET_FIRST_TASK(state: UI_I_TasksState): void {
|
|
72
|
+
state.hasFirstTask = true
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
M_SET_LOADING(
|
|
76
|
+
state: UI_I_TasksState,
|
|
77
|
+
payload: UI_I_TasksLoadingPayload
|
|
78
|
+
): void {
|
|
79
|
+
const { prop, value } = payload
|
|
80
|
+
state.loading[prop] = value
|
|
81
|
+
},
|
|
82
|
+
}
|