2017-07-14 18:02:01 +08:00
|
|
|
|
import {
|
2017-07-18 17:46:09 +08:00
|
|
|
|
FETCH_PROJECT_LIST,
|
2017-07-18 22:08:01 +08:00
|
|
|
|
PROJECT_ADD,
|
2017-07-19 20:59:59 +08:00
|
|
|
|
PROJECT_DEL,
|
2017-07-19 21:21:40 +08:00
|
|
|
|
CHANGE_UPDATE_MODAL,
|
|
|
|
|
PROJECT_UPDATE,
|
|
|
|
|
CHANGE_TABLE_LOADING
|
2017-07-14 18:02:01 +08:00
|
|
|
|
} from '../constants/action-types.js';
|
|
|
|
|
import axios from 'axios';
|
2017-07-19 22:31:18 +08:00
|
|
|
|
import variable from '../constants/variable';
|
2017-07-14 18:02:01 +08:00
|
|
|
|
|
2017-07-19 22:31:18 +08:00
|
|
|
|
const fetchProjectList = (id, pageNum) => {
|
2017-07-18 17:46:09 +08:00
|
|
|
|
return {
|
|
|
|
|
type: FETCH_PROJECT_LIST,
|
2017-07-19 22:31:18 +08:00
|
|
|
|
payload: axios.get('/project/list', {
|
|
|
|
|
params: {
|
|
|
|
|
group_id: id,
|
2017-07-23 17:31:14 +08:00
|
|
|
|
page: pageNum || 1,
|
2017-07-19 22:31:18 +08:00
|
|
|
|
limit: variable.PAGE_LIMIT
|
|
|
|
|
}
|
|
|
|
|
})
|
2017-07-18 22:08:01 +08:00
|
|
|
|
};
|
|
|
|
|
};
|
2017-07-18 17:46:09 +08:00
|
|
|
|
|
2017-07-19 20:59:59 +08:00
|
|
|
|
const changeUpdateModal = (data, index) => {
|
|
|
|
|
return {
|
2017-07-19 21:21:40 +08:00
|
|
|
|
type: CHANGE_UPDATE_MODAL,
|
2017-07-19 20:59:59 +08:00
|
|
|
|
payload: { data, index }
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2017-07-19 21:21:40 +08:00
|
|
|
|
const changeTableLoading = (data) => {
|
|
|
|
|
return {
|
|
|
|
|
type: CHANGE_TABLE_LOADING,
|
|
|
|
|
payload: data
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2017-07-14 18:02:01 +08:00
|
|
|
|
const addProject = (data) => {
|
2017-07-20 17:53:28 +08:00
|
|
|
|
const { name, prd_host, basepath, desc, group_id, protocol } = data;
|
2017-07-14 18:02:01 +08:00
|
|
|
|
const param = {
|
|
|
|
|
name,
|
|
|
|
|
prd_host,
|
2017-07-20 17:53:28 +08:00
|
|
|
|
protocol,
|
2017-07-14 18:02:01 +08:00
|
|
|
|
basepath,
|
2017-07-18 14:58:57 +08:00
|
|
|
|
desc,
|
|
|
|
|
group_id
|
2017-07-18 22:08:01 +08:00
|
|
|
|
};
|
2017-07-14 18:02:01 +08:00
|
|
|
|
return {
|
|
|
|
|
type: PROJECT_ADD,
|
|
|
|
|
// payload 可以返回 Promise,异步请求使用 axios 即可
|
2017-07-18 10:56:03 +08:00
|
|
|
|
payload: axios.post('/project/add', param)
|
2017-07-18 22:08:01 +08:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2017-07-19 20:59:59 +08:00
|
|
|
|
const updateProject = (data) => {
|
2017-07-23 17:31:14 +08:00
|
|
|
|
const { name, prd_host, basepath, desc, _id, protocol, env } = data;
|
2017-07-19 20:59:59 +08:00
|
|
|
|
const param = {
|
|
|
|
|
name,
|
|
|
|
|
prd_host,
|
2017-07-20 17:53:28 +08:00
|
|
|
|
protocol,
|
2017-07-19 20:59:59 +08:00
|
|
|
|
basepath,
|
|
|
|
|
desc,
|
2017-07-23 17:31:14 +08:00
|
|
|
|
id: _id,
|
|
|
|
|
env
|
2017-07-19 20:59:59 +08:00
|
|
|
|
};
|
|
|
|
|
return {
|
|
|
|
|
type: PROJECT_UPDATE,
|
|
|
|
|
// payload 可以返回 Promise,异步请求使用 axios 即可
|
|
|
|
|
payload: axios.post('/project/up', param)
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2017-07-18 22:08:01 +08:00
|
|
|
|
const delProject = (id) => {
|
|
|
|
|
const param = { id };
|
|
|
|
|
return {
|
|
|
|
|
type: PROJECT_DEL,
|
|
|
|
|
// payload 可以返回 Promise,异步请求使用 axios 即可
|
|
|
|
|
payload: axios.post('/project/del', param)
|
|
|
|
|
};
|
|
|
|
|
};
|
2017-07-14 18:02:01 +08:00
|
|
|
|
|
|
|
|
|
export default {
|
2017-07-18 17:46:09 +08:00
|
|
|
|
fetchProjectList,
|
2017-07-18 22:08:01 +08:00
|
|
|
|
addProject,
|
2017-07-19 20:59:59 +08:00
|
|
|
|
delProject,
|
|
|
|
|
changeUpdateModal,
|
2017-07-19 21:21:40 +08:00
|
|
|
|
updateProject,
|
|
|
|
|
changeTableLoading
|
2017-07-18 22:08:01 +08:00
|
|
|
|
};
|