mirror of
https://github.com/YMFE/yapi.git
synced 2025-02-17 13:49:43 +08:00
feat: 添加一个分组动态
This commit is contained in:
parent
59fdd6c249
commit
1be5f950e7
13
client/containers/Project/Activity/Timeline/Timeline.js → client/components/TimeLine/TimeLine.js
Executable file → Normal file
13
client/containers/Project/Activity/Timeline/Timeline.js → client/components/TimeLine/TimeLine.js
Executable file → Normal file
@ -2,10 +2,10 @@ import React, { Component } from 'react'
|
||||
import { Timeline, Spin, Avatar } from 'antd'
|
||||
import PropTypes from 'prop-types'
|
||||
import { connect } from 'react-redux'
|
||||
import { formatTime } from '../../../../common.js';
|
||||
import { formatTime } from '../../common.js';
|
||||
import { Link } from 'react-router-dom'
|
||||
import { fetchNewsData, fetchMoreNews } from '../../../../reducer/modules/news.js'
|
||||
import ErrMsg from '../../../../components/ErrMsg/ErrMsg.js';
|
||||
import { fetchNewsData, fetchMoreNews } from '../../reducer/modules/news.js'
|
||||
import ErrMsg from '../ErrMsg/ErrMsg.js';
|
||||
|
||||
function timeago(timestamp) {
|
||||
let minutes, hours, days, seconds, mouth, year;
|
||||
@ -78,7 +78,8 @@ class TimeTree extends Component {
|
||||
loading: PropTypes.bool,
|
||||
curpage: PropTypes.number,
|
||||
typeid: PropTypes.number,
|
||||
curUid: PropTypes.number
|
||||
curUid: PropTypes.number,
|
||||
type: PropTypes.string
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
@ -95,7 +96,7 @@ class TimeTree extends Component {
|
||||
if (this.props.curpage <= this.props.newsData.total) {
|
||||
|
||||
this.setState({ loading: true });
|
||||
this.props.fetchMoreNews(this.props.typeid, 'project', this.props.curpage+1, 8).then(function () {
|
||||
this.props.fetchMoreNews(this.props.typeid, this.props.type, this.props.curpage+1, 8).then(function () {
|
||||
that.setState({ loading: false });
|
||||
if (that.props.newsData.total === that.props.curpage) {
|
||||
that.setState({ bidden: "logbidden" })
|
||||
@ -106,7 +107,7 @@ class TimeTree extends Component {
|
||||
|
||||
componentWillMount() {
|
||||
|
||||
this.props.fetchNewsData(this.props.typeid, 'project', 1, 8)
|
||||
this.props.fetchNewsData(this.props.typeid, this.props.type, 1, 8)
|
||||
}
|
||||
|
||||
render() {
|
@ -2,6 +2,7 @@ import React, { Component } from 'react';
|
||||
import GroupList from './GroupList/GroupList.js';
|
||||
import ProjectList from './ProjectList/ProjectList.js';
|
||||
import MemberList from './MemberList/MemberList.js';
|
||||
import GroupLog from './GroupLog/GroupLog.js';
|
||||
import { Route, Switch, Redirect } from 'react-router-dom';
|
||||
import { Tabs, Layout } from 'antd';
|
||||
const { Content, Sider } = Layout;
|
||||
@ -27,6 +28,7 @@ export default class Group extends Component {
|
||||
<Tabs type="card" className="m-tab" style={{height: '100%'}}>
|
||||
<TabPane tab="项目列表" key="1"><ProjectList/></TabPane>
|
||||
<TabPane tab="成员列表" key="2"><MemberList/></TabPane>
|
||||
<TabPane tab="分组动态" key="3"><GroupLog/></TabPane>
|
||||
</Tabs>
|
||||
</Content>
|
||||
</Layout>
|
||||
|
36
client/containers/Group/GroupLog/GroupLog.js
Normal file
36
client/containers/Group/GroupLog/GroupLog.js
Normal file
@ -0,0 +1,36 @@
|
||||
import React, { Component } from 'react'
|
||||
import TimeTree from '../../../components/TimeLine/TimeLine'
|
||||
import { connect } from 'react-redux'
|
||||
import PropTypes from 'prop-types'
|
||||
// import { Button } from 'antd'
|
||||
@connect(
|
||||
state => {
|
||||
console.log(state);
|
||||
return {
|
||||
uid: state.user.uid + '',
|
||||
curGroupId: state.group.currGroup._id
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
class GroupLog extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
static propTypes = {
|
||||
uid: PropTypes.string,
|
||||
match: PropTypes.object,
|
||||
curGroupId: PropTypes.number
|
||||
}
|
||||
render () {
|
||||
return (
|
||||
<div className="g-row">
|
||||
<section className="news-box m-panel">
|
||||
<TimeTree type={"group"} typeid = {this.props.curGroupId} />
|
||||
</section>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default GroupLog;
|
@ -1,6 +1,6 @@
|
||||
import './Activity.scss'
|
||||
import React, { Component } from 'react'
|
||||
import TimeTree from './Timeline/Timeline'
|
||||
import TimeTree from '../../../components/TimeLine/TimeLine'
|
||||
import { connect } from 'react-redux'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Button } from 'antd'
|
||||
@ -41,7 +41,7 @@ class Activity extends Component {
|
||||
<Button type="primary"><a href = {`/api/project/download?project_id=${this.props.match.params.id}`}>下载Mock数据</a></Button>
|
||||
</div>
|
||||
</div>
|
||||
<TimeTree typeid = {+this.props.match.params.id} />
|
||||
<TimeTree type={"project"} typeid = {+this.props.match.params.id} />
|
||||
</section>
|
||||
</div>
|
||||
)
|
||||
|
@ -100,6 +100,14 @@ class groupController extends baseController {
|
||||
let result = await groupInst.save(data);
|
||||
|
||||
result = yapi.commons.fieldSelect(result, ['_id', 'group_name', 'group_desc', 'uid', 'members']);
|
||||
let username = this.getUsername();
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 新增了分组 "${params.group_name}"`,
|
||||
type: 'group',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: result._id
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
@ -165,6 +173,19 @@ class groupController extends baseController {
|
||||
delete groupUserdata._role;
|
||||
try {
|
||||
let result = await groupInst.addMember(params.id, groupUserdata);
|
||||
let username = this.getUsername();
|
||||
let rolename = {
|
||||
owner: "组长",
|
||||
dev: "开发者",
|
||||
guest: "访客"
|
||||
};
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 新增了分组成员 "${groupUserdata.username}" 为 "${rolename[params.role]}"`,
|
||||
type: 'group',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
@ -205,6 +226,20 @@ class groupController extends baseController {
|
||||
|
||||
try {
|
||||
let result = await groupInst.changeMemberRole(params.id, params.member_uid, params.role);
|
||||
let username = this.getUsername();
|
||||
let rolename = {
|
||||
owner: "组长",
|
||||
dev: "开发者",
|
||||
guest: "访客"
|
||||
};
|
||||
let groupUserdata = await this.getUserdata(params.member_uid, params.role);
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 更改了分组成员 "${groupUserdata.username}" 的权限为 "${rolename[params.role]}"`,
|
||||
type: 'group',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
@ -267,6 +302,20 @@ class groupController extends baseController {
|
||||
|
||||
try {
|
||||
let result = await groupInst.delMember(params.id, params.member_uid);
|
||||
let username = this.getUsername();
|
||||
let rolename = {
|
||||
owner: "组长",
|
||||
dev: "开发者",
|
||||
guest: "访客"
|
||||
};
|
||||
let groupUserdata = await this.getUserdata(params.member_uid, params.role);
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 删除了分组成员 "${groupUserdata.username}"`,
|
||||
type: 'group',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
@ -379,6 +428,14 @@ class groupController extends baseController {
|
||||
ctx.body = yapi.commons.resReturn(null, 404, '分组名和分组描述不能为空');
|
||||
}
|
||||
let result = await groupInst.up(id, data);
|
||||
let username = this.getUsername();
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 更新了 "${data.group_name}" 分组`,
|
||||
type: 'group',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: id
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (err) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, err.message);
|
||||
|
Loading…
Reference in New Issue
Block a user