create.config.ts
3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
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
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
95
96
import { MqttFieldsEnum, MqttFieldsNameEnum } from '../../../enum/formField/external';
import { CredentialsCard } from './CredentialsCard';
import { FormSchema, useComponentRegister } from '/@/components/Form';
useComponentRegister('CredentialsCard', CredentialsCard);
export const formSchemas: FormSchema[] = [
{
field: MqttFieldsEnum.TOPIC_PATTERN,
label: MqttFieldsNameEnum.TOPIC_PATTERN,
component: 'Input',
helpMessage:
'Hint: use ${metadataKey} for value from metadata, $[messageKey] for value from message body',
required: true,
componentProps: {
placeholder: `请输入${MqttFieldsNameEnum.TOPIC_PATTERN}`,
},
},
{
field: MqttFieldsEnum.HOST,
label: MqttFieldsNameEnum.HOST,
component: 'Input',
required: true,
colProps: { span: 8 },
componentProps: {
placeholder: `请输入${MqttFieldsNameEnum.HOST}`,
},
},
{
field: MqttFieldsEnum.PORT,
label: MqttFieldsNameEnum.PORT,
component: 'InputNumber',
required: true,
colProps: { span: 8 },
componentProps: {
placeholder: `请输入${MqttFieldsNameEnum.PORT}`,
},
},
{
field: MqttFieldsEnum.CONNECT_TIMEOUT_SEC,
label: MqttFieldsNameEnum.CONNECT_TIMEOUT_SEC,
component: 'Input',
required: true,
colProps: { span: 8 },
componentProps: {
placeholder: `请输入${MqttFieldsNameEnum.CONNECT_TIMEOUT_SEC}`,
},
},
{
field: MqttFieldsEnum.CLIENT_ID,
label: MqttFieldsNameEnum.CLIENT_ID,
component: 'Input',
helpMessage:
'Hint: Optional. Leave empty for auto-generated Client ID. Be careful when specifying the Client ID. Majority of the MQTT brokers will not allow multiple connections with the same Client ID. To connect to such brokers, your mqtt Client ID must be unique. When platform is running in a micro-services mode, the copy of rule node is launched in each micro-service. This will automatically lead to multiple mqtt clients with the same ID and may cause failures of the rule node. To avoid such failures enable "Add Service ID as suffix to Client ID" option below.',
componentProps: {
placeholder: `请输入${MqttFieldsNameEnum.TOPIC_PATTERN}`,
},
},
{
field: MqttFieldsEnum.APPEND_CLIENT_ID_SUFFIX,
label: MqttFieldsNameEnum.APPEND_CLIENT_ID_SUFFIX,
component: 'Checkbox',
renderComponentContent: () => ({
default: () =>
'Hint: Optional. Applied when "Client ID" specified explicitly. If selected then Service ID will be added to Client ID as a suffix. Helps to avoid failures when platform is running in a micro-services mode.',
}),
componentProps: ({ formModel }) => {
const clientId = formModel[MqttFieldsEnum.CLIENT_ID];
return {
disabled: !clientId,
};
},
},
{
field: MqttFieldsEnum.CLEAN_SESSION,
label: '',
component: 'Checkbox',
renderComponentContent: () => ({
default: () => MqttFieldsNameEnum.CLEAN_SESSION,
}),
},
{
field: MqttFieldsEnum.SSL,
label: '',
component: 'Checkbox',
renderComponentContent: () => ({
default: () => MqttFieldsNameEnum.SSL,
}),
},
{
field: MqttFieldsEnum.CREDENTIALS,
label: MqttFieldsNameEnum.CREDENTIALS,
component: 'CredentialsCard',
slot: MqttFieldsEnum.CREDENTIALS,
},
];