create.config.ts
3.21 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
97
98
import { useRuleChainI18n } from '../../../hook/useRuleChainI18n';
import { CredentialsCard } from './CredentialsCard';
import { MqttFieldsEnum } from './enum';
import { FormSchema, useComponentRegister } from '/@/components/Form';
const { tLabel, tPlaceholder, t } = useRuleChainI18n('external', 'mqtt');
useComponentRegister('CredentialsCard', CredentialsCard);
export const formSchemas: FormSchema[] = [
{
field: MqttFieldsEnum.TOPIC_PATTERN,
label: tLabel(MqttFieldsEnum.TOPIC_PATTERN),
component: 'Input',
helpMessage:
'Hint: use ${metadataKey} for value from metadata, $[messageKey] for value from message body',
required: true,
componentProps: {
placeholder: tPlaceholder(MqttFieldsEnum.TOPIC_PATTERN),
},
},
{
field: MqttFieldsEnum.HOST,
label: tLabel(MqttFieldsEnum.HOST),
component: 'Input',
required: true,
colProps: { span: 8 },
componentProps: {
placeholder: tPlaceholder(MqttFieldsEnum.HOST),
},
},
{
field: MqttFieldsEnum.PORT,
label: tLabel(MqttFieldsEnum.PORT),
component: 'InputNumber',
required: true,
colProps: { span: 8 },
componentProps: {
placeholder: tPlaceholder(MqttFieldsEnum.PORT),
},
},
{
field: MqttFieldsEnum.CONNECT_TIMEOUT_SEC,
label: tLabel(MqttFieldsEnum.CONNECT_TIMEOUT_SEC),
component: 'Input',
required: true,
colProps: { span: 8 },
componentProps: {
placeholder: tPlaceholder(MqttFieldsEnum.CONNECT_TIMEOUT_SEC),
},
},
{
field: MqttFieldsEnum.CLIENT_ID,
label: tLabel(MqttFieldsEnum.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: tPlaceholder(MqttFieldsEnum.TOPIC_PATTERN),
},
},
{
field: MqttFieldsEnum.APPEND_CLIENT_ID_SUFFIX,
label: tLabel(MqttFieldsEnum.APPEND_CLIENT_ID_SUFFIX),
component: 'Checkbox',
renderComponentContent: () => ({
default: () => t('rule.chain.external.mqtt.fields.appendClientIdSuffixDesc'),
}),
componentProps: ({ formModel }) => {
const clientId = formModel[MqttFieldsEnum.CLIENT_ID];
return {
disabled: !clientId,
};
},
},
{
field: MqttFieldsEnum.CLEAN_SESSION,
label: '',
component: 'Checkbox',
renderComponentContent: () => ({
default: () => tLabel(MqttFieldsEnum.CLEAN_SESSION),
}),
},
{
field: MqttFieldsEnum.SSL,
label: '',
component: 'Checkbox',
renderComponentContent: () => ({
default: () => tLabel(MqttFieldsEnum.SSL),
}),
},
{
field: MqttFieldsEnum.CREDENTIALS,
label: tLabel(MqttFieldsEnum.CREDENTIALS),
component: 'CredentialsCard',
slot: MqttFieldsEnum.CREDENTIALS,
},
];