|
|
@ -1,43 +1,105 @@ |
|
|
|
import React, { useEffect, useRef, useState } from 'react'; |
|
|
|
import { connect } from "react-redux"; |
|
|
|
import { Select, Modal, Form, Button } from "@douyinfe/semi-ui"; |
|
|
|
import { Tag, Modal, Table, Button } from "@douyinfe/semi-ui"; |
|
|
|
const statusKeys = { |
|
|
|
status: '状态', |
|
|
|
streamIn: '流入', |
|
|
|
streamOut: '流出', |
|
|
|
memUsedPercent: '内存使用', |
|
|
|
diskPercent: '磁盘使用', |
|
|
|
timeDiff: '时间偏差(最新心跳 服务器时间-设备时间)', |
|
|
|
uptime: '本次在线时长', |
|
|
|
sys: '系统',//系统平台+系统版本 |
|
|
|
programVersion: '软件信息',//软件版本 |
|
|
|
devConfVersion: '配置版本', |
|
|
|
acqConfVersion: '采集参数版本', |
|
|
|
pluginVersion: '插件版本', |
|
|
|
load1: 'Load1', |
|
|
|
load5: 'Load5', |
|
|
|
load15: 'Load15', |
|
|
|
} |
|
|
|
|
|
|
|
const GatewayStatusModal = (props) => { |
|
|
|
const { dispatch, actions, user, onCancel, dataToModal } = props; |
|
|
|
const { edition } = actions; |
|
|
|
const [listData, setListData] = useState(null); |
|
|
|
const [listData, setListData] = useState([]); |
|
|
|
//初始化 |
|
|
|
useEffect(() => { |
|
|
|
dispatch(edition.getGatewayStatus(dataToModal.id)).then(res => {//查询网关状态指标 |
|
|
|
if (res.success) { |
|
|
|
setListData(res.payload.data) |
|
|
|
//let a = formatDuring(172890) |
|
|
|
let tableData = Object.keys(statusKeys).map(k => { |
|
|
|
let value = k == 'sys' ? res.payload.data.platform + '-拼接-' + res.payload.data.sysVersion : res.payload.data[k] |
|
|
|
return { label: statusKeys[k], value } |
|
|
|
}) |
|
|
|
setListData(tableData) |
|
|
|
} |
|
|
|
}) |
|
|
|
}, []); |
|
|
|
|
|
|
|
const statusKeys = { |
|
|
|
status: '状态', |
|
|
|
streamIn: '流入', |
|
|
|
streamOut: '流出', |
|
|
|
memUsedPercent: '内存使用', |
|
|
|
diskPercent: '磁盘使用', |
|
|
|
timeDiff: '时间偏差(最新心跳 服务器时间-设备时间)', |
|
|
|
uptime: '本次在线时常',//??? |
|
|
|
sysVersion: '系统', |
|
|
|
status: '软件信息',//??? |
|
|
|
status: '配置版本',//??? |
|
|
|
acqConfVersion: '采集参数版本',//??? |
|
|
|
pluginVersion: '插件版本', |
|
|
|
load1: 'Load1', |
|
|
|
load5: 'Load5', |
|
|
|
load15: 'Load15', |
|
|
|
const getFileSize = (size) => { |
|
|
|
if (!size && parseInt(size) != 0) |
|
|
|
return "0K"; |
|
|
|
|
|
|
|
var num = 1024.00; //byte |
|
|
|
if (size < num) |
|
|
|
return size + "B"; |
|
|
|
if (size < Math.pow(num, 2)) |
|
|
|
return (size / num).toFixed(2) + "KB"; //kb |
|
|
|
if (size < Math.pow(num, 3)) |
|
|
|
return (size / Math.pow(num, 2)).toFixed(2) + "M"; //M |
|
|
|
if (size < Math.pow(num, 4)) |
|
|
|
return (size / Math.pow(num, 3)).toFixed(2) + "G"; //G |
|
|
|
return (size / Math.pow(num, 4)).toFixed(2) + "T"; //T |
|
|
|
} |
|
|
|
|
|
|
|
const formatDuring = (mss) => { |
|
|
|
var days = parseInt(mss / (60 * 60 * 24)); |
|
|
|
var hours = parseInt((mss % (60 * 60 * 24)) / (60 * 60)); |
|
|
|
var minutes = parseInt((mss % (60 * 60)) / (60)); |
|
|
|
var seconds = ((mss % 60)).toFixed(0); |
|
|
|
return days + " 天 " + hours + " 小时 " + minutes + " 分钟 " + seconds + " 秒 "; |
|
|
|
} |
|
|
|
return ( |
|
|
|
<Modal title={dataToModal.name} |
|
|
|
visible={true} destroyOnClose onCancel={onCancel} |
|
|
|
footer={[<Button onClick={onCancel}>关闭</Button>]}> |
|
|
|
<div></div> |
|
|
|
</Modal> |
|
|
|
|
|
|
|
const columns = [{ |
|
|
|
title: '属性', |
|
|
|
dataIndex: 'label', |
|
|
|
key: 'label', |
|
|
|
width: '60%' |
|
|
|
}, { |
|
|
|
title: '状态值', |
|
|
|
dataIndex: 'value', |
|
|
|
key: 'value', |
|
|
|
width: '40%', |
|
|
|
render: (text, record) => { |
|
|
|
if (record.label == '状态') { |
|
|
|
return text ? <Tag color='green'>在线</Tag> : <Tag color='grey'>离线</Tag> |
|
|
|
} else if (['流入', '流出'].indexOf(record.label) != -1) { |
|
|
|
return <span>{getFileSize(text)}</span> |
|
|
|
} else if (record.label.indexOf('使用') != -1) { |
|
|
|
return <span>{`${text}%`}</span> |
|
|
|
} else if (record.label.indexOf('时间偏差') != -1) { |
|
|
|
return <span>{`${text}ms`}</span> |
|
|
|
} else if (record.label.indexOf('时长') != -1) { |
|
|
|
return <span>{formatDuring(text)}</span> |
|
|
|
} else { |
|
|
|
return text |
|
|
|
} |
|
|
|
} |
|
|
|
}] |
|
|
|
return (<Modal title={'状态指标详情'} width={600} closable={true} |
|
|
|
visible={true} destroyOnClose onCancel={onCancel} |
|
|
|
footer={[<Button onClick={onCancel}>关闭</Button>]}> |
|
|
|
<div style={{ fontSize: 15, fontWeight: 'bold', marginBottom: 20 }}>{`序号:${dataToModal.serialNo}`} {`名称:${dataToModal.name}`}</div> |
|
|
|
<Table |
|
|
|
size='small' |
|
|
|
columns={columns} |
|
|
|
dataSource={listData} |
|
|
|
bordered={false} |
|
|
|
empty="暂无数据" |
|
|
|
pagination={false} |
|
|
|
/> |
|
|
|
</Modal> |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|