Commit 726aab0f authored by 皮倩雯's avatar 皮倩雯

fix: '宿主管理优化'

parent 3c09a493
Pipeline #71888 passed with stages
......@@ -13,14 +13,14 @@ import { Modal, notification } from 'antd';
import Sortable from 'sortablejs';
import styles from './SortModal.less';
import DragTable from '@/components/DragTable/DragTable';
import { SortScheme } from '@/services/webConfig/api';
import { SortScheme, SortSchemePost } from '@/services/webConfig/api';
const SortModal = props => {
const { callBackSubmit = () => {}, title, visible, onCancel, sortData } = props;
const [orderTable, setOrderTable] = useState([]);
const [flowIDs, setFlowIDs] = useState([]);
const onSumbit = () => {
SortScheme({ sortName: flowIDs.toString() }).then(res => {
SortSchemePost({ sortNames: flowIDs }).then(res => {
if (res.code === '0') {
callBackSubmit();
onCancel();
......
......@@ -28,8 +28,7 @@ const AddModal = props => {
useEffect(() => {
if (visible) {
if (type === 'edit') {
let data = ['CityServer', 'IOT', 'CivData', 'GIS'];
if (data.indexOf(pickItem.key) != -1) {
if (pickItem.remark) {
setHidden(true);
}
let aa = pickItem.methods.replace(/\s/g, '');
......@@ -80,7 +79,7 @@ const AddModal = props => {
setCurrent(true);
}
} else {
form.setFieldsValue({ IsAuthentication: true });
form.setFieldsValue({ IsAuthentication: true, Priority: 1, Methods: ['GET', 'POST'] });
}
} else {
setHidden(false);
......@@ -95,11 +94,8 @@ const AddModal = props => {
if (validate) {
setLoading(true);
let obj = form.getFieldsValue();
console.log(obj.IsAuthentication);
console.log(obj.Priority);
let aa = obj.Methods.toString();
obj.Methods = aa.replace(/\s/g, '');
console.log(obj.Methods);
let data = {
UpstreamPathTemplate: obj.UpstreamPathTemplate || null,
DownstreamPathTemplate: obj.DownstreamPathTemplate || null,
......@@ -125,65 +121,34 @@ const AddModal = props => {
ReRouteIsCaseSensitive: obj.ReRouteIsCaseSensitive || null,
DownstreamHttpMethod: obj.DownstreamHttpMethod || null,
};
console.log(data);
if (type === 'add') {
SaveRoutes([
{
...data,
IsEnable: 1,
},
])
.then(res => {
setLoading(false);
if (res.code === 0) {
onCancel();
callBackSubmit();
notification.success({
message: '提示',
duration: 3,
description: res.msg || '新增成功',
});
} else {
notification.error({
message: '提示',
duration: 3,
description: res.msg || '新增失败',
});
}
})
.catch(err => {
setLoading(false);
});
} else {
SaveRoutes([
{
id: pickItem.id,
...data,
IsEnable: 1,
},
])
.then(res => {
setLoading(false);
if (res.code === 0) {
onCancel();
callBackSubmit();
notification.success({
message: '提示',
duration: 3,
description: res.msg || '编辑成功',
});
} else {
notification.error({
message: '提示',
duration: 3,
description: res.msg || '编辑失败',
});
}
})
.catch(err => {
setLoading(false);
});
}
let str = type === 'add' ? '新增' : '编辑';
SaveRoutes([
{
...data,
IsEnable: 1,
},
])
.then(res => {
setLoading(false);
if (res.code === 0) {
onCancel();
callBackSubmit();
notification.success({
message: '提示',
duration: 3,
description: res.msg || `${str}成功`,
});
} else {
notification.error({
message: '提示',
duration: 3,
description: res.msg || `${str}失败`,
});
}
})
.catch(err => {
setLoading(false);
});
}
});
};
......@@ -274,7 +239,7 @@ const AddModal = props => {
},
]}
>
<Input allowClear placeholder="示例:/{url}" disabled={hidden} />
<Input allowClear placeholder="示例:/{url}" />
</Item>
<Item
label="上游请求方式"
......@@ -286,7 +251,7 @@ const AddModal = props => {
},
]}
>
<Checkbox.Group options={plainOptions} style={{ display: 'flex' }} disabled={hidden} />
<Checkbox.Group options={plainOptions} style={{ display: 'flex' }} />
</Item>
<Item
label="下游服务地址"
......@@ -302,12 +267,8 @@ const AddModal = props => {
</Item>
<Item label="身份认证" name="IsAuthentication">
<Radio.Group>
<Radio value={true} disabled={hidden}>
开启
</Radio>
<Radio value={false} disabled={hidden}>
关闭
</Radio>
<Radio value={true}>开启</Radio>
<Radio value={false}>关闭</Radio>
</Radio.Group>
</Item>
<Item
......@@ -360,7 +321,12 @@ const AddModal = props => {
name="Priority"
labelCol={{ span: 12 }}
>
<InputNumber min={0} max={10} defaultValue={0} disabled={hidden} />
<InputNumber
min={0}
max={10}
defaultValue={0}
disabled={pickItem.remark === '万能模板'}
/>
</Item>
</Col>
<Col span={16}>
......
/* eslint-disable indent */
/* eslint-disable no-unused-expressions */
/* eslint-disable no-else-return */
import React, { useEffect, useState } from 'react';
......@@ -28,12 +29,15 @@ import {
} from '@ant-design/icons';
import { useHistory } from 'react-router-dom';
import styles from './gateWay.less';
import axios from 'axios';
import {
GetGateWay,
UpdateGeteWay,
GetReRoutes,
GetReRoutesFirst,
DelRoutes,
DelRouteByUpUrl,
GetWayHealthCheck,
} from '@/services/hostmanager/hostmanager';
import { get, PUBLISH_SERVICE } from '@/services/index';
import configuration from '../../../../assets/images/icons/消息.svg';
......@@ -43,6 +47,7 @@ import CheckModal from './CheckModal';
const GateConfig = () => {
const [loading, setLoading] = useState(false); // 加载
const [allLoading, setAllLoading] = useState(false); // 加载
const [form] = Form.useForm();
const [flag, setFlag] = useState(1);
......@@ -63,70 +68,95 @@ const GateConfig = () => {
localStorage.setItem('panda-publish', '');
console.log(checked);
if (checked) {
UpdateGeteWay({ isUsed: checked }).then(res => {
if (res.code === 0) {
console.log(localStorage.getItem('token'));
// localStorage.removeItem('token');
window.globalConfig = {
...window.globalConfig,
access_token: localStorage.getItem('token'),
hasGateWay: true,
apiGatewayDomain: `${window.location.origin}${'/PandaCore/GateWay'}`,
};
setFlag(flag + 1);
message.success('设置成功');
// const key = 'authrizeFail';
// notification.warning({
// key,
// title: '提示',
// message: '授权失败,即将跳转到登录页',
// duration: 2,
// });
// setTimeout(() => {
// history.push(`/user/login`);
// }, 2000);
const key = 'authrizeFail';
const btn = (
<Button
type="primary"
size="small"
onClick={() => {
notification.close(key);
window.location.href = `/${process.env.PUBLIC_PATH || 'civmanage'}/user/login`;
}}
>
确定
</Button>
);
if (!/\/user\/login$/.test(window.location.pathname)) {
notification.warning({
key,
title: '提示',
message: '授权失败,即将跳转到登录页',
duration: 2,
btn,
setAllLoading(true);
// axios({
// method: 'get',
// url: `${tableData[0].url}/PandaOMS/OMS/health/get`,
// }).then(res => {
// console.log(res);
// debugger;
// });
GetWayHealthCheck().then(resData => {
setAllLoading(false);
if (resData.code === 0) {
UpdateGeteWay({ isUsed: checked }).then(res => {
if (res.code === 0) {
console.log(localStorage.getItem('token'));
// localStorage.removeItem('token');
window.globalConfig = {
...window.globalConfig,
access_token: localStorage.getItem('token'),
hasGateWay: true,
apiGatewayDomain: `${window.location.origin}${'/PandaCore/GateWay'}`,
};
setFlag(flag + 1);
message.success('设置成功');
// const key = 'authrizeFail';
// notification.warning({
// key,
// title: '提示',
// message: '授权失败,即将跳转到登录页',
// duration: 2,
// });
// setTimeout(() => {
// history.push(`/user/login`);
// }, 2000);
const key = 'authrizeFail';
const btn = (
<Button
type="primary"
size="small"
onClick={() => {
notification.close(key);
window.location.href = `/${process.env.PUBLIC_PATH || 'civmanage'}/user/login`;
}}
>
确定
</Button>
);
if (!/\/user\/login$/.test(window.location.pathname)) {
notification.warning({
key,
title: '提示',
message: '授权失败,即将跳转到登录页',
duration: 2,
btn,
});
setTimeout(() => {
window.location.href = `/${process.env.PUBLIC_PATH || 'civmanage'}/user/login`;
}, 2000);
}
} else {
message.error('设置失败');
}
});
setTimeout(() => {
localStorage.setItem('panda-publish', 'getway');
setLoading(true);
GetReRoutes({
UpstreamPathTemplate: '',
key: '',
}).then(res => {
setLoading(false);
if (res.code === 0) {
setTableData(res.data);
}
});
setTimeout(() => {
window.location.href = `/${process.env.PUBLIC_PATH || 'civmanage'}/user/login`;
}, 2000);
}
}, 0);
} else {
message.error('设置失败');
message.warning({
content: (
<>
万能模板下游服务 [<span style={{ color: '#1890ff' }}>{tableData[0].url}</span>]
检测不通过,请修复后再开启!
</>
),
style: {
marginTop: '10vh',
},
});
}
});
setTimeout(() => {
localStorage.setItem('panda-publish', 'getway');
setLoading(true);
GetReRoutes({
UpstreamPathTemplate: '',
key: '',
}).then(res => {
setLoading(false);
if (res.code === 0) {
setTableData(res.data);
}
});
}, 0);
} else {
UpdateGeteWay({ isUsed: checked }).then(res => {
if (res.code === 0) {
......@@ -213,46 +243,13 @@ const GateConfig = () => {
align: 'center',
width: 150,
render: (text, record) => {
if (record.key === 'CityServer') {
if (record.remark) {
return (
<Tooltip placement="top" title={text}>
<span>
{searchStyle1(text)}{' '}
<Tag color="cyan" style={{ marginRight: '0px' }}>
万能模板
</Tag>
</span>
</Tooltip>
);
} else if (record.key === 'IOT') {
return (
<Tooltip placement="top" title={text}>
<span>
{searchStyle1(text)}{' '}
<Tag color="purple" style={{ marginRight: '0px' }}>
物联
</Tag>
</span>
</Tooltip>
);
} else if (record.key === 'CivData') {
return (
<Tooltip placement="top" title={text}>
<span>
{searchStyle1(text)}{' '}
<Tag color="green" style={{ marginRight: '0px' }}>
中台
</Tag>
</span>
</Tooltip>
);
} else if (record.key === 'GIS') {
return (
<Tooltip placement="top" title={text}>
<span>
{searchStyle1(text)}{' '}
<Tag color="volcano" style={{ marginRight: '0px' }}>
GIS
{record.remark}
</Tag>
</span>
</Tooltip>
......@@ -273,13 +270,24 @@ const GateConfig = () => {
dataIndex: 'upstreamPathTemplate',
key: 'upstreamPathTemplate',
align: 'center',
render: (text, record) => (
<span>
<Tooltip placement="top" title={`上游路由模板:${text}`}>
{window.location.origin + `/PandaCore/GateWay${text}`}
</Tooltip>
</span>
),
render: (text, record) => {
let str = window.location.origin + `/PandaCore/GateWay${text}`;
let list = str.split(':');
list[0] = record.downstreamScheme;
let data = record.downstreamScheme;
list.forEach((i, j) => {
if (j > 0) {
data = data + ':' + i;
}
});
return (
<span>
<Tooltip placement="top" title={`上游路由模板:${text}`}>
{data}
</Tooltip>
</span>
);
},
},
// {
// title: '上游路由模板',
......@@ -377,41 +385,41 @@ const GateConfig = () => {
align: 'center',
fixed: 'right',
render: record => {
if (record.key != 'CityServer') {
return (
<Space size="middle">
<Tooltip title="编辑">
<EditTwoTone onClick={() => edit(record)} style={{ fontSize: '16px' }} />
</Tooltip>
{record.key != 'IOT' && record.key != 'CivData' && record.key != 'GIS' && (
<Tooltip title="删除">
<Popconfirm
placement="bottomRight"
title={
<p>
即将删除 <span>{record.loginName}</span>
,是否确认删除?
</p>
}
okText="确认"
cancelText="取消"
onConfirm={() => dele(record)}
>
<DeleteOutlined style={{ fontSize: '16px', color: '#e86060' }} />
</Popconfirm>
</Tooltip>
)}
</Space>
);
} else {
return (
<Space size="middle">
<Tooltip title="查看">
<SearchOutlined onClick={() => look(record)} style={{ fontSize: '16px' }} />
// if (record.key != 'CityServer') {
return (
<Space size="middle">
<Tooltip title="编辑">
<EditTwoTone onClick={() => edit(record)} style={{ fontSize: '16px' }} />
</Tooltip>
{!record.remark && (
<Tooltip title="删除">
<Popconfirm
placement="bottomRight"
title={
<p>
即将删除 <span>{record.loginName}</span>
,是否确认删除?
</p>
}
okText="确认"
cancelText="取消"
onConfirm={() => dele(record)}
>
<DeleteOutlined style={{ fontSize: '16px', color: '#e86060' }} />
</Popconfirm>
</Tooltip>
</Space>
);
}
)}
</Space>
);
// } else {
// return (
// <Space size="middle">
// <Tooltip title="查看">
// <SearchOutlined onClick={() => look(record)} style={{ fontSize: '16px' }} />
// </Tooltip>
// </Space>
// );
// }
},
},
];
......@@ -508,8 +516,8 @@ const GateConfig = () => {
description: '默认数据无法删除',
});
} else {
DelRoutes({
Ids: e.id,
DelRouteByUpUrl({
upTemplate: e.upstreamPathTemplate,
}).then(res => {
if (res.code === 0) {
GetReRoutes({
......@@ -549,124 +557,125 @@ const GateConfig = () => {
return (
<div className={styles.gateWay_container}>
<Card style={{ width: '100%', height: 'calc(100vh - 130px)' }}>
<div style={{ display: 'flex', alignItems: 'center', marginTop: '10px' }}>
<img src={configuration} style={{ height: '16px' }} alt="" />
<span style={{ marginLeft: '10px', fontWeight: 'bold' }}>网关配置</span>
</div>
<Divider />
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: '20px' }}>
<div style={{ display: 'flex', alignItems: 'center' }}>
<div
style={{
marginLeft: '35px',
}}
>
网关状态
<Switch
checkedChildren="开启"
unCheckedChildren="关闭"
checked={currentConfig}
onChange={OperateNginx}
style={{ marginLeft: '35px' }}
/>
</div>
{console.log(currentConfig)}
<Spin spinning={allLoading} tip="loading">
<Card style={{ width: '100%', height: 'calc(100vh - 130px)' }}>
<div style={{ display: 'flex', alignItems: 'center', marginTop: '10px' }}>
<img src={configuration} style={{ height: '16px' }} alt="" />
<span style={{ marginLeft: '10px', fontWeight: 'bold' }}>网关配置</span>
</div>
{/* {currentConfig ? (
<Divider />
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: '20px' }}>
<div style={{ display: 'flex', alignItems: 'center' }}>
<div
style={{
marginLeft: '35px',
}}
>
网关状态
<Switch
checkedChildren="开启"
unCheckedChildren="关闭"
checked={currentConfig}
onChange={OperateNginx}
style={{ marginLeft: '35px' }}
/>
</div>
{console.log(currentConfig)}
</div>
{/* {currentConfig ? (
) : (
<></>
)} */}
<div className={styles.head1}>
<span>快速搜索上游路由模板:</span>
<Input
value={searchWord}
placeholder="请输入上游路由模板"
style={{ width: 200 }}
onChange={handleSearch}
/>
<span style={{ marginLeft: '20px' }}>快速搜索关键字:</span>
<Input
value={searchWord1}
placeholder="请输入键值"
style={{ width: 200 }}
onChange={handleSearch1}
/>
<Button
type="primary"
icon={<SearchOutlined />}
onClick={submitSearch}
style={{ marginLeft: '20px' }}
>
搜索
</Button>
<Button icon={<SyncOutlined />} onClick={handleReset} style={{ marginLeft: '20px' }}>
重置
</Button>
<Button
icon={<PlusOutlined className={styles.icon} />}
onClick={add}
style={{
verticalAlign: 'middle',
marginTop: '-3px',
marginLeft: '20px',
}}
>
新增
</Button>
<div className={styles.head1}>
<span>快速搜索上游路由模板:</span>
<Input
value={searchWord}
placeholder="请输入上游路由模板"
style={{ width: 200 }}
onChange={handleSearch}
/>
<span style={{ marginLeft: '20px' }}>快速搜索关键字:</span>
<Input
value={searchWord1}
placeholder="请输入键值"
style={{ width: 200 }}
onChange={handleSearch1}
/>
<Button
type="primary"
icon={<SearchOutlined />}
onClick={submitSearch}
style={{ marginLeft: '20px' }}
>
搜索
</Button>
<Button icon={<SyncOutlined />} onClick={handleReset} style={{ marginLeft: '20px' }}>
重置
</Button>
<Button
icon={<PlusOutlined className={styles.icon} />}
onClick={add}
style={{
verticalAlign: 'middle',
marginTop: '-3px',
marginLeft: '20px',
}}
>
新增
</Button>
</div>
</div>
</div>
{/* {currentConfig ? (
{/* {currentConfig ? (
) : (
<></>
)} */}
<Spin spinning={loading} tip="loading">
<div className={styles.table}>
<Table
size="small"
bordered
rowKey={record => record.Id}
columns={columns}
dataSource={tableData}
scroll={{ y: 'calc(100vh - 380px)', x: 'max-content' }}
onRow={record => ({
onDoubleClick: event => {
console.log(record);
event.stopPropagation();
if (record.key == 'CityServer') {
look(record);
} else {
<Spin spinning={loading} tip="loading">
<div className={styles.table}>
<Table
size="small"
bordered
rowKey={record => record.Id}
columns={columns}
dataSource={tableData}
scroll={{ y: 'calc(100vh - 380px)', x: 'max-content' }}
onRow={record => ({
onDoubleClick: event => {
event.stopPropagation();
// if (record.key == 'CityServer') {
// look(record);
// } else {
edit(record);
}
}, // 双击
})}
pagination={{
showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条`,
pageSizeOptions: [10, 20, 50, 100],
defaultPageSize: 20,
showQuickJumper: true,
showSizeChanger: true,
}}
/>
</div>
</Spin>
// }
}, // 双击
})}
pagination={{
showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条`,
pageSizeOptions: [10, 20, 50, 100],
defaultPageSize: 20,
showQuickJumper: true,
showSizeChanger: true,
}}
/>
</div>
</Spin>
<AddModal
visible={addVisible}
pickItem={pickItem}
keepData={keepData}
onCancel={() => setAddVisible(false)}
type={type}
callBackSubmit={onSubmit}
/>
<CheckModal
visible={checkVisible}
pickItem={pickItem}
onCancel={() => setCheckVisible(false)}
/>
</Card>
<AddModal
visible={addVisible}
pickItem={pickItem}
keepData={keepData}
onCancel={() => setAddVisible(false)}
type={type}
callBackSubmit={onSubmit}
/>
<CheckModal
visible={checkVisible}
pickItem={pickItem}
onCancel={() => setCheckVisible(false)}
/>
</Card>
</Spin>
</div>
);
};
......
......@@ -80,9 +80,14 @@ export const GetGateWay = param => get(`${PUBLISH_SERVICE}/HostManager/GetGateWa
export const UpdateGeteWay = param => get(`${PUBLISH_SERVICE}/HostManager/UpdateGeteWay`, param);
// 网关配置
// export const GetReRoutesFirst = param => get(`/OcelotSettings/GetReRoutes`, param);
export const GetWayHealthCheck = param =>
get(`/PandaCore/GateWay/OcelotSettings/HealthCheck`, param);
export const GetReRoutes = param => get(`/PandaCore/GateWay/OcelotSettings/GetReRoutes`, param);
export const SaveRoutes = param => post(`/PandaCore/GateWay/OcelotSettings/SaveRoutes`, param);
export const DelRoutes = param => get(`/PandaCore/GateWay/OcelotSettings/DelRoutes`, param);
export const DelRouteByUpUrl = param =>
get(`/PandaCore/GateWay/OcelotSettings/DelRouteByUpUrl`, param);
// 代理服务老接口
export const GetNginxConfigInfoOLD = param =>
......
......@@ -337,3 +337,5 @@ export const GetRoleGroups = param => get(`${PUBLISH_SERVICE}/UserCenter/GetRole
export const GetWebMenuInfo = param => get(`${PUBLISH_SERVICE}/WebSite/GetWebMenuInfo`, param);
export const SortScheme = param => get(`${PANDA_GIS}/MapLayer/SortScheme`, param);
export const SortSchemePost = param => post(`${PANDA_GIS}/MapLayer/SortSchemePost`, 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