|
...
|
...
|
@@ -82,6 +82,14 @@ |
|
82
|
82
|
setValue(record);
|
|
83
|
83
|
});
|
|
84
|
84
|
|
|
|
85
|
+ // 判断转换方式
|
|
|
86
|
+ const isRabbitmq = (type) => {
|
|
|
87
|
+ return type == 'org.thingsboard.rule.engine.rabbitmq.TbRabbitMqNode';
|
|
|
88
|
+ };
|
|
|
89
|
+ const isKafka = (type) => {
|
|
|
90
|
+ return type == 'org.thingsboard.rule.engine.kafka.TbKafkaNode';
|
|
|
91
|
+ };
|
|
|
92
|
+
|
|
85
|
93
|
const handleSubmit = async (closeModalAfterSuccess = true) => {
|
|
86
|
94
|
try {
|
|
87
|
95
|
if (closeModalAfterSuccess) {
|
|
...
|
...
|
@@ -98,26 +106,30 @@ |
|
98
|
106
|
getDataFlowParams?.clientProperties
|
|
99
|
107
|
);
|
|
100
|
108
|
const data = getValue(description, name, getDataFlowMethod, getDataFlowParams);
|
|
101
|
|
- const { caCertFileName, certFileName, privateKeyFileName } = getDataFlowParams.credentials;
|
|
102
|
109
|
const configuration = {
|
|
103
|
|
- topicPattern: getDataFlowParams.topicPattern,
|
|
104
|
|
- host: getDataFlowParams.host,
|
|
105
|
|
- port: getDataFlowParams.port,
|
|
106
|
|
- connectTimeoutSec: getDataFlowParams.connectTimeoutSec,
|
|
107
|
|
- clientId: getDataFlowParams.clientId ? getDataFlowParams.clientId : null,
|
|
108
|
|
- cleanSession: getDataFlowParams.cleanSession,
|
|
109
|
|
- ssl: getDataFlowParams.ssl,
|
|
110
|
|
- appendClientIdSuffix: getDataFlowParams.appendClientIdSuffix,
|
|
111
|
|
- credentials: {
|
|
112
|
|
- type: getDataFlowParams.type,
|
|
113
|
|
- caCertFileName: caCertFileName ? caCertFileName : undefined,
|
|
114
|
|
- certFileName: certFileName ? certFileName : undefined,
|
|
115
|
|
- privateKeyFileName: privateKeyFileName ? privateKeyFileName : undefined,
|
|
116
|
|
- username: getDataFlowParams.username ? getDataFlowParams.username : undefined,
|
|
117
|
|
- password: getDataFlowParams.password ? getDataFlowParams.password : undefined,
|
|
118
|
|
- },
|
|
|
110
|
+ ...getDataFlowParams,
|
|
|
111
|
+ clientId: !isKafka(getDataFlowMethod?.type)
|
|
|
112
|
+ ? getDataFlowParams.clientId
|
|
|
113
|
+ ? getDataFlowParams.clientId
|
|
|
114
|
+ : null
|
|
|
115
|
+ : undefined,
|
|
|
116
|
+ kafkaHeadersCharset: isKafka(getDataFlowMethod?.type)
|
|
|
117
|
+ ? getDataFlowParams?.kafkaHeadersCharset
|
|
|
118
|
+ ? getDataFlowParams?.kafkaHeadersCharset
|
|
|
119
|
+ : 'UTF-8'
|
|
|
120
|
+ : undefined,
|
|
|
121
|
+ credentials: !isKafka(getDataFlowMethod?.type)
|
|
|
122
|
+ ? {
|
|
|
123
|
+ ...getDataFlowParams.credentials,
|
|
|
124
|
+ type: getDataFlowParams.type,
|
|
|
125
|
+ username: getDataFlowParams.username ? getDataFlowParams.username : undefined,
|
|
|
126
|
+ password: getDataFlowParams.password ? getDataFlowParams.password : undefined,
|
|
|
127
|
+ }
|
|
|
128
|
+ : undefined,
|
|
119
|
129
|
};
|
|
120
|
|
- const rest = await postAddConvertApi({ ...restData.data, ...data, configuration });
|
|
|
130
|
+ const rest = isRabbitmq(getDataFlowMethod?.type)
|
|
|
131
|
+ ? await postAddConvertApi({ ...restData.data, ...data })
|
|
|
132
|
+ : await postAddConvertApi({ ...restData.data, ...data, configuration });
|
|
121
|
133
|
if (rest) {
|
|
122
|
134
|
closeModalAfterSuccess && createMessage.success(`${businessText.value}成功`);
|
|
123
|
135
|
closeModalAfterSuccess && closeModal();
|
...
|
...
|
|