Commit 1a0d2d26 authored by mayongxin's avatar mayongxin

add:宿主管理-代理配置

parent a2316832
Pipeline #24684 passed with stages
in 18 minutes 59 seconds
# PUBLIC_PATH = reactOMS, 默认转发 /cityinterface
PROXY=/Cityinterface:http://192.168.10.150:8777;/Publish:http://192.168.10.150:8777;/Web4:http://192.168.10.150:8777;/CityTemp:http://192.168.10.150:8777
PROXY=/Cityinterface:http://192.168.12.46:8086;/Publish:http://192.168.12.46:8086;/Web4:http://192.168.10.150:8777;/CityTemp:http://192.168.10.150:8777
# 可设置第二个代理,test为转发前缀,后面为代理转发的地址
# PROXY2 = test : http://localhost:8006/
......
import React, { useEffect, useState } from 'react'
import { Card, Form, Input, Button, Select, message } from 'antd'
import styles from './IotConfig.less'
import { GetIOTPlatformVersion, GetTCPConfigInfo, PingIOTPlatform,SaveTcpAddress } from '@/services/platform/hostmanager'
import { GetIOTPlatformVersion, GetTCPConfigInfo, PingIOTPlatform, SaveTcpAddress } from '@/services/platform/hostmanager'
const layout = {
labelCol: { span: 8 },
wrapperCol: { span: 16 },
......@@ -24,13 +24,13 @@ const IotConfig = () => {
const [form] = Form.useForm();
const onFinish = (values) => {
if(values.IotAddress != null &&values.IotAddress.length > 0){
PingIot({ip:values.IotAddress,values:values})
}else{
if (values.IotAddress != null && values.IotAddress.length > 0) {
PingIot({ ip: values.IotAddress, values: values })
} else {
SaveIotConfig({
tcpAddress:values.TcpAddress,
iotAddress:values.IotAddress,
sslSafe:values.SSLSafe
tcpAddress: values.TcpAddress,
iotAddress: values.IotAddress,
sslSafe: values.SSLSafe
})
}
};
......@@ -42,7 +42,7 @@ const IotConfig = () => {
useEffect(() => {
GetCurentIotVerison()
GetIotConfig()
}, [])
const GetCurentIotVerison = () => {
......@@ -70,27 +70,27 @@ const IotConfig = () => {
}
)
}
const PingIot = (ip,values) => {
const PingIot = (ip, values) => {
PingIOTPlatform({
ip:ip
ip: ip
}).then(
res =>{
if(res.code === 0){
res => {
if (res.code === 0) {
SaveIotConfig({
tcpAddress:values.TcpAddress,
iotAddress:values.IotAddress,
sslSafe:values.SSLSafe
tcpAddress: values.TcpAddress,
iotAddress: values.IotAddress,
sslSafe: values.SSLSafe
})
}else{
} else {
message.info("物联平台服务器连接异常!");
}
}
)
}
const SaveIotConfig = (config) =>{
const SaveIotConfig = (config) => {
SaveTcpAddress(config).then(
res =>{
if(res.code === 0){
res => {
if (res.code === 0) {
message.info('配置保存成功');
}
}
......@@ -113,7 +113,7 @@ const IotConfig = () => {
<Form.Item
label="服务器地址(平台)"
name="IotAddress"
rules={[{ required: false, message: '请输入服务器地址!' }]}
rules={[{ required: true, pattern: new RegExp(/^(([1-9]?\d|1\d{2}|2[0-4]\d|25[0-5])\.){3}([1-9]?\d|1\d{2}|2[0-4]\d|25[0-5])$/, "g"),message: '请输入正确的IP例如:192.168.12.231' }]}
>
<Input />
......@@ -122,7 +122,7 @@ const IotConfig = () => {
<Form.Item
label="服务器地址(EMQ)"
name="TcpAddress"
rules={[{ required: true, message: '请输入服务器地址!' }]}
rules={[{ required: true, message: '请输入域名(IP):端口,例如:192.168.19.102:8131' }]}
>
......@@ -131,7 +131,6 @@ const IotConfig = () => {
<Form.Item
name="SSLSafe"
label="SSL(EMQ)"
hasFeedback
rules={[{ required: true, message: '请选择是否!' }]}
>
......@@ -141,7 +140,7 @@ const IotConfig = () => {
</Select>
</Form.Item>
<Form.Item {...tailLayout}>
<Button type="primary" htmlType="submit">
<Button type="primary" htmlType="submit" disabled={currentIotConfig.TcpAddress.length > 0 ? 0 : 1}>
保存连接
</Button>
</Form.Item>
......
......@@ -4,6 +4,7 @@ import PageContainer from '@/components/BasePageContainer';
import BaseConfig from './baseConfig/BaseConfig'
import IotConfig from './IotConfig/IotConfig'
import MessageConfig from './messageConfig/messageConfig'
import ProxyConfig from './proxyConfig/ProxyConfig'
const { TabPane } = Tabs;
......@@ -27,7 +28,7 @@ const HostManager = () => {
<MessageConfig/>
</TabPane>
<TabPane tab="代理配置" key="4">
Content of Tab Pane 3
<ProxyConfig/>
</TabPane>
</Tabs>
</PageContainer>
......
......@@ -106,7 +106,7 @@ const MessageConfig = () => {
<Form.Item
label="服务器地址(平台)"
name="messageAddress"
rules={[{ required: true, message: '请输入服务器地址!' }]}
rules={[{ required: true, message: '请输入域名(IP):端口,例如:192.168.19.102:8131' }]}
>
<Input />
......
import React, { useEffect, useState } from 'react'
import { Card, Form, Input, Button, Switch, message } from 'antd'
import styles from './ProxyConfig.less'
import { GetNginxConfigInfo, InsertNginxConfig, StartNginx, StopNginx, ReloadNginx, NginxCache, NginxLog } from '@/services/platform/hostmanager'
import { ReloadOutlined } from '@ant-design/icons';
const layout = {
labelCol: { span: 8 },
wrapperCol: { span: 16 },
};
const tailLayout = {
wrapperCol: { offset: 8, span: 16 },
};
const ProxyConfig = () => {
const [form] = Form.useForm();
const [flag, setFlag] = useState(1)
const [currentConfig, setCurrentConfig] = useState({
NginxPort: "",
IISIPProt: "",
EMQIPPort: "",
IsStartNginx: false,
IsStartNginxCache: false,
IsStartNginxLog: false
})
const onFinish = (values) => {
InsertNginxConfig({
port: values.NginxPort,
iisLocation: values.IISIPProt,
emqLocation: values.EMQIPPort
}).then(
res => {
if (res.code === 0) {
message.success("保存成功")
} else {
message.error("保存失败")
}
}
)
};
const onFinishFailed = (errorInfo) => {
};
const OperateNginx = (checked) => {
if (checked) {
OperateStartNginx()
} else {
OperateStopNginx()
}
}
//开启Nginx
const OperateStartNginx = () => {
StartNginx().then(
res => {
if (res.code === 0) {
message.success("开启成功")
setFlag(flag + 1)
} else {
message.error("开启失败")
}
}
)
}
//停止Nginx
const OperateStopNginx = () => {
StopNginx().then(
res => {
if (res.code === 0) {
message.success("关闭成功")
setFlag(flag + 1)
} else {
message.error("关闭失败")
}
}
)
}
//开启/关闭缓存
const OperateNginxCache = (isOpen) => {
NginxCache({
isOpen: isOpen ? 1 : 0,
}).then(
res => {
if (res.code === 0) {
setFlag(flag + 1)
message.success(isOpen ? "开启成功" : "关闭成功")
} else {
message.error(res.msg)
}
}
)
}
//开启/关闭日志
const OperateNginxLog = (isOpen) => {
NginxLog({
isOpen: isOpen ? 1 : 0,
}).then(
res => {
if (res.code === 0) {
setFlag(flag + 1)
message.success(isOpen ? "开启成功" : "关闭成功")
} else {
message.error(res.msg)
}
}
)
}
const OperateReloadNginx = () => {
ReloadNginx().then(
res => {
if (res.code === 0) {
message.success("重载成功")
} else {
message.error("重载失败")
}
}
)
}
useEffect(() => {
GetNginxConfigInfo().then(
res => {
if (res.code === 0) {
setCurrentConfig({
NginxPort: res.data.NginxPort,
IISIPPort: res.data.IISIPPort,
EMQIPPort: res.data.EMQIPPort,
IsStartNginx: res.data.IsStartNginx,
IsStartNginxCache: res.data.IsStartNginxCache,
IsStartNginxLog: res.data.IsStartNginxLog,
})
let obj = {};
Object.keys(currentConfig).forEach(k => {
obj[k] = res.data[k];
});
console.log(obj)
form.setFieldsValue(obj);
} else {
message.errorInfo(res.msg)
}
}
)
}, [flag])
// GetNginxConfigInfoOLD().then(
// res => {
// if (res.say.statusCode === "0000") {
// setCurrentConfig({
// NginxPort: res.getMe[0].NginxPort,
// IISIPProt: res.getMe[0].IISIPProt,
// EMQIPPort: res.getMe[0].EMQIPPort,
// IsStartNginx: res.getMe[0].IsStartNginx,
// IsStartNginxCache: res.getMe[0].IsStartNginxCache,
// IsStartNginxLog: res.getMe[0].IsStartNginxLog,
// })
// let obj = {};
// Object.keys(currentConfig).forEach(k => {
// obj[k] = res.getMe[0][k];
// });
// console.log(obj)
// form.setFieldsValue(obj);
// } else {
// message.errorInfo(res.msg)
// }
// }
// )
// }, [])
return (
<div className={styles.proxy_container}>
<Card title="配置文件管理" style={{ width: 350 }}>
<Form
{...layout}
form={form}
name="basic"
initialValues={{ remember: true }}
onFinish={onFinish}
onFinishFailed={onFinishFailed}
>
<Form.Item
label="端口(ngnix)"
name="NginxPort"
rules={[{ required: true,pattern: new RegExp(/^[1-9]\d*$/,'g'), message: '请输入ngnix端口,例如:8091' }]}
>
<Input />
</Form.Item>
<Form.Item
label="地址(IIS)"
name="IISIPProt"
rules={[{ required: true, message: '请输入服务器地址!' }]}
>
<Input />
</Form.Item>
<Form.Item
label="地址(EMQ)"
name="EMQIPPort"
hasFeedback
rules={[{ required: true, message: '请选择是否!' }]}
>
<Input />
</Form.Item>
<Form.Item {...tailLayout}>
<Button type="primary" htmlType="submit" disabled={currentConfig.NginxPort.length > 0 ? 0 : 1}>
保存
</Button>
</Form.Item>
</Form>
</Card>
<Card title="服务器管理" style={{ width: 350, marginLeft: 15 }}>
<div className={styles.operate_container}>
<div className={styles.operate_item}>
<div>服务器运行</div>
<Switch checkedChildren='开启' unCheckedChildren='关闭' checked={currentConfig.IsStartNginx} onChange={OperateNginx} />
</div>
<div className={styles.operate_item}>
<div>服务器日志</div>
<Switch checkedChildren='开启' unCheckedChildren='关闭' checked={currentConfig.IsStartNginxLog} onChange={OperateNginxLog} disabled={currentConfig.IsStartNginx > 0 ? 0 : 1}/>
</div>
<div className={styles.operate_item}>
<div>服务器缓存</div>
<Switch checkedChildren='开启' unCheckedChildren='关闭' checked={currentConfig.IsStartNginxCache} onChange={OperateNginxCache} disabled={currentConfig.IsStartNginx > 0 ? 0 : 1}/>
</div>
<div className={styles.operate_item}>
<div>服务器重载</div>
<Button type="primary" icon={<ReloadOutlined />} onClick={OperateReloadNginx} disabled={currentConfig.IsStartNginx > 0 ? 0 : 1}>重载</Button>
</div>
</div>
</Card>
</div>
)
}
export default ProxyConfig;
\ No newline at end of file
.proxy_container{
display: flex;
height: 100%;
width: 100%;
flex-direction: row;
justify-content: flex-start;
.operate_container{
display: flex;
flex-direction: column;
justify-content: space-around;
width: 100%;
height: 100%;
.operate_item{
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
height: 50px;
border-width: 1px;
border-color: #EEEEEE;
border-bottom-style: solid;
}
}
}
\ No newline at end of file
import { get, post, PUBLISH_SERVICE, CITY_SERVICE } from '@/services/index';
// export const S_GetDataBaseConfig = param =>
// get(`${CITY_SERVICE}/OMS.svc/S_GetDataBaseConfig`, param);
// export const GetTCPConfigInfo = param =>
// get(`${CITY_SERVICE}/MessagePlatform.svc/MessageManage/GetTCPConfigInfo`, param);
//基础信息展示
export const GetDataBaseConfig = param =>
get(`${PUBLISH_SERVICE}/DBManager/GetDataBaseConfig`, param);
export const GetBasicInfo = param =>
get(`${PUBLISH_SERVICE}/HostManager/GetBasicInfo`, param);
//物联平台接口
export const GetIOTPlatformVersion = param =>
get(`${PUBLISH_SERVICE}/HostManager/GetIOTPlatformVersion`, param);
export const GetTCPConfigInfo = param =>
......@@ -19,6 +15,7 @@ export const PingIOTPlatform = param =>
get(`${PUBLISH_SERVICE}/HostManager/PingIOTPlatform`, param);
export const SaveTcpAddress = param =>
get(`${PUBLISH_SERVICE}/HostManager/SaveTcpAddress`, param);
//消息平台接口
export const GetMessageConfigInfo = param =>
get(`${PUBLISH_SERVICE}/HostManager/GetMessageConfigInfo`, param);
export const ConnectMessPlatform = param =>
......@@ -26,3 +23,35 @@ export const ConnectMessPlatform = param =>
export const SaveSystemInfo = param =>
get(`${PUBLISH_SERVICE}/HostManager/SaveSystemInfo`, param);
//代理服务器接口
export const GetNginxConfigInfo = param =>
get(`${PUBLISH_SERVICE}/HostManager/GetNginxConfigInfo`, param);
export const InsertNginxConfig = param =>
get(`${PUBLISH_SERVICE}/HostManager/InsertNginxConfig`, param);
export const StartNginx = param =>
get(`${PUBLISH_SERVICE}/HostManager/StartNginx`, param);
export const StopNginx = param =>
get(`${PUBLISH_SERVICE}/HostManager/StopNginx`, param);
export const NginxLog = param =>
get(`${PUBLISH_SERVICE}/HostManager/NginxLog`, param);
export const NginxCache = param =>
get(`${PUBLISH_SERVICE}/HostManager/NginxCache`, param);
export const ReloadNginx = param =>
get(`${PUBLISH_SERVICE}/HostManager/ReloadNginx`, param);
//代理服务老接口
export const GetNginxConfigInfoOLD = param =>
get(`${CITY_SERVICE}/MessagePlatform.svc/MessageManage/GetNginxConfigInfo`, param);
export const InsertNginxConfigOLD = param =>
post(`${CITY_SERVICE}/MessagePlatform.svc/MessageManage/InsertNginxConfig`, param);
export const StartNginxOLD = param =>
post(`${CITY_SERVICE}/MessagePlatform.svc/MessageManage/StartNginx`, param);
export const StopNginxOLD = param =>
post(`${CITY_SERVICE}/MessagePlatform.svc/MessageManage/StopNginx`, param);
export const NginxLogOLD = param =>
post(`${CITY_SERVICE}/MessagePlatform.svc/MessageManage/NginxLog`, param);
export const NginxCacheOLD = param =>
post(`${CITY_SERVICE}/MessagePlatform.svc/MessageManage/NginxCache`, param);
export const ReloadNginxOLD = param =>
post(`${CITY_SERVICE}/MessagePlatform.svc/MessageManage/ReloadNginx`, param);
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