|
|
@@ -1,15 +1,14 @@
|
|
|
import React, {Component} from 'react';
|
|
|
import {Switch, Input, Icon, Spin, Row, Col, message} from 'antd';
|
|
|
-import {GET_PROJECT, SHOW_APIGWPATH} from "../../../gql";
|
|
|
+import {GET_PROJECT, SHOW_APIGWPATH, UPDATE_APIGROUP} from "../../../gql";
|
|
|
import gql from "graphql-tag";
|
|
|
-import {Query} from "react-apollo";
|
|
|
+import {Query, Mutation} from "react-apollo";
|
|
|
import copy from 'copy-to-clipboard';
|
|
|
|
|
|
class TencentResult extends Component {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
- this.state = {
|
|
|
- }
|
|
|
+ this.state = {}
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
@@ -24,7 +23,6 @@ class TencentResult extends Component {
|
|
|
if (error) {
|
|
|
return 'error!';
|
|
|
}
|
|
|
- // console.log(data);
|
|
|
let group = data.project_by_id.apiGWGroup_id || {};
|
|
|
return (
|
|
|
<div>
|
|
|
@@ -61,14 +59,19 @@ class TencentResult extends Component {
|
|
|
</Col>
|
|
|
<Col span={3}>
|
|
|
<span className={'schema-table-content'}>
|
|
|
- <SwitchStatus />
|
|
|
+ <SwitchStatus group={group}/>
|
|
|
+ {/*<span className={'schema-table-content name'}>删除</span>*/}
|
|
|
</span>
|
|
|
</Col>
|
|
|
</Row>
|
|
|
</div>
|
|
|
<div style={{marginTop: 30}}>
|
|
|
<div className={'schema-name'}>API 管理</div>
|
|
|
- <APIGWPathResult groupID={group.id}/>
|
|
|
+ <APIGWPathResult
|
|
|
+ group={group}
|
|
|
+ switchMenu={this.props.switchMenu}
|
|
|
+ switchAPI={this.props.switchAPI}
|
|
|
+ />
|
|
|
</div>
|
|
|
</div>
|
|
|
:
|
|
|
@@ -89,16 +92,53 @@ class SwitchStatus extends Component {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
this.state = {
|
|
|
-
|
|
|
+ checked: props.group.userStatus === 'open'
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ componentWillReceiveProps(next) {
|
|
|
+ this.setState({
|
|
|
+ checked: next.group.userStatus === 'open'
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
render() {
|
|
|
+ let {group} = this.props;
|
|
|
+ let {id, userDomain, groupName, frontType, region, environmentName} = group;
|
|
|
return (
|
|
|
- <div>
|
|
|
- <Switch defaultChecked onChange={(checked) => {
|
|
|
- this.setState({checked})
|
|
|
- }}/>
|
|
|
+ <div style={{display: 'inline', marginRight: '10px'}}>
|
|
|
+ <Mutation
|
|
|
+ mutation={gql(UPDATE_APIGROUP)}
|
|
|
+ onCompleted={(data) => {
|
|
|
+ this.setState({
|
|
|
+ checked: data.update_apiGWGroup.userStatus === 'open'
|
|
|
+ })
|
|
|
+ }}
|
|
|
+ >
|
|
|
+
|
|
|
+ {(update_apiGWGroup, {loading, error}) => {
|
|
|
+ if (loading)
|
|
|
+ return <Spin style={{marginLeft: 30, marginTop: 10}}/>;
|
|
|
+ if (error)
|
|
|
+ return 'error';
|
|
|
+ return (
|
|
|
+ <Switch checked={this.state.checked} onChange={(checked) => {
|
|
|
+ update_apiGWGroup({
|
|
|
+ variables: {
|
|
|
+ id,
|
|
|
+ userStatus: checked ? 'open' : 'close',
|
|
|
+ userDomain,
|
|
|
+ groupName,
|
|
|
+ frontType,
|
|
|
+ region,
|
|
|
+ environmentName,
|
|
|
+ updatedAt: new Date().getTime()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }}/>
|
|
|
+ )
|
|
|
+ }}
|
|
|
+ </Mutation>
|
|
|
</div>
|
|
|
)
|
|
|
}
|
|
|
@@ -107,15 +147,14 @@ class SwitchStatus extends Component {
|
|
|
class APIGWPathResult extends Component {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
- this.state = {
|
|
|
-
|
|
|
- }
|
|
|
+ this.state = {}
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
- let {groupID} = this.props;
|
|
|
+ let {group} = this.props;
|
|
|
+ let {id, frontType, defaultDomain, environmentName} = group;
|
|
|
return (
|
|
|
- <Query query={gql(SHOW_APIGWPATH)} variables={{apiGWGroup_id: groupID}}>
|
|
|
+ <Query query={gql(SHOW_APIGWPATH)} variables={{apiGWGroup_id: id}}>
|
|
|
{
|
|
|
({loading, error, data}) => {
|
|
|
if (loading) {
|
|
|
@@ -156,9 +195,15 @@ class APIGWPathResult extends Component {
|
|
|
<span className={'schema-table-content'}>{path.apiGWDesc}</span>
|
|
|
</Col>
|
|
|
<Col span={3}>
|
|
|
- <span className={'schema-table-content name'}>删除</span>
|
|
|
- <span> </span>
|
|
|
- <span className={'schema-table-content name'}>调试</span>
|
|
|
+ {/*<span className={'schema-table-content name'}>删除</span>*/}
|
|
|
+ {/*<span> </span>*/}
|
|
|
+ <span className={'schema-table-content name'}
|
|
|
+ onClick={() => {
|
|
|
+ this.props.switchMenu('menuLevel2', {key: 'graphiql'});
|
|
|
+ this.props.switchAPI(frontType.slice(0, 4) + '://' + defaultDomain +'/'+ environmentName +path.apiGWPath)
|
|
|
+ }}>
|
|
|
+ 调试
|
|
|
+ </span>
|
|
|
</Col>
|
|
|
</Row>
|
|
|
</div>
|