diff --git a/client/components/TimeLine/TimeLine.js b/client/components/TimeLine/TimeLine.js index 9bccd03b..98147dc0 100644 --- a/client/components/TimeLine/TimeLine.js +++ b/client/components/TimeLine/TimeLine.js @@ -58,7 +58,6 @@ function timeago(timestamp) { @connect( state => { - console.log(11); return { newsData: state.news.newsData, curpage: state.news.curpage, @@ -98,7 +97,7 @@ class TimeTree extends Component { if (this.props.curpage <= this.props.newsData.total) { 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 }); if (that.props.newsData.total === that.props.curpage) { that.setState({ bidden: "logbidden" }) @@ -108,7 +107,7 @@ class TimeTree extends Component { } componentWillMount() { - this.props.fetchNewsData(this.props.typeid, this.props.type, 1, 8) + this.props.fetchNewsData(this.props.typeid, this.props.type, 1, 10) } render() { let data = this.props.newsData ? this.props.newsData.list : []; @@ -121,7 +120,6 @@ class TimeTree extends Component { other: "其他" }; if (data && data.length) { - console.log(data); data = data.map(function (item, i) { return (} key={i}>
diff --git a/client/containers/Group/Group.js b/client/containers/Group/Group.js index e22c3525..800ce143 100755 --- a/client/containers/Group/Group.js +++ b/client/containers/Group/Group.js @@ -12,9 +12,11 @@ const TabPane = Tabs.TabPane; import { fetchNewsData } from '../../reducer/modules/news.js'; import './Group.scss'; @connect( + state => { return { curGroupId: state.group.currGroup._id, + curUserRole: state.group.currGroup.role, currGroup: state.group.currGroup } }, @@ -29,15 +31,15 @@ export default class Group extends Component { static propTypes = { fetchNewsData: PropTypes.func, curGroupId: PropTypes.number, + curUserRole: PropTypes.string, currGroup: PropTypes.object } onTabClick(key){ if(key == 3){ - this.props.fetchNewsData(this.props.curGroupId, "group", 1, 8) + this.props.fetchNewsData(this.props.curGroupId, "group", 1, 10) } } render () { - console.log(this.props.currGroup) const GroupContent = ( @@ -48,10 +50,8 @@ export default class Group extends Component { - { - this.props.currGroup.type === 'public'?:null - } - + {this.props.currGroup.type === 'public'?:null} + {["admin","owner","guest","dev"].indexOf(this.props.curUserRole)>-1?:""} diff --git a/client/containers/Group/Group.scss b/client/containers/Group/Group.scss index a6944eb2..cf39e6b4 100755 --- a/client/containers/Group/Group.scss +++ b/client/containers/Group/Group.scss @@ -4,3 +4,7 @@ @include row-width-limit; margin: 0 auto .24rem; } +.news-box .news-timeline .ant-timeline-item .ant-timeline-item-content{ + min-width: 300px !important; + width: 75% !important; +} \ No newline at end of file diff --git a/client/containers/Group/GroupList/GroupList.js b/client/containers/Group/GroupList/GroupList.js index 01bb55a1..754bce89 100755 --- a/client/containers/Group/GroupList/GroupList.js +++ b/client/containers/Group/GroupList/GroupList.js @@ -125,7 +125,7 @@ export default class GroupList extends Component { await this.props.fetchGroupList(); this.setState({ groupList: this.props.groupList }); 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 { message.error(res.data.errmsg) } @@ -144,7 +144,7 @@ export default class GroupList extends Component { await this.props.fetchGroupList(); this.setState({ groupList: this.props.groupList }); 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 @@ -170,7 +170,7 @@ export default class GroupList extends Component { const currGroup = this.props.groupList.find((group) => { return +group._id === +groupId }); this.props.setCurrGroup(currGroup); this.props.history.replace(`${currGroup._id}`); - this.props.fetchNewsData(groupId, "group", 1, 8) + this.props.fetchNewsData(groupId, "group", 1, 10) } @autobind diff --git a/client/containers/Group/ProjectList/ProjectList.js b/client/containers/Group/ProjectList/ProjectList.js index f5422015..24f77bd7 100755 --- a/client/containers/Group/ProjectList/ProjectList.js +++ b/client/containers/Group/ProjectList/ProjectList.js @@ -99,7 +99,10 @@ class ProjectList extends Component { } render() { - const projectData = this.state.projectData; + let projectData = this.state.projectData; + projectData = projectData.sort((a,b)=>{ + return b.up_time - a.up_time; + }) return (
@@ -114,9 +117,7 @@ class ProjectList extends Component { } - - {projectData.length ? projectData.map((item, index) => { diff --git a/server/controllers/interface.js b/server/controllers/interface.js index 2b1538ef..b8221dd0 100755 --- a/server/controllers/interface.js +++ b/server/controllers/interface.js @@ -166,6 +166,7 @@ class interfaceController extends baseController { username: username, 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 interfaceUrl = `http://${ctx.request.host}/project/${params.project_id}/interface/api/${result._id}` // this.sendNotice(params.project_id, { @@ -473,6 +474,7 @@ class interfaceController extends baseController { typeid: cate.project_id }); }); + this.projectModel.up(interfaceData.project_id,{up_time: new Date().getTime()}).then(); } else { let cateid = interfaceData.catid; this.catModel.get(cateid).then((cate) => { @@ -484,6 +486,7 @@ class interfaceController extends baseController { typeid: cate.project_id }); }); + this.projectModel.up(interfaceData.project_id,{up_time: new Date().getTime()}).then(); } if (params.switch_notice === true) { let project = await this.projectModel.getBaseInfo(interfaceData.project_id); @@ -548,7 +551,7 @@ class interfaceController extends baseController { typeid: cate.project_id }); }) - + this.projectModel.up(data.project_id,{up_time: new Date().getTime()}).then(); ctx.body = yapi.commons.resReturn(result); } catch (err) { diff --git a/server/controllers/interfaceCol.js b/server/controllers/interfaceCol.js index 4d2841bb..bc461ba8 100755 --- a/server/controllers/interfaceCol.js +++ b/server/controllers/interfaceCol.js @@ -95,6 +95,7 @@ class interfaceColController extends baseController{ username: username, typeid: params.project_id }); + // this.projectModel.up(params.project_id,{up_time: new Date().getTime()}).then(); ctx.body = yapi.commons.resReturn(result); }catch(e){ @@ -226,7 +227,7 @@ class interfaceColController extends baseController{ typeid: params.project_id }); }); - + this.projectModel.up(params.project_id,{up_time: new Date().getTime()}).then(); 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); @@ -398,6 +399,7 @@ class interfaceColController extends baseController{ username: username, typeid: colData.project_id }); + ctx.body = yapi.commons.resReturn(result) }catch(e){ 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); diff --git a/server/controllers/log.js b/server/controllers/log.js index 58f777fa..cff300ef 100755 --- a/server/controllers/log.js +++ b/server/controllers/log.js @@ -2,12 +2,14 @@ const logModel = require('../models/log.js'); const yapi = require('../yapi.js'); const baseController = require('./base.js'); const groupModel = require('../models/group'); +const projectModel = require('../models/project'); class logController extends baseController { constructor(ctx) { super(ctx); this.Model = yapi.getInst(logModel); this.groupModel = yapi.getInst(groupModel); + this.projectModel = yapi.getInst(projectModel); } /** @@ -35,13 +37,27 @@ class logController extends baseController { return ctx.body = yapi.commons.resReturn(null, 400, 'type不能为空'); } try { - let result = await this.Model.listWithPaging(typeid,type, page, limit); - let count = await this.Model.listCount(typeid,type); + 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 count = await this.Model.listCount(typeid,type); + + ctx.body = yapi.commons.resReturn({ + total: Math.ceil(count / limit), + list: result + }); + } - ctx.body = yapi.commons.resReturn({ - total: Math.ceil(count / limit), - list: result - }); } catch (err) { ctx.body = yapi.commons.resReturn(null, 402, err.message); } diff --git a/server/models/log.js b/server/models/log.js index 8ca15756..1628905e 100755 --- a/server/models/log.js +++ b/server/models/log.js @@ -58,13 +58,35 @@ class logModel extends baseModel { listWithPaging(typeid,type, page, limit) { page = parseInt(page); limit = parseInt(limit); - return this.model.find({ type: type, typeid: typeid }).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) { return this.model.count({ typeid: typeid,