mirror of
https://github.com/YMFE/yapi.git
synced 2024-12-03 04:50:32 +08:00
fix: 新增系统信息页面
This commit is contained in:
parent
e410285e9c
commit
9190c5353c
@ -364,8 +364,7 @@ class InterfaceColContent extends Component {
|
||||
})
|
||||
})
|
||||
axios.post('/api/col/up_col_index', changes).then(() => {
|
||||
|
||||
this.props.fetchInterfaceColList(this.props.match.params.id)
|
||||
this.props.fetchInterfaceColList(this.props.match.params.id)
|
||||
})
|
||||
if (rows) {
|
||||
this.setState({ rows });
|
||||
|
@ -100,6 +100,7 @@ export default class InterfaceColMenu extends Component {
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (this.props.interfaceColList !== nextProps.interfaceColList) {
|
||||
|
||||
this.setState({
|
||||
list: nextProps.interfaceColList
|
||||
})
|
||||
@ -402,7 +403,7 @@ export default class InterfaceColMenu extends Component {
|
||||
}
|
||||
|
||||
const item_interface_col_create = (interfaceCase) => {
|
||||
// console.log('interfaceCase', interfaceCase);
|
||||
|
||||
return (
|
||||
<TreeNode
|
||||
style={{ width: '100%' }}
|
||||
|
@ -7,7 +7,7 @@ module.exports = function () {
|
||||
this.bindHook('header_menu', function (menu) {
|
||||
menu.statisticsPage = {
|
||||
path: '/statistic',
|
||||
name: '数据统计',
|
||||
name: '系统信息',
|
||||
icon: 'bar-chart',
|
||||
adminFlag: true
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ const interfaceCaseModel = require('models/interfaceCase.js')
|
||||
const yapi = require('yapi.js');
|
||||
const config = require('./index.js');
|
||||
const commons = require('./util.js');
|
||||
const os = require("os");
|
||||
|
||||
class statisMockController extends baseController {
|
||||
constructor(ctx) {
|
||||
@ -59,6 +60,58 @@ class statisMockController extends baseController {
|
||||
mockDateList = await this.Model.getDayCount(dateInterval);
|
||||
return ctx.body = yapi.commons.resReturn({ mockCount, mockDateList });
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取邮箱状态信息
|
||||
* @interface statismock/getSystemStatus
|
||||
* @method get
|
||||
* @category statistics
|
||||
* @foldnumber 10
|
||||
* @returns {Object}
|
||||
*/
|
||||
async getSystemStatus(ctx) {
|
||||
let mail = '';
|
||||
if (yapi.WEBCONFIG.mail && yapi.WEBCONFIG.mail.enable) {
|
||||
mail = await this.checkEmail();
|
||||
// return ctx.body = yapi.commons.resReturn(result);
|
||||
|
||||
} else {
|
||||
console.log(3)
|
||||
mail = '未配置'
|
||||
}
|
||||
|
||||
let systemName = os.platform();
|
||||
let totalmem = commons.transformBytesToGB(os.totalmem());
|
||||
let freemem = commons.transformBytesToGB(os.freemem());
|
||||
let uptime = commons.transformSecondsToDay(os.uptime());
|
||||
let data = {
|
||||
mail,
|
||||
systemName,
|
||||
totalmem,
|
||||
freemem,
|
||||
uptime
|
||||
}
|
||||
|
||||
|
||||
return ctx.body = yapi.commons.resReturn(data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
checkEmail() {
|
||||
return new Promise((resolve, reject) => {
|
||||
let result = {}
|
||||
yapi.mail.verify((error) => {
|
||||
if (error) {
|
||||
result = '不可用';
|
||||
reject(result)
|
||||
} else {
|
||||
result = '可用';
|
||||
resolve(result)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -43,6 +43,13 @@ module.exports = function () {
|
||||
path: 'statismock/get',
|
||||
action: 'getMockDateList'
|
||||
})
|
||||
addRouter({
|
||||
controller: controller,
|
||||
method: 'get',
|
||||
path: 'statismock/get_system_status',
|
||||
action: 'getSystemStatus'
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
// MockServer生成mock数据后触发
|
||||
|
@ -59,6 +59,53 @@ CountOverview.propTypes = {
|
||||
date: PropTypes.object
|
||||
};
|
||||
|
||||
const StatusOverview = (props) => (
|
||||
<Row type="flex" justify="space-start" className="m-row">
|
||||
|
||||
<Col className="gutter-row" span={6}>
|
||||
<span>
|
||||
操作系统类型
|
||||
<Tooltip placement="rightTop" title="操作系统类型,返回值有'darwin', 'freebsd', 'linux', 'sunos' , 'win32'">
|
||||
<Icon className="m-help" type="question-circle" />
|
||||
</Tooltip>
|
||||
</span>
|
||||
<h2 className="gutter-box">{props.data.systemName}</h2>
|
||||
</Col>
|
||||
<Col className="gutter-row" span={6}>
|
||||
<span>
|
||||
系统运行时间
|
||||
<Tooltip placement="rightTop" title="操作系统运行时间">
|
||||
<Icon className="m-help" type="question-circle" />
|
||||
</Tooltip>
|
||||
</span>
|
||||
<h2 className="gutter-box">{props.data.uptime} day</h2>
|
||||
</Col>
|
||||
<Col className="gutter-row" span={6}>
|
||||
<span>
|
||||
系统空闲内存总量 / 内存总量
|
||||
<Tooltip placement="rightTop" title="统计yapi所有项目中的所有测试接口总数">
|
||||
<Icon className="m-help" type="question-circle" />
|
||||
</Tooltip>
|
||||
</span>
|
||||
<h2 className="gutter-box">{props.data.freemem} G / {props.data.totalmem} G </h2>
|
||||
</Col>
|
||||
<Col className="gutter-row" span={6}>
|
||||
<span>
|
||||
邮箱状态
|
||||
<Tooltip placement="rightTop" title="检测配置文件中配置邮箱的状态">
|
||||
<Icon className="m-help" type="question-circle" />
|
||||
</Tooltip>
|
||||
</span>
|
||||
<h2 className="gutter-box">{props.data.mail}</h2>
|
||||
|
||||
</Col>
|
||||
</Row>
|
||||
);
|
||||
|
||||
StatusOverview.propTypes = {
|
||||
data: PropTypes.object
|
||||
};
|
||||
|
||||
|
||||
@connect(
|
||||
null, {
|
||||
@ -78,13 +125,21 @@ class statisticsPage extends Component {
|
||||
projectCount: 0,
|
||||
interfaceCount: 0,
|
||||
interfactCaseCount: 0
|
||||
},
|
||||
status: {
|
||||
mail: '',
|
||||
systemName: '',
|
||||
totalmem: '',
|
||||
freemem: '',
|
||||
uptime: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async componentWillMount() {
|
||||
this.props.setBreadcrumb([{ name: '数据统计' }]);
|
||||
this.props.setBreadcrumb([{ name: '系统信息' }]);
|
||||
this.getStatisData();
|
||||
this.getSystemStatusData();
|
||||
}
|
||||
|
||||
// 获取统计数据
|
||||
@ -97,16 +152,36 @@ class statisticsPage extends Component {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 获取系统信息
|
||||
|
||||
async getSystemStatusData() {
|
||||
let result = await axios.get('/api/plugin/statismock/get_system_status')
|
||||
if (result.data.errcode === 0) {
|
||||
let statusData = result.data.data;
|
||||
this.setState({
|
||||
status: { ...statusData }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
render() {
|
||||
const { count } = this.state;
|
||||
const { count, status } = this.state;
|
||||
|
||||
return (
|
||||
<div className="g-statistic">
|
||||
<div className="statis-content">
|
||||
<CountOverview date={count}></CountOverview>
|
||||
<StatisChart />
|
||||
<div className="content">
|
||||
<h2 className="title">系统状况</h2>
|
||||
<div className="system-content">
|
||||
<StatusOverview data={status}></StatusOverview>
|
||||
</div>
|
||||
<h2 className="title">数据统计</h2>
|
||||
<div>
|
||||
<CountOverview date={count}></CountOverview>
|
||||
<StatisChart />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
@include row-width-limit;
|
||||
margin: 0 auto .24rem;
|
||||
margin-top: 24px;
|
||||
.statis-content {
|
||||
.content {
|
||||
-webkit-box-flex: 1;
|
||||
padding: 24px;
|
||||
width:100%;
|
||||
@ -13,7 +13,7 @@
|
||||
}
|
||||
.m-row {
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
padding-bottom: 16px;
|
||||
padding: 16px 0;
|
||||
}
|
||||
|
||||
.m-help {
|
||||
@ -54,4 +54,16 @@
|
||||
margin:16px 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.title{
|
||||
font-size: 16px;
|
||||
font-weight: 400;
|
||||
margin-bottom: 0.16rem;
|
||||
border-left: 3px solid #2395f1;
|
||||
padding-left: 8px;
|
||||
}
|
||||
|
||||
.system-content{
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
}
|
||||
|
@ -135,4 +135,16 @@ const dateSpacialWithSafari = str => {
|
||||
return date.getTime();
|
||||
}
|
||||
return new Date(str.replace(/-/g, '/')).getTime();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将内存单位从字节(b)变成GB
|
||||
*/
|
||||
|
||||
exports.transformBytesToGB = bytes => {
|
||||
return (bytes/1024/1024/1024).toFixed(2)
|
||||
}
|
||||
|
||||
exports.transformSecondsToDay = seconds => {
|
||||
return (seconds/3600/24).toFixed(2)
|
||||
}
|
||||
|
@ -57,6 +57,7 @@
|
||||
"mongoose": "4.7.0",
|
||||
"mongoose-auto-increment": "^5.0.1",
|
||||
"nodemailer": "^4.0.1",
|
||||
"os": "^0.1.1",
|
||||
"randexp": "^0.4.6",
|
||||
"request": "^2.81.0",
|
||||
"sha.js": "^2.4.9",
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -4779,7 +4779,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#48" target="_blank">./server/controllers/interfaceCol.js:48</a>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#52" target="_blank">./server/controllers/interfaceCol.js:52</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -4865,7 +4865,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#106" target="_blank">./server/controllers/interfaceCol.js:106</a>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#110" target="_blank">./server/controllers/interfaceCol.js:110</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -4927,7 +4927,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#174" target="_blank">./server/controllers/interfaceCol.js:174</a>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#178" target="_blank">./server/controllers/interfaceCol.js:178</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -4989,7 +4989,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#235" target="_blank">./server/controllers/interfaceCol.js:235</a>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#239" target="_blank">./server/controllers/interfaceCol.js:239</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -5171,7 +5171,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#483" target="_blank">./server/controllers/interfaceCol.js:483</a>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#487" target="_blank">./server/controllers/interfaceCol.js:487</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -5341,7 +5341,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#547" target="_blank">./server/controllers/interfaceCol.js:547</a>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#551" target="_blank">./server/controllers/interfaceCol.js:551</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -5403,7 +5403,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#614" target="_blank">./server/controllers/interfaceCol.js:614</a>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#618" target="_blank">./server/controllers/interfaceCol.js:618</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -5477,7 +5477,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#658" target="_blank">./server/controllers/interfaceCol.js:658</a>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#662" target="_blank">./server/controllers/interfaceCol.js:662</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -5537,7 +5537,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#690" target="_blank">./server/controllers/interfaceCol.js:690</a>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#694" target="_blank">./server/controllers/interfaceCol.js:694</a>
|
||||
</p>
|
||||
|
||||
|
||||
|
@ -194,7 +194,7 @@
|
||||
</li><li><p><img src="./images/show.jpeg" alt="一键秀"></p>
|
||||
<p> 一键秀(一键生成)已部署使用 YApi </p>
|
||||
</li><li><p><img src="./images/yonyou.jpg" alt="用友"></p>
|
||||
<p> 用友已经部署使用YApi并且自己开发了单点登录插件 </p>
|
||||
<p> 用友已经部署使用YApi,并且自己开发了单点登录插件 </p>
|
||||
</li></ul>
|
||||
|
||||
</article>
|
||||
|
@ -178,9 +178,9 @@
|
||||
<div class="content-right markdown-body use-sidebar" role="main">
|
||||
|
||||
<h3 class="subject" id="v1.3.5">v1.3.5 <a class="hashlink" href="#v1.3.5">#</a></h3><h4 class="subject" id="Feature">Feature <a class="hashlink" href="#Feature">#</a></h4><ul>
|
||||
<li>数据导入同步</li></ul>
|
||||
<li>数据导入同步,数据导入支持swagger 3.0</li></ul>
|
||||
<h4 class="subject" id="Bug_Fixed">Bug Fixed <a class="hashlink" href="#Bug_Fixed">#</a></h4><ul>
|
||||
<li>修复离开接口编辑页面的 confirm 框有时候会触发两次 & confirm 的 ‘X’ 按钮无效</li><li>修复添加集合后测试集合list不更新问题</li><li>测试集合点击对应接口侧边栏不切换</li><li>测试集合处,点击删除不成功</li><li>修改编辑接口后,再回到测试集合处数据不更新问题</li></ul>
|
||||
<li>修复离开接口编辑页面的 confirm 框有时候会触发两次 & confirm 的 ‘X’ 按钮无效</li><li>修复添加集合后测试集合list不更新问题</li><li>测试集合点击对应接口侧边栏不切换</li><li>测试集合处,点击删除不成功</li><li>修改编辑接口后,再回到测试集合处数据不更新问题</li><li>swagger 数据导入支持 2xx 的httpcode</li><li>修复mongodb帐号密码配置错误时引发的错误</li><li>修复删除分组后侧边数据没哟更新问题</li></ul>
|
||||
<h3 class="subject" id="v1.3.4">v1.3.4 <a class="hashlink" href="#v1.3.4">#</a></h3><h4 class="subject" id="Feature">Feature <a class="hashlink" href="#Feature">#</a></h4><ul>
|
||||
<li>进入project页面加入loading</li><li>接口list页table中加入分页</li><li>项目添加者自动变成项目组长</li></ul>
|
||||
<h4 class="subject" id="Bug_Fixed">Bug Fixed <a class="hashlink" href="#Bug_Fixed">#</a></h4><ul>
|
||||
|
@ -273,7 +273,7 @@ class interfaceController extends baseController {
|
||||
}
|
||||
|
||||
let result = await this.Model.getByPath(params.project_id, params.path, params.method, '_id');
|
||||
console.log('result', result);
|
||||
|
||||
if (result.length > 0) {
|
||||
result.forEach(async item => {
|
||||
params.id = item._id;
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user