Commit b9edb58b authored by 皮倩雯's avatar 皮倩雯

fix: '物联统一接入平台优化'

parent 94204383
Pipeline #62268 passed with stages
......@@ -21,6 +21,7 @@ import {
Timeline,
Tooltip,
Table,
message,
} from 'antd';
import PageContainer from '@/components/BasePageContainer';
import { connect } from 'react-redux';
......@@ -86,7 +87,7 @@ const DatabaseInitialization = props => {
const [keepValue, setKeepValue] = useState([]);
const [value, setValue] = useState([]);
const [product, setProduct] = useState([]);
const [msg, setMsg] = useState('');
const [msg, setMsg] = useState('null');
const [keepNumber, setkeepNumber] = useState('');
const [keepNa, setkeepNa] = useState('');
const [keepCo, setkeepCo] = useState('');
......@@ -236,6 +237,11 @@ const DatabaseInitialization = props => {
}
})
.catch(err => {
if (time) {
clearTimeout(time);
time = null;
}
message.error(err);
setFinish(true);
});
};
......@@ -381,11 +387,11 @@ const DatabaseInitialization = props => {
if (
res.data.Project &&
res.data.Project[0] &&
res.data.Project[res.data.Project.length - 1] == '已使用'
res.data.Project[res.data.Project.length - 1].license == '已使用'
) {
setbeforeColor('red');
setResult('检测到License已被使用');
setMsg('检测到License已被使用');
setResult('未检测到可用License');
setMsg('未检测到可用License');
} else {
setbeforeColor('red');
setResult('未检测到License');
......@@ -418,11 +424,11 @@ const DatabaseInitialization = props => {
if (
res.data.Project &&
res.data.Project[0] &&
res.data.Project[res.data.Project.length - 1] == '已使用'
res.data.Project[res.data.Project.length - 1].license == '已使用'
) {
setbeforeColor('red');
setResult('检测到License已被使用');
setMsg('检测到License已被使用');
setResult('未检测到可用License');
setMsg('未检测到可用License');
} else {
setbeforeColor('red');
setResult('未检测到License');
......@@ -469,11 +475,11 @@ const DatabaseInitialization = props => {
if (
res.data.Project &&
res.data.Project[0] &&
res.data.Project[res.data.Project.length - 1] == '已使用'
res.data.Project[res.data.Project.length - 1].license == '已使用'
) {
setbeforeColor('red');
setResult('检测到License已被使用');
setMsg('检测到License已被使用');
setResult('未检测到可用License');
setMsg('未检测到可用License');
} else {
setbeforeColor('red');
setResult('未检测到License');
......@@ -640,7 +646,7 @@ const DatabaseInitialization = props => {
NewInitAddDataBase({ ...obj, productSetting }).then(res => {
if (res.code === 0) {
GetDbChangeAppend();
setMsg('检测到License已被使用');
setMsg('未检测到可用License');
setfirstColor('green');
setDataResult('成功');
......@@ -694,7 +700,7 @@ const DatabaseInitialization = props => {
InitEditDataBase(obj).then(res => {
if (res.code === 0) {
GetDbChangeAppend();
setMsg('检测到License已被使用');
setMsg('未检测到可用License');
setfirstColor('green');
setDataResult('成功');
notification.success({
......@@ -713,15 +719,17 @@ const DatabaseInitialization = props => {
}
setTotalProduct(res.data.productPackageSumCount);
setSimpleProduct(res.data.productPackageCount);
SetAdminMenuToRole().then(resdata => {
if (resdata.code === 0) {
setLastColor('green');
setKeepLast('');
} else {
setLastColor('red');
setKeepLast(res.data.msg);
}
});
setLastColor('green');
setKeepLast('');
// SetAdminMenuToRole().then(resdata => {
// if (resdata.code === 0) {
// setLastColor('green');
// setKeepLast('');
// } else {
// setLastColor('red');
// setKeepLast(res.data.msg);
// }
// });
} else {
setDataResult(res.msg);
setFinish(true);
......@@ -1692,10 +1700,10 @@ const DatabaseInitialization = props => {
setinitVisibledetail(false);
setInitContentdetail('');
}}
width={900}
width={800}
maskClosable={false}
bodyStyle={{
height: '600px',
height: '500px',
// overflowY: 'auto',
}}
footer={[
......@@ -1712,6 +1720,7 @@ const DatabaseInitialization = props => {
handleClickdetail();
}}
key="back"
type="primary"
>
关闭窗口
</Button>,
......
......@@ -35,6 +35,9 @@ import {
DepositServiceDisable, // 停止数据库服务
DepositServiceEnable, // 启动数据库服务
} from '@/services/hostmanager/hostmanager';
import {
GetDbProduct, // 获取产品方案配置
} from '@/services/database/api';
const layout = {
labelCol: { span: 4 },
wrapperCol: { span: 20 },
......@@ -69,6 +72,9 @@ const IotConfig = () => {
const [flag, setFlag] = useState('');
const [processLength, setProcessLength] = useState(0);
const [switchStatus, setSwitchStatus] = useState(true);
const [dbStatus, setDbStatus] = useState(''); // 数据库状态
const [buStatus, setBuStatus] = useState(''); // 按钮状态
const [keep, setKeep] = useState('')
useEffect(() => {
HealthCheck().then(res => {
......@@ -94,6 +100,13 @@ const IotConfig = () => {
const getCurrentConfig = () => {
GetDataBaseConfig().then(res => {
if (res.code === 0) {
GetDbProduct(res.data).then(ress => {
console.log(ress.data.Project);
if (ress.data.Project.length > 0) {
console.log(ress.data.Project[ress.data.Project.length - 1].projectName);
setKeep(ress.data.Project[ress.data.Project.length - 1].projectName)
}
});
setCurrentDataBase(res.data);
// 数据库是否已添加
setLoading(true);
......@@ -104,6 +117,8 @@ const IotConfig = () => {
setShow4('none');
getStatus(res.data.ip, res.data.dbName);
} else {
setDbStatus(resdata1.msg);
setBuStatus('添加');
setSwitchStatus(true);
setShow3('none');
setShow4('inline-block');
......@@ -117,14 +132,21 @@ const IotConfig = () => {
// 查询是否禁用
GetServiceInfo({ host: x, dataBaseName: y })
.then(resdata => {
console.log(resdata.response.loadingProgress * 100);
setDbStatus(resdata.response.statusText);
setProcessLength(resdata.response.loadingProgress * 100);
if (resdata.response.statusText != '正常' && resdata.response.statusText != '已禁用') {
setBuStatus('启动中');
setSwitchStatus(true);
time = setTimeout(() => {
getStatus(x, y);
}, 1000);
} else {
if (resdata.response.statusText == '正常') {
setBuStatus('停止');
}
if (resdata.response.statusText == '已禁用') {
setBuStatus('启动');
}
if (time) {
clearTimeout(time);
time = null;
......@@ -133,7 +155,6 @@ const IotConfig = () => {
}
if (resdata.response.statusText == '正常') {
console.log(77777777);
setCurrentConfig(true);
} else {
setCurrentConfig(false);
......@@ -246,13 +267,17 @@ const IotConfig = () => {
// 添加当前连接数据库
const PingIot2 = () => {
if (show3 == 'inline-block') {
message.warning('该数据库已添加!');
} else if (!currentDataBase.ip) {
message.error('未获取数据库信息');
} else if (!currentSiteInfo) {
message.error('未获取站点编号');
console.log(buStatus);
console.log(show3);
if (show3 === 'inline-block') {
// 数据库已添加
if (buStatus === '停止') {
OperateNginx(false);
} else if (buStatus === '启动') {
OperateNginx(true);
}
} else {
// 数据库未添加
setLoading(true);
AddDB({
host: currentDataBase.ip,
......@@ -260,6 +285,7 @@ const IotConfig = () => {
pwd: currentDataBase.password,
dataBaseName: currentDataBase.dbName,
siteCode: currentSiteInfo,
name:keep,
}).then(res => {
setLoading(false);
if (res.success) {
......@@ -274,6 +300,34 @@ const IotConfig = () => {
}
});
}
// if (show3 == 'inline-block') {
// message.warning('该数据库已添加!');
// } else if (!currentDataBase.ip) {
// message.error('未获取数据库信息');
// } else if (!currentSiteInfo) {
// message.error('未获取站点编号');
// } else {
// setLoading(true);
// AddDB({
// host: currentDataBase.ip,
// user: currentDataBase.userName,
// pwd: currentDataBase.password,
// dataBaseName: currentDataBase.dbName,
// siteCode: currentSiteInfo,
// }).then(res => {
// setLoading(false);
// if (res.success) {
// setShow3('inline-block');
// setShow4('none');
// message.success('添加成功!');
// getStatus(currentDataBase.ip, currentDataBase.dbName);
// } else {
// setShow3('none');
// setShow4('inline-block');
// message.error(res.msg);
// }
// });
// }
};
const SaveIotConfig = config => {
......@@ -309,6 +363,8 @@ const IotConfig = () => {
dataBaseName: currentDataBase.dbName,
}).then(res => {
if (res.success) {
setDbStatus('已禁用');
setBuStatus('启动');
setProcessLength(0);
setCurrentConfig(checked);
message.success(res.msg);
......@@ -404,59 +460,41 @@ const IotConfig = () => {
</div>
<Divider />
<Form.Item label="当前数据库" style={{ marginLeft: '50px' }}>
<div style={{ display: 'flex', justifyContent: 'flex-start' }}>
<span style={{ marginLeft: '14px' }}>{`${currentDataBase.ip}/${
currentDataBase.dbName
}`}</span>
{show3==='none'?<></>: <span>({dbStatus})</span>}
</Form.Item>
<Form.Item label="加载进度" style={{ marginLeft: '65px' }}>
<div style={{ width: 200, marginBottom: '30px' }}>
<Progress
style={{ marginTop: '4px', marginLeft: '14px' }}
strokeColor={{
from: '#108ee9',
to: '#87d068',
}}
percent={processLength}
status={processLength == '100' ? 'success' : 'active'}
/>
</div>
<div>
<Button
type="primary"
onClick={() => PingIot2()}
style={{ marginLeft: '15px' }}
// disabled={show1 != 'inline-block'}
disabled={buStatus === '启动中'}
>
加入转存
{buStatus}
</Button>
<span style={{ display: show3 }}>
<img
src={Yes}
style={{
height: '24px',
marginTop: '5px',
marginLeft: '30px',
}}
alt=""
/>
</span>
<span style={{ display: show4 }}>
<CloseCircleFilled
style={{
fontSize: '24px',
marginTop: '10px',
marginLeft: '26px',
}}
/>
</span>
</div>
</Form.Item>
<Form.Item label="转存状态" style={{ marginLeft: '65px' }}>
<div style={{ display: 'flex', justifyContent: 'flex-start' }}>
<Switch
{/* <Switch
checkedChildren="开启"
unCheckedChildren="关闭"
checked={currentConfig}
onChange={OperateNginx}
style={{ marginLeft: '15px' }}
disabled={switchStatus}
/>
<div style={{ width: 200 }}>
<Progress
style={{ marginLeft: '40px' }}
strokeColor={{
from: '#108ee9',
to: '#87d068',
}}
percent={processLength}
status={processLength == '100' ? 'success' : 'active'}
/>
</div>
/> */}
</div>
</Form.Item>
</>
......
......@@ -90,7 +90,7 @@ const AddModal = props => {
setLoading(true);
let obj = form.getFieldsValue();
console.log(obj.IsAuthentication);
console.log(obj.Ptiority);
console.log(obj.Priority);
let aa = obj.Methods.toString();
obj.Methods = aa.replace(/\s/g, '');
console.log(obj.Methods);
......@@ -101,7 +101,7 @@ const AddModal = props => {
Url: obj.Url || null,
IsAuthentication: obj.IsAuthentication,
Key: obj.Key || null,
Priority: obj.Priority || null,
Priority: obj.Priority || 0,
UpstreamHost: obj.UpstreamHost || null,
AddHeasersToRequest: obj.AddHeasersToRequest || null,
UpstreamHeaderTransform: obj.UpstreamHeaderTransform || null,
......@@ -119,6 +119,7 @@ const AddModal = props => {
ReRouteIsCaseSensitive: obj.ReRouteIsCaseSensitive || null,
DownstreamHttpMethod: obj.DownstreamHttpMethod || null,
};
console.log(data);
if (type === 'add') {
SaveRoutes([
{
......
......@@ -95,6 +95,7 @@ const Master = props => {
if (res.code === 0) {
console.log(res.data);
let aa = res.data.title.split('<br/>');
let bb = res.data.qrCodeConfig.split('|');
form.setFieldsValue({
logo: res.data.logo,
primaryColor: res.data.primaryColor,
......@@ -103,6 +104,8 @@ const Master = props => {
title: aa[0],
titlebr: aa[1],
mapSettings: res.data.mapSettings,
qrCodename: bb[0],
qrCodeurl: bb[1],
});
setKeepSettings(res.data.mapSettings);
if (res.data.displayMode == '卡片') {
......@@ -140,6 +143,7 @@ const Master = props => {
if (obj.titlebr) {
obj.title = `${obj.title}<br/>${obj.titlebr}`;
}
console.log(obj.qrCodename || obj.qrCodeurl);
if (validate) {
AddIntegratedloginSetting({
logo: obj.logo,
......@@ -148,6 +152,7 @@ const Master = props => {
title: obj.title,
displayMode: obj.displayMode,
mapSettings: obj.displayMode == '卡片' ? keepSettings : obj.mapSettings,
qrCodeConfig: `${obj.qrCodename}|${obj.qrCodeurl}`,
})
.then(res => {
if (res.code === 0) {
......@@ -359,6 +364,12 @@ const Master = props => {
))}
</Select>
</Item>
<Item name="qrCodename" label="二维码名称">
<Input placeholder="请输入二维码名称" />
</Item>
<Item name="qrCodeurl" label="二维码URL">
<Input placeholder="请输入二维码URL" />
</Item>
<Item label="展示方式" name="displayMode">
<Radio.Group onChange={onChange} value={radio}>
<Radio value="卡片">卡片</Radio>
......
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