Commit 0d6a4215 authored by 皮倩雯's avatar 皮倩雯

fix: '运维前端增加EMQ_API 地址和 版本控制'

parent 1b169213
Pipeline #83281 passed with stages
......@@ -16,6 +16,7 @@ import {
Tooltip,
Modal,
Space,
Radio,
} from 'antd';
import { CloseCircleFilled, InfoCircleFilled, QuestionCircleOutlined } from '@ant-design/icons';
import styles from './IotConfig.less';
......@@ -40,6 +41,8 @@ import {
IsIotUpgrade, // 判断是否需要升级物联网统一接入平台
IotUpgrade, // 升级物联网统一接入平台
GetIotVersion, // 检查版本BS还是CS
SaveSysConfigurate,
SysConfiguration,
} from '@/services/hostmanager/hostmanager';
import {
GetDbProduct, // 获取产品方案配置
......@@ -225,19 +228,6 @@ const IotConfig = props => {
setFlag(1);
getCurrentConfig();
getSiteCode();
// HealthCheck()
// .then(ress => {
// if (ress.success) {
// setFlag(1);
// getCurrentConfig();
// getSiteCode();
// } else {
// setFlag(0);
// }
// })
// .catch(err => {
// console.log(err);
// });
}
}
});
......@@ -249,12 +239,16 @@ const IotConfig = props => {
}
});
form.setFieldsValue(obj);
// if (!obj.IotAddress || obj.IotAddress == null) {
// form.setFieldsValue({ IotAddress: '127.0.0.1' });
// }
// if (!obj.TcpAddress || obj.TcpAddress == null) {
// form.setFieldsValue({ TcpAddress: '127.0.0.1:8083' });
// }
SysConfiguration({ moduleName: 'EMQ_API' }).then(res1 => {
if (res1.code === 0) {
form.setFieldsValue({ configName: res1.data });
}
});
SysConfiguration({ moduleName: 'EMQ版本' }).then(res2 => {
if (res2.code === 0) {
form.setFieldsValue({ configValue: res2.data });
}
});
if (!obj.SSLSafe || obj.SSLSafe == null) {
form.setFieldsValue({ SSLSafe: '否' });
}
......@@ -264,27 +258,34 @@ const IotConfig = props => {
};
const onFinish = values => {
if (values.IotAddress != null && values.IotAddress.length > 0) {
if (values.SSLSafe === '是') {
values.SSLSafe = 1;
}
if (values.SSLSafe === '否') {
values.SSLSafe = 0;
}
PingIot({ ip: values.IotAddress, values });
} else {
if (values.SSLSafe === '是') {
values.SSLSafe = 1;
}
if (values.SSLSafe === '否') {
values.SSLSafe = 0;
form.validateFields().then(validate => {
if (validate) {
if (values.IotAddress != null && values.IotAddress.length > 0) {
if (values.SSLSafe === '是') {
values.SSLSafe = 1;
}
if (values.SSLSafe === '否') {
values.SSLSafe = 0;
}
PingIot({ ip: values.IotAddress, values });
} else {
if (values.SSLSafe === '是') {
values.SSLSafe = 1;
}
if (values.SSLSafe === '否') {
values.SSLSafe = 0;
}
SaveIotConfig(
{
tcpAddress: values.TcpAddress,
iotAddress: values.IotAddress || currentIotConfig.IotAddress,
sslSafe: values.SSLSafe,
},
values,
);
}
}
SaveIotConfig({
tcpAddress: values.TcpAddress,
iotAddress: values.IotAddress || currentIotConfig.IotAddress,
sslSafe: values.SSLSafe,
});
}
});
};
const onFinishFailed = errorInfo => {
......@@ -306,11 +307,14 @@ const IotConfig = props => {
};
const PingIot = ({ ip, values }) => {
SaveIotConfig({
tcpAddress: values.TcpAddress,
iotAddress: values.IotAddress,
sslSafe: values.SSLSafe,
});
SaveIotConfig(
{
tcpAddress: values.TcpAddress,
iotAddress: values.IotAddress,
sslSafe: values.SSLSafe,
},
values,
);
};
const PingIot1 = () => {
setLoading(true);
......@@ -388,12 +392,30 @@ const IotConfig = props => {
// }
};
const SaveIotConfig = config => {
const SaveIotConfig = (config, values) => {
setLoading(true);
SaveTcpAddress(config).then(res => {
setLoading(false);
if (res.code === 0) {
message.info('配置保存成功');
SaveSysConfigurate({
configName: 'EMQ版本',
configValue: values.configValue,
}).then(resData => {
if (resData.code === 0) {
SaveSysConfigurate({
configName: 'EMQ_API',
configValue: values.configName,
}).then(resData1 => {
if (resData1.code === 0) {
message.success('配置保存成功');
} else {
message.error(resData.msg);
}
});
} else {
message.error(resData.msg);
}
});
} else {
message.error(res.msg);
}
......@@ -444,7 +466,7 @@ const IotConfig = props => {
<Form
form={form}
name="basic"
initialValues={{ remember: true }}
initialValues={{ remember: true, configValue: 'V4' }}
onFinish={onFinish}
onFinishFailed={onFinishFailed}
>
......@@ -620,6 +642,25 @@ const IotConfig = props => {
<Option value="0"></Option>
</Select>
</Form.Item>
<Form.Item
style={{ marginLeft: '30px' }}
label="API地址"
name="configName"
rules={[
{
pattern: new RegExp(/^.*:.*$/),
message: '请输入正确的IP:端口',
},
]}
>
<Input style={{ width: '300px', marginLeft: '60px' }} />
</Form.Item>
<Form.Item style={{ marginLeft: '30px' }} label="EMQ版本" name="configValue">
<Radio.Group style={{ marginLeft: '50px' }}>
<Radio value="V4">V4</Radio>
<Radio value="V5">V5</Radio>
</Radio.Group>
</Form.Item>
<Form.Item>
<Button type="primary" htmlType="submit" style={{ marginLeft: '152px' }}>
保存
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment