bfg-common 1.3.246 → 1.3.248
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/components/atoms/alert/lib/models/interfaces.ts +2 -2
- package/components/atoms/switch/Switch.vue +111 -111
- package/components/atoms/table/compact/Compact.vue +526 -526
- package/components/common/diagramMain/DiagramMain.vue +57 -55
- package/components/common/diagramMain/modals/ManagePhysicalAdaptersModal.vue +9 -26
- package/components/common/diagramMain/modals/remove/RemoveModal.vue +9 -6
- package/components/common/diagramMain/port/Port.vue +15 -2
- package/components/common/vm/actions/clone/Clone.vue +518 -518
- package/components/common/vm/actions/common/customizeHardware/CustomizeHardware.vue +269 -269
- package/components/common/vm/actions/common/customizeHardware/virtualHardware/VirtualHardware.vue +693 -693
- package/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/config/dropdownItems.ts +59 -59
- package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/NewPciDevice.vue +165 -165
- package/components/common/vm/actions/common/select/storage/lib/config/config.ts +166 -166
- package/components/common/vm/actions/editSettings/EditSettings.vue +313 -313
- package/components/common/weekSelect/lib/config/options.ts +10 -10
- package/components/common/wizards/network/add/Add.vue +34 -23
- package/components/common/wizards/network/add/lib/models/interfaces.ts +13 -7
- package/composables/useAppVersion.ts +21 -21
- package/composables/useEnvLanguage.ts +20 -20
- package/lib/models/interfaces.ts +2 -2
- package/lib/utils/sendTask.ts +72 -72
- 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/mutations.ts +58 -58
- package/store/tasks/state.ts +16 -16
|
@@ -129,6 +129,7 @@ import {
|
|
|
129
129
|
UI_I_AdapterStatus,
|
|
130
130
|
UI_I_SwitchAdapterItem,
|
|
131
131
|
UI_I_DiagramData,
|
|
132
|
+
API_UI_I_SwitchItem,
|
|
132
133
|
} from '~/components/common/diagramMain/lib/models/interfaces'
|
|
133
134
|
import {
|
|
134
135
|
UI_I_ValidationReturn,
|
|
@@ -175,6 +176,7 @@ const props = withDefaults(
|
|
|
175
176
|
tcpStacks?: UI_I_TCPStack[]
|
|
176
177
|
tcpStackLoading?: boolean
|
|
177
178
|
diagramsData?: UI_I_DiagramData[]
|
|
179
|
+
isNetworkingLoading?: boolean
|
|
178
180
|
}>(),
|
|
179
181
|
{
|
|
180
182
|
standardSwitchesInitial: () => [],
|
|
@@ -186,6 +188,7 @@ const props = withDefaults(
|
|
|
186
188
|
tcpStacks: () => [],
|
|
187
189
|
tcpStackLoading: false,
|
|
188
190
|
diagramsData: [],
|
|
191
|
+
isNetworkingLoading: false,
|
|
189
192
|
}
|
|
190
193
|
)
|
|
191
194
|
|
|
@@ -486,17 +489,19 @@ const onGetFreeAdapters = (showAddAdapterModal: () => void): void => {
|
|
|
486
489
|
}
|
|
487
490
|
|
|
488
491
|
const checkFinal = async (): Promise<UI_I_ArbitraryObject<string>> => {
|
|
489
|
-
let
|
|
490
|
-
| UI_I_AddNetworkingZeroOrFirstSchemeDataSend
|
|
492
|
+
let data:
|
|
491
493
|
| UI_I_AddNetworkingSecondOrThirdSchemeDataSend
|
|
494
|
+
| UI_I_AddNetworkingZeroOrFirstSchemeDataSend
|
|
492
495
|
| UI_I_AddNetworkingFourthOrFifthSchemeDataSend
|
|
496
|
+
| API_UI_I_SwitchItem
|
|
497
|
+
| null = null
|
|
493
498
|
|
|
494
499
|
let type: 'network' | 'vmkernel' | 'adapter'
|
|
495
500
|
|
|
496
501
|
if (wizard.isSelectedScheme(0) || wizard.isSelectedScheme(1)) {
|
|
497
502
|
const vlan = getVlanId(portProperties.value.vlanId)
|
|
498
503
|
|
|
499
|
-
|
|
504
|
+
data = addNetworkingZeroOrFirstSchemeDataFunc(
|
|
500
505
|
targetDevice.value,
|
|
501
506
|
Number(vlan),
|
|
502
507
|
portProperties.value,
|
|
@@ -511,7 +516,7 @@ const checkFinal = async (): Promise<UI_I_ArbitraryObject<string>> => {
|
|
|
511
516
|
if (wizard.isSelectedScheme(2) || wizard.isSelectedScheme(3)) {
|
|
512
517
|
const vlan = getVlanId(connectionSettings.value.vlanId)
|
|
513
518
|
|
|
514
|
-
|
|
519
|
+
data = addNetworkingSecondOrThirdSchemeDataFunc(
|
|
515
520
|
connectionSettings.value,
|
|
516
521
|
targetDevice.value,
|
|
517
522
|
Number(vlan),
|
|
@@ -523,7 +528,7 @@ const checkFinal = async (): Promise<UI_I_ArbitraryObject<string>> => {
|
|
|
523
528
|
}
|
|
524
529
|
|
|
525
530
|
if (wizard.isSelectedScheme(4) || wizard.isSelectedScheme(5)) {
|
|
526
|
-
|
|
531
|
+
data = addNetworkingFourthOrFifthSchemeDataFunc(
|
|
527
532
|
targetDevice.value.switch,
|
|
528
533
|
wizard.isSelectedScheme(4),
|
|
529
534
|
adapterStatus.value,
|
|
@@ -537,7 +542,7 @@ const checkFinal = async (): Promise<UI_I_ArbitraryObject<string>> => {
|
|
|
537
542
|
return new Promise((resolve, _reject) =>
|
|
538
543
|
emits(
|
|
539
544
|
'add-networking-data-validate',
|
|
540
|
-
|
|
545
|
+
data,
|
|
541
546
|
type,
|
|
542
547
|
(err_arg: UI_I_ArbitraryObject<string>): void => {
|
|
543
548
|
resolve(err_arg)
|
|
@@ -551,13 +556,13 @@ const finalValidationFunc = async (
|
|
|
551
556
|
): Promise<UI_I_ValidationReturn> => {
|
|
552
557
|
let stepHasError = false
|
|
553
558
|
|
|
554
|
-
wizard.setLoader(true)
|
|
559
|
+
// wizard.setLoader(true)
|
|
555
560
|
|
|
556
561
|
const validationFields: {
|
|
557
562
|
[key: string]: string
|
|
558
563
|
} = await checkFinal()
|
|
559
564
|
|
|
560
|
-
wizard.setLoader(false)
|
|
565
|
+
// wizard.setLoader(false)
|
|
561
566
|
|
|
562
567
|
for (const fieldName in validationFields) {
|
|
563
568
|
const stepId = wizard.getStepIdByFieldName(fieldName)
|
|
@@ -723,17 +728,19 @@ const onHideAddNetworkingModal = (): void => {
|
|
|
723
728
|
}
|
|
724
729
|
|
|
725
730
|
const onSubmit = async (): Promise<void> => {
|
|
726
|
-
|
|
727
|
-
let sendData:
|
|
728
|
-
| UI_I_AddNetworkingZeroOrFirstSchemeDataSend
|
|
731
|
+
let data:
|
|
729
732
|
| UI_I_AddNetworkingSecondOrThirdSchemeDataSend
|
|
733
|
+
| UI_I_AddNetworkingZeroOrFirstSchemeDataSend
|
|
734
|
+
| UI_I_AddNetworkingFourthOrFifthSchemeDataSend
|
|
735
|
+
| API_UI_I_SwitchItem
|
|
730
736
|
| null = null
|
|
737
|
+
|
|
731
738
|
let type: 'network' | 'vmkernel' | 'adapter' = 'network'
|
|
732
739
|
|
|
733
740
|
if (wizard.isSelectedScheme(0) || wizard.isSelectedScheme(1)) {
|
|
734
741
|
const vlan = getVlanId(portProperties.value.vlanId)
|
|
735
742
|
type = 'vmkernel'
|
|
736
|
-
|
|
743
|
+
data = addNetworkingZeroOrFirstSchemeDataFunc(
|
|
737
744
|
targetDevice.value,
|
|
738
745
|
Number(vlan),
|
|
739
746
|
portProperties.value,
|
|
@@ -746,7 +753,7 @@ const onSubmit = async (): Promise<void> => {
|
|
|
746
753
|
if (wizard.isSelectedScheme(2) || wizard.isSelectedScheme(3)) {
|
|
747
754
|
const vlan = getVlanId(connectionSettings.value.vlanId)
|
|
748
755
|
type = 'network'
|
|
749
|
-
|
|
756
|
+
data = addNetworkingSecondOrThirdSchemeDataFunc(
|
|
750
757
|
connectionSettings.value,
|
|
751
758
|
targetDevice.value,
|
|
752
759
|
Number(vlan),
|
|
@@ -757,7 +764,7 @@ const onSubmit = async (): Promise<void> => {
|
|
|
757
764
|
|
|
758
765
|
if (wizard.isSelectedScheme(4) || wizard.isSelectedScheme(5)) {
|
|
759
766
|
type = 'adapter'
|
|
760
|
-
|
|
767
|
+
data = addNetworkingFourthOrFifthSchemeDataFunc(
|
|
761
768
|
targetDevice.value.switch,
|
|
762
769
|
wizard.isSelectedScheme(4),
|
|
763
770
|
adapterStatus.value,
|
|
@@ -766,20 +773,24 @@ const onSubmit = async (): Promise<void> => {
|
|
|
766
773
|
)
|
|
767
774
|
}
|
|
768
775
|
|
|
769
|
-
|
|
770
|
-
emits(
|
|
771
|
-
'send-add-networking-data',
|
|
772
|
-
sendData,
|
|
773
|
-
type,
|
|
774
|
-
() => wizard.setLoader(false),
|
|
775
|
-
onHideAddNetworkingModal
|
|
776
|
-
)
|
|
776
|
+
data &&
|
|
777
|
+
emits('send-add-networking-data', data, type, onHideAddNetworkingModal)
|
|
777
778
|
}
|
|
778
779
|
|
|
779
780
|
onMounted(() => {
|
|
780
781
|
hostname.value = location.hostname
|
|
781
782
|
})
|
|
782
783
|
|
|
784
|
+
watch(
|
|
785
|
+
() => props.isNetworkingLoading,
|
|
786
|
+
(newValue: boolean) => {
|
|
787
|
+
wizard.setLoader(newValue)
|
|
788
|
+
},
|
|
789
|
+
{
|
|
790
|
+
immediate: true,
|
|
791
|
+
}
|
|
792
|
+
)
|
|
793
|
+
|
|
783
794
|
watch(
|
|
784
795
|
props.tcpStacks,
|
|
785
796
|
(newValue: UI_I_TCPStack[]) => {
|
|
@@ -1018,4 +1029,4 @@ watch(
|
|
|
1018
1029
|
color: var(--main-color-mode2);
|
|
1019
1030
|
}
|
|
1020
1031
|
}
|
|
1021
|
-
</style>
|
|
1032
|
+
</style>
|
|
@@ -4,6 +4,10 @@ import {
|
|
|
4
4
|
UI_I_State,
|
|
5
5
|
} from '~/lib/models/interfaces'
|
|
6
6
|
import { UI_T_TCP } from '~/components/common/wizards/network/add/lib/models/types'
|
|
7
|
+
import {
|
|
8
|
+
UI_I_AdapterStatus,
|
|
9
|
+
API_UI_I_SwitchItem,
|
|
10
|
+
} from '~/components/common/diagramMain/lib/models/interfaces'
|
|
7
11
|
|
|
8
12
|
export interface UI_I_Services {
|
|
9
13
|
vMotion?: boolean
|
|
@@ -69,7 +73,8 @@ export interface UI_I_SelectedNetwork {
|
|
|
69
73
|
export interface UI_I_Switch {
|
|
70
74
|
name: string
|
|
71
75
|
id: string
|
|
72
|
-
mtu
|
|
76
|
+
mtu: number
|
|
77
|
+
nics: UI_I_AdapterStatus
|
|
73
78
|
}
|
|
74
79
|
|
|
75
80
|
export interface UI_I_SelectedSwitch {
|
|
@@ -193,22 +198,23 @@ export interface UI_I_AddNetworkingEmits {
|
|
|
193
198
|
(event: 'hide'): void
|
|
194
199
|
(
|
|
195
200
|
event: 'add-networking-data-validate',
|
|
196
|
-
|
|
201
|
+
data:
|
|
197
202
|
| UI_I_AddNetworkingSecondOrThirdSchemeDataSend
|
|
198
203
|
| UI_I_AddNetworkingZeroOrFirstSchemeDataSend
|
|
199
|
-
| UI_I_AddNetworkingFourthOrFifthSchemeDataSend
|
|
204
|
+
| UI_I_AddNetworkingFourthOrFifthSchemeDataSend
|
|
205
|
+
| API_UI_I_SwitchItem,
|
|
200
206
|
type: string,
|
|
201
207
|
setValidation: (err_arg: UI_I_ArbitraryObject<string>) => void
|
|
202
208
|
): void
|
|
203
209
|
(
|
|
204
210
|
event: 'send-add-networking-data',
|
|
205
|
-
|
|
211
|
+
data:
|
|
206
212
|
| UI_I_AddNetworkingSecondOrThirdSchemeDataSend
|
|
207
213
|
| UI_I_AddNetworkingZeroOrFirstSchemeDataSend
|
|
208
|
-
| UI_I_AddNetworkingFourthOrFifthSchemeDataSend
|
|
214
|
+
| UI_I_AddNetworkingFourthOrFifthSchemeDataSend
|
|
215
|
+
| API_UI_I_SwitchItem,
|
|
209
216
|
type: string,
|
|
210
|
-
|
|
211
|
-
onHideAddNetworkingModal: () => void
|
|
217
|
+
hideModal: () => void
|
|
212
218
|
): void
|
|
213
219
|
(event: 'get-existing-standard-switches', cb: () => void): void
|
|
214
220
|
(event: 'get-free-adapters', cb: () => void): void
|
|
@@ -1,21 +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
|
-
}
|
|
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
|
+
}
|
|
@@ -1,20 +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
|
-
}
|
|
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/lib/models/interfaces.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { UI_T_NotificationStatus } from '~/components/atoms/alert/lib/models/types'
|
|
2
2
|
import { UI_E_State } from '~/lib/models/enums'
|
|
3
3
|
|
|
4
4
|
export interface UI_I_ItemView {
|
|
@@ -21,7 +21,7 @@ export interface UI_I_SendTaskParams {
|
|
|
21
21
|
args: any
|
|
22
22
|
}
|
|
23
23
|
export interface UI_I_NotifyBodyMessage {
|
|
24
|
-
status:
|
|
24
|
+
status: UI_T_NotificationStatus
|
|
25
25
|
title: string
|
|
26
26
|
desc: string
|
|
27
27
|
}
|
package/lib/utils/sendTask.ts
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
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<void> => {
|
|
47
|
-
// @ts-ignore
|
|
48
|
-
const { error } = await useMyFetch<never, API_UI_I_Error>(url, {
|
|
49
|
-
body,
|
|
50
|
-
method: 'POST',
|
|
51
|
-
key: Date.now().toString(),
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
if (error.value && error.value.data.error_code !== 0) {
|
|
55
|
-
handleErrors(error)
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export async function sendTask({
|
|
60
|
-
method,
|
|
61
|
-
target,
|
|
62
|
-
args,
|
|
63
|
-
}: UI_I_SendTaskParams): Promise<void> {
|
|
64
|
-
const argsToBase64 = args ? base64.encode(args) : ''
|
|
65
|
-
await handleRequest('/ui/tasks', {
|
|
66
|
-
method,
|
|
67
|
-
params: {
|
|
68
|
-
target,
|
|
69
|
-
args: argsToBase64,
|
|
70
|
-
},
|
|
71
|
-
})
|
|
72
|
-
}
|
|
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<void> => {
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
const { error } = await useMyFetch<never, API_UI_I_Error>(url, {
|
|
49
|
+
body,
|
|
50
|
+
method: 'POST',
|
|
51
|
+
key: Date.now().toString(),
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
if (error.value && error.value.data.error_code !== 0) {
|
|
55
|
+
handleErrors(error)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export async function sendTask({
|
|
60
|
+
method,
|
|
61
|
+
target,
|
|
62
|
+
args,
|
|
63
|
+
}: UI_I_SendTaskParams): Promise<void> {
|
|
64
|
+
const argsToBase64 = args ? base64.encode(args) : ''
|
|
65
|
+
await handleRequest('/ui/tasks', {
|
|
66
|
+
method,
|
|
67
|
+
params: {
|
|
68
|
+
target,
|
|
69
|
+
args: argsToBase64,
|
|
70
|
+
},
|
|
71
|
+
})
|
|
72
|
+
}
|