mirror of
https://github.com/YMFE/yapi.git
synced 2025-01-06 12:45:22 +08:00
feat: merge to local
This commit is contained in:
commit
73bf7b3d17
client
doc/build
exampleCode/api
server
server_dist
static/image
@ -1,6 +1,7 @@
|
||||
import LoginRedux from './reducer/Login/Login_redux.js'
|
||||
import login from './reducer/Login/login.js'
|
||||
import group from './reducer/group/group.js'
|
||||
import project from './reducer/group/project.js'
|
||||
import Interface from './reducer/Interface/InterfaceReducer.js'
|
||||
import news from './reducer/news/news.js'
|
||||
import user from './reducer/user/user.js'
|
||||
@ -10,6 +11,7 @@ export default {
|
||||
login,
|
||||
LoginRedux,
|
||||
Interface,
|
||||
news,
|
||||
user
|
||||
user,
|
||||
project,
|
||||
news
|
||||
}
|
||||
|
@ -17,18 +17,3 @@ export function setCurrGroup(group) {
|
||||
payload: group
|
||||
}
|
||||
}
|
||||
|
||||
export function addGroup(groupName) {
|
||||
return function(dispatch, getState) {
|
||||
const group = getState().group;
|
||||
const groupList = group.groupList || [];
|
||||
const newGroupList = groupList.concat([{ group_name: groupName + groupList.length }]);
|
||||
dispatch({
|
||||
type: FETCH_GROUP_LIST,
|
||||
payload: { data: {
|
||||
data: newGroupList,
|
||||
errcode: 0
|
||||
}}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -8,14 +8,18 @@ const cookies = new Cookies();
|
||||
|
||||
const loginActions = (data) => {
|
||||
return (dispatch) => {
|
||||
axios.get('/user/login', data).then((res) => {
|
||||
cookies.set(data.email, data.password);
|
||||
dispatch({
|
||||
type: LOGIN,
|
||||
payload: {
|
||||
data: res
|
||||
}
|
||||
});
|
||||
axios.post('/user/login', data).then((res) => {
|
||||
if (res.data.errcode === 0) {
|
||||
cookies.set(data.email, data.password);
|
||||
dispatch({
|
||||
type: LOGIN,
|
||||
payload: {
|
||||
data: res
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.log('登录失败,errcode不为0');
|
||||
}
|
||||
}).catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
@ -30,7 +34,7 @@ const regActions = (data) => {
|
||||
username: data.userName
|
||||
}
|
||||
return () => {
|
||||
axios.get('/user/login', param).then((res) => {
|
||||
axios.post('/user/login', param).then((res) => {
|
||||
console.log(res);
|
||||
}).catch((err) => {
|
||||
console.log(err);
|
||||
|
@ -1,5 +1,6 @@
|
||||
import {
|
||||
FETCH_NEWS_DATA
|
||||
FETCH_NEWS_DATA,
|
||||
FETCH_MORE_NEWS
|
||||
} from '../constants/action-types.js';
|
||||
|
||||
export function fetchNewsData () {
|
||||
@ -64,3 +65,27 @@ export function fetchNotVieweNews () {
|
||||
payload: data
|
||||
}
|
||||
}
|
||||
|
||||
export function fetchMoreNews () {
|
||||
return (dispatch)=>{
|
||||
const data = [{
|
||||
name: 'John Brown2212',
|
||||
date: '2015-11-11 13:00:15',
|
||||
desc: '创建服务现场'
|
||||
}, {
|
||||
name: 'John Brown1132',
|
||||
date: '2015-11-11 13:00:15',
|
||||
desc: '技术测试异常'
|
||||
}, {
|
||||
name: 'John Brown23212',
|
||||
date: '2015-11-11 13:00:15',
|
||||
desc: '网络异常正在修复'
|
||||
}]
|
||||
|
||||
dispatch({
|
||||
type: FETCH_MORE_NEWS,
|
||||
payload: data
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ const addProject = (data) => {
|
||||
return {
|
||||
type: PROJECT_ADD,
|
||||
// payload 可以返回 Promise,异步请求使用 axios 即可
|
||||
payload: axios.get('/project/add', param)
|
||||
payload: axios.post('/project/add', param)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,13 +3,14 @@ import React, { Component } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { connect } from 'react-redux'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { Icon } from 'antd'
|
||||
import { Icon, Layout, Menu} from 'antd'
|
||||
import loginTypeAction from '../../actions/login';
|
||||
|
||||
const { Header } = Layout;
|
||||
const ToolUser = (props)=> (
|
||||
<ul>
|
||||
<li><Icon type="question-circle-o" />帮助</li>
|
||||
<li><Icon type="user" />{ props.user }</li>
|
||||
<li>消息{ props.msg.length }</li>
|
||||
<li>退出</li>
|
||||
</ul>
|
||||
);
|
||||
@ -29,7 +30,7 @@ ToolGuest.propTypes={
|
||||
onReg:PropTypes.func
|
||||
}
|
||||
|
||||
class Header extends Component {
|
||||
class HeaderCom extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
@ -45,31 +46,41 @@ class Header extends Component {
|
||||
const { login, user, msg } = this.props;
|
||||
return (
|
||||
<acticle className="header-box">
|
||||
<div className="content">
|
||||
<h1>
|
||||
<Link to={`/`}>YAPI</Link>
|
||||
</h1>
|
||||
<ul className="nav-toolbar">
|
||||
<li>
|
||||
<Link to={`/ProjectGroups`}>分组</Link>
|
||||
</li>
|
||||
<li>
|
||||
<a>我的项目</a>
|
||||
</li>
|
||||
<li>
|
||||
<a>文档</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul className="user-toolbar">
|
||||
{login?<ToolUser user={user} msg={msg}/>:''}
|
||||
</ul>
|
||||
</div>
|
||||
<Layout className="'layout">
|
||||
<Header>
|
||||
<div className="content">
|
||||
<div className="logo">
|
||||
YAPI
|
||||
</div>
|
||||
<Menu
|
||||
mode="horizontal"
|
||||
className="nav-toolbar"
|
||||
theme="dark"
|
||||
style={{ lineHeight : '.64rem'}}
|
||||
defaultSelectedKeys={['1']}
|
||||
>
|
||||
<Menu.Item key="1">
|
||||
<Link to={`/`}>首页</Link>
|
||||
</Menu.Item>
|
||||
<Menu.Item key="2">
|
||||
<Link to={`/ProjectGroups`}>分组</Link>
|
||||
</Menu.Item>
|
||||
<Menu.Item key="3">
|
||||
文档
|
||||
</Menu.Item>
|
||||
</Menu>
|
||||
<div className="user-toolbar">
|
||||
{login?<ToolUser user={user} msg={msg}/>:''}
|
||||
</div>
|
||||
</div>
|
||||
</Header>
|
||||
</Layout>
|
||||
</acticle>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Header.propTypes={
|
||||
HeaderCom.propTypes={
|
||||
user: PropTypes.string,
|
||||
msg: PropTypes.string,
|
||||
login:PropTypes.bool,
|
||||
@ -85,5 +96,5 @@ export default connect(
|
||||
}
|
||||
},
|
||||
{loginTypeAction}
|
||||
)(Header)
|
||||
)(HeaderCom)
|
||||
|
||||
|
@ -1,29 +1,35 @@
|
||||
@import '../../styles/common.scss';
|
||||
$color-white : #fff;
|
||||
$color-blue : #30a1f2;
|
||||
$color-blue : #108ee9;
|
||||
$color-blue-deeper: #34495E;
|
||||
$color-grey-deep : #929aac;
|
||||
$color-black-light : #404040;
|
||||
/* .header-box.css */
|
||||
.header-box {
|
||||
display: block;
|
||||
line-height: .64rem;
|
||||
background: #000c15;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
//line-height: .64rem;
|
||||
font-size: 0.14rem;
|
||||
color: $color-white;
|
||||
z-index: 9999;
|
||||
|
||||
// 内容宽度
|
||||
.content {
|
||||
max-width: 11rem;
|
||||
max-width: 10.3rem;
|
||||
margin: 0 auto;
|
||||
zoom: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: .25rem;
|
||||
.logo {
|
||||
font-size: .3rem;
|
||||
float: left;
|
||||
margin: 0 .2rem 0 0;
|
||||
color: $color-white;
|
||||
cursor: pointer;
|
||||
//cursor: pointer;
|
||||
a{
|
||||
color: $color-white;
|
||||
&:hover {
|
||||
@ -36,37 +42,30 @@ $color-grey-deep : #929aac;
|
||||
}
|
||||
|
||||
.nav-toolbar {
|
||||
font-size: .15rem;
|
||||
box-sizing: border-box;
|
||||
float: left;
|
||||
li {
|
||||
float: left;
|
||||
margin: 0 .2rem;
|
||||
a{
|
||||
color: $color-white;
|
||||
&:hover {
|
||||
color: $color-blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.user-toolbar{
|
||||
float: right;
|
||||
line-height: .12rem;
|
||||
line-height: .14rem;
|
||||
li{
|
||||
float: left;
|
||||
height: .12rem;
|
||||
margin: .26rem 0;
|
||||
padding: 0 .1rem;
|
||||
font-size: .12rem;
|
||||
padding: 0 0 0 .12rem;
|
||||
font-size: .14rem;
|
||||
cursor: pointer;
|
||||
a{
|
||||
color: $color-white;
|
||||
&:hover{
|
||||
color: $color-blue;
|
||||
}
|
||||
}
|
||||
color: $color-white;
|
||||
&:not(:last-child){
|
||||
border-right: .01rem solid $color-white;
|
||||
padding: 0 .12rem;
|
||||
}
|
||||
&:hover{
|
||||
color: $color-blue;
|
||||
}
|
||||
i{
|
||||
margin-right: .09rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
72
client/components/Intro/Intro.js
Normal file
72
client/components/Intro/Intro.js
Normal file
@ -0,0 +1,72 @@
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Row, Col, Icon } from 'antd'
|
||||
import "./Intro.scss"
|
||||
|
||||
const IntroPart = (props) =>(
|
||||
<Col span={12} className="switch-content">
|
||||
<div className="icon-switch">
|
||||
<Icon type="smile-o" />
|
||||
</div>
|
||||
<div>
|
||||
<p><b>{props.title}</b></p>
|
||||
<p>{props.des}</p>
|
||||
</div>
|
||||
</Col>
|
||||
)
|
||||
|
||||
IntroPart.propTypes = {
|
||||
title : PropTypes.string,
|
||||
des : PropTypes.string
|
||||
}
|
||||
|
||||
class Intro extends React.Component{
|
||||
constructor(props){
|
||||
super(props);
|
||||
}
|
||||
static propTypes={
|
||||
intro : PropTypes.shape({
|
||||
title:PropTypes.string,
|
||||
des:PropTypes.string,
|
||||
img:PropTypes.string,
|
||||
detail:PropTypes.arrayOf(PropTypes.shape({
|
||||
title:PropTypes.string,
|
||||
des:PropTypes.string
|
||||
}))
|
||||
})
|
||||
}
|
||||
render(){
|
||||
const { intro } = this.props;
|
||||
return(
|
||||
<div className="intro-container">
|
||||
<Row>
|
||||
<Col span={12}>
|
||||
<div>
|
||||
<div className="img-container">
|
||||
<img src={intro.img}/>
|
||||
</div>
|
||||
</div>
|
||||
</Col>
|
||||
<Col span={12} className="des-container">
|
||||
<div>
|
||||
<div className="des-title">
|
||||
{intro.title}
|
||||
</div>
|
||||
<div className="des-detail">
|
||||
{intro.des}
|
||||
</div>
|
||||
</div>
|
||||
<div className="des-switch">
|
||||
{intro.detail.map(function(item,i){
|
||||
return(<IntroPart key={i} title={item.title} des={item.des}/>)
|
||||
})}
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default Intro;
|
||||
|
49
client/components/Intro/Intro.scss
Normal file
49
client/components/Intro/Intro.scss
Normal file
@ -0,0 +1,49 @@
|
||||
$imgUrl : "../../../static/image/";
|
||||
$color-grey : #E5E5E5;
|
||||
$color-blue : #108ee9;
|
||||
$color-white: #fff;
|
||||
|
||||
.intro-container{
|
||||
.des-container{
|
||||
padding-left: .15rem;
|
||||
.des-title{
|
||||
font-size: .24rem;
|
||||
margin-bottom: .1rem;
|
||||
}
|
||||
.des-detail{
|
||||
font-size: .15rem;
|
||||
margin-bottom: .2rem;
|
||||
}
|
||||
.des-switch{
|
||||
.switch-content{
|
||||
font-size: .14rem;
|
||||
margin-bottom: .15rem;
|
||||
div{
|
||||
float: left;
|
||||
}
|
||||
.icon-switch{
|
||||
height: .3rem;
|
||||
width: .3rem;
|
||||
border-radius: .02rem;
|
||||
background-color: $color-blue;
|
||||
margin-right: .1rem;
|
||||
color: $color-white;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.img-container{
|
||||
padding-right: .15rem;
|
||||
//background-image: url("#{$imgUrl}demo-img.png");
|
||||
img{
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
border: .01rem solid $color-grey;
|
||||
box-shadow : 0 0 3px 1px $color-grey;
|
||||
border-radius: .04rem;
|
||||
}
|
||||
}
|
||||
}
|
@ -18,7 +18,8 @@ export const REGISTER = 'REGISTER';
|
||||
export const LOGIN_TYPE = 'LOGIN_TYPE';
|
||||
|
||||
// News
|
||||
export const FETCH_NEWS_DATA = 'FETCH_NEWS_DATA'
|
||||
export const FETCH_NEWS_DATA = 'FETCH_NEWS_DATA';
|
||||
export const FETCH_MORE_NEWS = 'FETCH_MORE_NEWS';
|
||||
|
||||
// User
|
||||
export const CHANGE_CUR_UID = 'CHANGE_CUR_UID'
|
||||
|
@ -1,26 +1,77 @@
|
||||
import './Home.scss'
|
||||
import React, { Component } from 'react'
|
||||
import { Row, Col } from 'antd'
|
||||
import PropTypes from "prop-types"
|
||||
import Login from '../Login/login-wrap'
|
||||
import Intro from '../../components/Intro/Intro'
|
||||
|
||||
|
||||
class Home extends Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
}
|
||||
|
||||
static propTypes = {
|
||||
introList:PropTypes.array
|
||||
}
|
||||
render () {
|
||||
return (
|
||||
<div className="home-main">
|
||||
<div className="main-one">
|
||||
<div className="home-des">
|
||||
<p className="title">YAPI</p>
|
||||
<div className="detail">一个高效,易用,功能强大的api管理系统</div>
|
||||
<div className="container">
|
||||
<Row>
|
||||
<Col span={24}>
|
||||
<div className="home-des">
|
||||
<p className="title">YAPI</p>
|
||||
<div className="detail">一个高效,易用,功能强大的api管理系统</div>
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row>
|
||||
<Col span={8} className="main-one-left">
|
||||
<Login/>
|
||||
</Col>
|
||||
<Col span={16} className="main-one-right">
|
||||
<div className="img-container">
|
||||
<img src="./static/image/demo-img.png"/>
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
<Login/>
|
||||
</div>
|
||||
{ this.props.introList.map(function(intro,i){
|
||||
return (
|
||||
<div className="main-part" key={i}>
|
||||
<div className="container">
|
||||
<Intro intro={intro}/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Home.defaultProps={
|
||||
introList:[{
|
||||
title:"接口管理",
|
||||
des:"yapi将满足你的所有接口管理需求。不再需要 为每个项目搭建独立的接口管理平台和编写离线的接口文档",
|
||||
detail:[
|
||||
{title:"接口管理",des:"强大的接口文档"},
|
||||
{title:"接口管理",des:"强大的接口文档"},
|
||||
{title:"接口管理",des:"强大的接口文档"}
|
||||
],
|
||||
img:"./static/image/demo-img.png"
|
||||
},{
|
||||
title:"接口管理",
|
||||
des:"yapi将满足你的所有接口管理需求。不再需要 为每个项目搭建独立的接口管理平台和编写离线的接口文档",
|
||||
detail:[
|
||||
{title:"接口管理",des:"强大的接口文档"},
|
||||
{title:"接口管理",des:"强大的接口文档"}
|
||||
],
|
||||
img:"./static/image/demo-img.png"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
export default Home
|
||||
|
@ -1,27 +1,61 @@
|
||||
@import '../../styles/common.scss';
|
||||
/* .home-main.css */
|
||||
|
||||
$color-white : #fff;
|
||||
$color-blue-lighter : #f1f5ff;
|
||||
$color-grey-lighter : #F7F7F7;
|
||||
$color-blue-light: #5dade2;
|
||||
$color-black-lighter: #404040;
|
||||
|
||||
|
||||
.home-main {
|
||||
display: -webkit-box;
|
||||
max-width: 11rem;
|
||||
margin: 0 auto;
|
||||
margin-top: .64rem;
|
||||
-webkit-box-orient: vertical;
|
||||
background: $color-grey-lighter;
|
||||
.main-one{
|
||||
height:calc(100% - .64rem);
|
||||
padding: .5rem 0;
|
||||
padding: .5rem .5rem 0 .5rem;
|
||||
//background: radial-gradient(ellipse at center,#45484d 0%,#000 100%);
|
||||
.home-des{
|
||||
padding: .3rem 0;
|
||||
padding: 0 .3rem .3rem 0;
|
||||
.title{
|
||||
font-size: .6rem;
|
||||
}
|
||||
.detail{
|
||||
font-size: .23rem;
|
||||
font-size: .2rem;
|
||||
}
|
||||
}
|
||||
.login-form{
|
||||
|
||||
}
|
||||
.img-container{
|
||||
margin-bottom: -.2rem;
|
||||
img{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
box-shadow : 0 0 3px 0 $color-black-lighter;
|
||||
border-radius: .03rem;
|
||||
}
|
||||
}
|
||||
.main-one-left{
|
||||
padding-right: .15rem;
|
||||
}
|
||||
.main-one-right{
|
||||
padding-left: .15rem;
|
||||
}
|
||||
}
|
||||
|
||||
.main-part{
|
||||
padding: .9rem .5rem;
|
||||
&:nth-child(odd){
|
||||
background-color: $color-blue-lighter;
|
||||
}
|
||||
&:nth-child(even){
|
||||
background-color: $color-white;
|
||||
}
|
||||
}
|
||||
.container{
|
||||
max-width: 10.3rem;
|
||||
margin: 0 auto;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,4 @@
|
||||
@import '../../styles/common.scss';
|
||||
|
||||
/* .login-main.css */
|
||||
.login-form {
|
||||
width: 4rem;
|
||||
}
|
||||
|
||||
|
@ -30,11 +30,11 @@ class News extends Component {
|
||||
this.props.fetchNewsData()
|
||||
}
|
||||
render () {
|
||||
const data = this.props.newsData;
|
||||
const data = this.props.newsData
|
||||
return (
|
||||
<section className="news-box">
|
||||
<NewsList />
|
||||
<NewsTimeline data = {data} />
|
||||
<NewsTimeline newsData = {data} />
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
@ -25,7 +25,57 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.news-timeline{
|
||||
margin-left: 30px;
|
||||
margin-top: 30px;
|
||||
}
|
||||
}
|
||||
|
||||
.ant-timeline-item-content{
|
||||
background-color: #ececec;
|
||||
margin-left: 30px;
|
||||
border-radius: 4px;
|
||||
border-left:4px solid #ececec;
|
||||
min-width: 350px;
|
||||
max-width: 450px;
|
||||
padding: 10px;
|
||||
|
||||
.timelineDate{
|
||||
display: block;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.timelineName{
|
||||
float: right;
|
||||
}
|
||||
|
||||
p{
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
div{
|
||||
overflow: hidden
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.ant-timeline-item-content:before{
|
||||
content:'';
|
||||
display: block;
|
||||
margin-left: -40px;
|
||||
width: 0px;
|
||||
height: 0px;
|
||||
float: left;
|
||||
border-width: 10px 13px;
|
||||
border-style: solid;
|
||||
border-color: transparent #ececec transparent transparent;
|
||||
}
|
||||
|
||||
.ant-timeline-item-tail{
|
||||
top: 16px;
|
||||
}
|
||||
|
||||
.ant-timeline-item-head{
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
@ -1,25 +1,41 @@
|
||||
import React, { Component } from 'react'
|
||||
import { Timeline } from 'antd'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
import { connect } from 'react-redux'
|
||||
import { fetchMoreNews } from '../../../actions/news.js'
|
||||
@connect(
|
||||
state=>{
|
||||
return state;
|
||||
},
|
||||
{
|
||||
fetchMoreNews: fetchMoreNews
|
||||
}
|
||||
)
|
||||
class NewsTimeline extends Component {
|
||||
static propTypes = {
|
||||
data: PropTypes.array
|
||||
newsData: PropTypes.array,
|
||||
fetchMoreNews: PropTypes.func
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
super(props);
|
||||
}
|
||||
|
||||
render () {
|
||||
const data = this.props.data;
|
||||
const data = this.props.newsData;
|
||||
return (
|
||||
<section className="news-timeline">
|
||||
<Timeline pending={<a href="#">See more</a>}>
|
||||
<Timeline pending={<a onClick = {this.props.fetchMoreNews}>See more</a>}>
|
||||
{
|
||||
data.map(function(item,i){
|
||||
return (
|
||||
<Timeline.Item color = 'green' key = {i} >{ item.date + item.desc + item.name }</Timeline.Item>
|
||||
<Timeline.Item color = 'green' key = {i} >
|
||||
<div>
|
||||
<span className='timelineDate'>{item.date}</span>
|
||||
<span className='timelineName'>{item.name}</span>
|
||||
</div>
|
||||
<p>{item.desc}</p>
|
||||
</Timeline.Item>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
import React, { Component } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { connect } from 'react-redux'
|
||||
import { Card, Button } from 'antd'
|
||||
import { Card, Button, Icon, Modal, Input, message } from 'antd'
|
||||
import { autobind } from 'core-decorators';
|
||||
import axios from 'axios';
|
||||
|
||||
import {
|
||||
fetchGroupList,
|
||||
@ -28,25 +29,61 @@ export default class GroupList extends Component {
|
||||
static propTypes = {
|
||||
groupList: PropTypes.array,
|
||||
currGroup: PropTypes.object,
|
||||
addGroup: PropTypes.func,
|
||||
fetchGroupList: PropTypes.func,
|
||||
setCurrGroup: PropTypes.func
|
||||
}
|
||||
|
||||
state = {
|
||||
addGroupModalVisible: false,
|
||||
newGroupName: '',
|
||||
newGroupDesc: ''
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
this.props.fetchGroupList().then(() => {
|
||||
const currGroup = this.props.groupList[0];
|
||||
const currGroup = this.props.groupList[0] || { group_name: '', group_desc: '' };
|
||||
this.props.setCurrGroup(currGroup)
|
||||
});
|
||||
}
|
||||
|
||||
@autobind
|
||||
showModal() {
|
||||
this.setState({
|
||||
addGroupModalVisible: true
|
||||
});
|
||||
}
|
||||
@autobind
|
||||
addGroup() {
|
||||
this.props.addGroup('group');
|
||||
const { newGroupName: group_name, newGroupDesc: group_desc } = this.state;
|
||||
axios.post('/group/add', { group_name, group_desc }).then(res => {
|
||||
if (res.data.errcode) {
|
||||
message.error(res.data.errmsg);
|
||||
} else {
|
||||
this.setState({
|
||||
addGroupModalVisible: false
|
||||
});
|
||||
this.props.fetchGroupList()
|
||||
}
|
||||
});
|
||||
}
|
||||
@autobind
|
||||
handleCancel(e) {
|
||||
console.log(e);
|
||||
this.setState({
|
||||
addGroupModalVisible: false
|
||||
});
|
||||
}
|
||||
@autobind
|
||||
inputNewGroupName(e) {
|
||||
this.setState({newGroupName: e.target.value});
|
||||
}
|
||||
@autobind
|
||||
inputNewGroupDesc(e) {
|
||||
this.setState({newGroupDesc: e.target.value});
|
||||
}
|
||||
|
||||
render () {
|
||||
@ -54,13 +91,25 @@ export default class GroupList extends Component {
|
||||
|
||||
return (
|
||||
<Card title="Groups">
|
||||
<Button type="primary" onClick={this.addGroup}>添加分组</Button>
|
||||
<div>{currGroup.group_name}</div>
|
||||
<Button type="primary" onClick={this.showModal}>添加分组</Button>
|
||||
<div className="curr-group">{currGroup.group_name}</div>
|
||||
{
|
||||
groupList.map((group, index) => (
|
||||
<div key={index}>{group.group_name}</div>
|
||||
<div key={index}>
|
||||
<div className="group-name">{group.group_name}</div>
|
||||
<Icon type="edit" />
|
||||
</div>
|
||||
))
|
||||
}
|
||||
<Modal
|
||||
title="添加分组"
|
||||
visible={this.state.addGroupModalVisible}
|
||||
onOk={this.addGroup}
|
||||
onCancel={this.handleCancel}
|
||||
>
|
||||
<Input placeholder="请输入分组名称" onChange={this.inputNewGroupName}></Input>
|
||||
<Input placeholder="请输入分组描述" onChange={this.inputNewGroupDesc}></Input>
|
||||
</Modal>
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
|
@ -0,0 +1,8 @@
|
||||
.group-name {
|
||||
display: inline-block;
|
||||
}
|
||||
.curr-group {
|
||||
background: #34495E;
|
||||
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.20);
|
||||
border-radius: 4px 4px 0 0;
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
.ant-input-group-wrapper {
|
||||
width: 100%;
|
||||
}
|
@ -1,10 +1,13 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import { Table, Button, Modal, Form, Input, Icon, Tooltip } from 'antd';
|
||||
import { Table, Button, Modal, Form, Input, Icon, Tooltip, Select } from 'antd';
|
||||
import { addProject } from '../../../actions/project';
|
||||
const { TextArea } = Input;
|
||||
const FormItem = Form.Item;
|
||||
const Option = Select.Option;
|
||||
|
||||
import './ProjectList.scss'
|
||||
|
||||
const columns = [{
|
||||
title: 'Name',
|
||||
@ -59,12 +62,12 @@ const formItemLayout = {
|
||||
addProject
|
||||
}
|
||||
)
|
||||
|
||||
class ProjectList extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
visible: false
|
||||
visible: false,
|
||||
protocol: 'http:\/\/'
|
||||
}
|
||||
}
|
||||
static propTypes = {
|
||||
@ -80,6 +83,7 @@ class ProjectList extends Component {
|
||||
e.preventDefault();
|
||||
this.props.form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
values.prd_host = this.state.protocol + values.prd_host;
|
||||
console.log('Received values of form: ', values);
|
||||
this.setState({
|
||||
visible: false
|
||||
@ -94,9 +98,14 @@ class ProjectList extends Component {
|
||||
visible: false
|
||||
});
|
||||
}
|
||||
handleSubmit = (e) => {
|
||||
console.log(e);
|
||||
|
||||
// 修改线上域名的协议类型 (http/https)
|
||||
protocolChange = (value) => {
|
||||
this.setState({
|
||||
protocol: value
|
||||
})
|
||||
}
|
||||
|
||||
render() {
|
||||
const { getFieldDecorator } = this.props.form;
|
||||
return (
|
||||
@ -107,7 +116,7 @@ class ProjectList extends Component {
|
||||
onOk={this.handleOk}
|
||||
onCancel={this.handleCancel}
|
||||
>
|
||||
<Form onSubmit={this.handleSubmit}>
|
||||
<Form>
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
@ -138,7 +147,11 @@ class ProjectList extends Component {
|
||||
required: true, message: '请输入项目线上域名!'
|
||||
}]
|
||||
})(
|
||||
<Input />
|
||||
<Input addonBefore={(
|
||||
<Select defaultValue="http://" onChange={this.protocolChange}>
|
||||
<Option value="http://">{'http:\/\/'}</Option>
|
||||
<Option value="https://">{'https:\/\/'}</Option>
|
||||
</Select>)} />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
|
@ -13,6 +13,7 @@ const initialState = {
|
||||
export default (state = initialState, action) => {
|
||||
switch (action.type) {
|
||||
case LOGIN: {
|
||||
console.log(action);
|
||||
return {
|
||||
...state,
|
||||
isLogin: true,
|
||||
|
@ -5,7 +5,7 @@ import {
|
||||
|
||||
const initialState = {
|
||||
groupList: [],
|
||||
currGroup: 'MFE'
|
||||
currGroup: { group_name: '' }
|
||||
};
|
||||
|
||||
export default (state = initialState, action) => {
|
||||
|
19
client/reducer/group/project.js
Normal file
19
client/reducer/group/project.js
Normal file
@ -0,0 +1,19 @@
|
||||
import {
|
||||
PROJECT_ADD
|
||||
} from '../../constants/action-types';
|
||||
|
||||
const initialState = {
|
||||
groupList: [],
|
||||
currGroup: 'MFE'
|
||||
};
|
||||
|
||||
export default (state = initialState, action) => {
|
||||
switch (action.type) {
|
||||
case PROJECT_ADD: {
|
||||
console.log(action.payload);
|
||||
return state;
|
||||
}
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
@ -1,5 +1,6 @@
|
||||
import {
|
||||
FETCH_NEWS_DATA
|
||||
FETCH_NEWS_DATA,
|
||||
FETCH_MORE_NEWS
|
||||
} from '../../constants/action-types.js'
|
||||
|
||||
const initialState = {
|
||||
@ -9,12 +10,20 @@ const initialState = {
|
||||
export default (state = initialState, action) => {
|
||||
switch (action.type) {
|
||||
case FETCH_NEWS_DATA: {
|
||||
|
||||
return {
|
||||
...state,
|
||||
newsData: action.payload
|
||||
};
|
||||
}
|
||||
case FETCH_MORE_NEWS: {
|
||||
state.newsData.push(...action.payload);
|
||||
return {
|
||||
...state
|
||||
}
|
||||
}
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,11 +14,10 @@ export default () => {
|
||||
<Route path="/" component={ Home } exact />
|
||||
<Route path="/ProjectGroups" component={ ProjectGroups } />
|
||||
<Route path="/Interface" component={ Interface } />
|
||||
<Route path="/user" component={User} />
|
||||
<Route path="/user" component={User} />
|
||||
<Route path="/News" component={ News } />
|
||||
</div>
|
||||
|
||||
</HashRouter>
|
||||
)
|
||||
}
|
||||
|
184
doc/build/api.html
vendored
184
doc/build/api.html
vendored
@ -155,7 +155,7 @@
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="#-project-get_member_list-json">/project/get_member_list.json</a>
|
||||
<a href="#-project-get_member_list">/project/get_member_list</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
@ -872,6 +872,50 @@
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
<small class="text-muted">参数:</small>
|
||||
</p>
|
||||
<div class="docs-table">
|
||||
<table class="yo-table yo-table-border">
|
||||
<colgroup>
|
||||
<col class="c1">
|
||||
<col class="c2">
|
||||
<col class="c3">
|
||||
<col class="c4">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr class="active">
|
||||
<th>参数名</th>
|
||||
<th>类型</th>
|
||||
<th>描述</th>
|
||||
<th>必选</th>
|
||||
<th>支持版本</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tr>
|
||||
<td>pageNo</td>
|
||||
<td>Number</td>
|
||||
<td>分页页码</td>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>pageSize</td>
|
||||
<td>Number</td>
|
||||
<td>分页大小</td>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
@ -894,7 +938,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/user.js.html#299" target="_blank">./server/controllers/user.js:299</a>
|
||||
<a href="./static/server/controllers/user.js.html#314" target="_blank">./server/controllers/user.js:314</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -956,7 +1000,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/user.js.html#328" target="_blank">./server/controllers/user.js:328</a>
|
||||
<a href="./static/server/controllers/user.js.html#343" target="_blank">./server/controllers/user.js:343</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -1018,7 +1062,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/user.js.html#352" target="_blank">./server/controllers/user.js:352</a>
|
||||
<a href="./static/server/controllers/user.js.html#367" target="_blank">./server/controllers/user.js:367</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -1043,14 +1087,34 @@
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tr>
|
||||
<td>uid</td>
|
||||
<td></td>
|
||||
<td>用户uid</td>
|
||||
<td>
|
||||
|
||||
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
|
||||
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>role</td>
|
||||
<td></td>
|
||||
<td>用户角色,只有管理员有权限修改</td>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>username</td>
|
||||
<td></td>
|
||||
<td>String</td>
|
||||
<td>
|
||||
|
||||
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
|
||||
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
@ -1061,8 +1125,6 @@
|
||||
<td>String</td>
|
||||
<td>
|
||||
|
||||
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
|
||||
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
@ -1092,7 +1154,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/user.js.html#388" target="_blank">./server/controllers/user.js:388</a>
|
||||
<a href="./static/server/controllers/user.js.html#412" target="_blank">./server/controllers/user.js:412</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -1456,13 +1518,13 @@
|
||||
|
||||
<div class="con-list-item">
|
||||
<blockquote class="api">
|
||||
<h3 id="-project-get_member_list-json" class="page-header subject">
|
||||
/project/get_member_list.json
|
||||
<h3 id="-project-get_member_list" class="page-header subject">
|
||||
/project/get_member_list
|
||||
|
||||
<span class="ui-badge">GET</span>
|
||||
|
||||
|
||||
<a class="hashlink" href="#-project-get_member_list-json">#</a>
|
||||
<a class="hashlink" href="#-project-get_member_list">#</a>
|
||||
</h3>
|
||||
</blockquote>
|
||||
<p>
|
||||
@ -1521,12 +1583,9 @@
|
||||
<span class="token punctuation">{</span>
|
||||
<span class="token string">"_id"</span><span class="token punctuation">:</span> <span class="token number">101</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"email"</span><span class="token punctuation">:</span> <span class="token string">"admin@admin.com"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"password"</span><span class="token punctuation">:</span> <span class="token string">"e00084747ecba89837affe8a048e83c751e44209"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"passsalt"</span><span class="token punctuation">:</span> <span class="token string">"fmf3kytyysc4swwuqc15rk9"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"role"</span><span class="token punctuation">:</span> <span class="token string">"admin"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"add_time"</span><span class="token punctuation">:</span> <span class="token number">1499932673</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"up_time"</span><span class="token punctuation">:</span> <span class="token number">1499932673</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"__v"</span><span class="token punctuation">:</span> <span class="token number">0</span>
|
||||
<span class="token string">"up_time"</span><span class="token punctuation">:</span> <span class="token number">1499932673</span>
|
||||
<span class="token punctuation">}</span>
|
||||
<span class="token punctuation">]</span>
|
||||
<span class="token punctuation">}</span>
|
||||
@ -1553,7 +1612,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#176" target="_blank">./server/controllers/project.js:176</a>
|
||||
<a href="./static/server/controllers/project.js.html#182" target="_blank">./server/controllers/project.js:182</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -1636,7 +1695,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#200" target="_blank">./server/controllers/project.js:200</a>
|
||||
<a href="./static/server/controllers/project.js.html#206" target="_blank">./server/controllers/project.js:206</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -1673,6 +1732,26 @@
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>pageNo</td>
|
||||
<td>Number</td>
|
||||
<td>分页页码</td>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>pageSize</td>
|
||||
<td>Number</td>
|
||||
<td>分页大小</td>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@ -1681,38 +1760,37 @@
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>
|
||||
<span class="token punctuation">{</span>
|
||||
<span class="token string">"_id"</span><span class="token punctuation">:</span> <span class="token number">7</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"name"</span><span class="token punctuation">:</span> <span class="token string">"project_a1"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"desc"</span><span class="token punctuation">:</span> <span class="token string">"tttttt"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"prd_host"</span><span class="token punctuation">:</span> <span class="token string">"project.a1.cc"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"basepath"</span><span class="token punctuation">:</span> <span class="token string">"/a1"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"uid"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"group_id"</span><span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"add_time"</span><span class="token punctuation">:</span> <span class="token number">1499331378</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"up_time"</span><span class="token punctuation">:</span> <span class="token number">1499331378</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"__v"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"members"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>
|
||||
<span class="token number">0</span>
|
||||
<span class="token punctuation">]</span>
|
||||
<span class="token punctuation">}</span><span class="token punctuation">,</span>
|
||||
<span class="token punctuation">{</span>
|
||||
<span class="token string">"_id"</span><span class="token punctuation">:</span> <span class="token number">8</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"name"</span><span class="token punctuation">:</span> <span class="token string">"project_a2"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"desc"</span><span class="token punctuation">:</span> <span class="token string">"tttttt"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"prd_host"</span><span class="token punctuation">:</span> <span class="token string">"project.a2.cc"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"basepath"</span><span class="token punctuation">:</span> <span class="token string">"/a1"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"uid"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"group_id"</span><span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"add_time"</span><span class="token punctuation">:</span> <span class="token number">1499331387</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"up_time"</span><span class="token punctuation">:</span> <span class="token number">1499331387</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"__v"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"members"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>
|
||||
<span class="token number">0</span>
|
||||
<span class="token punctuation">]</span>
|
||||
<span class="token punctuation">}</span>
|
||||
<span class="token punctuation">]</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
<span class="token string">"total"</span><span class="token punctuation">:</span> <span class="token number">2</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"list"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>
|
||||
<span class="token punctuation">{</span>
|
||||
<span class="token string">"_id"</span><span class="token punctuation">:</span> <span class="token number">133</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"name"</span><span class="token punctuation">:</span> <span class="token string">"project_a1"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"prd_host"</span><span class="token punctuation">:</span> <span class="token string">"project.a2.cc"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"basepath"</span><span class="token punctuation">:</span> <span class="token string">"/a1/"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"uid"</span><span class="token punctuation">:</span> <span class="token number">101</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"group_id"</span><span class="token punctuation">:</span> <span class="token number">101</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"add_time"</span><span class="token punctuation">:</span> <span class="token number">1500004234</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"up_time"</span><span class="token punctuation">:</span> <span class="token number">1500004234</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"__v"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"env"</span><span class="token punctuation">:</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"members"</span><span class="token punctuation">:</span><span class="token punctuation">[</span><span class="token string">"101"</span><span class="token punctuation">]</span>
|
||||
<span class="token punctuation">}</span><span class="token punctuation">,</span>
|
||||
<span class="token punctuation">{</span>
|
||||
<span class="token string">"_id"</span><span class="token punctuation">:</span> <span class="token number">163</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"name"</span><span class="token punctuation">:</span> <span class="token string">"project_a2"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"prd_host"</span><span class="token punctuation">:</span> <span class="token string">"project.a2.cc"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"basepath"</span><span class="token punctuation">:</span> <span class="token string">"/a2/"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"uid"</span><span class="token punctuation">:</span> <span class="token number">101</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"group_id"</span><span class="token punctuation">:</span> <span class="token number">101</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"add_time"</span><span class="token punctuation">:</span> <span class="token number">1500006397</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"up_time"</span><span class="token punctuation">:</span> <span class="token number">1500006397</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"__v"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"env"</span><span class="token punctuation">:</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"members"</span><span class="token punctuation">:</span><span class="token punctuation">[</span><span class="token string">"101"</span><span class="token punctuation">]</span>
|
||||
<span class="token punctuation">}</span>
|
||||
<span class="token punctuation">]</span>
|
||||
<span class="token punctuation">}</span>
|
||||
<span class="token punctuation">}</span></code></pre>
|
||||
|
||||
|
||||
@ -1736,7 +1814,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#224" target="_blank">./server/controllers/project.js:224</a>
|
||||
<a href="./static/server/controllers/project.js.html#244" target="_blank">./server/controllers/project.js:244</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -1808,7 +1886,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#257" target="_blank">./server/controllers/project.js:257</a>
|
||||
<a href="./static/server/controllers/project.js.html#277" target="_blank">./server/controllers/project.js:277</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -1968,7 +2046,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#318" target="_blank">./server/controllers/project.js:318</a>
|
||||
<a href="./static/server/controllers/project.js.html#338" target="_blank">./server/controllers/project.js:338</a>
|
||||
</p>
|
||||
|
||||
|
||||
|
@ -169,7 +169,7 @@ class projectController extends baseController {
|
||||
|
||||
/**
|
||||
* 获取项目成员列表
|
||||
* @interface /project/get_member_list.json
|
||||
* @interface /project/get_member_list
|
||||
* @method GET
|
||||
* @category project
|
||||
* @foldnumber 10
|
||||
@ -191,7 +191,13 @@ class projectController extends baseController {
|
||||
|
||||
for(let i of project.members) {
|
||||
let user = await userInst.findById(i);
|
||||
result.push(user);
|
||||
result.push({
|
||||
_id: user._id,
|
||||
email: user.email,
|
||||
role: user.role,
|
||||
add_time: user.add_time,
|
||||
up_time: user.up_time
|
||||
});
|
||||
}
|
||||
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
@ -232,18 +238,32 @@ class projectController extends baseController {
|
||||
* @category project
|
||||
* @foldnumber 10
|
||||
* @param {Number} group_id 项目group_id,不能为空
|
||||
* @param {Number} [pageNo] 分页页码
|
||||
* @param {Number} [pageSize] 分页大小
|
||||
* @returns {Object}
|
||||
* @example ./api/project/list.json
|
||||
*/
|
||||
|
||||
async list(ctx) {
|
||||
let group_id = ctx.request.query.group_id;
|
||||
let group_id = ctx.request.query.group_id,
|
||||
pageNo = ctx.request.query.pageNo || 1,
|
||||
pageSize = ctx.request.query.pageSize || 10;
|
||||
|
||||
if(!group_id){
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '项目分组id不能为空');
|
||||
}
|
||||
|
||||
try{
|
||||
let result = await this.Model.list(group_id);
|
||||
ctx.body = yapi.commons.resReturn(result)
|
||||
let resResult = [];
|
||||
for(let i = (pageNo - 1) * pageSize; i < pageNo * pageSize; i++) {
|
||||
if(!result[i]) break;
|
||||
resResult.push(result[i]);
|
||||
}
|
||||
ctx.body = yapi.commons.resReturn({
|
||||
total: result.length,
|
||||
list: resResult
|
||||
})
|
||||
}catch(err){
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message)
|
||||
}
|
||||
|
36
doc/build/static/server/controllers/user.js.html
vendored
36
doc/build/static/server/controllers/user.js.html
vendored
@ -307,18 +307,33 @@ class userController extends baseController{
|
||||
* @method GET
|
||||
* @category user
|
||||
* @foldnumber 10
|
||||
* @param {Number} [pageNo] 分页页码
|
||||
* @param {Number} [pageSize] 分页大小
|
||||
* @returns {Object}
|
||||
* @example
|
||||
*/
|
||||
|
||||
async list(ctx){
|
||||
let pageNo = ctx.request.query.pageNo || 1,
|
||||
pageSize = ctx.request.query.pageSize || 10;
|
||||
|
||||
if(this.getRole() !== 'admin'){
|
||||
return ctx.body = yapi.commons.resReturn(null, 402, '没有权限');
|
||||
}
|
||||
var userInst = yapi.getInst(userModel);
|
||||
try{
|
||||
let user = await userInst.list();
|
||||
return ctx.body = yapi.commons.resReturn(user);
|
||||
let result = [];
|
||||
|
||||
for(let i = (pageNo - 1) * pageSize; i < pageNo * pageSize; i++) {
|
||||
if(!user[i]) break;
|
||||
result.push(user[i]);
|
||||
}
|
||||
|
||||
return ctx.body = yapi.commons.resReturn({
|
||||
total: user.length,
|
||||
list: result
|
||||
});
|
||||
}catch(e){
|
||||
return ctx.body = yapi.commons.resReturn(null,402,e.message);
|
||||
}
|
||||
@ -381,8 +396,10 @@ class userController extends baseController{
|
||||
* 更新用户个人信息
|
||||
* @interface /user/update
|
||||
* @method POST
|
||||
* @param username String
|
||||
* @param email String
|
||||
* @param uid 用户uid
|
||||
* @param [role] 用户角色,只有管理员有权限修改
|
||||
* @param [username] String
|
||||
* @param [email] String
|
||||
* @category user
|
||||
* @foldnumber 10
|
||||
* @returns {Object}
|
||||
@ -390,13 +407,20 @@ class userController extends baseController{
|
||||
*/
|
||||
async update(ctx){ //更新用户信息
|
||||
try{
|
||||
let params = ctx.request.body;
|
||||
if(this.getRole() !== 'admin' && params.uid != this.getUid()){
|
||||
return ctx.body = yapi.commons.resReturn(null,401,'没有权限');
|
||||
}
|
||||
var userInst = yapi.getInst(userModel);
|
||||
let id = this.getUid();
|
||||
let id = params.uid;
|
||||
let data ={
|
||||
up_time: yapi.commons.time()
|
||||
};
|
||||
ctx.request.body.username && (data.username = ctx.request.body.username)
|
||||
ctx.request.body.email && (data.email = ctx.request.body.email)
|
||||
if(this.getRole() === 'admin'){
|
||||
params.role && (data.role = params.role)
|
||||
}
|
||||
params.username && (data.username = params.username)
|
||||
params.email && (data.email = params.email)
|
||||
|
||||
if(data.email){
|
||||
var checkRepeat = await userInst.checkRepeat(data.email);//然后检查是否已经存在该用户
|
||||
|
@ -5,12 +5,9 @@
|
||||
{
|
||||
"_id": 101,
|
||||
"email": "admin@admin.com",
|
||||
"password": "e00084747ecba89837affe8a048e83c751e44209",
|
||||
"passsalt": "fmf3kytyysc4swwuqc15rk9",
|
||||
"role": "admin",
|
||||
"add_time": 1499932673,
|
||||
"up_time": 1499932673,
|
||||
"__v": 0
|
||||
"up_time": 1499932673
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -1,36 +1,35 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "success",
|
||||
"data": [
|
||||
{
|
||||
"_id": 7,
|
||||
"name": "project_a1",
|
||||
"desc": "tttttt",
|
||||
"prd_host": "project.a1.cc",
|
||||
"basepath": "/a1",
|
||||
"uid": 0,
|
||||
"group_id": 1,
|
||||
"add_time": 1499331378,
|
||||
"up_time": 1499331378,
|
||||
"__v": 0,
|
||||
"members": [
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"_id": 8,
|
||||
"name": "project_a2",
|
||||
"desc": "tttttt",
|
||||
"prd_host": "project.a2.cc",
|
||||
"basepath": "/a1",
|
||||
"uid": 0,
|
||||
"group_id": 1,
|
||||
"add_time": 1499331387,
|
||||
"up_time": 1499331387,
|
||||
"__v": 0,
|
||||
"members": [
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
"data": {
|
||||
"total": 2,
|
||||
"list": [
|
||||
{
|
||||
"_id": 133,
|
||||
"name": "project_a1",
|
||||
"prd_host": "project.a2.cc",
|
||||
"basepath": "/a1/",
|
||||
"uid": 101,
|
||||
"group_id": 101,
|
||||
"add_time": 1500004234,
|
||||
"up_time": 1500004234,
|
||||
"__v": 0,
|
||||
"env":[],
|
||||
"members":["101"]
|
||||
},
|
||||
{
|
||||
"_id": 163,
|
||||
"name": "project_a2",
|
||||
"prd_host": "project.a2.cc",
|
||||
"basepath": "/a2/",
|
||||
"uid": 101,
|
||||
"group_id": 101,
|
||||
"add_time": 1500006397,
|
||||
"up_time": 1500006397,
|
||||
"__v": 0,
|
||||
"env":[],
|
||||
"members":["101"]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
24
exampleCode/api/user/list.json
Normal file
24
exampleCode/api/user/list.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "success",
|
||||
"data":{
|
||||
"total": 2,
|
||||
"list":[
|
||||
{
|
||||
"_id": 101,
|
||||
"email": "admin@admin.com",
|
||||
"role": "admin",
|
||||
"add_time": 1499932673,
|
||||
"up_time": 1499932673
|
||||
},
|
||||
{
|
||||
"_id": 263,
|
||||
"username": "2515418556",
|
||||
"email": "2515418556@qq.com",
|
||||
"role": "member",
|
||||
"add_time": 1500023432,
|
||||
"up_time": 1500024967
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -142,7 +142,7 @@ class projectController extends baseController {
|
||||
|
||||
/**
|
||||
* 获取项目成员列表
|
||||
* @interface /project/get_member_list.json
|
||||
* @interface /project/get_member_list
|
||||
* @method GET
|
||||
* @category project
|
||||
* @foldnumber 10
|
||||
@ -164,7 +164,13 @@ class projectController extends baseController {
|
||||
|
||||
for(let i of project.members) {
|
||||
let user = await userInst.findById(i);
|
||||
result.push(user);
|
||||
result.push({
|
||||
_id: user._id,
|
||||
email: user.email,
|
||||
role: user.role,
|
||||
add_time: user.add_time,
|
||||
up_time: user.up_time
|
||||
});
|
||||
}
|
||||
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
@ -205,18 +211,32 @@ class projectController extends baseController {
|
||||
* @category project
|
||||
* @foldnumber 10
|
||||
* @param {Number} group_id 项目group_id,不能为空
|
||||
* @param {Number} [pageNo] 分页页码
|
||||
* @param {Number} [pageSize] 分页大小
|
||||
* @returns {Object}
|
||||
* @example ./api/project/list.json
|
||||
*/
|
||||
|
||||
async list(ctx) {
|
||||
let group_id = ctx.request.query.group_id;
|
||||
let group_id = ctx.request.query.group_id,
|
||||
pageNo = ctx.request.query.pageNo || 1,
|
||||
pageSize = ctx.request.query.pageSize || 10;
|
||||
|
||||
if(!group_id){
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '项目分组id不能为空');
|
||||
}
|
||||
|
||||
try{
|
||||
let result = await this.Model.list(group_id);
|
||||
ctx.body = yapi.commons.resReturn(result)
|
||||
let resResult = [];
|
||||
for(let i = (pageNo - 1) * pageSize; i < pageNo * pageSize; i++) {
|
||||
if(!result[i]) break;
|
||||
resResult.push(result[i]);
|
||||
}
|
||||
ctx.body = yapi.commons.resReturn({
|
||||
total: result.length,
|
||||
list: resResult
|
||||
})
|
||||
}catch(err){
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message)
|
||||
}
|
||||
|
@ -280,18 +280,33 @@ class userController extends baseController{
|
||||
* @method GET
|
||||
* @category user
|
||||
* @foldnumber 10
|
||||
* @param {Number} [pageNo] 分页页码
|
||||
* @param {Number} [pageSize] 分页大小
|
||||
* @returns {Object}
|
||||
* @example
|
||||
*/
|
||||
|
||||
async list(ctx){
|
||||
let pageNo = ctx.request.query.pageNo || 1,
|
||||
pageSize = ctx.request.query.pageSize || 10;
|
||||
|
||||
if(this.getRole() !== 'admin'){
|
||||
return ctx.body = yapi.commons.resReturn(null, 402, '没有权限');
|
||||
}
|
||||
var userInst = yapi.getInst(userModel);
|
||||
try{
|
||||
let user = await userInst.list();
|
||||
return ctx.body = yapi.commons.resReturn(user);
|
||||
let result = [];
|
||||
|
||||
for(let i = (pageNo - 1) * pageSize; i < pageNo * pageSize; i++) {
|
||||
if(!user[i]) break;
|
||||
result.push(user[i]);
|
||||
}
|
||||
|
||||
return ctx.body = yapi.commons.resReturn({
|
||||
total: user.length,
|
||||
list: result
|
||||
});
|
||||
}catch(e){
|
||||
return ctx.body = yapi.commons.resReturn(null,402,e.message);
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ createAction('project', 'up', 'post', 'up')
|
||||
createAction('project', 'del', 'post', 'del')
|
||||
createAction('project', 'add_member', 'post', 'addMember')
|
||||
createAction('project', 'del_member', 'post', 'delMember')
|
||||
createAction('project', 'get_member_list.json', 'get', 'getMemberList')
|
||||
createAction('project', 'get_member_list', 'get', 'getMemberList')
|
||||
createAction('project', 'search', 'get', 'search')
|
||||
|
||||
//interface
|
||||
|
@ -371,7 +371,7 @@ var projectController = function (_baseController) {
|
||||
|
||||
/**
|
||||
* 获取项目成员列表
|
||||
* @interface /project/get_member_list.json
|
||||
* @interface /project/get_member_list
|
||||
* @method GET
|
||||
* @category project
|
||||
* @foldnumber 10
|
||||
@ -427,7 +427,13 @@ var projectController = function (_baseController) {
|
||||
case 18:
|
||||
user = _context4.sent;
|
||||
|
||||
result.push(user);
|
||||
result.push({
|
||||
_id: user._id,
|
||||
email: user.email,
|
||||
role: user.role,
|
||||
add_time: user.add_time,
|
||||
up_time: user.up_time
|
||||
});
|
||||
|
||||
case 20:
|
||||
_iteratorNormalCompletion = true;
|
||||
@ -564,6 +570,8 @@ var projectController = function (_baseController) {
|
||||
* @category project
|
||||
* @foldnumber 10
|
||||
* @param {Number} group_id 项目group_id,不能为空
|
||||
* @param {Number} [pageNo] 分页页码
|
||||
* @param {Number} [pageSize] 分页大小
|
||||
* @returns {Object}
|
||||
* @example ./api/project/list.json
|
||||
*/
|
||||
@ -572,12 +580,12 @@ var projectController = function (_baseController) {
|
||||
key: 'list',
|
||||
value: function () {
|
||||
var _ref6 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee6(ctx) {
|
||||
var group_id, result;
|
||||
var group_id, pageNo, pageSize, result, resResult, i;
|
||||
return _regenerator2.default.wrap(function _callee6$(_context6) {
|
||||
while (1) {
|
||||
switch (_context6.prev = _context6.next) {
|
||||
case 0:
|
||||
group_id = ctx.request.query.group_id;
|
||||
group_id = ctx.request.query.group_id, pageNo = ctx.request.query.pageNo || 1, pageSize = ctx.request.query.pageSize || 10;
|
||||
|
||||
if (group_id) {
|
||||
_context6.next = 3;
|
||||
@ -593,23 +601,50 @@ var projectController = function (_baseController) {
|
||||
|
||||
case 6:
|
||||
result = _context6.sent;
|
||||
resResult = [];
|
||||
i = (pageNo - 1) * pageSize;
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context6.next = 13;
|
||||
case 9:
|
||||
if (!(i < pageNo * pageSize)) {
|
||||
_context6.next = 16;
|
||||
break;
|
||||
}
|
||||
|
||||
if (result[i]) {
|
||||
_context6.next = 12;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context6.abrupt('break', 16);
|
||||
|
||||
case 12:
|
||||
resResult.push(result[i]);
|
||||
|
||||
case 13:
|
||||
i++;
|
||||
_context6.next = 9;
|
||||
break;
|
||||
|
||||
case 10:
|
||||
_context6.prev = 10;
|
||||
case 16:
|
||||
ctx.body = _yapi2.default.commons.resReturn({
|
||||
total: result.length,
|
||||
list: resResult
|
||||
});
|
||||
_context6.next = 22;
|
||||
break;
|
||||
|
||||
case 19:
|
||||
_context6.prev = 19;
|
||||
_context6.t0 = _context6['catch'](3);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, e.message);
|
||||
|
||||
case 13:
|
||||
case 22:
|
||||
case 'end':
|
||||
return _context6.stop();
|
||||
}
|
||||
}
|
||||
}, _callee6, this, [[3, 10]]);
|
||||
}, _callee6, this, [[3, 19]]);
|
||||
}));
|
||||
|
||||
function list(_x6) {
|
||||
|
@ -618,6 +618,8 @@ var userController = function (_baseController) {
|
||||
* @method GET
|
||||
* @category user
|
||||
* @foldnumber 10
|
||||
* @param {Number} [pageNo] 分页页码
|
||||
* @param {Number} [pageSize] 分页大小
|
||||
* @returns {Object}
|
||||
* @example
|
||||
*/
|
||||
@ -626,39 +628,69 @@ var userController = function (_baseController) {
|
||||
key: 'list',
|
||||
value: function () {
|
||||
var _ref9 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee9(ctx) {
|
||||
var userInst, user;
|
||||
var pageNo, pageSize, userInst, user, result, i;
|
||||
return _regenerator2.default.wrap(function _callee9$(_context9) {
|
||||
while (1) {
|
||||
switch (_context9.prev = _context9.next) {
|
||||
case 0:
|
||||
pageNo = ctx.request.query.pageNo || 1, pageSize = ctx.request.query.pageSize || 10;
|
||||
|
||||
if (!(this.getRole() !== 'admin')) {
|
||||
_context9.next = 2;
|
||||
_context9.next = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context9.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 402, '没有权限'));
|
||||
|
||||
case 2:
|
||||
case 3:
|
||||
userInst = _yapi2.default.getInst(_user2.default);
|
||||
_context9.prev = 3;
|
||||
_context9.next = 6;
|
||||
_context9.prev = 4;
|
||||
_context9.next = 7;
|
||||
return userInst.list();
|
||||
|
||||
case 6:
|
||||
case 7:
|
||||
user = _context9.sent;
|
||||
return _context9.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(user));
|
||||
result = [];
|
||||
i = (pageNo - 1) * pageSize;
|
||||
|
||||
case 10:
|
||||
_context9.prev = 10;
|
||||
_context9.t0 = _context9['catch'](3);
|
||||
return _context9.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 402, _context9.t0.message));
|
||||
if (!(i < pageNo * pageSize)) {
|
||||
_context9.next = 17;
|
||||
break;
|
||||
}
|
||||
|
||||
if (user[i]) {
|
||||
_context9.next = 13;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context9.abrupt('break', 17);
|
||||
|
||||
case 13:
|
||||
result.push(user[i]);
|
||||
|
||||
case 14:
|
||||
i++;
|
||||
_context9.next = 10;
|
||||
break;
|
||||
|
||||
case 17:
|
||||
return _context9.abrupt('return', ctx.body = _yapi2.default.commons.resReturn({
|
||||
total: user.length,
|
||||
list: result
|
||||
}));
|
||||
|
||||
case 20:
|
||||
_context9.prev = 20;
|
||||
_context9.t0 = _context9['catch'](4);
|
||||
return _context9.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 402, _context9.t0.message));
|
||||
|
||||
case 23:
|
||||
case 'end':
|
||||
return _context9.stop();
|
||||
}
|
||||
}
|
||||
}, _callee9, this, [[3, 10]]);
|
||||
}, _callee9, this, [[4, 20]]);
|
||||
}));
|
||||
|
||||
function list(_x10) {
|
||||
|
@ -82,7 +82,7 @@ createAction('project', 'up', 'post', 'up');
|
||||
createAction('project', 'del', 'post', 'del');
|
||||
createAction('project', 'add_member', 'post', 'addMember');
|
||||
createAction('project', 'del_member', 'post', 'delMember');
|
||||
createAction('project', 'get_member_list.json', 'get', 'getMemberList');
|
||||
createAction('project', 'get_member_list', 'get', 'getMemberList');
|
||||
createAction('project', 'search', 'get', 'search');
|
||||
|
||||
//interface
|
||||
|
BIN
static/image/demo-img.png
Normal file
BIN
static/image/demo-img.png
Normal file
Binary file not shown.
After (image error) Size: 66 KiB |
Loading…
Reference in New Issue
Block a user