mirror of
https://github.com/YMFE/yapi.git
synced 2025-03-07 14:16:52 +08:00
feat: addproject接口添加groupname字段
This commit is contained in:
parent
a6b88f4472
commit
42a6dba6ac
@ -41,7 +41,6 @@ class ProjectList extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
protocol: 'http:\/\/',
|
||||
groupList: []
|
||||
}
|
||||
}
|
||||
@ -59,8 +58,9 @@ class ProjectList extends Component {
|
||||
e.preventDefault();
|
||||
form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
values.protocol = this.state.protocol.split(':')[0];
|
||||
|
||||
values.group_id = values.group.split(':')[0];
|
||||
values.group_name = values.group.split(':')[1];
|
||||
delete values.group;
|
||||
addProject(values).then((res) => {
|
||||
if (res.payload.data.errcode == 0) {
|
||||
form.resetFields();
|
||||
@ -72,14 +72,6 @@ class ProjectList extends Component {
|
||||
});
|
||||
}
|
||||
|
||||
// 修改线上域名的协议类型 (http/https)
|
||||
@autobind
|
||||
protocolChange(value) {
|
||||
this.setState({
|
||||
protocol: value
|
||||
})
|
||||
}
|
||||
|
||||
async componentWillMount() {
|
||||
await this.props.fetchGroupList();
|
||||
this.setState({groupList: this.props.groupList});
|
||||
@ -108,14 +100,14 @@ class ProjectList extends Component {
|
||||
{...formItemLayout}
|
||||
label="所属分组"
|
||||
>
|
||||
{getFieldDecorator('group_id', {
|
||||
initialValue: this.state.groupList.length > 0? this.state.groupList[0]._id.toString() : null ,
|
||||
{getFieldDecorator('group', {
|
||||
initialValue: this.state.groupList.length > 0? this.state.groupList[0]._id.toString() + ':' + this.state.groupList[0].group_name : null ,
|
||||
rules: [{
|
||||
required: true, message: '请选择项目所属的分组!'
|
||||
}]
|
||||
})(
|
||||
<Select>
|
||||
{this.state.groupList.map((item, index) => <Option value={item._id.toString()} key={index}>{item.group_name}</Option>)}
|
||||
{this.state.groupList.map((item, index) => <Option value={item._id.toString() + ':' + this.state.groupList[0].group_name} key={index}>{item.group_name}</Option>)}
|
||||
</Select>
|
||||
)}
|
||||
</FormItem>
|
||||
|
@ -1,14 +1,48 @@
|
||||
import React, { Component } from 'react'
|
||||
import { Card } from 'antd';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import { fetchGroupMemberList } from '../../../../reducer/modules/group.js';
|
||||
import '../Setting.scss';
|
||||
|
||||
@connect(
|
||||
state => {
|
||||
return {
|
||||
projectMsg: state.project.projectMsg
|
||||
}
|
||||
},
|
||||
{
|
||||
fetchGroupMemberList
|
||||
}
|
||||
)
|
||||
class ProjectMember extends Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
groupMemberList: []
|
||||
}
|
||||
}
|
||||
static propTypes = {
|
||||
projectMsg: PropTypes.object,
|
||||
fetchGroupMemberList: PropTypes.func
|
||||
}
|
||||
async componentWillMount() {
|
||||
const groupMemberList = await this.props.fetchGroupMemberList(this.props.projectMsg.group_id);
|
||||
console.log(groupMemberList);
|
||||
this.setState({
|
||||
groupMemberList: groupMemberList.payload.data.data
|
||||
})
|
||||
}
|
||||
|
||||
render () {
|
||||
|
||||
console.log(this.state);
|
||||
return (
|
||||
<div className="m-panel">
|
||||
Test
|
||||
<Card title="分组">
|
||||
<p>Card content</p>
|
||||
<p>Card content</p>
|
||||
<p>Card content</p>
|
||||
</Card>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { Component } from 'react'
|
||||
import { Form, Input, Icon, Tooltip, Select, Button, Row, Col, message, Card } from 'antd';
|
||||
import { Form, Input, Icon, Tooltip, Select, Button, Row, Col, message, Card, Radio } from 'antd';
|
||||
import PropTypes from 'prop-types';
|
||||
import { updateProject, delProject, getProjectMsg } from '../../../../reducer/modules/project';
|
||||
import { fetchGroupMsg } from '../../../../reducer/modules/group';
|
||||
@ -7,6 +7,7 @@ import { connect } from 'react-redux';
|
||||
const { TextArea } = Input;
|
||||
const FormItem = Form.Item;
|
||||
const Option = Select.Option;
|
||||
const RadioGroup = Radio.Group;
|
||||
import '../Setting.scss';
|
||||
|
||||
// layout
|
||||
@ -81,10 +82,8 @@ class ProjectMessage extends Component {
|
||||
domain: values['envs-protocol-' + index] + values['envs-domain-' + index]
|
||||
}
|
||||
});
|
||||
// console.log(assignValue);
|
||||
|
||||
updateProject(assignValue).then((res) => {
|
||||
console.log(res);
|
||||
if (res.payload.data.errcode == 0) {
|
||||
message.success('修改成功! ');
|
||||
} else {
|
||||
@ -152,8 +151,8 @@ class ProjectMessage extends Component {
|
||||
const { projectMsg } = this.props;
|
||||
let initFormValues = {};
|
||||
let envMessage = [];
|
||||
const { name, basepath, desc, env } = projectMsg;
|
||||
initFormValues = { name, basepath, desc, env };
|
||||
const { name, basepath, desc, env, project_type } = projectMsg;
|
||||
initFormValues = { name, basepath, desc, env, project_type };
|
||||
if (env && env.length !== 0) {
|
||||
envMessage = env;
|
||||
}
|
||||
@ -328,6 +327,28 @@ class ProjectMessage extends Component {
|
||||
<Icon type="plus" /> 添加环境配置
|
||||
</Button>
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="权限"
|
||||
>
|
||||
{getFieldDecorator('project_type', {
|
||||
rules: [{
|
||||
required: true
|
||||
}],
|
||||
initialValue: initFormValues.project_type
|
||||
})(
|
||||
<RadioGroup>
|
||||
<Radio value="private" className="radio">
|
||||
<Icon type="lock" />私有<br /><span className="radio-desc">只有组长和项目开发者可以索引并查看项目信息</span>
|
||||
</Radio>
|
||||
<br />
|
||||
<Radio value="public" className="radio">
|
||||
<Icon type="unlock" />公开<br /><span className="radio-desc">任何人都可以索引并查看项目信息</span>
|
||||
</Radio>
|
||||
</RadioGroup>
|
||||
)}
|
||||
</FormItem>
|
||||
</Form>
|
||||
<Row>
|
||||
<Col sm={{ offset: 6 }} lg={{ offset: 3 }}>
|
||||
|
@ -101,14 +101,15 @@ export function getProjectMsg(id) {
|
||||
// }
|
||||
|
||||
export function addProject(data) {
|
||||
const { name, prd_host, basepath, desc, group_id, protocol } = data;
|
||||
const { name, prd_host, basepath, desc, group_id, group_name, protocol } = data;
|
||||
const param = {
|
||||
name,
|
||||
prd_host,
|
||||
protocol,
|
||||
basepath,
|
||||
desc,
|
||||
group_id
|
||||
group_id,
|
||||
group_name
|
||||
};
|
||||
return {
|
||||
type: PROJECT_ADD,
|
||||
@ -117,11 +118,10 @@ export function addProject(data) {
|
||||
}
|
||||
|
||||
export function updateProject(data) {
|
||||
const { name, prd_host, basepath, desc, _id, protocol, env } = data;
|
||||
const { name, project_type, basepath, desc, _id, env } = data;
|
||||
const param = {
|
||||
name,
|
||||
prd_host,
|
||||
protocol,
|
||||
project_type,
|
||||
basepath,
|
||||
desc,
|
||||
id: _id,
|
||||
|
@ -48,6 +48,7 @@ class projectController extends baseController {
|
||||
* @param {String} name 项目名称,不能为空
|
||||
* @param {String} basepath 项目基本路径,不能为空
|
||||
* @param {Number} group_id 项目分组id,不能为空
|
||||
* @param {Number} group_name 项目分组名称,不能为空
|
||||
* @param {String} project_type private public
|
||||
* @param {String} [desc] 项目描述
|
||||
* @returns {Object}
|
||||
@ -59,6 +60,7 @@ class projectController extends baseController {
|
||||
name: 'string',
|
||||
basepath: 'string',
|
||||
group_id: 'number',
|
||||
group_name: 'string',
|
||||
desc: 'string',
|
||||
color: 'string',
|
||||
icon: 'string'
|
||||
@ -96,6 +98,7 @@ class projectController extends baseController {
|
||||
project_type: params.project_type || 'private',
|
||||
uid: this.getUid(),
|
||||
group_id: params.group_id,
|
||||
group_name: params.group_name,
|
||||
icon: params.icon,
|
||||
color: params.color,
|
||||
add_time: yapi.commons.time(),
|
||||
@ -111,6 +114,7 @@ class projectController extends baseController {
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.group_id,
|
||||
typename: params.group_name,
|
||||
color: params.color,
|
||||
icon: params.icon
|
||||
});
|
||||
|
@ -15,7 +15,7 @@ class groupModel extends baseModel {
|
||||
up_time: Number,
|
||||
members: [
|
||||
{
|
||||
uid: Number,
|
||||
uid: Number,
|
||||
role: {type: String, enum:['owner', 'dev']},
|
||||
username: String,
|
||||
email: String
|
||||
@ -115,4 +115,4 @@ class groupModel extends baseModel {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = groupModel;
|
||||
module.exports = groupModel;
|
||||
|
@ -13,6 +13,7 @@ class projectModel extends baseModel {
|
||||
basepath: {type: String },
|
||||
desc: String,
|
||||
group_id: { type: Number, required: true },
|
||||
group_name: { type: String, required: true },
|
||||
project_type: {type:String, required: true, enum: ['public', 'private']},
|
||||
members: [
|
||||
{uid: Number, role: {type: String, enum:['owner', 'dev']},username: String, email: String}
|
||||
@ -33,6 +34,11 @@ class projectModel extends baseModel {
|
||||
}
|
||||
|
||||
get(id) {
|
||||
this.model.findOne({
|
||||
_id: id
|
||||
}).select("uid group_name ").exec().then((res) => {
|
||||
console.log(res);
|
||||
})
|
||||
return this.model.findOne({
|
||||
_id: id
|
||||
}).exec();
|
||||
|
@ -125,6 +125,7 @@ var projectController = function (_baseController) {
|
||||
* @param {String} name 项目名称,不能为空
|
||||
* @param {String} basepath 项目基本路径,不能为空
|
||||
* @param {Number} group_id 项目分组id,不能为空
|
||||
* @param {Number} group_name 项目分组名称,不能为空
|
||||
* @param {String} project_type private public
|
||||
* @param {String} [desc] 项目描述
|
||||
* @returns {Object}
|
||||
@ -146,6 +147,7 @@ var projectController = function (_baseController) {
|
||||
name: 'string',
|
||||
basepath: 'string',
|
||||
group_id: 'number',
|
||||
group_name: 'string',
|
||||
desc: 'string',
|
||||
color: 'string',
|
||||
icon: 'string'
|
||||
@ -214,6 +216,7 @@ var projectController = function (_baseController) {
|
||||
project_type: params.project_type || 'private',
|
||||
uid: this.getUid(),
|
||||
group_id: params.group_id,
|
||||
group_name: params.group_name,
|
||||
icon: params.icon,
|
||||
color: params.color,
|
||||
add_time: _yapi2.default.commons.time(),
|
||||
@ -233,6 +236,7 @@ var projectController = function (_baseController) {
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.group_id,
|
||||
typename: params.group_name,
|
||||
color: params.color,
|
||||
icon: params.icon
|
||||
});
|
||||
|
@ -52,6 +52,7 @@ var projectModel = function (_baseModel) {
|
||||
basepath: { type: String },
|
||||
desc: String,
|
||||
group_id: { type: Number, required: true },
|
||||
group_name: { type: String, required: true },
|
||||
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 }],
|
||||
@ -70,6 +71,11 @@ var projectModel = function (_baseModel) {
|
||||
}, {
|
||||
key: 'get',
|
||||
value: function get(id) {
|
||||
this.model.findOne({
|
||||
_id: id
|
||||
}).select("uid group_name ").exec().then(function (res) {
|
||||
console.log(res);
|
||||
});
|
||||
return this.model.findOne({
|
||||
_id: id
|
||||
}).exec();
|
||||
|
Loading…
Reference in New Issue
Block a user