2017-07-11 19:12:13 +08:00
|
|
|
import './Interface.scss'
|
|
|
|
import React, { Component } from 'react'
|
|
|
|
import { connect } from 'react-redux'
|
|
|
|
import PropTypes from 'prop-types'
|
2017-07-20 15:38:25 +08:00
|
|
|
import axios from 'axios'
|
2017-07-11 19:12:13 +08:00
|
|
|
import InterfaceList from './InterfaceList/InterfaceList.js'
|
|
|
|
import InterfaceTable from './InterfaceTable/InterfaceTable.js'
|
2017-07-13 20:09:04 +08:00
|
|
|
import InterfaceMode from './InterfaceMode/InterfaceMode.js'
|
2017-07-24 10:59:17 +08:00
|
|
|
import moment from 'moment'
|
2017-07-18 18:25:53 +08:00
|
|
|
import {
|
2017-07-26 15:38:34 +08:00
|
|
|
fetchInterfaceData,
|
2017-07-13 20:09:04 +08:00
|
|
|
projectMember,
|
2017-07-26 16:25:34 +08:00
|
|
|
closeProjectMember,
|
|
|
|
saveInterfaceProjectId
|
2017-08-08 10:07:55 +08:00
|
|
|
} from '../../reducer/modules/interface.js'
|
2017-07-11 19:12:13 +08:00
|
|
|
|
|
|
|
@connect(
|
|
|
|
state => {
|
|
|
|
return {
|
2017-07-13 20:09:04 +08:00
|
|
|
interfaceData: state.Interface.interfaceData,
|
|
|
|
modalVisible: state.Interface.modalVisible,
|
2017-07-14 11:27:34 +08:00
|
|
|
closeProjectMember: state.Interface.closeProjectMember
|
2017-07-11 19:12:13 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2017-07-13 20:09:04 +08:00
|
|
|
fetchInterfaceData,
|
|
|
|
projectMember,
|
2017-07-26 16:25:34 +08:00
|
|
|
closeProjectMember,
|
|
|
|
saveInterfaceProjectId
|
2017-07-11 19:12:13 +08:00
|
|
|
}
|
|
|
|
)
|
2017-07-13 20:09:04 +08:00
|
|
|
|
2017-07-11 19:12:13 +08:00
|
|
|
class Interface extends Component {
|
|
|
|
static propTypes = {
|
2017-07-13 20:09:04 +08:00
|
|
|
fetchInterfaceData: PropTypes.func,
|
|
|
|
interfaceData: PropTypes.array,
|
|
|
|
projectMember: PropTypes.func,
|
2017-07-26 16:25:34 +08:00
|
|
|
saveInterfaceProjectId: PropTypes.func,
|
2017-07-13 20:09:04 +08:00
|
|
|
closeProjectMember: PropTypes.func,
|
2017-07-14 11:27:34 +08:00
|
|
|
modalVisible: PropTypes.bool
|
2017-07-11 19:12:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props)
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillMount () {
|
2017-07-25 17:41:58 +08:00
|
|
|
const interfaceId = this.getInterfaceId()
|
2017-07-20 15:38:25 +08:00
|
|
|
const params = {
|
2017-07-20 16:34:46 +08:00
|
|
|
params: {
|
2017-07-28 17:44:28 +08:00
|
|
|
project_id: interfaceId
|
2017-07-20 16:34:46 +08:00
|
|
|
}
|
2017-07-20 15:38:25 +08:00
|
|
|
}
|
|
|
|
|
2017-07-26 16:25:34 +08:00
|
|
|
this.props.saveInterfaceProjectId(interfaceId)
|
2017-07-20 15:38:25 +08:00
|
|
|
axios.get('/interface/list', params)
|
2017-07-24 10:59:17 +08:00
|
|
|
.then(result => {
|
|
|
|
result = result.data.data
|
|
|
|
result.map(value => {
|
2017-07-26 19:07:29 +08:00
|
|
|
value.add_time = moment(value.add_time*1000).format('YYYY-MM-DD HH:mm:ss')
|
2017-07-24 10:59:17 +08:00
|
|
|
return value
|
|
|
|
})
|
|
|
|
this.props.fetchInterfaceData(result)
|
2017-07-20 15:38:25 +08:00
|
|
|
})
|
|
|
|
.catch(e => {
|
|
|
|
console.log(e)
|
|
|
|
})
|
2017-07-11 19:12:13 +08:00
|
|
|
}
|
|
|
|
|
2017-07-25 17:41:58 +08:00
|
|
|
getInterfaceId () {
|
2017-07-28 17:30:56 +08:00
|
|
|
const reg = /project\/(\d+)/g
|
2017-07-25 17:41:58 +08:00
|
|
|
const url = location.href
|
|
|
|
url.match(reg)
|
|
|
|
return RegExp.$1
|
|
|
|
}
|
|
|
|
|
2017-07-11 19:12:13 +08:00
|
|
|
render () {
|
2017-07-13 20:09:04 +08:00
|
|
|
const { interfaceData, projectMember, modalVisible } = this.props
|
2017-07-11 19:12:13 +08:00
|
|
|
return (
|
2017-07-27 16:29:28 +08:00
|
|
|
<div className="g-doc">
|
2017-07-14 14:44:32 +08:00
|
|
|
<section className="interface-box">
|
|
|
|
<InterfaceList projectMember={projectMember} />
|
|
|
|
<InterfaceMode modalVisible={modalVisible} closeProjectMember={this.props.closeProjectMember} />
|
|
|
|
<InterfaceTable data={interfaceData} />
|
|
|
|
</section>
|
|
|
|
</div>
|
2017-07-11 19:12:13 +08:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-24 10:59:17 +08:00
|
|
|
export default Interface
|