mirror of
https://github.com/YMFE/yapi.git
synced 2025-03-13 14:26:50 +08:00
Merge branch 'dev' of gitlab.corp.qunar.com:mfe/yapi into dev
This commit is contained in:
commit
d02c02d76e
@ -1,7 +1,7 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { AutoComplete } from 'antd';
|
||||
import axios from 'axios'
|
||||
import axios from 'axios';
|
||||
|
||||
class UsernameAutoComplete extends Component {
|
||||
constructor(props) {
|
||||
@ -56,7 +56,7 @@ class UsernameAutoComplete extends Component {
|
||||
return (
|
||||
<AutoComplete
|
||||
dataSource={this.state.dataSource.map(i => i.username)}
|
||||
style={{ width: 350 }}
|
||||
style={{ width: '100%' }}
|
||||
onSelect={this.onSelect}
|
||||
onSearch={this.handleSearch}
|
||||
placeholder="请输入用户名"
|
||||
|
@ -9,6 +9,7 @@ const { TextArea } = Input;
|
||||
const Search = Input.Search;
|
||||
const TYPE_EDIT = 'edit';
|
||||
const confirm = Modal.confirm;
|
||||
import UsernameAutoComplete from '../../../components/UsernameAutoComplete/UsernameAutoComplete.js';
|
||||
import {
|
||||
fetchGroupList,
|
||||
setCurrGroup,
|
||||
@ -50,7 +51,8 @@ export default class GroupList extends Component {
|
||||
newGroupDesc: '',
|
||||
currGroupName: '',
|
||||
currGroupDesc: '',
|
||||
groupList: []
|
||||
groupList: [],
|
||||
owner_uid: 0
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
@ -105,8 +107,8 @@ export default class GroupList extends Component {
|
||||
}
|
||||
@autobind
|
||||
async addGroup() {
|
||||
const { newGroupName: group_name, newGroupDesc: group_desc } = this.state;
|
||||
const res = await axios.post('/api/group/add', { group_name, group_desc })
|
||||
const { newGroupName: group_name, newGroupDesc: group_desc, owner_uid } = this.state;
|
||||
const res = await axios.post('/api/group/add', { group_name, group_desc, owner_uid })
|
||||
if (!res.data.errcode) {
|
||||
this.setState({
|
||||
addGroupModalVisible: false
|
||||
@ -155,6 +157,13 @@ export default class GroupList extends Component {
|
||||
this.props.history.replace(`${currGroup._id}`);
|
||||
}
|
||||
|
||||
@autobind
|
||||
onUserSelect(childState) {
|
||||
this.setState({
|
||||
owner_uid: childState.uid
|
||||
})
|
||||
}
|
||||
|
||||
showConfirm =()=> {
|
||||
let that = this;
|
||||
confirm({
|
||||
@ -164,17 +173,17 @@ export default class GroupList extends Component {
|
||||
|
||||
<div style={{marginTop: '15px'}}><b>请输入分组名称确认此操作:</b><input id="group_name" /></div>
|
||||
</div>,
|
||||
onOk() {
|
||||
let groupName = document.getElementById('group_name').value;
|
||||
onOk() {
|
||||
let groupName = document.getElementById('group_name').value;
|
||||
if(that.props.currGroup.group_name !== groupName){
|
||||
message.error('分组名称有误')
|
||||
return new Promise((resolve, reject)=>{
|
||||
reject('error')
|
||||
})
|
||||
})
|
||||
}else{
|
||||
that.deleteGroup()
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
iconType: 'delete',
|
||||
onCancel() { }
|
||||
@ -212,7 +221,7 @@ export default class GroupList extends Component {
|
||||
const { currGroup } = this.props;
|
||||
const delmark = <Icon className="edit-group" type="edit" title="编辑分组" onClick={() => this.showModal(TYPE_EDIT)}/>
|
||||
const editmark = <Icon className="delete-group" onClick={()=> {this.showConfirm()}} type="delete" title="删除分组"/>
|
||||
|
||||
|
||||
|
||||
|
||||
return (
|
||||
@ -274,6 +283,12 @@ export default class GroupList extends Component {
|
||||
<TextArea rows = {3} placeholder="请输入分组描述" onChange={this.inputNewGroupDesc}></TextArea>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row gutter={6} className="modal-input">
|
||||
<Col span="5"><div className="label">组长:</div></Col>
|
||||
<Col span="15">
|
||||
<UsernameAutoComplete callbackState={this.onUserSelect} />
|
||||
</Col>
|
||||
</Row>
|
||||
</Modal>
|
||||
<Modal
|
||||
title="编辑分组"
|
||||
|
@ -2,10 +2,10 @@ import React, { Component } from 'react';
|
||||
import { Table } from 'antd';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import { Select, Button, Modal, Row, Col, message } from 'antd';
|
||||
import { Select, Button, Modal, Row, Col, message, Popconfirm } from 'antd';
|
||||
import './MemberList.scss';
|
||||
import { autobind } from 'core-decorators';
|
||||
import { fetchGroupMemberList, fetchGroupMsg, addMember } from '../../../reducer/modules/group.js'
|
||||
import { fetchGroupMemberList, fetchGroupMsg, addMember, delMember, changeMemberRole } from '../../../reducer/modules/group.js'
|
||||
import UsernameAutoComplete from '../../../components/UsernameAutoComplete/UsernameAutoComplete.js';
|
||||
const Option = Select.Option;
|
||||
|
||||
@ -29,7 +29,9 @@ const arrayAddKey = (arr) => {
|
||||
{
|
||||
fetchGroupMemberList,
|
||||
fetchGroupMsg,
|
||||
addMember
|
||||
addMember,
|
||||
delMember,
|
||||
changeMemberRole
|
||||
}
|
||||
)
|
||||
class MemberList extends Component {
|
||||
@ -50,20 +52,31 @@ class MemberList extends Component {
|
||||
fetchGroupMemberList: PropTypes.func,
|
||||
fetchGroupMsg: PropTypes.func,
|
||||
addMember: PropTypes.func,
|
||||
delMember: PropTypes.func,
|
||||
changeMemberRole: PropTypes.func,
|
||||
role: PropTypes.string
|
||||
}
|
||||
|
||||
@autobind
|
||||
handleChange(value) {
|
||||
console.log(`selected ${value}`);
|
||||
}
|
||||
|
||||
showModal = () => {
|
||||
@autobind
|
||||
showAddMemberModal() {
|
||||
this.setState({
|
||||
visible: true
|
||||
});
|
||||
}
|
||||
|
||||
// 重新获取列表
|
||||
@autobind
|
||||
reFetchList() {
|
||||
this.props.fetchGroupMemberList(this.props.currGroup._id).then((res) => {
|
||||
this.setState({
|
||||
userInfo: arrayAddKey(res.payload.data.data),
|
||||
visible: false
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 增 - 添加成员
|
||||
@autobind
|
||||
handleOk() {
|
||||
console.log(this.props.currGroup._id, this.state.inputUid);
|
||||
@ -74,29 +87,55 @@ class MemberList extends Component {
|
||||
console.log(res);
|
||||
if (!res.payload.data.errcode) {
|
||||
message.success('添加成功!');
|
||||
// 添加成功后重新获取分组成员列表
|
||||
this.props.fetchGroupMemberList(this.props.currGroup._id).then((res) => {
|
||||
this.setState({
|
||||
userInfo: arrayAddKey(res.payload.data.data),
|
||||
visible: false
|
||||
});
|
||||
});
|
||||
this.reFetchList(); // 添加成功后重新获取分组成员列表
|
||||
}
|
||||
});
|
||||
}
|
||||
// 添加成员时 选择新增成员权限
|
||||
@autobind
|
||||
changeNewMemberRole(value) {
|
||||
return () => {
|
||||
console.log(this.props.currGroup._id, value);
|
||||
}
|
||||
}
|
||||
|
||||
// 删 - 删除分组成员
|
||||
@autobind
|
||||
deleteConfirm(member_uid) {
|
||||
return () => {
|
||||
const id = this.props.currGroup._id;
|
||||
this.props.delMember({ id, member_uid }).then((res) => {
|
||||
if (!res.payload.data.errcode) {
|
||||
message.success(res.payload.data.errmsg);
|
||||
this.reFetchList(); // 添加成功后重新获取分组成员列表
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 改 - 修改成员权限
|
||||
@autobind
|
||||
changeUserRole(e) {
|
||||
console.log(e);
|
||||
const id = this.props.currGroup._id;
|
||||
const role = e.split('-')[0];
|
||||
const member_uid = e.split('-')[1];
|
||||
this.props.changeMemberRole({ id, member_uid, role }).then((res) => {
|
||||
if (!res.payload.data.errcode) {
|
||||
message.success(res.payload.data.errmsg);
|
||||
this.reFetchList(); // 添加成功后重新获取分组成员列表
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 关闭模态框
|
||||
@autobind
|
||||
handleCancel() {
|
||||
// 取消模态框的时候重置模态框中的值
|
||||
this.setState({
|
||||
visible: false
|
||||
});
|
||||
}
|
||||
|
||||
@autobind
|
||||
changeMemberRole(e) {
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (this.props.currGroup !== nextProps.currGroup) {
|
||||
@ -136,7 +175,6 @@ class MemberList extends Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
console.log(this.state);
|
||||
const columns = [{
|
||||
title: this.props.currGroup.group_name + ' 分组成员 ('+this.state.userInfo.length + ') 人',
|
||||
dataIndex: 'username',
|
||||
@ -148,18 +186,20 @@ class MemberList extends Component {
|
||||
</div>);
|
||||
}
|
||||
}, {
|
||||
title: (this.state.role === 'owner' || this.state.role === 'admin') ? <div className="btn-container"><Button className="btn" type="primary" icon="plus" onClick={this.showModal}>添加成员</Button></div> : '',
|
||||
title: (this.state.role === 'owner' || this.state.role === 'admin') ? <div className="btn-container"><Button className="btn" type="primary" icon="plus" onClick={this.showAddMemberModal}>添加成员</Button></div> : '',
|
||||
key: 'action',
|
||||
className: 'member-opration',
|
||||
render: (text, record) => {
|
||||
if (this.state.role === 'owner' || this.state.role === 'admin') {
|
||||
return (
|
||||
<div>
|
||||
<Select defaultValue={record.role} className="select" onChange={this.handleChange}>
|
||||
<Option value="owner">组长</Option>
|
||||
<Option value="dev">开发者</Option>
|
||||
<Select defaultValue={record.role+'-'+record.uid} className="select" onChange={this.changeUserRole}>
|
||||
<Option value={'owner-'+record.uid}>组长</Option>
|
||||
<Option value={'dev-'+record.uid}>开发者</Option>
|
||||
</Select>
|
||||
<Button type="danger" icon="minus" className="btn-danger" />
|
||||
<Popconfirm placement="topRight" title="你确定要删除吗? " onConfirm={this.deleteConfirm(record.uid)} okText="确定" cancelText="">
|
||||
<Button type="danger" icon="minus" className="btn-danger" />
|
||||
</Popconfirm>
|
||||
</div>
|
||||
)
|
||||
} else {
|
||||
@ -178,13 +218,13 @@ class MemberList extends Component {
|
||||
<Row gutter={6} className="modal-input">
|
||||
<Col span="5"><div className="label">用户名: </div></Col>
|
||||
<Col span="15">
|
||||
<UsernameAutoComplete callbackState={this.onUserSelect} style={{ width: 150 }} />
|
||||
<UsernameAutoComplete callbackState={this.onUserSelect} />
|
||||
</Col>
|
||||
</Row>
|
||||
<Row gutter={6} className="modal-input">
|
||||
<Col span="5"><div className="label">权限: </div></Col>
|
||||
<Col span="15">
|
||||
<Select size="large" defaultValue="dev" className="select" onChange={this.changeMemberRole}>
|
||||
<Select size="large" defaultValue="dev" className="select" onChange={this.changeNewMemberRole}>
|
||||
<Option value="owner">组长</Option>
|
||||
<Option value="dev">开发者</Option>
|
||||
</Select>
|
||||
|
@ -127,7 +127,7 @@ class TimeTree extends Component {
|
||||
}
|
||||
return (
|
||||
<section className="news-timeline">
|
||||
{data ? <Timeline pending={pending}>{data}</Timeline> : data}
|
||||
{data ? <Timeline pending={pending}>{data}</Timeline> : "还没有任何动态"}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import { connect } from 'react-redux'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Table } from 'antd'
|
||||
const mockEditor = require('./mockEditor.js')
|
||||
// import { formatTime } from '../../../../common.js';
|
||||
import { formatTime } from '../../../../common.js';
|
||||
|
||||
// import { Card } from 'antd'
|
||||
// import { getMockUrl } from '../../reducer/modules/news.js'
|
||||
@ -15,51 +15,134 @@ const mockEditor = require('./mockEditor.js')
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
class View extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
static propTypes = {
|
||||
viewData: PropTypes.object
|
||||
curData: PropTypes.object
|
||||
}
|
||||
|
||||
req_body_form(req_body_type,req_body_form){
|
||||
if(req_body_type === 'json'){
|
||||
mockEditor({
|
||||
container: 'vreq_body_json',
|
||||
data: req_body_form,
|
||||
readOnly:true,
|
||||
onChange: function () {}
|
||||
})
|
||||
return <div className="colBody">
|
||||
<span className="colKey">请求Body:</span>
|
||||
<div id="vreq_body_json" style={{ minHeight: "300px" }}></div>
|
||||
</div>
|
||||
|
||||
componentDidMount() {
|
||||
let that = this;
|
||||
mockEditor({
|
||||
container: 'vreq_body_json',
|
||||
data: that.props.req_body_form,
|
||||
onChange: function () {}
|
||||
})
|
||||
mockEditor({
|
||||
container: 'vres_body_json',
|
||||
data: that.props.res_body,
|
||||
onChange: function () {}
|
||||
})
|
||||
mockEditor({
|
||||
container: 'vreq_query_json',
|
||||
data: that.props.req_query,
|
||||
onChange: function () {}
|
||||
})
|
||||
}else if(req_body_type === 'form'){
|
||||
|
||||
const columns = [{
|
||||
title: '参数名称',
|
||||
dataIndex: 'name',
|
||||
key: 'name'
|
||||
}, {
|
||||
title: '参数值',
|
||||
dataIndex: 'value',
|
||||
key: 'value'
|
||||
}, {
|
||||
title: '备注',
|
||||
dataIndex: 'required',
|
||||
key: 'required',
|
||||
width: '45%'
|
||||
}];
|
||||
|
||||
const dataSource = [];
|
||||
if(req_body_form&&req_body_form.length){
|
||||
req_body_form.map((item,i)=>{
|
||||
dataSource.push({
|
||||
key: i,
|
||||
name: item.name,
|
||||
value: item.desc,
|
||||
required: item.required?"必须":"非必须"
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return <div className="colBody">
|
||||
<span className="colKey">请求Body:</span>
|
||||
<Table bordered size="small" pagination = {false} columns= {columns} dataSource = {dataSource} />
|
||||
</div>
|
||||
|
||||
}else if(req_body_type === 'file'){
|
||||
|
||||
return <div className="colBody">
|
||||
<span className="colKey">请求Body:</span>
|
||||
<div style={{ minHeight: "300px" }}>file</div>
|
||||
</div>
|
||||
|
||||
}else if(req_body_type === 'raw'){
|
||||
|
||||
return <div className="colBody">
|
||||
<span className="colKey">请求Body:</span>
|
||||
<div style={{ minHeight: "300px" }}>raw</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
res_body(res_body_type,res_body){
|
||||
if(res_body_type === 'json'){
|
||||
return <div className="colBody">
|
||||
<span className="colKey">返回Body:</span>
|
||||
<div id="vres_body_json" style={{ minHeight: "300px" }}></div>
|
||||
</div>
|
||||
|
||||
}else if(res_body_type === 'form'){
|
||||
|
||||
const columns = [{
|
||||
title: '参数名称',
|
||||
dataIndex: 'name',
|
||||
key: 'name'
|
||||
}, {
|
||||
title: '参数值',
|
||||
dataIndex: 'value',
|
||||
key: 'value'
|
||||
}, {
|
||||
title: '备注',
|
||||
dataIndex: 'required',
|
||||
key: 'required',
|
||||
width: '45%'
|
||||
}];
|
||||
|
||||
const dataSource = [];
|
||||
if(res_body&&res_body.length){
|
||||
res_body.map((item,i)=>{
|
||||
dataSource.push({
|
||||
key: i,
|
||||
name: item.name,
|
||||
value: item.desc,
|
||||
required: item.required?"必须":"非必须"
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return <div className="colBody">
|
||||
<span className="colKey">返回Body:</span>
|
||||
<Table bordered size="small" pagination = {false} columns= {columns} dataSource = {dataSource} />
|
||||
</div>
|
||||
|
||||
}else if(res_body_type === 'file'){
|
||||
|
||||
return <div className="colBody">
|
||||
<span className="colKey">返回Body:</span>
|
||||
<div>{res_body}</div>
|
||||
</div>
|
||||
|
||||
}else if(res_body_type === 'raw'){
|
||||
|
||||
return <div className="colBody">
|
||||
<span className="colKey">返回Body:</span>
|
||||
<div>{res_body}</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
render () {
|
||||
|
||||
const dataSource = [{
|
||||
key: 1,
|
||||
name: '1',
|
||||
value: '胡彦斌',
|
||||
desc: 32
|
||||
}, {
|
||||
key: 2,
|
||||
name: '2',
|
||||
value: '胡彦斌',
|
||||
desc: 32
|
||||
}];
|
||||
|
||||
req_query(query){
|
||||
const columns = [{
|
||||
title: '参数名称',
|
||||
dataIndex: 'name',
|
||||
@ -70,117 +153,127 @@ class View extends Component {
|
||||
key: 'value'
|
||||
}, {
|
||||
title: '备注',
|
||||
dataIndex: 'desc',
|
||||
key: 'desc',
|
||||
dataIndex: 'required',
|
||||
key: 'required',
|
||||
width: '45%'
|
||||
}];
|
||||
|
||||
const dataSource = [];
|
||||
if(query&&query.length){
|
||||
query.map((item,i)=>{
|
||||
dataSource.push({
|
||||
key: i,
|
||||
name: item.name,
|
||||
value: item.desc,
|
||||
required: item.required?"必须":"非必须"
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return <Table bordered size="small" pagination = {false} columns= {columns} dataSource = {dataSource} />;
|
||||
}
|
||||
componentDidUpdate(){
|
||||
if(this.props.curData.req_body_type === "json"){
|
||||
mockEditor({
|
||||
container: 'vreq_body_json',
|
||||
data: this.props.curData.req_body_form,
|
||||
readOnly:true,
|
||||
onChange: function () {}
|
||||
})
|
||||
}
|
||||
if(this.props.curData.res_body_type === "json"){
|
||||
mockEditor({
|
||||
container: 'vres_body_json',
|
||||
data: this.props.curData.res_body,
|
||||
readOnly:true,
|
||||
onChange: function () {}
|
||||
})
|
||||
}
|
||||
}
|
||||
render () {
|
||||
|
||||
const dataSource = [];
|
||||
if(this.props.curData.req_headers&&this.props.curData.req_headers.length){
|
||||
this.props.curData.req_headers.map((item,i)=>{
|
||||
dataSource.push({
|
||||
key: i,
|
||||
name: item.name,
|
||||
required: item.required?"必须":"非必须",
|
||||
value: item.value
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const columns = [{
|
||||
title: '参数名称',
|
||||
dataIndex: 'name',
|
||||
key: 'name'
|
||||
}, {
|
||||
title: '参数值',
|
||||
dataIndex: 'value',
|
||||
key: 'value'
|
||||
}, {
|
||||
title: '备注',
|
||||
dataIndex: 'required',
|
||||
key: 'required',
|
||||
width: '45%'
|
||||
}];
|
||||
|
||||
return <div className="caseContainer">
|
||||
{/*<Card title={`接口名:${this.props.viewData.casename}`}></Card>*/}
|
||||
<div className="colName">
|
||||
<span className="colKey">接口名:</span>
|
||||
<span className="colValue">{this.props.viewData.title}</span>
|
||||
<span className="colValue">{this.props.curData.title}</span>
|
||||
</div>
|
||||
<div className="colMethod">
|
||||
<span className="colKey">请求方法:</span>
|
||||
<span className="colValue">{this.props.curData.method}</span>
|
||||
</div>
|
||||
<div className="colPath">
|
||||
<span className="colKey">接口路径:</span>
|
||||
<span className="colValue">{this.props.viewData.path}</span>
|
||||
<span className="colValue">{this.props.curData.path}</span>
|
||||
</div>
|
||||
<div className="colstatus">
|
||||
<span className="colKey">状态:</span>
|
||||
<span className="colValue">{this.props.viewData.status}</span>
|
||||
<span className="colValue">{this.props.curData.status}</span>
|
||||
</div>
|
||||
<div className="colMock">
|
||||
<span className="colKey">Mock地址:</span>
|
||||
<span className="colValue">{this.props.viewData.mockUrl}</span>
|
||||
<div className="colAddTime">
|
||||
<span className="colKey">创建时间:</span>
|
||||
<span className="colValue">{formatTime(this.props.curData.add_time)}</span>
|
||||
</div>
|
||||
<div className="colUpTime">
|
||||
<span className="colKey">更新时间:</span>
|
||||
<span className="colValue">{formatTime(this.props.curData.up_time)}</span>
|
||||
</div>
|
||||
<div className="colDesc">
|
||||
<span className="colKey">接口描述:</span>
|
||||
<span className="colValue">{this.props.viewData.desc}</span>
|
||||
<span className="colValue">{this.props.curData.desc}</span>
|
||||
</div>
|
||||
<div className="colHeader">
|
||||
<span className="colKey">请求Headers:</span>
|
||||
<Table size="small" pagination = {false} columns= {columns} dataSource = {dataSource} />
|
||||
<Table bordered size="small" pagination = {false} columns= {columns} dataSource = {dataSource} />
|
||||
</div>
|
||||
<div className="colQuery">
|
||||
<span className="colKey">Query:</span>
|
||||
<div span={18} offset={4} id="vreq_query_json" style={{ minHeight: "150px" }}></div>
|
||||
{this.req_query(this.props.curData.req_query)}
|
||||
</div>
|
||||
<div className="colBody">
|
||||
<span className="colKey">请求Body:</span>
|
||||
<div span={18} offset={4} id="vreq_body_json" style={{ minHeight: "300px" }}></div>
|
||||
<div className="colreqBodyType">
|
||||
<span className="colKey">请求Body类型:</span>
|
||||
<span className="colValue">{this.props.curData.req_body_type}</span>
|
||||
</div>
|
||||
<div className="colBody">
|
||||
<span className="colKey">响应Body:</span>
|
||||
<div span={18} offset={4} id="vres_body_json" style={{ minHeight: "300px" }}></div>
|
||||
{this.req_body_form("form",this.props.curData.req_body_form)}
|
||||
<div className="colreqBodyType">
|
||||
<span className="colKey">返回Body类型:</span>
|
||||
<span className="colValue">{this.props.curData.req_body_type}</span>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
{this.res_body("json",this.props.curData.res_body)}
|
||||
{/*{this.res_body("file",[{
|
||||
name: "key",
|
||||
desc: "123",
|
||||
required: 0
|
||||
}])}*/}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
let data = {
|
||||
title: '',
|
||||
path: '',
|
||||
status: 'undone',
|
||||
method: 'get',
|
||||
req_query: [{
|
||||
name: '',
|
||||
desc: '',
|
||||
required: "1"
|
||||
}],
|
||||
req_body_type: 'form',
|
||||
req_headers: [{
|
||||
name: '',
|
||||
value: '', required: "1"
|
||||
}],
|
||||
req_body_form: [{
|
||||
name: '',
|
||||
type: '',
|
||||
required: ''
|
||||
}],
|
||||
res_body_type: 'json',
|
||||
res_body: '{a:123}',
|
||||
desc: 'FP的好处是没有OO的复杂仪式感,是沿着数据结构+算法的思路进行抽象和结构化。如果顶层设计做好,代码复用度极高,代码量少。比如要生成一颗树我用迭归算法直接生成',
|
||||
res_body_mock: '',
|
||||
mockUrl: "this.props.mockUrl"
|
||||
}
|
||||
// {
|
||||
// casename:"caename",
|
||||
// uid: 107,
|
||||
// col_id: 211,
|
||||
// index: 0,
|
||||
// project_id: 112,
|
||||
// add_time: new Date().getTime(),
|
||||
// up_time: new Date().getTime(),
|
||||
// env: "测试环境",
|
||||
// domain: "域名",
|
||||
// path: "路径",
|
||||
// method: "GET",
|
||||
// req_query: [{
|
||||
// name: "String",
|
||||
// value: "String",
|
||||
// required: "1"
|
||||
// }],
|
||||
// req_headers: [{
|
||||
// name: "String",
|
||||
// value: "String",
|
||||
// required: "1"
|
||||
// }],
|
||||
// req_body_type: "json",
|
||||
// res_body_form: [{
|
||||
// name: "String",
|
||||
// value: "String",
|
||||
// required: "1"
|
||||
// }],
|
||||
// res_body_other: "String"
|
||||
// }
|
||||
View.defaultProps = {
|
||||
viewData: data
|
||||
}
|
||||
|
||||
export default View
|
||||
|
@ -13,12 +13,27 @@
|
||||
.colKey{
|
||||
font-weight: bolder;
|
||||
margin-right: 16px;
|
||||
padding-bottom: 16px;
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
.colName,.colPath,.colstatus,.colMock{
|
||||
.colreqBodyType{
|
||||
margin: 0px;
|
||||
.colKey{
|
||||
padding-bottom: 0px;
|
||||
}
|
||||
}
|
||||
.ace_print-margin{
|
||||
display: none;
|
||||
}
|
||||
.colName,.colPath,.colstatus,.colAddTime,.colUpTime,.colMethod{
|
||||
width: 50%;
|
||||
float: left;
|
||||
padding: 8px 16px;
|
||||
|
||||
.colKey{
|
||||
padding-bottom: 0px;
|
||||
}
|
||||
}
|
||||
.colDesc{
|
||||
line-height: 1.5em;
|
||||
|
@ -5,7 +5,9 @@ const FETCH_GROUP_LIST = 'yapi/group/FETCH_GROUP_LIST';
|
||||
const SET_CURR_GROUP = 'yapi/group/SET_CURR_GROUP';
|
||||
const FETCH_GROUP_MEMBER = 'yapi/group/FETCH_GROUP_MEMBER';
|
||||
const FETCH_GROUP_MSG = 'yapi/group/FETCH_GROUP_MSG';
|
||||
const ADD_FROUP_MEMBER = 'yapi/group/ADD_FROUP_MEMBER';
|
||||
const ADD_GROUP_MEMBER = 'yapi/group/ADD_GROUP_MEMBER';
|
||||
const DEL_GROUP_MEMBER = 'yapi/group/DEL_GROUP_MEMBER';
|
||||
const CHANGE_GROUP_MEMBER = 'yapi/group/CHANGE_GROUP_MEMBER';
|
||||
|
||||
// Reducer
|
||||
const initialState = {
|
||||
@ -57,14 +59,30 @@ export function fetchGroupMsg(id) {
|
||||
}
|
||||
}
|
||||
|
||||
// 添加项目分组成员
|
||||
// 添加分组成员
|
||||
export function addMember(param) {
|
||||
return {
|
||||
type: ADD_FROUP_MEMBER,
|
||||
type: ADD_GROUP_MEMBER,
|
||||
payload: axios.post('/api/group/add_member', param)
|
||||
}
|
||||
}
|
||||
|
||||
// 删除分组成员
|
||||
export function delMember(param) {
|
||||
return {
|
||||
type: DEL_GROUP_MEMBER,
|
||||
payload: axios.post('/api/group/del_member', param)
|
||||
}
|
||||
}
|
||||
|
||||
// 修改分组成员权限
|
||||
export function changeMemberRole(param) {
|
||||
return {
|
||||
type: CHANGE_GROUP_MEMBER,
|
||||
payload: axios.post('/api/group/change_member_role', param)
|
||||
}
|
||||
}
|
||||
|
||||
// 获取分组成员列表
|
||||
export function fetchGroupMemberList(id) {
|
||||
return {
|
||||
|
@ -8,22 +8,6 @@ class logController extends baseController {
|
||||
super(ctx);
|
||||
this.Model = yapi.getInst(logModel);
|
||||
this.groupModel = yapi.getInst(groupModel);
|
||||
try{
|
||||
// var res = this.Model.save({
|
||||
// uid: 107,
|
||||
// typeid: 21,
|
||||
// type: 'project',
|
||||
// username: '小明明宝宝',
|
||||
// content: '小明应该修改了的项目宝宝',
|
||||
// time: yapi.commons.time()
|
||||
// });
|
||||
// var res = this.Model.del(107);
|
||||
// ctx.body = yapi.commons.resReturn(null, 200,res);
|
||||
}catch(err){
|
||||
// ctx.body = yapi.commons.resReturn(null, 402, err.message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -99,7 +99,7 @@ class projectController extends baseController {
|
||||
try {
|
||||
let result = await this.Model.save(data);
|
||||
let username = this.getUsername();
|
||||
await this.logModel.save({
|
||||
yapi.commons.saveLog({
|
||||
content: `用户${username}添加了项目${params.name}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
@ -150,7 +150,7 @@ class projectController extends baseController {
|
||||
try {
|
||||
let result = await this.Model.addMember(params.id, userdata);
|
||||
let username = this.getUsername();
|
||||
await this.logModel.save({
|
||||
yapi.commons.saveLog({
|
||||
content: `用户${username}添加了项目成员${userdata.username}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
@ -196,17 +196,14 @@ class projectController extends baseController {
|
||||
let result = await this.Model.delMember(params.id, params.member_uid);
|
||||
let username = this.getUsername();
|
||||
let project = await this.Model.get(params.id);
|
||||
for(let i in project.members){
|
||||
if(i.uid === params.member_uid){
|
||||
await this.logModel.save({
|
||||
content: `用户${username}删除了项目${project.name}中的成员${i.username}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
});
|
||||
}
|
||||
}
|
||||
let member = await yapi.getInst(userModel).findById(params.member_uid);
|
||||
yapi.commons.saveLog({
|
||||
content: `用户${username}删除了项目${project.name}中的成员${member.username}`,
|
||||
type: 'project',
|
||||
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);
|
||||
@ -381,18 +378,14 @@ class projectController extends baseController {
|
||||
|
||||
let username = this.getUsername();
|
||||
let project = await this.Model.get(params.id);
|
||||
for(let i in project.members){
|
||||
if(i.uid === params.member_uid){
|
||||
await this.logModel.save({
|
||||
content: `用户${username}修改了项目${project.name}中成员${i.username}的角色为${params.role}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let member = await yapi.getInst(userModel).findByUids(params.member_uid);
|
||||
yapi.commons.saveLog({
|
||||
content: `用户${username}修改了项目${project.name}中成员${member.username}的角色为${params.role}`,
|
||||
type: 'project',
|
||||
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);
|
||||
@ -466,14 +459,13 @@ class projectController extends baseController {
|
||||
let result = await this.Model.up(id, data);
|
||||
|
||||
let username = this.getUsername();
|
||||
await this.logModel.save({
|
||||
content: `用户${username}更新了项目${params.name}`,
|
||||
yapi.commons.saveLog({
|
||||
content: `用户${username}更新了项目${projectData.name}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: id
|
||||
});
|
||||
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
|
@ -2,7 +2,8 @@ import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
import yapi from '../yapi.js';
|
||||
import sha1 from 'sha1';
|
||||
import json5 from 'json5'
|
||||
import logModel from '../models/log.js';
|
||||
import json5 from 'json5';
|
||||
|
||||
exports.resReturn = (data, num, errmsg) => {
|
||||
num = num || 0;
|
||||
@ -223,4 +224,23 @@ exports.handleParams = (params, keys) => {
|
||||
}
|
||||
|
||||
return params;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
exports.saveLog = (logData) => {
|
||||
try {
|
||||
let logInst = yapi.getInst(logModel);
|
||||
let data = {
|
||||
content: logData.content,
|
||||
type: logData.type,
|
||||
uid: logData.uid,
|
||||
username: logData.username,
|
||||
typeid: logData.typeid
|
||||
};
|
||||
logInst.save(data).then(
|
||||
|
||||
);
|
||||
} catch(e) {
|
||||
yapi.commons.log(e, 'error'); // eslint-disable-line
|
||||
}
|
||||
};
|
||||
|
@ -56,21 +56,6 @@ var logController = function (_baseController) {
|
||||
|
||||
_this.Model = _yapi2.default.getInst(_log2.default);
|
||||
_this.groupModel = _yapi2.default.getInst(_group2.default);
|
||||
try {
|
||||
// var res = this.Model.save({
|
||||
// uid: 107,
|
||||
// typeid: 21,
|
||||
// type: 'project',
|
||||
// username: '小明明宝宝',
|
||||
// content: '小明应该修改了的项目宝宝',
|
||||
// time: yapi.commons.time()
|
||||
// });
|
||||
// var res = this.Model.del(107);
|
||||
// ctx.body = yapi.commons.resReturn(null, 200,res);
|
||||
} catch (err) {
|
||||
// ctx.body = yapi.commons.resReturn(null, 402, err.message);
|
||||
}
|
||||
|
||||
return _this;
|
||||
}
|
||||
|
||||
|
@ -214,32 +214,30 @@ var projectController = function (_baseController) {
|
||||
case 23:
|
||||
result = _context.sent;
|
||||
username = this.getUsername();
|
||||
_context.next = 27;
|
||||
return this.logModel.save({
|
||||
|
||||
_yapi2.default.commons.saveLog({
|
||||
content: '\u7528\u6237' + username + '\u6DFB\u52A0\u4E86\u9879\u76EE' + params.name,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.group_id
|
||||
});
|
||||
|
||||
case 27:
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context.next = 33;
|
||||
_context.next = 32;
|
||||
break;
|
||||
|
||||
case 30:
|
||||
_context.prev = 30;
|
||||
case 29:
|
||||
_context.prev = 29;
|
||||
_context.t1 = _context['catch'](20);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context.t1.message);
|
||||
|
||||
case 33:
|
||||
case 32:
|
||||
case 'end':
|
||||
return _context.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, this, [[20, 30]]);
|
||||
}, _callee, this, [[20, 29]]);
|
||||
}));
|
||||
|
||||
function add(_x) {
|
||||
@ -336,32 +334,30 @@ var projectController = function (_baseController) {
|
||||
case 23:
|
||||
result = _context2.sent;
|
||||
username = this.getUsername();
|
||||
_context2.next = 27;
|
||||
return this.logModel.save({
|
||||
|
||||
_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
|
||||
});
|
||||
|
||||
case 27:
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context2.next = 33;
|
||||
_context2.next = 32;
|
||||
break;
|
||||
|
||||
case 30:
|
||||
_context2.prev = 30;
|
||||
case 29:
|
||||
_context2.prev = 29;
|
||||
_context2.t1 = _context2['catch'](20);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context2.t1.message);
|
||||
|
||||
case 33:
|
||||
case 32:
|
||||
case 'end':
|
||||
return _context2.stop();
|
||||
}
|
||||
}
|
||||
}, _callee2, this, [[20, 30]]);
|
||||
}, _callee2, this, [[20, 29]]);
|
||||
}));
|
||||
|
||||
function addMember(_x2) {
|
||||
@ -386,7 +382,7 @@ var projectController = function (_baseController) {
|
||||
key: 'delMember',
|
||||
value: function () {
|
||||
var _ref3 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee3(ctx) {
|
||||
var params, check, result, username, project, i;
|
||||
var params, check, result, username, project, member;
|
||||
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
||||
while (1) {
|
||||
switch (_context3.prev = _context3.next) {
|
||||
@ -449,51 +445,35 @@ var projectController = function (_baseController) {
|
||||
|
||||
case 22:
|
||||
project = _context3.sent;
|
||||
_context3.t1 = _regenerator2.default.keys(project.members);
|
||||
_context3.next = 25;
|
||||
return _yapi2.default.getInst(_user2.default).findById(params.member_uid);
|
||||
|
||||
case 24:
|
||||
if ((_context3.t2 = _context3.t1()).done) {
|
||||
_context3.next = 31;
|
||||
break;
|
||||
}
|
||||
case 25:
|
||||
member = _context3.sent;
|
||||
|
||||
i = _context3.t2.value;
|
||||
|
||||
if (!(i.uid === params.member_uid)) {
|
||||
_context3.next = 29;
|
||||
break;
|
||||
}
|
||||
|
||||
_context3.next = 29;
|
||||
return this.logModel.save({
|
||||
content: '\u7528\u6237' + username + '\u5220\u9664\u4E86\u9879\u76EE' + project.name + '\u4E2D\u7684\u6210\u5458' + i.username,
|
||||
_yapi2.default.commons.saveLog({
|
||||
content: '\u7528\u6237' + username + '\u5220\u9664\u4E86\u9879\u76EE' + project.name + '\u4E2D\u7684\u6210\u5458' + member.username,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
});
|
||||
|
||||
case 29:
|
||||
_context3.next = 24;
|
||||
break;
|
||||
|
||||
case 31:
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context3.next = 37;
|
||||
_context3.next = 33;
|
||||
break;
|
||||
|
||||
case 34:
|
||||
_context3.prev = 34;
|
||||
_context3.t3 = _context3['catch'](15);
|
||||
case 30:
|
||||
_context3.prev = 30;
|
||||
_context3.t1 = _context3['catch'](15);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context3.t3.message);
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context3.t1.message);
|
||||
|
||||
case 37:
|
||||
case 33:
|
||||
case 'end':
|
||||
return _context3.stop();
|
||||
}
|
||||
}
|
||||
}, _callee3, this, [[15, 34]]);
|
||||
}, _callee3, this, [[15, 30]]);
|
||||
}));
|
||||
|
||||
function delMember(_x3) {
|
||||
@ -862,7 +842,7 @@ var projectController = function (_baseController) {
|
||||
key: 'changeMemberRole',
|
||||
value: function () {
|
||||
var _ref9 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee9(ctx) {
|
||||
var params, groupInst, check, result, username, project, i;
|
||||
var params, groupInst, check, result, username, project, member;
|
||||
return _regenerator2.default.wrap(function _callee9$(_context9) {
|
||||
while (1) {
|
||||
switch (_context9.prev = _context9.next) {
|
||||
@ -929,52 +909,35 @@ var projectController = function (_baseController) {
|
||||
|
||||
case 24:
|
||||
project = _context9.sent;
|
||||
_context9.t1 = _regenerator2.default.keys(project.members);
|
||||
_context9.next = 27;
|
||||
return _yapi2.default.getInst(_user2.default).findByUids(params.member_uid);
|
||||
|
||||
case 26:
|
||||
if ((_context9.t2 = _context9.t1()).done) {
|
||||
_context9.next = 33;
|
||||
break;
|
||||
}
|
||||
case 27:
|
||||
member = _context9.sent;
|
||||
|
||||
i = _context9.t2.value;
|
||||
|
||||
if (!(i.uid === params.member_uid)) {
|
||||
_context9.next = 31;
|
||||
break;
|
||||
}
|
||||
|
||||
_context9.next = 31;
|
||||
return this.logModel.save({
|
||||
content: '\u7528\u6237' + username + '\u4FEE\u6539\u4E86\u9879\u76EE' + project.name + '\u4E2D\u6210\u5458' + i.username + '\u7684\u89D2\u8272\u4E3A' + params.role,
|
||||
_yapi2.default.commons.saveLog({
|
||||
content: '\u7528\u6237' + username + '\u4FEE\u6539\u4E86\u9879\u76EE' + project.name + '\u4E2D\u6210\u5458' + member.username + '\u7684\u89D2\u8272\u4E3A' + params.role,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
});
|
||||
|
||||
case 31:
|
||||
_context9.next = 26;
|
||||
break;
|
||||
|
||||
case 33:
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context9.next = 39;
|
||||
_context9.next = 35;
|
||||
break;
|
||||
|
||||
case 36:
|
||||
_context9.prev = 36;
|
||||
_context9.t3 = _context9['catch'](17);
|
||||
case 32:
|
||||
_context9.prev = 32;
|
||||
_context9.t1 = _context9['catch'](17);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context9.t3.message);
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context9.t1.message);
|
||||
|
||||
case 39:
|
||||
case 35:
|
||||
case 'end':
|
||||
return _context9.stop();
|
||||
}
|
||||
}
|
||||
}, _callee9, this, [[17, 36]]);
|
||||
}, _callee9, this, [[17, 32]]);
|
||||
}));
|
||||
|
||||
function changeMemberRole(_x10) {
|
||||
@ -1101,33 +1064,30 @@ var projectController = function (_baseController) {
|
||||
case 31:
|
||||
result = _context10.sent;
|
||||
username = this.getUsername();
|
||||
_context10.next = 35;
|
||||
return this.logModel.save({
|
||||
content: '\u7528\u6237' + username + '\u66F4\u65B0\u4E86\u9879\u76EE' + params.name,
|
||||
|
||||
_yapi2.default.commons.saveLog({
|
||||
content: '\u7528\u6237' + username + '\u66F4\u65B0\u4E86\u9879\u76EE' + projectData.name,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: _id2
|
||||
});
|
||||
|
||||
case 35:
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context10.next = 41;
|
||||
_context10.next = 40;
|
||||
break;
|
||||
|
||||
case 38:
|
||||
_context10.prev = 38;
|
||||
case 37:
|
||||
_context10.prev = 37;
|
||||
_context10.t1 = _context10['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context10.t1.message);
|
||||
|
||||
case 41:
|
||||
case 40:
|
||||
case 'end':
|
||||
return _context10.stop();
|
||||
}
|
||||
}
|
||||
}, _callee10, this, [[0, 38]]);
|
||||
}, _callee10, this, [[0, 37]]);
|
||||
}));
|
||||
|
||||
function up(_x11) {
|
||||
|
@ -24,6 +24,10 @@ var _sha = require('sha1');
|
||||
|
||||
var _sha2 = _interopRequireDefault(_sha);
|
||||
|
||||
var _log = require('../models/log.js');
|
||||
|
||||
var _log2 = _interopRequireDefault(_log);
|
||||
|
||||
var _json = require('json5');
|
||||
|
||||
var _json2 = _interopRequireDefault(_json);
|
||||
@ -251,4 +255,20 @@ exports.handleParams = function (params, keys) {
|
||||
}
|
||||
|
||||
return params;
|
||||
};
|
||||
|
||||
exports.saveLog = function (logData) {
|
||||
try {
|
||||
var logInst = _yapi2.default.getInst(_log2.default);
|
||||
var data = {
|
||||
content: logData.content,
|
||||
type: logData.type,
|
||||
uid: logData.uid,
|
||||
username: logData.username,
|
||||
typeid: logData.typeid
|
||||
};
|
||||
logInst.save(data).then();
|
||||
} catch (e) {
|
||||
_yapi2.default.commons.log(e, 'error'); // eslint-disable-line
|
||||
}
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user