Commit c7d152e452b5e00a0b47844c9a4c393466abf28f

Authored by loveumiko
1 parent 2d4d93a5

fix: 修改数据流转配置参数问题

... ... @@ -152,12 +152,14 @@ export const modelKafkaForm: FormSchema[] = [
152 152 field: 'otherProperties',
153 153 label: '其他属性',
154 154 colProps: { span: 24 },
  155 + defaultValue: {},
155 156 component: 'JAddInput',
156 157 },
157 158 {
158 159 field: 'addMetadataKeyValuesAsKafkaHeaders',
159 160 label: '是否启用',
160 161 colProps: { span: 12 },
  162 + defaultValue: false,
161 163 component: 'Checkbox',
162 164 renderComponentContent: '将消息的元数据以键值对的方式添加到Kafka消息头中',
163 165 },
... ...
... ... @@ -32,9 +32,9 @@
32 32 import { modelFormPublicConfig } from '../../../dataflowmodal/config';
33 33
34 34 const credentialsFile = reactive({
35   - caCertFileName: '',
36   - certFileName: '',
37   - privateKeyFileName: '',
  35 + caCertFileName: undefined,
  36 + certFileName: undefined,
  37 + privateKeyFileName: undefined,
38 38 });
39 39
40 40 const [register, { validateFields, setFieldsValue, resetFields }] = useForm({
... ...
... ... @@ -12,6 +12,7 @@ class RabbitMqFormPartialConfig {
12 12 static password = 'guest'; //密码
13 13 static connectionTimeout = 60000; //连接超时(毫秒)
14 14 static handshakeTimeout = 10000; //握手超时(毫秒)
  15 + static automaticRecoveryEnabled = false;
15 16
16 17 //anonymous Select options配置
17 18 static getMessageProperties() {
... ... @@ -43,6 +44,7 @@ export const modeRabbitMqForm: FormSchema[] = [
43 44 label: '交换名称模式',
44 45 colProps: { span: 12 },
45 46 component: 'Input',
  47 + defaultValue: '',
46 48 componentProps: {
47 49 maxLength: 255,
48 50 placeholder: '请输入模式',
... ... @@ -52,6 +54,7 @@ export const modeRabbitMqForm: FormSchema[] = [
52 54 field: 'routingKeyPattern',
53 55 label: '路由密钥模式',
54 56 colProps: { span: 12 },
  57 + defaultValue: '',
55 58 component: 'Input',
56 59 componentProps: {
57 60 maxLength: 255,
... ... @@ -63,6 +66,7 @@ export const modeRabbitMqForm: FormSchema[] = [
63 66 component: 'Select',
64 67 label: '消息属性',
65 68 colProps: { span: 12 },
  69 + defaultValue: null,
66 70 componentProps: {
67 71 placeholder: '请选择消息属性',
68 72 options: RabbitMqFormPartialConfig.getMessageProperties(),
... ... @@ -129,6 +133,7 @@ export const modeRabbitMqForm: FormSchema[] = [
129 133 field: 'automaticRecoveryEnabled',
130 134 label: '是否启用',
131 135 colProps: { span: 12 },
  136 + defaultValue: RabbitMqFormPartialConfig.automaticRecoveryEnabled,
132 137 component: 'Checkbox',
133 138 renderComponentContent: '自动恢复',
134 139 },
... ... @@ -159,6 +164,7 @@ export const modeRabbitMqForm: FormSchema[] = [
159 164 label: '客户端属性',
160 165 colProps: { span: 24 },
161 166 component: 'JAddInput',
  167 + defaultValue: {},
162 168 },
163 169 {
164 170 field: 'description',
... ...
... ... @@ -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();
... ...