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

fix: '宿主管理优化'

parent 3c09a493
Pipeline #71888 passed with stages
...@@ -13,14 +13,14 @@ import { Modal, notification } from 'antd'; ...@@ -13,14 +13,14 @@ import { Modal, notification } from 'antd';
import Sortable from 'sortablejs'; import Sortable from 'sortablejs';
import styles from './SortModal.less'; import styles from './SortModal.less';
import DragTable from '@/components/DragTable/DragTable'; import DragTable from '@/components/DragTable/DragTable';
import { SortScheme } from '@/services/webConfig/api'; import { SortScheme, SortSchemePost } from '@/services/webConfig/api';
const SortModal = props => { const SortModal = props => {
const { callBackSubmit = () => {}, title, visible, onCancel, sortData } = props; const { callBackSubmit = () => {}, title, visible, onCancel, sortData } = props;
const [orderTable, setOrderTable] = useState([]); const [orderTable, setOrderTable] = useState([]);
const [flowIDs, setFlowIDs] = useState([]); const [flowIDs, setFlowIDs] = useState([]);
const onSumbit = () => { const onSumbit = () => {
SortScheme({ sortName: flowIDs.toString() }).then(res => { SortSchemePost({ sortNames: flowIDs }).then(res => {
if (res.code === '0') { if (res.code === '0') {
callBackSubmit(); callBackSubmit();
onCancel(); onCancel();
......
...@@ -28,8 +28,7 @@ const AddModal = props => { ...@@ -28,8 +28,7 @@ const AddModal = props => {
useEffect(() => { useEffect(() => {
if (visible) { if (visible) {
if (type === 'edit') { if (type === 'edit') {
let data = ['CityServer', 'IOT', 'CivData', 'GIS']; if (pickItem.remark) {
if (data.indexOf(pickItem.key) != -1) {
setHidden(true); setHidden(true);
} }
let aa = pickItem.methods.replace(/\s/g, ''); let aa = pickItem.methods.replace(/\s/g, '');
...@@ -80,7 +79,7 @@ const AddModal = props => { ...@@ -80,7 +79,7 @@ const AddModal = props => {
setCurrent(true); setCurrent(true);
} }
} else { } else {
form.setFieldsValue({ IsAuthentication: true }); form.setFieldsValue({ IsAuthentication: true, Priority: 1, Methods: ['GET', 'POST'] });
} }
} else { } else {
setHidden(false); setHidden(false);
...@@ -95,11 +94,8 @@ const AddModal = props => { ...@@ -95,11 +94,8 @@ const AddModal = props => {
if (validate) { if (validate) {
setLoading(true); setLoading(true);
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
console.log(obj.IsAuthentication);
console.log(obj.Priority);
let aa = obj.Methods.toString(); let aa = obj.Methods.toString();
obj.Methods = aa.replace(/\s/g, ''); obj.Methods = aa.replace(/\s/g, '');
console.log(obj.Methods);
let data = { let data = {
UpstreamPathTemplate: obj.UpstreamPathTemplate || null, UpstreamPathTemplate: obj.UpstreamPathTemplate || null,
DownstreamPathTemplate: obj.DownstreamPathTemplate || null, DownstreamPathTemplate: obj.DownstreamPathTemplate || null,
...@@ -125,8 +121,7 @@ const AddModal = props => { ...@@ -125,8 +121,7 @@ const AddModal = props => {
ReRouteIsCaseSensitive: obj.ReRouteIsCaseSensitive || null, ReRouteIsCaseSensitive: obj.ReRouteIsCaseSensitive || null,
DownstreamHttpMethod: obj.DownstreamHttpMethod || null, DownstreamHttpMethod: obj.DownstreamHttpMethod || null,
}; };
console.log(data); let str = type === 'add' ? '新增' : '编辑';
if (type === 'add') {
SaveRoutes([ SaveRoutes([
{ {
...data, ...data,
...@@ -141,49 +136,19 @@ const AddModal = props => { ...@@ -141,49 +136,19 @@ const AddModal = props => {
notification.success({ notification.success({
message: '提示', message: '提示',
duration: 3, duration: 3,
description: res.msg || '新增成功', description: res.msg || `${str}成功`,
}); });
} else { } else {
notification.error({ notification.error({
message: '提示', message: '提示',
duration: 3, duration: 3,
description: res.msg || '新增失败', description: res.msg || `${str}失败`,
}); });
} }
}) })
.catch(err => { .catch(err => {
setLoading(false); 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);
});
}
} }
}); });
}; };
...@@ -274,7 +239,7 @@ const AddModal = props => { ...@@ -274,7 +239,7 @@ const AddModal = props => {
}, },
]} ]}
> >
<Input allowClear placeholder="示例:/{url}" disabled={hidden} /> <Input allowClear placeholder="示例:/{url}" />
</Item> </Item>
<Item <Item
label="上游请求方式" label="上游请求方式"
...@@ -286,7 +251,7 @@ const AddModal = props => { ...@@ -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>
<Item <Item
label="下游服务地址" label="下游服务地址"
...@@ -302,12 +267,8 @@ const AddModal = props => { ...@@ -302,12 +267,8 @@ const AddModal = props => {
</Item> </Item>
<Item label="身份认证" name="IsAuthentication"> <Item label="身份认证" name="IsAuthentication">
<Radio.Group> <Radio.Group>
<Radio value={true} disabled={hidden}> <Radio value={true}>开启</Radio>
开启 <Radio value={false}>关闭</Radio>
</Radio>
<Radio value={false} disabled={hidden}>
关闭
</Radio>
</Radio.Group> </Radio.Group>
</Item> </Item>
<Item <Item
...@@ -360,7 +321,12 @@ const AddModal = props => { ...@@ -360,7 +321,12 @@ const AddModal = props => {
name="Priority" name="Priority"
labelCol={{ span: 12 }} labelCol={{ span: 12 }}
> >
<InputNumber min={0} max={10} defaultValue={0} disabled={hidden} /> <InputNumber
min={0}
max={10}
defaultValue={0}
disabled={pickItem.remark === '万能模板'}
/>
</Item> </Item>
</Col> </Col>
<Col span={16}> <Col span={16}>
......
/* eslint-disable indent */
/* eslint-disable no-unused-expressions */ /* eslint-disable no-unused-expressions */
/* eslint-disable no-else-return */ /* eslint-disable no-else-return */
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
...@@ -28,12 +29,15 @@ import { ...@@ -28,12 +29,15 @@ import {
} from '@ant-design/icons'; } from '@ant-design/icons';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
import styles from './gateWay.less'; import styles from './gateWay.less';
import axios from 'axios';
import { import {
GetGateWay, GetGateWay,
UpdateGeteWay, UpdateGeteWay,
GetReRoutes, GetReRoutes,
GetReRoutesFirst, GetReRoutesFirst,
DelRoutes, DelRoutes,
DelRouteByUpUrl,
GetWayHealthCheck,
} from '@/services/hostmanager/hostmanager'; } from '@/services/hostmanager/hostmanager';
import { get, PUBLISH_SERVICE } from '@/services/index'; import { get, PUBLISH_SERVICE } from '@/services/index';
import configuration from '../../../../assets/images/icons/消息.svg'; import configuration from '../../../../assets/images/icons/消息.svg';
...@@ -43,6 +47,7 @@ import CheckModal from './CheckModal'; ...@@ -43,6 +47,7 @@ import CheckModal from './CheckModal';
const GateConfig = () => { const GateConfig = () => {
const [loading, setLoading] = useState(false); // 加载 const [loading, setLoading] = useState(false); // 加载
const [allLoading, setAllLoading] = useState(false); // 加载
const [form] = Form.useForm(); const [form] = Form.useForm();
const [flag, setFlag] = useState(1); const [flag, setFlag] = useState(1);
...@@ -63,6 +68,17 @@ const GateConfig = () => { ...@@ -63,6 +68,17 @@ const GateConfig = () => {
localStorage.setItem('panda-publish', ''); localStorage.setItem('panda-publish', '');
console.log(checked); console.log(checked);
if (checked) { if (checked) {
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 => { UpdateGeteWay({ isUsed: checked }).then(res => {
if (res.code === 0) { if (res.code === 0) {
console.log(localStorage.getItem('token')); console.log(localStorage.getItem('token'));
...@@ -127,6 +143,20 @@ const GateConfig = () => { ...@@ -127,6 +143,20 @@ const GateConfig = () => {
} }
}); });
}, 0); }, 0);
} else {
message.warning({
content: (
<>
万能模板下游服务 [<span style={{ color: '#1890ff' }}>{tableData[0].url}</span>]
检测不通过,请修复后再开启!
</>
),
style: {
marginTop: '10vh',
},
});
}
});
} else { } else {
UpdateGeteWay({ isUsed: checked }).then(res => { UpdateGeteWay({ isUsed: checked }).then(res => {
if (res.code === 0) { if (res.code === 0) {
...@@ -213,46 +243,13 @@ const GateConfig = () => { ...@@ -213,46 +243,13 @@ const GateConfig = () => {
align: 'center', align: 'center',
width: 150, width: 150,
render: (text, record) => { render: (text, record) => {
if (record.key === 'CityServer') { if (record.remark) {
return ( return (
<Tooltip placement="top" title={text}> <Tooltip placement="top" title={text}>
<span> <span>
{searchStyle1(text)}{' '} {searchStyle1(text)}{' '}
<Tag color="cyan" style={{ marginRight: '0px' }}> <Tag color="cyan" style={{ marginRight: '0px' }}>
万能模板 {record.remark}
</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
</Tag> </Tag>
</span> </span>
</Tooltip> </Tooltip>
...@@ -273,13 +270,24 @@ const GateConfig = () => { ...@@ -273,13 +270,24 @@ const GateConfig = () => {
dataIndex: 'upstreamPathTemplate', dataIndex: 'upstreamPathTemplate',
key: 'upstreamPathTemplate', key: 'upstreamPathTemplate',
align: 'center', align: 'center',
render: (text, record) => ( 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> <span>
<Tooltip placement="top" title={`上游路由模板:${text}`}> <Tooltip placement="top" title={`上游路由模板:${text}`}>
{window.location.origin + `/PandaCore/GateWay${text}`} {data}
</Tooltip> </Tooltip>
</span> </span>
), );
},
}, },
// { // {
// title: '上游路由模板', // title: '上游路由模板',
...@@ -377,13 +385,13 @@ const GateConfig = () => { ...@@ -377,13 +385,13 @@ const GateConfig = () => {
align: 'center', align: 'center',
fixed: 'right', fixed: 'right',
render: record => { render: record => {
if (record.key != 'CityServer') { // if (record.key != 'CityServer') {
return ( return (
<Space size="middle"> <Space size="middle">
<Tooltip title="编辑"> <Tooltip title="编辑">
<EditTwoTone onClick={() => edit(record)} style={{ fontSize: '16px' }} /> <EditTwoTone onClick={() => edit(record)} style={{ fontSize: '16px' }} />
</Tooltip> </Tooltip>
{record.key != 'IOT' && record.key != 'CivData' && record.key != 'GIS' && ( {!record.remark && (
<Tooltip title="删除"> <Tooltip title="删除">
<Popconfirm <Popconfirm
placement="bottomRight" placement="bottomRight"
...@@ -403,15 +411,15 @@ const GateConfig = () => { ...@@ -403,15 +411,15 @@ const GateConfig = () => {
)} )}
</Space> </Space>
); );
} else { // } else {
return ( // return (
<Space size="middle"> // <Space size="middle">
<Tooltip title="查看"> // <Tooltip title="查看">
<SearchOutlined onClick={() => look(record)} style={{ fontSize: '16px' }} /> // <SearchOutlined onClick={() => look(record)} style={{ fontSize: '16px' }} />
</Tooltip> // </Tooltip>
</Space> // </Space>
); // );
} // }
}, },
}, },
]; ];
...@@ -508,8 +516,8 @@ const GateConfig = () => { ...@@ -508,8 +516,8 @@ const GateConfig = () => {
description: '默认数据无法删除', description: '默认数据无法删除',
}); });
} else { } else {
DelRoutes({ DelRouteByUpUrl({
Ids: e.id, upTemplate: e.upstreamPathTemplate,
}).then(res => { }).then(res => {
if (res.code === 0) { if (res.code === 0) {
GetReRoutes({ GetReRoutes({
...@@ -549,6 +557,7 @@ const GateConfig = () => { ...@@ -549,6 +557,7 @@ const GateConfig = () => {
return ( return (
<div className={styles.gateWay_container}> <div className={styles.gateWay_container}>
<Spin spinning={allLoading} tip="loading">
<Card style={{ width: '100%', height: 'calc(100vh - 130px)' }}> <Card style={{ width: '100%', height: 'calc(100vh - 130px)' }}>
<div style={{ display: 'flex', alignItems: 'center', marginTop: '10px' }}> <div style={{ display: 'flex', alignItems: 'center', marginTop: '10px' }}>
<img src={configuration} style={{ height: '16px' }} alt="" /> <img src={configuration} style={{ height: '16px' }} alt="" />
...@@ -633,13 +642,12 @@ const GateConfig = () => { ...@@ -633,13 +642,12 @@ const GateConfig = () => {
scroll={{ y: 'calc(100vh - 380px)', x: 'max-content' }} scroll={{ y: 'calc(100vh - 380px)', x: 'max-content' }}
onRow={record => ({ onRow={record => ({
onDoubleClick: event => { onDoubleClick: event => {
console.log(record);
event.stopPropagation(); event.stopPropagation();
if (record.key == 'CityServer') { // if (record.key == 'CityServer') {
look(record); // look(record);
} else { // } else {
edit(record); edit(record);
} // }
}, // 双击 }, // 双击
})} })}
pagination={{ pagination={{
...@@ -667,6 +675,7 @@ const GateConfig = () => { ...@@ -667,6 +675,7 @@ const GateConfig = () => {
onCancel={() => setCheckVisible(false)} onCancel={() => setCheckVisible(false)}
/> />
</Card> </Card>
</Spin>
</div> </div>
); );
}; };
......
...@@ -80,9 +80,14 @@ export const GetGateWay = param => get(`${PUBLISH_SERVICE}/HostManager/GetGateWa ...@@ -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 UpdateGeteWay = param => get(`${PUBLISH_SERVICE}/HostManager/UpdateGeteWay`, param);
// 网关配置 // 网关配置
// export const GetReRoutesFirst = param => get(`/OcelotSettings/GetReRoutes`, 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 GetReRoutes = param => get(`/PandaCore/GateWay/OcelotSettings/GetReRoutes`, param);
export const SaveRoutes = param => post(`/PandaCore/GateWay/OcelotSettings/SaveRoutes`, param); export const SaveRoutes = param => post(`/PandaCore/GateWay/OcelotSettings/SaveRoutes`, param);
export const DelRoutes = param => get(`/PandaCore/GateWay/OcelotSettings/DelRoutes`, 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 => export const GetNginxConfigInfoOLD = param =>
......
...@@ -337,3 +337,5 @@ export const GetRoleGroups = param => get(`${PUBLISH_SERVICE}/UserCenter/GetRole ...@@ -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 GetWebMenuInfo = param => get(`${PUBLISH_SERVICE}/WebSite/GetWebMenuInfo`, param);
export const SortScheme = param => get(`${PANDA_GIS}/MapLayer/SortScheme`, 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