Quellcode durchsuchen

Merge branch 'master' of http://gogs.ioobot.com:6680/xy/online

wly vor 7 Jahren
Ursprung
Commit
f9b3d5d29d

+ 1 - 1
src/app/App.jsx

@@ -364,7 +364,7 @@ class GraphqlSidebar extends Component {
                     ({loading, error, data}) => {
                         if (loading) return <Spin style={{marginLeft: 3}}/>;
                         if (error) return 'error!';
-                        console.log('CASE_SCHEMA_AND_PROJECT data', data);
+                        // console.log('CASE_SCHEMA_AND_PROJECT data', data);
                         localStorage.setItem('ecommerce', data.caseProject.find(project => project.schema_id.schemaName === 'ecommerce').schema_id.schemaData);
                         localStorage.setItem('subscribe', data.caseProject.find(project => project.schema_id.schemaName === 'subscribe').schema_id.schemaData);
                         localStorage.setItem('bills', data.caseProject.find(project => project.schema_id.schemaName === 'bills').schema_id.schemaData);

+ 8 - 12
src/app/common/deploy/Deploy.jsx

@@ -8,22 +8,18 @@ import AmazonConfig from './amazon/AmazonConfig';
 
 import './index.css';
 
-const tabListNoTitle = [{
+const tabListNoTitle =
+[{
     key: 'tencent',
     tab: <FormattedMessage id='Tencent'/>,
+}, {
+    key: 'aliyun',
+    tab: <FormattedMessage id='Aliyun'/>,
+}, {
+    key: 'amazon',
+    tab: <FormattedMessage id='AWS'/>,
 }];
 
-// [{
-//     key: 'tencent',
-//     tab: <FormattedMessage id='Tencent'/>,
-// }, {
-//     key: 'aliyun',
-//     tab: <FormattedMessage id='Aliyun'/>,
-// }, {
-//     key: 'amazon',
-//     tab: <FormattedMessage id='AWS'/>,
-// }];
-
 
 class Deploy extends Component {
     constructor(props) {

+ 2 - 2
src/app/common/deploy/ali/AliConfig.jsx

@@ -1,5 +1,5 @@
 import React, {Component} from 'react';
-
+import {FormattedMessage} from 'react-intl';
 
 class AliConfig extends Component {
     constructor(props) {
@@ -13,7 +13,7 @@ class AliConfig extends Component {
     render() {
         return (
             <div>
-                aliyun
+                <p><b><FormattedMessage id="It is under development, please look forward to it. Thank you for your attention"/></b></p>
             </div>
         )
     }

+ 2 - 2
src/app/common/deploy/amazon/AmazonConfig.js

@@ -1,5 +1,5 @@
 import React, {Component} from 'react';
-
+import {FormattedMessage} from 'react-intl';
 
 class AmazonConfig extends Component {
     constructor(props) {
@@ -13,7 +13,7 @@ class AmazonConfig extends Component {
     render() {
         return (
             <div>
-                amazon
+                <p><b><FormattedMessage id="It is under development, please look forward to it. Thank you for your attention"/></b></p>
             </div>
         )
     }

+ 2 - 2
src/app/common/deploy/huawei/HuaweiConfig.jsx

@@ -1,5 +1,5 @@
 import React, {Component} from 'react';
-
+import {FormattedMessage} from 'react-intl';
 
 class HuaweiConfig extends Component {
     constructor(props) {
@@ -13,7 +13,7 @@ class HuaweiConfig extends Component {
     render() {
         return (
             <div>
-                huawei
+                <p><b><FormattedMessage id="It is under development, please look forward to it. Thank you for your attention"/></b></p>
             </div>
         )
     }

+ 22 - 11
src/app/common/deploy/tencent/APIGroupCard.js

@@ -31,6 +31,16 @@ const toolTipTitle = {
     'region': 'its region',
 };
 
+const youMustFill = {
+    'groupName': true,
+    'environmentName': true,
+    'defaultDomain': true,
+    'frontType': true,
+    'userDomain': true,
+    'userStatus': true,
+    'region': true,
+};
+
 const removePrefix = (prefix, value) => {
     let r = new RegExp(prefix);
     return value.replace(r, '');
@@ -44,8 +54,8 @@ const shiftPrefix = (prefix, value) => {
 class APIGroupCard extends Component {
     constructor(props) {
         super(props);
-        let {groupName, environmentName, defaultDomain, frontType, userDomain, userStatus, region} = props.group;
-        props.group !== '' ?
+        if(props.group !== '' && props.group !== null) {
+            let {groupName, environmentName, defaultDomain, frontType, userDomain, userStatus, region} = props.group;
             this.state = {
                 showOK: false,
                 groupName,
@@ -56,7 +66,7 @@ class APIGroupCard extends Component {
                 userStatus,
                 groupRegion: region
             }
-            :
+        } else {
             this.state = {
                 showOK: false,
                 groupName: 'graphql_endpoint',
@@ -67,10 +77,11 @@ class APIGroupCard extends Component {
                 userStatus: 'open',
                 groupRegion: props.region === '' ? 'ap-beijing' : props.region,
             };
+        }
     }
 
     componentWillReceiveProps(next) {
-        if(next.group !== '') {
+        if(next.group !== '' && next.group !== null) {
             let {groupName, environmentName, defaultDomain, frontType, userDomain, userStatus, region} = next.group;
             this.setState( {
                 groupName,
@@ -179,7 +190,7 @@ class APIGroupCard extends Component {
             <div>
                 <div style={{marginBottom: 10}}>
                             <span className='vice-title'>{valueToKey['groupName']}
-                                <span> </span>
+                                &nbsp;
                                 <Tooltip placement="top" title={toolTipTitle['groupName']}>
                                     <Icon type="question-circle"/>
                                 </Tooltip>
@@ -190,7 +201,7 @@ class APIGroupCard extends Component {
 
                 <div style={{marginBottom: 10}}>
                             <span className='vice-title'>{valueToKey['region']}
-                                <span> </span>
+                                &nbsp;
                                 <Tooltip placement="top" title={toolTipTitle['region']}>
                                     <Icon type="question-circle"/>
                                 </Tooltip>
@@ -209,7 +220,7 @@ class APIGroupCard extends Component {
 
                 <div style={{marginBottom: 10}}>
                             <span className='vice-title'>{valueToKey['environmentName']}
-                                <span> </span>
+                                &nbsp;
                                 <Tooltip placement="top" title={toolTipTitle['environmentName']}>
                                     <Icon type="question-circle"/>
                                 </Tooltip>
@@ -226,7 +237,7 @@ class APIGroupCard extends Component {
 
                         <div style={{marginBottom: 10}}>
                             <span className='vice-title'>{valueToKey['frontType']}
-                                <span> </span>
+                                &nbsp;
                                 <Tooltip placement="top" title={toolTipTitle['frontType']}>
                                     <Icon type="question-circle"/>
                                 </Tooltip>
@@ -240,7 +251,7 @@ class APIGroupCard extends Component {
                         </div>
                         {/*<div style={{marginBottom: 10}}>*/}
                             {/*<span className='vice-title'>{valueToKey['defaultDomain']}*/}
-                                {/*<span> </span>*/}
+                                {/*&nbsp;*/}
                                 {/*<Tooltip placement="top" title={toolTipTitle['defaultDomain']}>*/}
                                     {/*<Icon type="question-circle"/>*/}
                                 {/*</Tooltip>*/}
@@ -250,7 +261,7 @@ class APIGroupCard extends Component {
 
                         <div style={{marginBottom: 10}}>
                             <span className='vice-title'>{valueToKey['userDomain']}
-                                <span> </span>
+                                &nbsp;
                                 <Tooltip placement="top" title={toolTipTitle['userDomain']}>
                                     <Icon type="question-circle"/>
                                 </Tooltip>
@@ -260,7 +271,7 @@ class APIGroupCard extends Component {
                         </div>
                         {/*<div style={{marginBottom: 10}}>*/}
                             {/*<span className='vice-title'>{valueToKey['userStatus']}*/}
-                                {/*<span> </span>*/}
+                                {/*&nbsp;*/}
                                 {/*<Tooltip placement="top" title={toolTipTitle['userStatus']}>*/}
                                     {/*<Icon type="question-circle"/>*/}
                                 {/*</Tooltip>*/}

+ 14 - 7
src/app/common/deploy/tencent/APIPathCard.js

@@ -23,11 +23,17 @@ const toolTipTitle = {
     'requestMethod': 'its requestMethod'
 };
 
+const youMustFill = {
+    'apiGWName': true,
+    'apiGWDesc': true,
+    'requestMethod': true
+};
+
 class APIPathCard extends Component {
     constructor(props) {
         super(props);
-        let {apiGWName, apiGWDesc, requestMethod} = props.path;
-        props.path !== '' ?
+        if(props.path !== '' && props.path !== null) {
+            let {apiGWName, apiGWDesc, requestMethod} = props.path;
             this.state = {
                 configs: ['apiGWName', 'apiGWDesc'],
                 showOK: false,
@@ -35,7 +41,7 @@ class APIPathCard extends Component {
                 apiGWDesc,
                 requestMethod: requestMethod
             }
-            :
+        } else {
             this.state = {
                 configs: ['apiGWName', 'apiGWDesc'],
                 showOK: false,
@@ -43,11 +49,12 @@ class APIPathCard extends Component {
                 apiGWDesc: '',
                 requestMethod: 'GET'
             };
+        }
     }
 
 
     componentWillReceiveProps(next) {
-        if (next.path !== '') {
+        if (next.path !== '' && next.path !== null) {
             let {apiGWName, apiGWDesc, requestMethod} = next.path;
             this.setState({
                 apiGWName,
@@ -89,7 +96,7 @@ class APIPathCard extends Component {
             updatedAt: ''
         };
         if (this.props.path === '') {
-            if(this.props.deployID !== '' && this.props.groupID!=='') {
+            if(this.props.deployID !== '' && this.props.groupID!=='' && this.props.deployID !== null && this.props.groupID!==null) {
                 request(graphqlUrl, ADD_APIGWPATH, varObj).then(
                     data => {
                         if (data.create_apiGWPath !== null) {
@@ -148,7 +155,7 @@ class APIPathCard extends Component {
                             this.state.configs.map(config => (
                                 <div key={config} style={{marginBottom: 10}}>
                                     <span className='vice-title'>{valueToKey[config]}
-                                        <span> </span>
+                                        &nbsp;
                                         <Tooltip placement="top" title={toolTipTitle[config]}>
                                             <Icon type="question-circle"/>
                                         </Tooltip>
@@ -160,7 +167,7 @@ class APIPathCard extends Component {
                         }
                         <div style={{marginBottom: 10}}>
                             <span className='vice-title'>{valueToKey['requestMethod']}
-                                <span> </span>
+                                &nbsp;
                                 <Tooltip placement="top" title={toolTipTitle['requestMethod']}>
                                     <Icon type="question-circle"/>
                                 </Tooltip>

+ 21 - 8
src/app/common/deploy/tencent/DeployCard.js

@@ -35,6 +35,18 @@ const toolTipTitle = {
     'description': 'its description',
 };
 
+const youMustFill = {
+    'functionName': true,
+    'cosBucketName': true,
+    'cosObjectName': true,
+    'cosBucketRegion': true,
+    'serviceName': true,
+    'subnetId': false,
+    'vpcId': false,
+    'region': true,
+    'description': false,
+};
+
 const removePrefix = (prefix, value) => {
     let r = new RegExp(prefix);
     return value.replace(r, '');
@@ -48,8 +60,8 @@ const shiftPrefix = (prefix, value) => {
 class DeployCard extends Component {
     constructor(props) {
         super(props);
-        let {functionName, cosBucketName, cosObjectName, cosBucketRegion, serviceName, vpcId, subnetId, region, description} = props.deploy;
-        props.deploy !== '' ?
+        if(props.deploy !== '' && props.deploy !== null) {
+            let {functionName, cosBucketName, cosObjectName, cosBucketRegion, serviceName, vpcId, subnetId, region, description} = props.deploy;
             this.state = {
                 configs: ['cosBucketName', 'cosObjectName', 'description', 'vpcId', 'subnetId'],
                 description,
@@ -63,7 +75,7 @@ class DeployCard extends Component {
                 vpcId,
                 subnetId
             }
-            :
+        } else {
             this.state = {
                 configs: ['cosBucketName', 'cosObjectName', 'description', 'vpcId', 'subnetId'],
                 description: '',
@@ -77,10 +89,11 @@ class DeployCard extends Component {
                 vpcId: '',
                 subnetId: '',
             };
+        }
     }
 
     componentWillReceiveProps(next) {
-        if (next.deploy !== '') {
+        if (next.deploy !== '' && next.deploy !== null) {
             let {functionName, cosBucketName, cosObjectName, cosBucketRegion, serviceName, vpcId, subnetId, region, description} = next.deploy;
             this.setState({
                 description,
@@ -207,7 +220,7 @@ class DeployCard extends Component {
             <div>
                 <div style={{marginBottom: 10}}>
                     <span className='vice-title'>{valueToKey['functionName']}
-                        <span> </span>
+                        &nbsp;
                         <Tooltip placement="top" title={toolTipTitle['functionName']}>
                             <Icon type="question-circle"/>
                         </Tooltip>
@@ -217,7 +230,7 @@ class DeployCard extends Component {
                 </div>
                 <div style={{marginBottom: 10}}>
                     <span className='vice-title'>{valueToKey['region']}
-                        <span> </span>
+                        &nbsp;
                         <Tooltip placement="top" title={toolTipTitle['region']}>
                             <Icon type="question-circle"/>
                         </Tooltip>
@@ -236,7 +249,7 @@ class DeployCard extends Component {
                     <Panel header="Want more options?" style={customPanelStyle}>
                         <div style={{marginBottom: 10}}>
                             <span className='vice-title'>{valueToKey['cosBucketRegion']}
-                                <span> </span>
+                                &nbsp;
                                 <Tooltip placement="top" title={toolTipTitle['cosBucketRegion']}>
                                     <Icon type="question-circle"/>
                                 </Tooltip>
@@ -268,7 +281,7 @@ class DeployCard extends Component {
                             this.state.configs.map(config => (
                                 <div key={config} style={{marginBottom: 10}}>
                                     <span className='vice-title'>{valueToKey[config]}
-                                        <span> </span>
+                                        &nbsp;
                                         <Tooltip placement="top" title={toolTipTitle[config]}>
                                             <Icon type="question-circle"/>
                                         </Tooltip>

+ 38 - 22
src/app/common/deploy/tencent/TencentConfig.js

@@ -1,5 +1,5 @@
 import React, {Component} from 'react';
-import {Row, Col, Card, Button, Spin} from 'antd';
+import {Row, Col, Card, Button, Spin, Alert} from 'antd';
 import axios from 'axios';
 import APIGroupCard from './APIGroupCard';
 import APIPathCard from './APIPathCard';
@@ -40,7 +40,7 @@ class TencentConfig extends Component {
     };
 
     pass = (value, kind) => {
-        if(kind === 'deploy')
+        if (kind === 'deploy')
             this.setState({
                 deployIdPassToPath: value
             });
@@ -54,23 +54,23 @@ class TencentConfig extends Component {
         let _this = this;
 
         axios.get(`${deployUrl}`,
-        // axios.get(`http://localhost:8999/graphql/deployall`,
+            // axios.get(`http://localhost:8999/graphql/deployall`,
             {
                 params: {
                     'cloud-name': 'tencent',
-                    schema:"ecommerce_schemaID",
-                    deploy:"deploy_1544504304478_57468453",
-                    api:"path_1544504334478_82625598",
-                    group:"group_1544504325443_46750115"
+                    schema: "ecommerce_schemaID",
+                    deploy: "deploy_1544504304478_57468453",
+                    api: "path_1544504334478_82625598",
+                    group: "group_1544504325443_46750115"
                 }
             })
             .then((res) => {
                 console.log('deploy res', res);
             })
             .catch((err) => {
-                console.log('err',err);
-                console.log('err.response',err.response);
-                console.log('err.response.data',err.response.data);
+                console.log('err', err);
+                console.log('err.response', err.response);
+                console.log('err.response.data', err.response.data);
             });
     };
 
@@ -91,9 +91,9 @@ class TencentConfig extends Component {
                         let group = '',
                             deploy = '',
                             path = '',
-                            cloudID= 'tencent_CloudID';
+                            cloudID = 'tencent_CloudID';
 
-                        if(data.project_by_id.cloud_id !== null && data.project_by_id.cloud_id.cloudName === 'tencent') {
+                        if (data.project_by_id.cloud_id !== null && data.project_by_id.cloud_id.cloudName === 'tencent') {
                             group = data.project_by_id.apiGWGroup_id;
                             deploy = data.project_by_id.deploy_id;
                             cloudID = data.project_by_id.cloud_id.id;
@@ -101,9 +101,23 @@ class TencentConfig extends Component {
                         let defaultName = data.project_by_id.projectName;
                         return (
                             <div>
+                                {
+                                    data.project_by_id.schema_id.schemaState === 'ok' ?
+                                        ''
+                                        :
+                                        this.props.trialcase ?
+                                            ''
+                                            :
+                                            <div style={{marginBottom: 10}}>
+                                                <Alert message="数据表结构不符合规范,暂不能部署,请修改" type="warning"
+                                                       banner closable/>
+                                            </div>
+                                }
                                 <div style={{padding: '30px'}}>
                                     <Row gutter={16}>
                                         <Col span={14}>
+
+
                                             <FormattedMessage id="fc Deploy">
                                                 {
                                                     msg =>
@@ -137,7 +151,8 @@ class TencentConfig extends Component {
                                                         </Card>
                                                 }
                                             </FormattedMessage>
-                                            <Query query={gql(SHOW_APIGWPATH)} variables={{apiGWGroup_id: data.project_by_id.apiGWGroup_id? data.project_by_id.apiGWGroup_id.id : ''}}>
+                                            <Query query={gql(SHOW_APIGWPATH)}
+                                                   variables={{apiGWGroup_id: data.project_by_id.apiGWGroup_id ? data.project_by_id.apiGWGroup_id.id : ''}}>
                                                 {
                                                     ({loading, error, data}) => {
                                                         if (loading) {
@@ -146,7 +161,7 @@ class TencentConfig extends Component {
                                                         if (error) {
                                                             return 'error!';
                                                         }
-                                                        if(data.apiGWPath_by_props.length>0)
+                                                        if (data.apiGWPath_by_props.length > 0)
                                                             path = data.apiGWPath_by_props[0];
                                                         return (
                                                             <FormattedMessage id="API Path">
@@ -158,12 +173,12 @@ class TencentConfig extends Component {
                                                                                 defalutName={defaultName}
                                                                                 userID={this.props.userID}
                                                                                 trialcase={this.props.trialcase}
-                                                                                deployID={deploy? deploy.id : this.state.deployIdPassToPath}
-                                                                                groupID={group? group.id : this.state.groupIdPassToPath}
+                                                                                deployID={deploy ? deploy.id : this.state.deployIdPassToPath}
+                                                                                groupID={group ? group.id : this.state.groupIdPassToPath}
                                                                             />
                                                                         </Card>
                                                                 }
-                                                                </FormattedMessage>
+                                                            </FormattedMessage>
                                                         )
                                                     }
                                                 }
@@ -181,14 +196,15 @@ class TencentConfig extends Component {
                                             </FormattedMessage>
                                         </Col>
                                         <Col offset={2} span={6}>
-                                            <Button type='primary' disabled={data.project_by_id.schema_id.schemaState === 'ok'? '': 'disabled'} onClick={()=>this.deployFC()}><FormattedMessage id="deploy"/>!</Button>
                                             {
-                                                data.project_by_id.schema_id.schemaState === 'ok'?
+                                                this.props.trialcase ?
                                                     ''
                                                     :
-                                                    <div>
-                                                        <span>if button is disabled, check your schema</span>
-                                                    </div>
+                                                    data.project_by_id.schema_id.schemaState === 'ok' ?
+                                                        <Button type='primary' onClick={() => this.deployFC()}><FormattedMessage id="deploy"/>!</Button>
+                                                        :
+                                                        <Button type='primary' disabled><FormattedMessage id="deploy"/>!</Button>
+
                                             }
                                         </Col>
                                     </Row>

+ 3 - 18
src/app/common/manage/AliyunResult.js

@@ -1,34 +1,19 @@
 import React, {Component} from 'react';
 import {Switch, Input, Icon} from 'antd';
+import {FormattedMessage} from 'react-intl';
 
 class AliyunResult extends Component {
     constructor(props) {
         super(props);
         this.state = {
-            url: '1111',
-            checked: true
+
         }
     }
 
     render() {
         return (
             <div>
-                <div style={{width: 300}}>
-                    <span>URL: </span>
-                    <Input
-                        placeholder="display your URL"
-                        prefix={<Icon type="copy"/>}
-                        value={this.state.url}
-                        onChange={() => {}}
-                        disabled={!this.state.checked}
-                    />
-                </div>
-                <div style={{marginTop: 30}}>
-                    <span>fc switch </span>
-                    <Switch defaultChecked onChange={(checked) => {
-                        this.setState({checked})
-                    }}/>
-                </div>
+                <p><b><FormattedMessage id="It is under development, please look forward to it. Thank you for your attention"/></b></p>
             </div>
         )
     }

+ 2 - 17
src/app/common/manage/AmazonResult.js

@@ -1,6 +1,6 @@
 import React, {Component} from 'react';
 import {Switch, Input, Icon} from 'antd';
-
+import {FormattedMessage} from 'react-intl';
 class AmazonResult extends Component {
     constructor(props) {
         super(props);
@@ -13,22 +13,7 @@ class AmazonResult extends Component {
     render() {
         return (
             <div>
-                <div style={{width: 300}}>
-                    <span>URL: </span>
-                    <Input
-                        placeholder="display your URL"
-                        prefix={<Icon type="copy"/>}
-                        value={this.state.url}
-                        onChange={() => {}}
-                        disabled={!this.state.checked}
-                    />
-                </div>
-                <div style={{marginTop: 30}}>
-                    <span>fc switch </span>
-                    <Switch defaultChecked onChange={(checked) => {
-                        this.setState({checked})
-                    }}/>
-                </div>
+                <p><b><FormattedMessage id="It is under development, please look forward to it. Thank you for your attention"/></b></p>
             </div>
         )
     }

+ 8 - 12
src/app/common/manage/Manage.jsx

@@ -7,22 +7,18 @@ import AliyunResult from './AliyunResult';
 import AmazonResult from './AmazonResult';
 
 
-const tabListNoTitle = [{
+const tabListNoTitle =
+[{
     key: 'tencent',
     tab: <FormattedMessage id='Tencent'/>,
+}, {
+    key: 'aliyun',
+    tab: <FormattedMessage id='Aliyun'/>,
+}, {
+    key: 'amazon',
+    tab: <FormattedMessage id='AWS'/>,
 }];
 
-// [{
-//     key: 'tencent',
-//     tab: <FormattedMessage id='Tencent'/>,
-// }, {
-//     key: 'aliyun',
-//     tab: <FormattedMessage id='Aliyun'/>,
-// }, {
-//     key: 'amazon',
-//     tab: <FormattedMessage id='AWS'/>,
-// }];
-
 
 class Manage extends Component {
     constructor(props) {

+ 1 - 1
src/app/graphqlService/TrialCase.jsx

@@ -91,7 +91,7 @@ class TrialCase extends Component {
                                     case 'manage':
                                         return <Manage trialcase={true} userID={this.state.userID} projectID={projectID} switchMenu={this.switchMenu} switchAPI={this.switchAPI}/>;
                                     case 'graphiql':
-                                        return <Graphql api={this.state.api}/>;
+                                        return <Graphql api={this.state.api} projectID={projectID}/>;
                                     case 'template':
                                         return <GenerateJs schemaID={schemaID} schemaName={schemaName}/>;
                                     case 'preview':

+ 1 - 1
src/app/graphqlService/UserCreate.jsx

@@ -86,7 +86,7 @@ class UserCreate extends Component {
                                     case 'manage':
                                         return <Manage trialcase={false} userID={this.state.userID} projectID={projectID} switchMenu={this.switchMenu} switchAPI={this.switchAPI}/>;
                                     case 'graphiql':
-                                        return <Graphql api={this.state.api}/>;
+                                        return <Graphql api={this.state.api} projectID={projectID}/>;
                                     case 'template':
                                         return <GenerateJs schemaID={schemaID} schemaName={schemaName}/>;
                                     case 'metabase':

+ 49 - 22
src/app/graphqlService/component/graphql/Graphql.jsx

@@ -1,28 +1,25 @@
 import React, {Component} from 'react';
-import {Input, Alert} from 'antd';
+import {Input, Spin} from 'antd';
 import GraphiQL from "graphiql";
 import fetch from "isomorphic-fetch";
-import {graphqlUrl} from "../../../../config";
+import gql from "graphql-tag";
+import {Query} from "react-apollo";
 
-class Graphql extends Component {
+import {GET_PROJECT} from "../../../../gql";
 
+class Graphql extends Component {
     constructor(props) {
         super(props);
         this.state = {
-            // api: 'http://service-hnqzcew1-1254337200.ap-beijing.apigateway.myqcloud.com/release/graphql',
-            // api: 'http://service-4i9xdoqo-1254337200.ap-guangzhou.apigateway.myqcloud.com/release/graphql',
-            // api: 'http://service-ci2tk8iu-1254337200.ap-guangzhou.apigateway.myqcloud.com/release/graphql',
-            // 便于开发调试,请删除并换成上面
-            api: props.api ? props.api : 'http://service-7po2y2xb-1254337200.ap-beijing.apigateway.myqcloud.com/test/graphql'
-            // api: 'http://service-28dm054z-1254337200.ap-shanghai.apigateway.myqcloud.com/release/graphql'
-            // api: 'http://service-acb8p44v-1254337200.ap-beijing.apigateway.myqcloud.com/release/graphql'
-
-        }
+            api: props.api,
+            show: false
+        };
     };
 
     componentWillReceiveProps(next) {
         this.setState({
-            api: next.api ? next.api : 'http://service-7po2y2xb-1254337200.ap-beijing.apigateway.myqcloud.com/test/graphql'
+            api: next.api,
+            show: false
         })
     }
 
@@ -36,16 +33,46 @@ class Graphql extends Component {
     };
 
     render() {
+        let projectID = this.props.projectID ? this.props.projectID : 'ecommerce_projectID';
         return (
-            <div>
-                {/*<Alert message="online 数据库,非开发环境请移除"*/}
-                       {/*type="warning" banner closable/>*/}
-                <Input style={{marginTop: 10}} addonBefore="POST" defaultValue={this.state.api}
-                       onChange={(e) => {
-                           this.setState({api: e.target.value})
-                       }}/>
-                <GraphiQL fetcher={this.graphQLFetcher}/>
-            </div>
+            <Query query={gql(GET_PROJECT)} variables={{id: projectID}}>
+                {
+                    ({loading, error, data}) => {
+                        if (loading) {
+                            return <Spin style={{marginLeft: 3}}/>
+                        }
+                        if (error) {
+                            return 'error!';
+                        }
+                        console.log(data);
+                        let group = data.project_by_id.apiGWGroup_id;
+                        if (this.state.api === '') {
+                            this.setState({
+                                // 多路径没做
+                                api: group.frontType.slice(0, 4) + '://' + group.defaultDomain +'/'+ group.environmentName + '/graphql',
+                                show: true
+                            })
+                        }
+                        return (
+                            <div>
+                                <Input
+                                    style={{marginTop: 10}}
+                                    addonBefore="POST"
+                                    defaultValue={this.state.api}
+                                    onChange={(e) => {
+                                        this.setState({api: e.target.value})
+                                    }}/>
+                                {
+                                    this.state.show?
+                                        <GraphiQL fetcher={this.graphQLFetcher}/>
+                                        :
+                                        ''
+                                }
+                            </div>
+                        )
+                    }
+                }
+            </Query>
         )
     }
 

+ 2 - 1
src/app/graphqlService/component/schema/Schema.jsx

@@ -516,7 +516,8 @@ class CopySchemaButton extends Component {
             user_id: userID,
             schemaCreatedAt: createdAt,
             schemaUpdatedAt: '',
-            schemaState: 'copy',
+            // copy的时候直接给 ok,不用检测
+            schemaState: 'ok',
             schemaData: JSON.stringify([]),
             reference:  schemaID
         };