Bladeren bron

Merge remote-tracking branch 'origin/master'

Csy817 7 jaren geleden
bovenliggende
commit
40946b4ff9

+ 11 - 10
src/app/App.jsx

@@ -363,10 +363,10 @@ 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);
-                        localStorage.setItem('ecommerce', data.caseSchema.find(obj => obj.schemaName === 'ecommerce').schemaData);
-                        localStorage.setItem('subscribe', data.caseSchema.find(obj => obj.schemaName === 'subscribe').schemaData);
-                        localStorage.setItem('bills', data.caseSchema.find(obj => obj.schemaName === 'bills').schemaData);
+                        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);
                         return (
                             <Menu
                                 theme="dark"
@@ -390,15 +390,16 @@ class GraphqlSidebar extends Component {
                                     key="trial-case"
                                     title={<span><Icon type="appstore" theme="twoTone"/><span><FormattedMessage id="Case Show"/></span></span>}>
                                     {
-                                        data.caseSchema.map((schema) =>
-                                            <Menu.Item key={schema.schemaName}>
+                                        data.caseProject.map((project) =>
+                                            <Menu.Item key={project.schema_id.schemaName}>
                                                 <Link to={{
-                                                    pathname: `/graphql-service/trial-case/${schema.schemaName}`,
+                                                    pathname: `/graphql-service/trial-case/${project.schema_id.schemaName}`,
                                                     state: {
-                                                        schemaName: schema.schemaName,
-                                                        schemaID: schema.id
+                                                        schemaName: project.schema_id.schemaName,
+                                                        schemaID: project.schema_id.id,
+                                                        projectID: project.id
                                                     }
-                                                }}>{schema.schemaName}</Link>
+                                                }}>{project.schema_id.schemaName}</Link>
                                             </Menu.Item>)
                                     }
                                 </SubMenu>

+ 4 - 4
src/app/common/deploy/tencent/TencentConfig.js

@@ -75,7 +75,8 @@ class TencentConfig extends Component {
     };
 
     render() {
-        let {userID, projectID, trialcase} = this.props;
+        let projectID = this.props.projectID ? this.props.projectID : 'ecommerce_projectID';
+
         return (
             <Query query={gql(GET_PROJECT)} variables={{id: projectID}}>
                 {
@@ -97,7 +98,6 @@ class TencentConfig extends Component {
                             deploy = data.project_by_id.deploy_id;
                             cloudID = data.project_by_id.cloud_id.id;
                         }
-                        console.log('object',data);
                         let defaultName = data.project_by_id.projectName;
                         return (
                             <div>
@@ -181,9 +181,9 @@ class TencentConfig extends Component {
                                             </FormattedMessage>
                                         </Col>
                                         <Col offset={2} span={6}>
-                                            <Button type='primary' disabled={this.state.couldDeploy? '': 'disabled'} onClick={()=>this.deployFC()}><FormattedMessage id="deploy"/>!</Button>
+                                            <Button type='primary' disabled={data.project_by_id.schema_id.schemaState === 'ok'? '': 'disabled'} onClick={()=>this.deployFC()}><FormattedMessage id="deploy"/>!</Button>
                                             {
-                                                this.state.couldDeploy?
+                                                data.project_by_id.schema_id.schemaState === 'ok'?
                                                     ''
                                                     :
                                                     <div>

+ 37 - 0
src/app/common/manage/AliyunResult.js

@@ -0,0 +1,37 @@
+import React, {Component} from 'react';
+import {Switch, Input, Icon} from 'antd';
+
+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>
+            </div>
+        )
+    }
+}
+
+export default AliyunResult;

+ 37 - 0
src/app/common/manage/AmazonResult.js

@@ -0,0 +1,37 @@
+import React, {Component} from 'react';
+import {Switch, Input, Icon} from 'antd';
+
+class AmazonResult 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>
+            </div>
+        )
+    }
+}
+
+export default AmazonResult;

+ 50 - 20
src/app/common/manage/Manage.jsx

@@ -1,34 +1,64 @@
 import React, {Component} from 'react';
-import {Switch, Input, Icon} from 'antd';
+import {FormattedMessage} from 'react-intl';
+import {Card} from 'antd';
+
+import TencentResult from './TencentResult';
+import AliyunResult from './AliyunResult';
+import AmazonResult from './AmazonResult';
+
+
+const tabListNoTitle = [{
+    key: 'tencent',
+    tab: <FormattedMessage id='Tencent'/>,
+}];
+
+// [{
+//     key: 'tencent',
+//     tab: <FormattedMessage id='Tencent'/>,
+// }, {
+//     key: 'aliyun',
+//     tab: <FormattedMessage id='Aliyun'/>,
+// }, {
+//     key: 'amazon',
+//     tab: <FormattedMessage id='AWS'/>,
+// }];
+
 
 class Manage extends Component {
     constructor(props) {
         super(props);
         this.state = {
-            url: '1111',
-            checked: true
-        }
+            cloud: 'tencent'
+        };
+    }
+
+    componentWillReceiveProps(next) {
+        this.setState({
+            projectID: next.projectID
+        })
     }
 
     render() {
+        const contentListNoTitle = {
+            tencent: <TencentResult userID={this.props.userID} projectID={this.props.projectID} trialcase={this.props.trialcase}/>,
+            aliyun: <AliyunResult/>,
+            amazon: <AmazonResult/>,
+        };
+
         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>
+                <Card
+                    style={{width: '100%'}}
+                    tabList={tabListNoTitle}
+                    activeTabKey={this.state.cloud}
+                    onTabChange={(cloud) => {
+                        this.setState({
+                            cloud
+                        })
+                    }}
+                >
+                    {contentListNoTitle[this.state.cloud]}
+                </Card>
             </div>
         )
     }

+ 38 - 0
src/app/common/manage/TencentResult.js

@@ -0,0 +1,38 @@
+import React, {Component} from 'react';
+import {Switch, Input, Icon} from 'antd';
+
+class TencentResult extends Component {
+    constructor(props) {
+        super(props);
+        this.state = {
+            url: '1111',
+            checked: true
+        }
+    }
+
+    render() {
+        return (
+            <div>
+                <div style={{width: 300}}>
+                    <span>Tencent</span>
+                    <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>
+            </div>
+        )
+    }
+}
+
+export default TencentResult;

+ 4 - 5
src/app/graphqlService/TrialCase.jsx

@@ -50,10 +50,9 @@ class TrialCase extends Component {
     }
 
     render() {
-        let schemaID = this.props.history.location.state ? this.props.history.location.state.schemaID : "ecommerce_schemaID";
-        let schemaName = this.props.history.location.state ? this.props.history.location.state.schemaName : "ecommerce";
-        let projectID = this.props.history.location.state ? this.props.history.location.state.projectID : "";
-        let _this = this;
+        let schemaID = this.props.location.state ? this.props.location.state.schemaID : "ecommerce_schemaID";
+        let schemaName = this.props.location.state ? this.props.location.state.schemaName : "ecommerce";
+        let projectID = this.props.location.state ? this.props.location.state.projectID : "";
         return (
             <div>
                 <Menu
@@ -83,7 +82,7 @@ class TrialCase extends Component {
                                     case 'deploy':
                                         return <Deploy trialcase={true} userID={this.state.userID} projectID={projectID}/>;
                                     case 'manage':
-                                        return <Manage/>;
+                                        return <Manage trialcase={true} userID={this.state.userID} projectID={projectID}/>;
                                     case 'graphiql':
                                         return <Graphql/>;
                                     case 'template':

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

@@ -47,9 +47,9 @@ class UserCreate extends Component {
 
 
     render() {
-        let schemaID = this.props.history.location.state ? this.props.history.location.state.schemaID : "ecommerce_schemaID";
-        let schemaName = this.props.history.location.state ? this.props.history.location.state.schemaName : "ecommerce";
-        let projectID = this.props.history.location.state ? this.props.history.location.state.projectID : "";
+        let schemaID = this.props.location.state ? this.props.location.state.schemaID : "ecommerce_schemaID";
+        let schemaName = this.props.location.state ? this.props.location.state.schemaName : "ecommerce";
+        let projectID = this.props.location.state ? this.props.location.state.projectID : "";
         return (
             <div>
                 <Menu
@@ -78,7 +78,7 @@ class UserCreate extends Component {
                                     case 'deploy':
                                         return <Deploy trialcase={false} userID={this.state.userID} projectID={projectID}/>;
                                     case 'manage':
-                                        return <Manage/>;
+                                        return <Manage trialcase={false} userID={this.state.userID} projectID={projectID}/>;
                                     case 'graphiql':
                                         return <Graphql/>;
                                     case 'template':

+ 4 - 4
src/app/wechatService/WxTrialCase.js

@@ -24,9 +24,9 @@ class WxTrialCase extends Component {
     };
 
     render() {
-        let configID = this.props.history.location.state ? this.props.history.location.state.configID : "ecommerce_wxConfigID";
-        let appName = this.props.history.location.state ? this.props.history.location.state.appName : "ecommerce";
-        let projectID = this.props.history.location.state ? this.props.history.location.state.projectID : "";
+        let configID = this.props.location.state ? this.props.location.state.configID : "ecommerce_wxConfigID";
+        let appName = this.props.location.state ? this.props.location.state.appName : "ecommerce";
+        let projectID = this.props.location.state ? this.props.location.state.projectID : "";
         return (
             <div>
                 <Menu
@@ -57,7 +57,7 @@ class WxTrialCase extends Component {
                                 case 'wechat-deploy':
                                     return <WxDeploy trialcase={true} userID={this.state.userID} configID={configID}/>;
                                 case 'wechat-manage':
-                                    return <Manage/>;
+                                    return <Manage trialcase={true} userID={this.state.userID} configID={configID}/>;
                                 default:
                                     return <WxConfig/>
                             }

+ 4 - 4
src/app/wechatService/WxUserCreate.js

@@ -45,9 +45,9 @@ class WxUserCreate extends Component {
     };
 
     render() {
-        let configID = this.props.history.location.state ? this.props.history.location.state.configID : "ecommerce_wxConfigID";
-        let appName = this.props.history.location.state ? this.props.history.location.state.appName : "ecommerce";
-        let projectID = this.props.history.location.state ? this.props.history.location.state.projectID : "";
+        let configID = this.props.location.state ? this.props.location.state.configID : "ecommerce_wxConfigID";
+        let appName = this.props.location.state ? this.props.location.state.appName : "ecommerce";
+        let projectID = this.props.location.state ? this.props.location.state.projectID : "";
         return (
             <div>
                 <Menu
@@ -78,7 +78,7 @@ class WxUserCreate extends Component {
                                 case 'wechat-deploy':
                                     return <WxDeploy trialcase={false} userID={this.state.userID} configID={configID}/>;
                                 case 'wechat-manage':
-                                    return <Manage/>;
+                                    return <Manage trialcase={false} userID={this.state.userID} configID={configID}/>;
                                 default:
                                     return <WxConfig/>
                             }

+ 22 - 5
src/gql.js

@@ -347,12 +347,29 @@ const ADD_PROJECT_AND_WX = `
 
 const CASE_SCHEMA_AND_PROJECT = `
             query CASE_SCHEMA_AND_PROJECT($user_id: ID, $projectType: String ) {
-                caseSchema:schema_by_props(user_id: "ioobot") {
-                    schemaData
-                    schemaName
+                caseProject:project_by_props(
+                    projectType: $projectType,
+                    user_id: "ioobot"
+                ) {
+                    updatedAt
+                    apiGWGroup_id {
+                        id
+                    }
+                    createdAt
+                    projectName
                     id
-                    reference
-                    schemaState
+                    projectType
+                    wxConfig_id {
+                        id
+                        appName
+                    }
+                    schema_id {
+                        schemaData
+                        schemaName
+                        id
+                        reference
+                        schemaState
+                    }
                 }
                 
                 project:project_by_props(