mirror of
https://github.com/YMFE/yapi.git
synced 2025-02-23 13:59:28 +08:00
fix: 为log添加头像
This commit is contained in:
parent
191656b1e5
commit
f6c94d698f
@ -42,20 +42,18 @@ class Activity extends Component {
|
||||
}
|
||||
render () {
|
||||
return (
|
||||
<div>
|
||||
<div className="g-row">
|
||||
<section className="news-box">
|
||||
<div className="logHead">
|
||||
{/*<Breadcrumb />*/}
|
||||
<div className="Mockurl">
|
||||
<span>Mock地址:</span>
|
||||
<p>{this.state.mockURL}</p>
|
||||
<Button type="primary"><a href = {`/api/project/download?project_id=${this.props.match.params.id}`}>下载Mock数据</a></Button>
|
||||
</div>
|
||||
<div className="g-row">
|
||||
<section className="news-box">
|
||||
<div className="logHead">
|
||||
{/*<Breadcrumb />*/}
|
||||
<div className="Mockurl">
|
||||
<span>Mock地址:</span>
|
||||
<p>{this.state.mockURL}</p>
|
||||
<Button type="primary"><a href = {`/api/project/download?project_id=${this.props.match.params.id}`}>下载Mock数据</a></Button>
|
||||
</div>
|
||||
<TimeTree typeid = {+this.props.match.params.id} />
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
<TimeTree typeid = {+this.props.match.params.id} />
|
||||
</section>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
font-size: 0.14rem;
|
||||
background: #FFF;
|
||||
display: block;
|
||||
min-height: 550px;
|
||||
|
||||
.news-timeline{
|
||||
padding: 24px;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { Component } from 'react'
|
||||
import { Timeline, Spin } from 'antd'
|
||||
import { Timeline, Spin, Avatar } from 'antd'
|
||||
import PropTypes from 'prop-types'
|
||||
import { connect } from 'react-redux'
|
||||
import { formatTime } from '../../../../common.js';
|
||||
@ -58,7 +58,8 @@ function timeago(timestamp) {
|
||||
state => {
|
||||
return {
|
||||
newsData: state.news.newsData,
|
||||
curpage: state.news.curpage
|
||||
curpage: state.news.curpage,
|
||||
curUid: state.user.uid
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -75,7 +76,8 @@ class TimeTree extends Component {
|
||||
setLoading: PropTypes.func,
|
||||
loading: PropTypes.bool,
|
||||
curpage: PropTypes.number,
|
||||
typeid: PropTypes.number
|
||||
typeid: PropTypes.number,
|
||||
curUid: PropTypes.number
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
@ -109,8 +111,9 @@ class TimeTree extends Component {
|
||||
render() {
|
||||
let data = this.props.newsData ? this.props.newsData.list : [];
|
||||
if (data && data.length) {
|
||||
|
||||
data = data.map(function (item, i) {
|
||||
return (<Timeline.Item key={i}>
|
||||
return (<Timeline.Item dot={<Avatar src={`/api/user/avatar?uid=${item.uid}`} />} key={i}>
|
||||
<span className="logoTimeago">{timeago(item.add_time)}</span>
|
||||
<span className="logusername"><Link to={`/user/profile/${item.uid}`}>{item.username}</Link></span>
|
||||
<span className="logtype">{item.type}</span>
|
||||
|
@ -219,7 +219,7 @@ class View extends Component {
|
||||
width: '45%'
|
||||
}];
|
||||
|
||||
return <div className="caseContainer">
|
||||
return this.props.curData.title?<div className="caseContainer">
|
||||
<div className="colName">
|
||||
<span className="colKey">接口名:</span>
|
||||
<span className="colValue">{this.props.curData.title}</span>
|
||||
@ -271,7 +271,7 @@ class View extends Component {
|
||||
desc: "123",
|
||||
required: 0
|
||||
}])}*/}
|
||||
</div>
|
||||
</div>:<div className="caseContainer">接口不存在</div>;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,9 @@ class projectController extends baseController {
|
||||
name: 'string',
|
||||
basepath: 'string',
|
||||
group_id: 'number',
|
||||
desc: 'string'
|
||||
desc: 'string',
|
||||
color: 'string',
|
||||
icon: 'string'
|
||||
});
|
||||
|
||||
if (await this.checkAuth(params.group_id, 'group', 'edit') !== true) {
|
||||
@ -92,6 +94,8 @@ class projectController extends baseController {
|
||||
project_type: params.project_type || 'private',
|
||||
uid: this.getUid(),
|
||||
group_id: params.group_id,
|
||||
icon: params.icon,
|
||||
color: params.color,
|
||||
add_time: yapi.commons.time(),
|
||||
up_time: yapi.commons.time()
|
||||
};
|
||||
@ -104,7 +108,9 @@ class projectController extends baseController {
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.group_id
|
||||
typeid: params.group_id,
|
||||
color: params.color,
|
||||
icon: params.icon
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
@ -150,12 +156,15 @@ class projectController extends baseController {
|
||||
try {
|
||||
let result = await this.Model.addMember(params.id, userdata);
|
||||
let username = this.getUsername();
|
||||
let project = await this.Model.get(params.id);
|
||||
yapi.commons.saveLog({
|
||||
content: `用户${username}添加了项目成员${userdata.username}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
typeid: params.id,
|
||||
color: project.color,
|
||||
icon: project.icon
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
@ -202,7 +211,9 @@ class projectController extends baseController {
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
typeid: params.id,
|
||||
color: project.color,
|
||||
icon: project.icon
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
@ -384,7 +395,9 @@ class projectController extends baseController {
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
typeid: params.id,
|
||||
color: project.color,
|
||||
icon: project.icon
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
@ -418,7 +431,9 @@ class projectController extends baseController {
|
||||
name: 'string',
|
||||
basepath: 'string',
|
||||
group_id: 'number',
|
||||
desc: 'string'
|
||||
desc: 'string',
|
||||
icon: 'string',
|
||||
color: 'string'
|
||||
});
|
||||
if (!id) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 405, '项目id不能为空');
|
||||
@ -455,7 +470,8 @@ class projectController extends baseController {
|
||||
data.basepath = params.basepath;
|
||||
}
|
||||
if (params.env) data.env = params.env;
|
||||
|
||||
if(params.color) data.color = params.color;
|
||||
if(params.icon) data.icon = params.icon;
|
||||
let result = await this.Model.up(id, data);
|
||||
|
||||
let username = this.getUsername();
|
||||
@ -464,7 +480,9 @@ class projectController extends baseController {
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: id
|
||||
typeid: id,
|
||||
icon: params.icon,
|
||||
color: params.color
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
|
@ -20,6 +20,8 @@ class projectModel extends baseModel {
|
||||
env: [
|
||||
{ name: String, domain: String }
|
||||
],
|
||||
icon: String,
|
||||
color: String,
|
||||
add_time: Number,
|
||||
up_time: Number
|
||||
};
|
||||
@ -58,7 +60,7 @@ class projectModel extends baseModel {
|
||||
list(group_id, auth) {
|
||||
let params = {group_id: group_id}
|
||||
if(!auth) params.project_type = 'public';
|
||||
return this.model.find(params).select("_id uid name basepath desc group_id project_type env add_time up_time").sort({ _id: -1 }).exec();
|
||||
return this.model.find(params).select("_id uid name basepath desc group_id project_type color icon env add_time up_time").sort({ _id: -1 }).exec();
|
||||
}
|
||||
|
||||
listWithPaging(group_id, page, limit) {
|
||||
|
@ -138,7 +138,9 @@ var projectController = function (_baseController) {
|
||||
name: 'string',
|
||||
basepath: 'string',
|
||||
group_id: 'number',
|
||||
desc: 'string'
|
||||
desc: 'string',
|
||||
color: 'string',
|
||||
icon: 'string'
|
||||
});
|
||||
|
||||
_context.next = 4;
|
||||
@ -204,6 +206,8 @@ var projectController = function (_baseController) {
|
||||
project_type: params.project_type || 'private',
|
||||
uid: this.getUid(),
|
||||
group_id: params.group_id,
|
||||
icon: params.icon,
|
||||
color: params.color,
|
||||
add_time: _yapi2.default.commons.time(),
|
||||
up_time: _yapi2.default.commons.time()
|
||||
};
|
||||
@ -220,7 +224,9 @@ var projectController = function (_baseController) {
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.group_id
|
||||
typeid: params.group_id,
|
||||
color: params.color,
|
||||
icon: params.icon
|
||||
});
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context.next = 32;
|
||||
@ -262,7 +268,7 @@ var projectController = function (_baseController) {
|
||||
key: 'addMember',
|
||||
value: function () {
|
||||
var _ref2 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2(ctx) {
|
||||
var params, check, userdata, result, username;
|
||||
var params, check, userdata, result, username, project;
|
||||
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
||||
while (1) {
|
||||
switch (_context2.prev = _context2.next) {
|
||||
@ -334,30 +340,37 @@ var projectController = function (_baseController) {
|
||||
case 23:
|
||||
result = _context2.sent;
|
||||
username = this.getUsername();
|
||||
_context2.next = 27;
|
||||
return this.Model.get(params.id);
|
||||
|
||||
case 27:
|
||||
project = _context2.sent;
|
||||
|
||||
_yapi2.default.commons.saveLog({
|
||||
content: '\u7528\u6237' + username + '\u6DFB\u52A0\u4E86\u9879\u76EE\u6210\u5458' + userdata.username,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
typeid: params.id,
|
||||
color: project.color,
|
||||
icon: project.icon
|
||||
});
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context2.next = 32;
|
||||
_context2.next = 35;
|
||||
break;
|
||||
|
||||
case 29:
|
||||
_context2.prev = 29;
|
||||
case 32:
|
||||
_context2.prev = 32;
|
||||
_context2.t1 = _context2['catch'](20);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context2.t1.message);
|
||||
|
||||
case 32:
|
||||
case 35:
|
||||
case 'end':
|
||||
return _context2.stop();
|
||||
}
|
||||
}
|
||||
}, _callee2, this, [[20, 29]]);
|
||||
}, _callee2, this, [[20, 32]]);
|
||||
}));
|
||||
|
||||
function addMember(_x2) {
|
||||
@ -456,7 +469,9 @@ var projectController = function (_baseController) {
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
typeid: params.id,
|
||||
color: project.color,
|
||||
icon: project.icon
|
||||
});
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context3.next = 33;
|
||||
@ -920,7 +935,9 @@ var projectController = function (_baseController) {
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
typeid: params.id,
|
||||
color: project.color,
|
||||
icon: project.icon
|
||||
});
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context9.next = 35;
|
||||
@ -983,7 +1000,9 @@ var projectController = function (_baseController) {
|
||||
name: 'string',
|
||||
basepath: 'string',
|
||||
group_id: 'number',
|
||||
desc: 'string'
|
||||
desc: 'string',
|
||||
icon: 'string',
|
||||
color: 'string'
|
||||
});
|
||||
|
||||
if (_id2) {
|
||||
@ -1057,11 +1076,12 @@ var projectController = function (_baseController) {
|
||||
data.basepath = params.basepath;
|
||||
}
|
||||
if (params.env) data.env = params.env;
|
||||
|
||||
_context10.next = 31;
|
||||
if (params.color) data.color = params.color;
|
||||
if (params.icon) data.icon = params.icon;
|
||||
_context10.next = 33;
|
||||
return this.Model.up(_id2, data);
|
||||
|
||||
case 31:
|
||||
case 33:
|
||||
result = _context10.sent;
|
||||
username = this.getUsername();
|
||||
|
||||
@ -1070,24 +1090,26 @@ var projectController = function (_baseController) {
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: _id2
|
||||
typeid: _id2,
|
||||
icon: params.icon,
|
||||
color: params.color
|
||||
});
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context10.next = 40;
|
||||
_context10.next = 42;
|
||||
break;
|
||||
|
||||
case 37:
|
||||
_context10.prev = 37;
|
||||
case 39:
|
||||
_context10.prev = 39;
|
||||
_context10.t1 = _context10['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context10.t1.message);
|
||||
|
||||
case 40:
|
||||
case 42:
|
||||
case 'end':
|
||||
return _context10.stop();
|
||||
}
|
||||
}
|
||||
}, _callee10, this, [[0, 37]]);
|
||||
}, _callee10, this, [[0, 39]]);
|
||||
}));
|
||||
|
||||
function up(_x11) {
|
||||
|
@ -55,6 +55,8 @@ var projectModel = function (_baseModel) {
|
||||
project_type: { type: String, required: true, enum: ['public', 'private'] },
|
||||
members: [{ uid: Number, role: { type: String, enum: ['owner', 'dev'] }, username: String, email: String }],
|
||||
env: [{ name: String, domain: String }],
|
||||
icon: String,
|
||||
color: String,
|
||||
add_time: Number,
|
||||
up_time: Number
|
||||
};
|
||||
@ -99,7 +101,7 @@ var projectModel = function (_baseModel) {
|
||||
value: function list(group_id, auth) {
|
||||
var params = { group_id: group_id };
|
||||
if (!auth) params.project_type = 'public';
|
||||
return this.model.find(params).select("_id uid name basepath desc group_id project_type env add_time up_time").sort({ _id: -1 }).exec();
|
||||
return this.model.find(params).select("_id uid name basepath desc group_id project_type color icon env add_time up_time").sort({ _id: -1 }).exec();
|
||||
}
|
||||
}, {
|
||||
key: 'listWithPaging',
|
||||
|
Loading…
Reference in New Issue
Block a user