mirror of
https://github.com/YMFE/yapi.git
synced 2025-01-18 13:04:46 +08:00
Merge branch 'dev' of gitlab.corp.qunar.com:mfe/yapi into dev
This commit is contained in:
commit
8b036dff69
@ -58,7 +58,6 @@ function timeago(timestamp) {
|
|||||||
@connect(
|
@connect(
|
||||||
|
|
||||||
state => {
|
state => {
|
||||||
console.log(11);
|
|
||||||
return {
|
return {
|
||||||
newsData: state.news.newsData,
|
newsData: state.news.newsData,
|
||||||
curpage: state.news.curpage,
|
curpage: state.news.curpage,
|
||||||
@ -98,7 +97,7 @@ class TimeTree extends Component {
|
|||||||
if (this.props.curpage <= this.props.newsData.total) {
|
if (this.props.curpage <= this.props.newsData.total) {
|
||||||
|
|
||||||
this.setState({ loading: true });
|
this.setState({ loading: true });
|
||||||
this.props.fetchMoreNews(this.props.typeid, this.props.type, this.props.curpage+1, 8).then(function () {
|
this.props.fetchMoreNews(this.props.typeid, this.props.type, this.props.curpage+1, 10).then(function () {
|
||||||
that.setState({ loading: false });
|
that.setState({ loading: false });
|
||||||
if (that.props.newsData.total === that.props.curpage) {
|
if (that.props.newsData.total === that.props.curpage) {
|
||||||
that.setState({ bidden: "logbidden" })
|
that.setState({ bidden: "logbidden" })
|
||||||
@ -108,7 +107,7 @@ class TimeTree extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
this.props.fetchNewsData(this.props.typeid, this.props.type, 1, 8)
|
this.props.fetchNewsData(this.props.typeid, this.props.type, 1, 10)
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
let data = this.props.newsData ? this.props.newsData.list : [];
|
let data = this.props.newsData ? this.props.newsData.list : [];
|
||||||
@ -121,7 +120,6 @@ class TimeTree extends Component {
|
|||||||
other: "其他"
|
other: "其他"
|
||||||
};
|
};
|
||||||
if (data && data.length) {
|
if (data && data.length) {
|
||||||
console.log(data);
|
|
||||||
data = data.map(function (item, i) {
|
data = data.map(function (item, i) {
|
||||||
return (<Timeline.Item dot={<Link to={`/user/profile/${item.uid}`}><Avatar src={`/api/user/avatar?uid=${item.uid}`} /></Link>} key={i}>
|
return (<Timeline.Item dot={<Link to={`/user/profile/${item.uid}`}><Avatar src={`/api/user/avatar?uid=${item.uid}`} /></Link>} key={i}>
|
||||||
<div className="logMesHeade">
|
<div className="logMesHeade">
|
||||||
|
@ -12,9 +12,11 @@ const TabPane = Tabs.TabPane;
|
|||||||
import { fetchNewsData } from '../../reducer/modules/news.js';
|
import { fetchNewsData } from '../../reducer/modules/news.js';
|
||||||
import './Group.scss';
|
import './Group.scss';
|
||||||
@connect(
|
@connect(
|
||||||
|
|
||||||
state => {
|
state => {
|
||||||
return {
|
return {
|
||||||
curGroupId: state.group.currGroup._id,
|
curGroupId: state.group.currGroup._id,
|
||||||
|
curUserRole: state.group.currGroup.role,
|
||||||
currGroup: state.group.currGroup
|
currGroup: state.group.currGroup
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -29,15 +31,15 @@ export default class Group extends Component {
|
|||||||
static propTypes = {
|
static propTypes = {
|
||||||
fetchNewsData: PropTypes.func,
|
fetchNewsData: PropTypes.func,
|
||||||
curGroupId: PropTypes.number,
|
curGroupId: PropTypes.number,
|
||||||
|
curUserRole: PropTypes.string,
|
||||||
currGroup: PropTypes.object
|
currGroup: PropTypes.object
|
||||||
}
|
}
|
||||||
onTabClick(key){
|
onTabClick(key){
|
||||||
if(key == 3){
|
if(key == 3){
|
||||||
this.props.fetchNewsData(this.props.curGroupId, "group", 1, 8)
|
this.props.fetchNewsData(this.props.curGroupId, "group", 1, 10)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
render () {
|
render () {
|
||||||
console.log(this.props.currGroup)
|
|
||||||
const GroupContent = (
|
const GroupContent = (
|
||||||
<Layout style={{minHeight: 'calc(100vh - 100px)', marginLeft: '24px', marginTop: '24px'}}>
|
<Layout style={{minHeight: 'calc(100vh - 100px)', marginLeft: '24px', marginTop: '24px'}}>
|
||||||
<Sider style={{ height: '100%' }} width={300}>
|
<Sider style={{ height: '100%' }} width={300}>
|
||||||
@ -48,10 +50,8 @@ export default class Group extends Component {
|
|||||||
<Content style={{ height: '100%', margin: '0 24px 0 16px', overflow: 'initial',backgroundColor: '#fff'}}>
|
<Content style={{ height: '100%', margin: '0 24px 0 16px', overflow: 'initial',backgroundColor: '#fff'}}>
|
||||||
<Tabs onTabClick={this.onTabClick.bind(this)} type="card" className="m-tab" style={{height: '100%'}}>
|
<Tabs onTabClick={this.onTabClick.bind(this)} type="card" className="m-tab" style={{height: '100%'}}>
|
||||||
<TabPane tab="项目列表" key="1"><ProjectList/></TabPane>
|
<TabPane tab="项目列表" key="1"><ProjectList/></TabPane>
|
||||||
{
|
{this.props.currGroup.type === 'public'?<TabPane tab="成员列表" key="2"><MemberList/></TabPane>:null}
|
||||||
this.props.currGroup.type === 'public'?<TabPane tab="成员列表" key="2"><MemberList/></TabPane>:null
|
{["admin","owner","guest","dev"].indexOf(this.props.curUserRole)>-1?<TabPane tab="分组动态" key="3"><GroupLog/></TabPane>:""}
|
||||||
}
|
|
||||||
<TabPane tab="分组动态" key="3"><GroupLog/></TabPane>
|
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</Content>
|
</Content>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
@ -4,3 +4,7 @@
|
|||||||
@include row-width-limit;
|
@include row-width-limit;
|
||||||
margin: 0 auto .24rem;
|
margin: 0 auto .24rem;
|
||||||
}
|
}
|
||||||
|
.news-box .news-timeline .ant-timeline-item .ant-timeline-item-content{
|
||||||
|
min-width: 300px !important;
|
||||||
|
width: 75% !important;
|
||||||
|
}
|
@ -125,7 +125,7 @@ export default class GroupList extends Component {
|
|||||||
await this.props.fetchGroupList();
|
await this.props.fetchGroupList();
|
||||||
this.setState({ groupList: this.props.groupList });
|
this.setState({ groupList: this.props.groupList });
|
||||||
this.props.setCurrGroup(res.data.data)
|
this.props.setCurrGroup(res.data.data)
|
||||||
this.props.fetchNewsData(this.props.currGroup._id, "group", 1, 8)
|
this.props.fetchNewsData(this.props.currGroup._id, "group", 1, 10)
|
||||||
} else {
|
} else {
|
||||||
message.error(res.data.errmsg)
|
message.error(res.data.errmsg)
|
||||||
}
|
}
|
||||||
@ -144,7 +144,7 @@ export default class GroupList extends Component {
|
|||||||
await this.props.fetchGroupList();
|
await this.props.fetchGroupList();
|
||||||
this.setState({ groupList: this.props.groupList });
|
this.setState({ groupList: this.props.groupList });
|
||||||
this.props.setCurrGroup({ group_name, group_desc, _id: id });
|
this.props.setCurrGroup({ group_name, group_desc, _id: id });
|
||||||
this.props.fetchNewsData(this.props.currGroup._id, "group", 1, 8)
|
this.props.fetchNewsData(this.props.currGroup._id, "group", 1, 10)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@autobind
|
@autobind
|
||||||
@ -170,7 +170,7 @@ export default class GroupList extends Component {
|
|||||||
const currGroup = this.props.groupList.find((group) => { return +group._id === +groupId });
|
const currGroup = this.props.groupList.find((group) => { return +group._id === +groupId });
|
||||||
this.props.setCurrGroup(currGroup);
|
this.props.setCurrGroup(currGroup);
|
||||||
this.props.history.replace(`${currGroup._id}`);
|
this.props.history.replace(`${currGroup._id}`);
|
||||||
this.props.fetchNewsData(groupId, "group", 1, 8)
|
this.props.fetchNewsData(groupId, "group", 1, 10)
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
|
@ -99,7 +99,10 @@ class ProjectList extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const projectData = this.state.projectData;
|
let projectData = this.state.projectData;
|
||||||
|
projectData = projectData.sort((a,b)=>{
|
||||||
|
return b.up_time - a.up_time;
|
||||||
|
})
|
||||||
return (
|
return (
|
||||||
<div style={{ paddingTop: '24px' }} className="m-panel card-panel card-panel-s project-list" >
|
<div style={{ paddingTop: '24px' }} className="m-panel card-panel card-panel-s project-list" >
|
||||||
<Row className="project-list-header">
|
<Row className="project-list-header">
|
||||||
@ -114,9 +117,7 @@ class ProjectList extends Component {
|
|||||||
<Tooltip title="您没有权限,请联系该分组组长或管理员">
|
<Tooltip title="您没有权限,请联系该分组组长或管理员">
|
||||||
<Button type="primary" disabled >添加项目</Button>
|
<Button type="primary" disabled >添加项目</Button>
|
||||||
</Tooltip>}
|
</Tooltip>}
|
||||||
|
|
||||||
</Col>
|
</Col>
|
||||||
|
|
||||||
</Row>
|
</Row>
|
||||||
<Row gutter={16}>
|
<Row gutter={16}>
|
||||||
{projectData.length ? projectData.map((item, index) => {
|
{projectData.length ? projectData.map((item, index) => {
|
||||||
|
@ -166,6 +166,7 @@ class interfaceController extends baseController {
|
|||||||
username: username,
|
username: username,
|
||||||
typeid: params.project_id
|
typeid: params.project_id
|
||||||
});
|
});
|
||||||
|
this.projectModel.up(params.project_id,{up_time: new Date().getTime()}).then();
|
||||||
//let project = await this.projectModel.getBaseInfo(params.project_id);
|
//let project = await this.projectModel.getBaseInfo(params.project_id);
|
||||||
// let interfaceUrl = `http://${ctx.request.host}/project/${params.project_id}/interface/api/${result._id}`
|
// let interfaceUrl = `http://${ctx.request.host}/project/${params.project_id}/interface/api/${result._id}`
|
||||||
// this.sendNotice(params.project_id, {
|
// this.sendNotice(params.project_id, {
|
||||||
@ -473,6 +474,7 @@ class interfaceController extends baseController {
|
|||||||
typeid: cate.project_id
|
typeid: cate.project_id
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
this.projectModel.up(interfaceData.project_id,{up_time: new Date().getTime()}).then();
|
||||||
} else {
|
} else {
|
||||||
let cateid = interfaceData.catid;
|
let cateid = interfaceData.catid;
|
||||||
this.catModel.get(cateid).then((cate) => {
|
this.catModel.get(cateid).then((cate) => {
|
||||||
@ -484,6 +486,7 @@ class interfaceController extends baseController {
|
|||||||
typeid: cate.project_id
|
typeid: cate.project_id
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
this.projectModel.up(interfaceData.project_id,{up_time: new Date().getTime()}).then();
|
||||||
}
|
}
|
||||||
if (params.switch_notice === true) {
|
if (params.switch_notice === true) {
|
||||||
let project = await this.projectModel.getBaseInfo(interfaceData.project_id);
|
let project = await this.projectModel.getBaseInfo(interfaceData.project_id);
|
||||||
@ -548,7 +551,7 @@ class interfaceController extends baseController {
|
|||||||
typeid: cate.project_id
|
typeid: cate.project_id
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
this.projectModel.up(data.project_id,{up_time: new Date().getTime()}).then();
|
||||||
|
|
||||||
ctx.body = yapi.commons.resReturn(result);
|
ctx.body = yapi.commons.resReturn(result);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -95,6 +95,7 @@ class interfaceColController extends baseController{
|
|||||||
username: username,
|
username: username,
|
||||||
typeid: params.project_id
|
typeid: params.project_id
|
||||||
});
|
});
|
||||||
|
// this.projectModel.up(params.project_id,{up_time: new Date().getTime()}).then();
|
||||||
ctx.body = yapi.commons.resReturn(result);
|
ctx.body = yapi.commons.resReturn(result);
|
||||||
|
|
||||||
}catch(e){
|
}catch(e){
|
||||||
@ -226,7 +227,7 @@ class interfaceColController extends baseController{
|
|||||||
typeid: params.project_id
|
typeid: params.project_id
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
this.projectModel.up(params.project_id,{up_time: new Date().getTime()}).then();
|
||||||
|
|
||||||
ctx.body = yapi.commons.resReturn(result);
|
ctx.body = yapi.commons.resReturn(result);
|
||||||
|
|
||||||
@ -295,7 +296,7 @@ class interfaceColController extends baseController{
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.projectModel.up(caseData.project_id,{up_time: new Date().getTime()}).then();
|
||||||
|
|
||||||
ctx.body = yapi.commons.resReturn(result);
|
ctx.body = yapi.commons.resReturn(result);
|
||||||
|
|
||||||
@ -398,6 +399,7 @@ class interfaceColController extends baseController{
|
|||||||
username: username,
|
username: username,
|
||||||
typeid: colData.project_id
|
typeid: colData.project_id
|
||||||
});
|
});
|
||||||
|
|
||||||
ctx.body = yapi.commons.resReturn(result)
|
ctx.body = yapi.commons.resReturn(result)
|
||||||
}catch(e){
|
}catch(e){
|
||||||
ctx.body = yapi.commons.resReturn(null, 400, e.message)
|
ctx.body = yapi.commons.resReturn(null, 400, e.message)
|
||||||
@ -510,7 +512,7 @@ class interfaceColController extends baseController{
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.projectModel.up(caseData.project_id,{up_time: new Date().getTime()}).then();
|
||||||
return ctx.body = yapi.commons.resReturn(result);
|
return ctx.body = yapi.commons.resReturn(result);
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,12 +2,14 @@ const logModel = require('../models/log.js');
|
|||||||
const yapi = require('../yapi.js');
|
const yapi = require('../yapi.js');
|
||||||
const baseController = require('./base.js');
|
const baseController = require('./base.js');
|
||||||
const groupModel = require('../models/group');
|
const groupModel = require('../models/group');
|
||||||
|
const projectModel = require('../models/project');
|
||||||
|
|
||||||
class logController extends baseController {
|
class logController extends baseController {
|
||||||
constructor(ctx) {
|
constructor(ctx) {
|
||||||
super(ctx);
|
super(ctx);
|
||||||
this.Model = yapi.getInst(logModel);
|
this.Model = yapi.getInst(logModel);
|
||||||
this.groupModel = yapi.getInst(groupModel);
|
this.groupModel = yapi.getInst(groupModel);
|
||||||
|
this.projectModel = yapi.getInst(projectModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,6 +37,18 @@ class logController extends baseController {
|
|||||||
return ctx.body = yapi.commons.resReturn(null, 400, 'type不能为空');
|
return ctx.body = yapi.commons.resReturn(null, 400, 'type不能为空');
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
if(type === "group"){
|
||||||
|
let projectList = await this.projectModel.list(typeid);
|
||||||
|
for(let i in projectList){
|
||||||
|
projectList[i] = projectList[i]._id;
|
||||||
|
}
|
||||||
|
let projectLogList = await this.Model.listWithPagingByGroup(typeid,projectList,page,limit);
|
||||||
|
let total = await this.Model.listCountByGroup(typeid,projectList);
|
||||||
|
ctx.body = yapi.commons.resReturn({
|
||||||
|
list: projectLogList,
|
||||||
|
total: Math.ceil(total / limit)
|
||||||
|
});
|
||||||
|
}else if(type === "project"){
|
||||||
let result = await this.Model.listWithPaging(typeid,type, page, limit);
|
let result = await this.Model.listWithPaging(typeid,type, page, limit);
|
||||||
let count = await this.Model.listCount(typeid,type);
|
let count = await this.Model.listCount(typeid,type);
|
||||||
|
|
||||||
@ -42,6 +56,8 @@ class logController extends baseController {
|
|||||||
total: Math.ceil(count / limit),
|
total: Math.ceil(count / limit),
|
||||||
list: result
|
list: result
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
ctx.body = yapi.commons.resReturn(null, 402, err.message);
|
ctx.body = yapi.commons.resReturn(null, 402, err.message);
|
||||||
}
|
}
|
||||||
|
@ -58,13 +58,35 @@ class logModel extends baseModel {
|
|||||||
listWithPaging(typeid,type, page, limit) {
|
listWithPaging(typeid,type, page, limit) {
|
||||||
page = parseInt(page);
|
page = parseInt(page);
|
||||||
limit = parseInt(limit);
|
limit = parseInt(limit);
|
||||||
|
|
||||||
return this.model.find({
|
return this.model.find({
|
||||||
type: type,
|
type: type,
|
||||||
typeid: typeid
|
typeid: typeid
|
||||||
}).sort({add_time:-1}).skip((page - 1) * limit).limit(limit).exec();
|
}).sort({add_time:-1}).skip((page - 1) * limit).limit(limit).exec();
|
||||||
}
|
}
|
||||||
|
listWithPagingByGroup(typeid, pidList, page, limit) {
|
||||||
|
page = parseInt(page);
|
||||||
|
limit = parseInt(limit);
|
||||||
|
return this.model.find({
|
||||||
|
"$or":[{
|
||||||
|
type: "project",
|
||||||
|
typeid: {"$in": pidList}
|
||||||
|
},{
|
||||||
|
type: "group",
|
||||||
|
typeid: typeid
|
||||||
|
}]
|
||||||
|
}).sort({add_time:-1}).skip((page - 1) * limit).limit(limit).exec();
|
||||||
|
}
|
||||||
|
listCountByGroup(typeid,pidList) {
|
||||||
|
return this.model.count({
|
||||||
|
"$or":[{
|
||||||
|
type: "project",
|
||||||
|
typeid: {"$in": pidList}
|
||||||
|
},{
|
||||||
|
type: "group",
|
||||||
|
typeid: typeid
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
}
|
||||||
listCount(typeid,type) {
|
listCount(typeid,type) {
|
||||||
return this.model.count({
|
return this.model.count({
|
||||||
typeid: typeid,
|
typeid: typeid,
|
||||||
|
Loading…
Reference in New Issue
Block a user