kulley пре 6 година
родитељ
комит
df18f5ee61

+ 0 - 1
src/app/basicVersion/BasicVersion.jsx

@@ -221,7 +221,6 @@ class User extends Component {
     }
 
     logout = () => {
-
         axios.get(logoutUrl)
             .then((res) => {
                 console.log('logout success',res);

+ 44 - 42
src/app/basicVersion/caseShow/CaseShow.jsx

@@ -1,6 +1,5 @@
-
 import React, {Component} from 'react';
-import {Layout, Card, Button, Avatar, Spin, Icon, Row, Col, notification,Tag } from 'antd';
+import {Layout, Card, Button, Avatar, Spin, Icon, Row, Col, notification, Tag} from 'antd';
 import lo from '../../../images/lo.png'
 import './index.css'
 import {graphqlUrl} from "../../../config";
@@ -47,8 +46,8 @@ class CaseShow extends Component {
 
                 if (this._isMounted) {
                     this.setState({
-                        examplesIoobot:IooList,
-                        examplesOthers:UserList
+                        examplesIoobot: IooList,
+                        examplesOthers: UserList
                     })
                 }
             }
@@ -57,9 +56,9 @@ class CaseShow extends Component {
 
     examplesFilter(example) {
         // console.log('examples',example);
-        let hash = {},i = 0,list = [];
+        let hash = {}, i = 0, list = [];
 
-        example.forEach(function(item) {
+        example.forEach(function (item) {
             let {title} = item;
             hash[title] ? list[hash[title] - 1].content.push(item) : hash[title] = ++i && list.push({
                 title,
@@ -76,18 +75,17 @@ class CaseShow extends Component {
     }
 
     schemaIDChangeBucket = (schemaID) => {
-        if (this.props.location && this.props.location.state) {
-            switch (schemaID) {
-                case 'order_schemaID':
-                    return 'appointment';
-                case 'ecommerce_schemaID':
-                    return 'e-commerce';
-                case 'bills_schemaID':
-                    return 'bills';
-                default:
-                    break;
-            }
+        switch (schemaID) {
+            case 'order_schemaID':
+                return 'appointment';
+            case 'ecommerce_schemaID':
+                return 'e-commerce';
+            case 'bills_schemaID':
+                return 'bills';
+            default:
+                return 'nothing';
         }
+
     };
 
     backToMe = () => {
@@ -113,22 +111,23 @@ class CaseShow extends Component {
                         !showCustom ?
                             <div>
                                 <div className={'card card-head'}>
-                                    <Card.Grid className={'card-head-item orange-change'} >
+                                    <Card.Grid className={'card-head-item orange-change'}>
                                         <p>我们永久无年费 &nbsp;&nbsp;&nbsp;&nbsp; 告别高成本</p>
                                         <p>省钱、更省心</p>
                                     </Card.Grid>
-                                    <Card.Grid className={'card-head-item pink-change'} >
+                                    <Card.Grid className={'card-head-item pink-change'}>
                                         <p>数据完全私有 &nbsp;&nbsp;&nbsp;&nbsp; 安全更可靠</p>
                                         <p>数据分析图表为您提供更细致的服务</p>
                                     </Card.Grid>
-                                    <Card.Grid className={'card-head-item blue-change'} >
+                                    <Card.Grid className={'card-head-item blue-change'}>
                                         <p>模板不满意 &nbsp;&nbsp;&nbsp;&nbsp; 快来定制化吧!</p>
                                         <p>上手有困难,联系我们即可</p>
                                         <Button
                                             onClick={() => {
                                                 this.props.history.push({
                                                     pathname: `/common/communication`
-                                                })}}>立即定制</Button>
+                                                })
+                                            }}>立即定制</Button>
                                     </Card.Grid>
                                 </div>
                                 <div className={'schema-name'}>
@@ -144,22 +143,24 @@ class CaseShow extends Component {
                                                 let gzh = exampleList.filter(case1 => case1.description === '微信公众号');
                                                 let xcx = exampleList.filter(case1 => case1.description === '微信小程序');
                                                 let value = exampleList[0];
-                                                return(
-                                                    <Row key={index} className='card card-case' type="flex" justify="space-around" align="middle">
-                                                        <Col span={6} style={{padding:'20px'}}>
+                                                return (
+                                                    <Row key={index} className='card card-case' type="flex"
+                                                         justify="space-around" align="middle">
+                                                        <Col span={6} style={{padding: '20px'}}>
                                                             <div className="wrap">
                                                                 <div className="case-name">{value.title}</div>
                                                                 <div className="wrapper">
-                                                                    <div >
-                                                                        <div >
-                                                                            <div >模板简介:</div>
-                                                                            <div >{value.detailDescription ? value.detailDescription : '暂无简介' }</div>
+                                                                    <div>
+                                                                        <div>
+                                                                            <div>模板简介:</div>
+                                                                            <div>{value.detailDescription ? value.detailDescription : '暂无简介'}</div>
                                                                         </div>
                                                                         <br/>
-                                                                        <div >
+                                                                        <div>
                                                                             {value.detailAttention ?
                                                                                 <div>适用行业: &nbsp;&nbsp;
-                                                                                    <Tag color="blue">{value.detailAttention}</Tag>
+                                                                                    <Tag
+                                                                                        color="blue">{value.detailAttention}</Tag>
                                                                                 </div>
                                                                                 :
                                                                                 ''
@@ -177,7 +178,8 @@ class CaseShow extends Component {
                                                                                 <Icon type="github"/>&nbsp;&nbsp;
                                                                                 {
                                                                                     value.codeAddress ?
-                                                                                        <a href={value.codeAddress}>查看源码 可自行修改使用</a>
+                                                                                        <a href={value.codeAddress}>查看源码
+                                                                                            可自行修改使用</a>
                                                                                         :
                                                                                         '该作者未留下代码仓库地址'
                                                                                 }
@@ -187,17 +189,19 @@ class CaseShow extends Component {
                                                                 </div>
                                                             </div>
                                                         </Col>
-                                                        <Col span={9} style={{padding:'20px'}}>
+                                                        <Col span={9} style={{padding: '20px'}}>
                                                             {gzh.length ?
-                                                                <CaseShowDetail caseContent={gzh} showCustom={this.showCustom}/>
+                                                                <CaseShowDetail caseContent={gzh}
+                                                                                showCustom={this.showCustom}/>
                                                                 :
                                                                 <div>敬请期待</div>
                                                             }
 
                                                         </Col>
-                                                        <Col span={9} style={{padding:'20px'}}>
+                                                        <Col span={9} style={{padding: '20px'}}>
                                                             {xcx.length ?
-                                                                <CaseShowDetail caseContent={xcx} showCustom={this.showCustom}/>
+                                                                <CaseShowDetail caseContent={xcx}
+                                                                                showCustom={this.showCustom}/>
                                                                 :
                                                                 <div>敬请期待</div>
                                                             }
@@ -227,16 +231,14 @@ export default CaseShow;
 class CaseShowDetail extends Component {
     constructor(props) {
         super(props);
-        this.state = {
-
-        }
+        this.state = {}
     }
 
     render() {
         let caseDetail = this.props.caseContent[0];
         // console.log('caseDetail',caseDetail);
 
-        return(
+        return (
             <div key={caseDetail.id}>
                 <Query query={gql(SHOW_CASE)} variables={{id: caseDetail.id}}>
                     {
@@ -253,7 +255,7 @@ class CaseShowDetail extends Component {
                                 <div>
                                     <div className={'case-show-head'}>{caseDetail.description}</div>
                                     <div className={'wrapper'}>
-                                        <div >
+                                        <div>
                                             <img
                                                 key={thisCase.detailImages[0]}
                                                 src={thisCase.detailImages[0]}
@@ -262,7 +264,7 @@ class CaseShowDetail extends Component {
                                             />
                                         </div>
                                         <div className={'right'}>
-                                            <div className="cl-center" >
+                                            <div className="cl-center">
                                                 <div className='cover-div'>
                                                     <img
                                                         className='cover-img'
@@ -275,7 +277,7 @@ class CaseShowDetail extends Component {
                                             </div>
                                             <div className="cl-center">
                                                 <Button type="primary"
-                                                        style={{borderRadius:30}}
+                                                        style={{borderRadius: 30}}
                                                         onClick={() => {
                                                             this.props.showCustom(caseDetail.schema_id.id);
                                                         }}><FormattedMessage id='Publish immediately'/></Button>

+ 363 - 143
src/app/basicVersion/caseShow/UserCustom.js

@@ -3,7 +3,7 @@ import {Link} from 'react-router-dom';
 import {deployAll, graphqlUrl, storeFile, copyCos} from "../../../config";
 import {ADD_APIGROUP, ADD_APIGWPATH, ADD_DEPLOY, ADD_PROJECT, SHOW_CLOUD} from "../../../gql";
 import {CloudConfig} from "../../../login/CloudConfig";
-import {Layout,Button, message, Modal, Icon, Steps, Row, Col} from 'antd';
+import {Layout, Button, message, Modal, Icon, Steps, Row, Col, Radio, Input} from 'antd';
 import {FormattedMessage} from 'react-intl';
 import {request} from 'graphql-request'
 import {idGen} from "../../../func";
@@ -12,6 +12,7 @@ import './index.css';
 
 const {Content} = Layout;
 const Step = Steps.Step;
+const RadioGroup = Radio.Group;
 axios.defaults.withCredentials = true;
 
 class UserCustom extends Component {
@@ -20,40 +21,235 @@ class UserCustom extends Component {
         this.state = {
             userID: props.userID,
             bucketName: props.bucketName,
-            customName: '',
             cloudName: 'tencent',
-            dbKind: 'fc-db', // mongodb fc-db
             disableDeployButton: false,
-            deployFailed: false
-        };
-
-        this.cloudState = {
+            deployFailed: false,
             cloudID: '',
             secretID: '',
             secretKey: '',
             appId: ''
-        }
+        };
+
+        console.log(this.state, 'userCustom state')
     }
 
     getCloudDetail = (cloudID, secretID, secretKey, appId) => {
-        this.cloudState = {
+        this.setState({
             cloudID,
             secretID,
             secretKey,
             appId
+        })
+    };
+
+    componentWillMount() {
+        this._isMounted = true;
+    }
+
+    componentWillUnmount() {
+        this._isMounted = false;
+    }
+
+    render() {
+        let {disableDeployButton, userID, cloudID, bucketName, deployFailed, appId, secretID, secretKey} = this.state;
+        return (
+            <Content className="content">
+                <div>
+                    <div className="column-menu" onClick={() => {
+                        this.props.backToMe()
+                    }}>
+                        <Icon type="left" style={{color: '#3187FA'}}/>
+                        <FormattedMessage id="back to case show"/>
+                    </div>
+
+                    <Row>
+                        <Col span={9} offset={2}>
+                            <div className='step-kind'>
+                                发布体验
+                            </div>
+                            <Steps direction="vertical" current={2}>
+                                <Step title=<Step00/> />
+                                <Step title=<Step01/> />
+                            </Steps>
+                        </Col>
+                        <Col span={9} offset={2}>
+                            <div className='step-kind'>
+                                发布上线
+                            </div>
+                            <Steps direction="vertical" current={5}>
+                                <Step title=<Step10/> />
+                                <Step title=<Step11 getCloudDetail={this.getCloudDetail} userID={userID}/> />
+                                <Step title=<Step12/> />
+                                <Step title=<Step13/> />
+                                <Step title=
+                                          <Step14
+                                      getPrimaryConfigDetail={this.getPrimaryConfigDetail}
+                                      userID={userID}
+                                      bucketName={bucketName}
+                                      secretID={secretID}
+                                      secretKey={secretKey}
+                                      appId={appId}
+                                      cloudID={cloudID}
+                                />
+                                />
+                            </Steps>
+                        </Col>
+                    </Row>
+                </div>
+            </Content>
+        )
+    }
+}
+
+export default UserCustom;
+
+class CloudQueryAndConfig extends Component {
+    constructor(props) {
+        super(props);
+        this.state = {
+            cloudName: props.cloudName,
+            userID: props.userID,
+            cloudID: '',
+            secretID: '',
+            secretKey: '',
+            appId: '',
+            visible: false,
+            confirmLoading: false,
+        }
+    }
+
+    searchCloud = () => {
+        this._isMounted = true;
+        let {userID, cloudName} = this.state;
+        // 如果登录,查询该用户是否设置 cloud
+        request(graphqlUrl, SHOW_CLOUD, {user_id: userID}).then(data => {
+                let clouds = data.cloud_by_props.filter(cloud => cloud.cloudName === cloudName);
+                // 如果限制一个云服务商一个 cloud,那么就是clouds[0]
+                if (clouds.length === 1) {
+                    let cloud = clouds[0];
+                    let {id, secretId, secretKey, appId} = cloud;
+                    if (this._isMounted) {
+                        this.setState({
+                            cloudID: id,
+                            secretID: secretId,
+                            secretKey,
+                            appId,
+                        });
+                    }
+                    this.props.getCloudDetail(id, secretId, secretKey, appId);
+                } else if (clouds.length > 1) {
+                    console.log('数据库有多个同一云服务商的 key');
+                } else {
+                    if (this._isMounted) {
+                        console.log('数据库没有云服务商的 key');
+                    }
+                }
+            }
+        )
+    };
+
+    showModal = () => {
+        if (this.state.userID) {
+            this.setState({
+                visible: true,
+            });
+        } else {
+            message.warning('请先登录');
+        }
+    };
+
+    handleCancel = () => {
+        this.setState({
+            visible: false,
+        });
+        this.props.reCheck();
+    };
+
+    componentWillMount() {
+        this.searchCloud();
+        this._isMounted = true;
+    }
+
+    componentWillUnmount() {
+        this._isMounted = false;
+    }
+
+    componentWillReceiveProps(next) {
+        this.setState({
+            cloudName: next.cloudName,
+            userID: next.userID,
+        }, this.searchCloud);
+    }
+
+    render() {
+        let {visible, confirmLoading, cloudName} = this.state;
+        return (
+            <div>
+                <Button type='primary' onClick={this.showModal}>填写秘钥</Button>
+
+                <Modal
+                    title="云服务商秘钥设置"
+                    visible={visible}
+                    confirmLoading={confirmLoading}
+                    footer={null}
+                    onCancel={this.handleCancel}
+                >
+                    <CloudConfig cloudName={cloudName}/>
+                </Modal>
+            </div>
+        )
+    }
+}
+
+class NameAndDB extends Component {
+    constructor(props) {
+        super(props);
+        this.state = {
+            userID: props.userID,
+            visible: false,
+            confirmLoading: false,
+            customName: props.bucketName + '-' + props.userID,
+            dbKind: 'fc-db',
+            host: '',
+            db: '',
+            username: '',
+            password: '',
+            admin: ''
+        }
+    }
+
+
+    showModal = () => {
+        if (this.state.userID) {
+            this.setState({
+                visible: true,
+            });
+        } else {
+            message.warning('请先登录');
         }
     };
 
-    deploy = () => {
+    handleCancel = () => {
+        this.setState({
+            visible: false,
+        });
+    };
+
+    componentWillMount() {
+        this._isMounted = true;
+    }
+
+    componentWillUnmount() {
+        this._isMounted = false;
+    }
+
+    deploy = (userID, dbKind, bucketName, customName, cloudID) => {
         this._isMounted = true;
         let _this = this;
-        let {userID, dbKind, bucketName, customName} = this.state;
-        let {cloudID} = this.cloudState;
 
         if (bucketName === '') {
             console.log('state, 没有传值');
         } else {
-
             console.log('开始调用');
             this.setState({
                 disableDeployButton: true
@@ -208,151 +404,162 @@ class UserCustom extends Component {
         }
     };
 
-    componentWillMount() {
-        this._isMounted = true;
-    }
-
-    componentWillUnmount() {
-        this._isMounted = false;
-    }
-
-    render() {
-        let {cloudName, customName, disableDeployButton, userID, check, dbKind, bucketName, deployFailed} = this.state;
-        let {appId, secretID, secretKey} = this.cloudState;
-        return (
-            <Content className="content">
-                <div>
-                    <div className="column-menu" onClick={() => {
-                        this.props.backToMe()
-                    }}>
-                        <Icon type="left" style={{color: '#3187FA'}}/>
-                        <FormattedMessage id="back to case show"/>
-                    </div>
-
-                    <Row>
-                        <Col span={9} offset={2}>
-                            <div className='step-kind'>
-                                发布体验
-                            </div>
-                            <Steps direction="vertical" current={2}>
-                                <Step title=<Step00/> />
-                                <Step title=<Step01/> />
-                            </Steps>
-                        </Col>
-                        <Col span={9} offset={2}>
-                            <div className='step-kind'>
-                                发布上线
-                            </div>
-                            <Steps direction="vertical" current={5}>
-                                <Step title=<Step10/> />
-                                <Step title=<Step11 getCloudDetail={this.getCloudDetail} userID={userID}/> />
-                                <Step title=<Step12/> />
-                                <Step title=<Step13/> />
-                                <Step title=<Step14/> />
-                            </Steps>
-                        </Col>
-                    </Row>
-                </div>
-            </Content>
-
-        )
-    }
-}
-
-export default UserCustom;
-
-class CloudQueryAndConfig extends Component {
-    constructor(props) {
-        super(props);
-        this.state = {
-            cloudName: props.cloudName,
-            userID: props.userID,
-            cloudID: '',
-            secretID: '',
-            secretKey: '',
-            appId: '',
-            visible: false,
-            confirmLoading: false,
-        }
-    }
+    storeEdnAndDeploy = (secretID, secretKey, appId, bucketName, dbKind, userID, admin, username, password, db, host, customName, cloudID) => {
+        // store *.edn to cos
+        let deployConf = dbKind === 'mongodb' ?
+            ` {:secretId "${secretID}"\n` +
+            ` :secretKey "${secretKey}"\n` +
+            ` :appId "${appId}"\n` +
+            ' :region "ap-beijing" \n' +
+            ' }\n'
+            :
+            ` {:secretId "${secretID}"\n` +
+            ` :secretKey "${secretKey}"\n` +
+            ` :appId "${appId}"\n` +
+            ' :region "ap-beijing"\n' +
+            ' :bucket "fc-db"\n' +
+            ' :trustStore "/etc/ssl/certs/java/cacerts"\n' +
+            ` :fc-db-store "save/${bucketName}.dat"\n` +
+            ' :fc-db-dir "fc-db"\n' +
+            ' :local-tmp-dir "/tmp"\n' +
+            ' :local-db-file "fcdb.dat"\n' +
+            ' :update-tx? true \n' +
+            ' :force-down? true\n' +
+            ' }';
+
+        let a = axios.post(storeFile, {
+            'file-name': `${bucketName}/${dbKind}/${userID}/deploy-conf.edn`,
+            bucket: 'case',
+            cont: deployConf
+        });
 
-    searchCloud = () => {
-        this._isMounted = true;
-        let {userID, cloudName} = this.state;
-        // 如果登录,查询该用户是否设置 cloud
-        request(graphqlUrl, SHOW_CLOUD, {user_id: userID}).then(data => {
-                let clouds = data.cloud_by_props.filter(cloud => cloud.cloudName === cloudName);
-                // 如果限制一个云服务商一个 cloud,那么就是clouds[0]
-                if (clouds.length === 1) {
-                    let cloud = clouds[0];
-                    let {id, secretId, secretKey, appId} = cloud;
-                    if (this._isMounted) {
-                        this.setState({
-                            cloudID: id,
-                            secretID: secretId,
-                            secretKey,
-                            appId,
-                        });
-                    }
-                    this.props.getCloudDetail(id, secretId, secretKey, appId);
-                } else if (clouds.length > 1) {
-                    console.log('数据库有多个同一云服务商的 key');
-                } else {
-                    if (this._isMounted) {
-                        console.log('数据库没有云服务商的 key');
-                    }
-                }
+        let cont = '{:uri {\n' +
+            `:auth {:admin-db   "${admin}"\n` +
+            ` :u    "${username}"\n` +
+            ` :p   "${password}"\n` +
+            ` :host "${host}"}}\n` +
+            ` :db-name "${db}"}`;
+
+        let b = dbKind === 'mongodb' ?
+            axios.post(storeFile, {
+                'file-name': `${bucketName}/${dbKind}/${userID}/mongo-config.edn`,
+                bucket: 'case',
+                cont
+            })
+            :
+            Promise.resolve({status: 200});
+
+        Promise.all([a, b]).then(value => {
+            if (value.every(res => res.status === 200)) {
+                console.log('store file success , start deploying');
+                this.deploy(userID, dbKind, bucketName, customName, cloudID);
             }
-        )
-    };
-
-    showModal = () => {
-        if(this.state.userID) {
-            this.setState({
-                visible: true,
-            });
-        } else {
-            message.warning('请先登录');
-        }
-    };
-
-    handleCancel = () => {
-        this.setState({
-            visible: false,
         });
-        this.props.reCheck();
-    };
-
-    componentWillMount() {
-        this.searchCloud();
-        this._isMounted = true;
-    }
-
-    componentWillUnmount() {
-        this._isMounted = false;
-    }
-
-    componentWillReceiveProps(next) {
-        this.setState({
-            cloudName: next.cloudName,
-            userID: next.userID,
-        }, this.searchCloud);
     }
 
     render() {
-        let {visible, confirmLoading, cloudName} = this.state;
+        let {
+            visible,
+            confirmLoading,
+            userID,
+            dbKind,
+            host,
+            db,
+            username,
+            password,
+            admin,
+            customName
+        } = this.state;
+        let {secretID, secretKey, appId, bucketName, cloudID} = this.props
         return (
             <div>
-                <Button type='primary' onClick={this.showModal}>点击填写</Button>
+                <Button type='primary' onClick={this.showModal}>开始部署</Button>
 
                 <Modal
-                    title="云服务商秘钥设置"
+                    title="名称和数据库配置"
                     visible={visible}
                     confirmLoading={confirmLoading}
                     footer={null}
                     onCancel={this.handleCancel}
                 >
-                    <CloudConfig cloudName={cloudName}/>
+                    <div>
+                        <div>
+                            <div className={'schema-name'}><FormattedMessage id='Name'/></div>
+                            <div>
+                                <span className='item-title-cloud'><FormattedMessage id='name'/>:</span>
+                                <Input style={{width: 250}} value={this.state.customName}
+                                       onChange={(e) => {
+                                           this.setState({customName: e.target.value})
+                                       }}/>
+                            </div>
+                        </div>
+
+                        <div style={{marginTop: 20}}>
+                            <div className={'schema-name'}><FormattedMessage id='DB Choose'/></div>
+                            <RadioGroup onChange={(e) => {
+                                this.setState({dbKind: e.target.value})
+                            }} value={this.state.dbKind}>
+                                <Radio value='fc-db'>fc-db</Radio>
+                                <Radio value='mongodb'>mongodb</Radio>
+                            </RadioGroup>
+                        </div>
+
+                        {
+                            this.state.dbKind === 'mongodb' ?
+                                <div>
+                                    <div>
+                                        <span>host</span>
+                                        <Input style={{width: 250}} value={this.state.host}
+                                               onChange={(e) => {
+                                                   this.setState({host: e.target.value})
+                                               }}
+                                        />
+                                    </div>
+
+                                    <div>
+                                        <span>db-name</span>
+                                        <Input style={{width: 250}} value={this.state.db}
+                                               onChange={(e) => {
+                                                   this.setState({db: e.target.value})
+                                               }}
+                                        />
+                                    </div>
+
+                                    <div>
+                                        <span>admin-db</span>
+                                        <Input style={{width: 250}} value={this.state.admin}
+                                               onChange={(e) => {
+                                                   this.setState({admin: e.target.value})
+                                               }}
+                                        />
+                                    </div>
+
+                                    <div>
+                                        <span>username</span>
+                                        <Input style={{width: 250}} value={this.state.username}
+                                               onChange={(e) => {
+                                                   this.setState({username: e.target.value})
+                                               }}
+                                        />
+                                    </div>
+
+                                    <div>
+                                        <span>password</span>
+                                        <Input type='password' style={{width: 250}} value={this.state.password}
+                                               onChange={(e) => {
+                                                   this.setState({password: e.target.value})
+                                               }}
+                                        />
+                                    </div>
+                                </div>
+                                :
+                                ''
+                        }
+
+                        <Button type='primary' onClick={() => {
+                            this.storeEdnAndDeploy(secretID, secretKey, appId, bucketName, dbKind, userID, admin, username, password, db, host, customName, cloudID)
+                        }}>开始部署</Button>
+                    </div>
                 </Modal>
             </div>
         )
@@ -423,11 +630,24 @@ const Step13 = (props) => (
     <div className='step-block'>
         第四步:微信公众号/小程序 后台填写配置
         <Button style={{marginLeft: 20}}>使用帮助</Button>
+        <div>
+            <Button type='primary'>填写配置</Button>
+        </div>
     </div>
 );
 
 const Step14 = (props) => (
     <div className='step-block'>
         开始使用
+        <div>
+            <NameAndDB
+                userID={props.userID}
+                bucketName={props.bucketName}
+                secretID={props.secretID}
+                secretKey={props.secretKey}
+                appId={props.appId}
+                cloudID={props.cloudID}
+            />
+        </div>
     </div>
 );

+ 407 - 0
src/app/basicVersion/caseShow/backup.js

@@ -0,0 +1,407 @@
+import React, {Component} from 'react';
+import {Layout, Button, notification, Spin, Row, Col, Icon, message, Input, Radio, Modal} from 'antd';
+import {getCookie} from "../../../cookie";
+import {graphqlUrl, storeFile} from "../../../config";
+import {SEARCH_APIGROUP, SHOW_CLOUD} from "../../../gql";
+import {request} from 'graphql-request'
+import axios from 'axios';
+import {deployAll} from "../../../config";
+import {ADD_APIGWPATH, ADD_APIGROUP, ADD_DEPLOY, ADD_PROJECT} from "../../../gql";
+import {idGen} from "../../../func";
+import {FormattedMessage} from 'react-intl';
+import copy from 'copy-to-clipboard';
+import {CloudConfig} from '../../../login/CloudConfig';
+
+const {Content} = Layout;
+const RadioGroup = Radio.Group;
+axios.defaults.withCredentials = true;
+
+class DeployCloudChoose extends Component {
+    constructor() {
+        super();
+        this.state = {
+            userID: '',
+            check: new Date().getTime(),
+
+            disableDeployButton: false,
+            domain: '',
+
+            cloudName: 'tencent',
+            cloudID: '',
+            secretID: '',
+            secretKey: '',
+            appId: '',
+
+            customName: '',
+            bucketName: '',
+            dbKind: 'fc-db', // mongodb fc-db
+        }
+    }
+
+    componentWillMount() {
+        this._isMounted = true;
+
+        // 查询是否登录
+        let userID = getCookie('user_id');
+        if (userID !== undefined && userID !== '') {
+            this.setState({
+                userID
+            });
+        }
+
+        // 查询跳转来的案例,转成 apigroup id
+        let groupID = '';
+        if (this.props.location && this.props.location.state) {
+            switch (this.props.location.state.schemaID) {
+                case 'order_schemaID':
+                    this.setState({
+                        bucketName: 'appointment'
+                    });
+                    groupID = 'order';
+                    break;
+                case 'ecommerce_schemaID':
+                    this.setState({
+                        bucketName: 'e-commerce'
+                    });
+                    groupID = 'ecommerce';
+                    break;
+                case 'bills_schemaID':
+                    this.setState({
+                        bucketName: 'bills'
+                    });
+                    groupID = 'bills';
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        // 查询该案例的 domain
+        request(graphqlUrl, SEARCH_APIGROUP, {id: groupID}).then(res => {
+            let caseDeploy = res.apiGWGroupbyid;
+            let domain = caseDeploy.defaultDomain;
+            if (this._isMounted) {
+                this.setState({
+                    domain
+                })
+            }
+        })
+
+    }
+
+    componentWillUnmount() {
+        this._isMounted = false;
+    }
+
+    deploy = () => {
+        this._isMounted = true;
+        let _this = this;
+        let {userID, dbKind, bucketName, customName} = this.state;
+
+        if (bucketName === '') {
+            console.log('state, 没有传值');
+        } else {
+
+            // 开始调用
+            console.log('开始调用');
+            this.setState({
+                disableDeployButton: true
+            });
+
+            let now = new Date().getTime(),
+                functionName = this.state.userID + '_' + customName,
+                serviceName = this.state.userID + '_' + customName,
+                resources = [`${bucketName}/schema.edn`, `${bucketName}/resolve-map.edn`, `${bucketName}/${dbKind}/${userID}/deploy-conf.edn`];
+
+            if (dbKind === 'mongodb') {
+                resources.push(`${bucketName}/${dbKind}/${userID}/mongo-config.edn`)
+            }
+
+
+            console.log('now', now, 'functionName', functionName, 'serviceName', serviceName, 'resources', resources);
+            axios.post(deployAll,
+                {
+                    'fc-name': functionName,
+                    'bucket': dbKind === 'mongodb' ? 'native-fc' : 'fcdb-deploy',
+                    'object-file': 'fc-only.zip',
+                    'res-bucket': 'case',
+                    'resources': resources,
+                    'service-name': serviceName,
+                    'path': "/*"
+                })
+                .then(function (response) {
+                    console.log('response', response);
+                    if (response['data']['apigw-result'] && response['data']['fc-result']) {
+                        // 处理数据
+                        let result = response['data']['apigw-result'];
+                        let apiData = result['api-info'];
+                        let serviceData = result['service-info'];
+
+                        // 存数据
+                        let pathID = idGen('path'),
+                            groupID = idGen('group'),
+                            deployID = idGen('deploy'),
+                            projectID = idGen('project');
+
+                        let {apiId, path, method} = apiData;
+                        let {serviceName, serviceId, subDomain} = serviceData;
+
+                        let {userID, cloudID} = _this.state;
+
+                        let pathVarObj = {
+                            id: idGen('path'),
+                            user_id: userID,
+                            apiGWGroup_id: pathID,
+                            deploy_id: deployID,
+                            apiGWName: functionName,
+                            requestMethod: method,
+                            apiGWPath: path,
+                            apiId: apiId,
+                            apiGWDesc: '',
+                            serviceType: 'SCF',
+                            timeout: 300,
+                            createdAt: now,
+                            updatedAt: ''
+                        };
+
+                        let projectVarObj = {
+                            id: projectID,
+                            projectType: 'case',
+                            cloud_id: cloudID,
+                            user_id: userID,
+                            projectName: functionName,
+                            database_id: '',
+                            apiGWGroup_id: '',
+                            deploy_id: '',
+                            case_id: '',
+                            wxConfig_id: '',
+                            schema_id: '',
+                            createdAt: now,
+                            updatedAt: '',
+                            projectStatus: 'deployed'
+                        };
+
+                        let groupVarObj = {
+                            id: groupID,
+                            cloud_id: cloudID,
+                            user_id: userID,
+                            userStatus: '',
+                            userDomain: '',
+                            groupName: serviceName,
+                            frontType: '',
+                            region: '',
+                            environmentName: '',
+                            defaultDomain: subDomain,
+                            status: '',
+                            serviceId: serviceId,
+                            createdAt: now,
+                            updatedAt: ''
+                        };
+
+                        let deployVarObj = {
+                            id: deployID,
+                            cloud_id: cloudID,
+                            functionName,
+                            cosObjectName: '',
+                            region: '',
+                            cosBucketRegion: '',
+                            description: '',
+                            cosBucketName: '',
+                            vpcId: '',
+                            subnetId: '',
+                            memorySize: 512,
+                            timeout: 300,
+                            handler: '',
+                            serviceName: "",
+                            fc_id: '',
+                            createdAt: now,
+                            updatedAt: ''
+                        };
+
+                        let add_apigwpath = request(graphqlUrl, ADD_APIGWPATH, pathVarObj),
+                            add_project = request(graphqlUrl, ADD_PROJECT, projectVarObj),
+                            add_apigroup = request(graphqlUrl, ADD_APIGROUP, groupVarObj),
+                            add_deploy = request(graphqlUrl, ADD_DEPLOY, deployVarObj);
+
+                        Promise.all([add_apigwpath, add_project, add_apigroup, add_deploy])
+                            .then(value => {
+                                console.log(value);
+
+                                // 展示数据
+                                if (_this._isMounted) {
+                                    _this.setState({
+                                        disableDeployButton: false
+                                    });
+                                }
+
+                                _this.props.changeTabBar('my-deploy');
+                                _this.props.history.push({
+                                    pathname: `/common/deploy`,
+                                    state: {
+                                        // 处理传回数据,直接拼接
+                                        url: `http://${subDomain}/test/graphql`
+                                    }
+                                });
+                            })
+                            .catch(err => {
+                                console.log(err);
+                            });
+                    } else {
+                        console.log('deployAll 失败');
+                    }
+
+                })
+                .catch(function (error) {
+                    console.log('axios error', error);
+                });
+        }
+    };
+
+
+    render() {
+        let {userID, disableDeployButton, appId, secretID, secretKey, bucketName, dbKind, domain, showCustom, cloudName, check} = this.state;
+        return (
+            <div className={'deploy-choose-cloud'}>
+                <Layout style={{padding: '24px', minHeight: '300px'}}>
+                    <Content style={{padding: '20px 50px', background: '#fff'}}>
+
+
+
+                        <div style={{marginTop: 20}}>
+                            {
+                                !showCustom ?
+                                    <div className={'choose-cloud-button-group'}>
+                                        <Button className={'choose-cloud-button'} type='primary' onClick={() => {
+                                            if (userID === '') {
+                                                notification['warning']({
+                                                    message: '需要登录',
+                                                    description: '后续使用,需要先登录',
+                                                });
+
+                                                this.props.history.push({
+                                                    pathname: `/login`
+                                                })
+                                            } else {
+                                                this.setState({
+                                                    showCustom: true
+                                                })
+                                            }
+                                        }}>自定义参数设置</Button>
+                                    </div>
+                                    :
+                                    <div>
+                                        <hr/>
+                                        <div>
+                                            <div className={'schema-name'}><FormattedMessage id='Name'/></div>
+                                            <div>
+                                                <span className='item-title-cloud'><FormattedMessage id='name'/>:</span>
+                                                <Input style={{width: 250}} value={this.state.customName}
+                                                       onChange={(e) => {
+                                                           this.setState({customName: e.target.value})
+                                                       }}/>
+                                            </div>
+                                        </div>
+                                        <div style={{marginTop: 20}}>
+                                            <div className={'schema-name'}><FormattedMessage id='Cloud Setting'/></div>
+                                            <RadioGroup onChange={(e) => {
+                                                this.setState({cloudName: e.target.value})
+                                            }} value={this.state.cloudName}>
+                                                <Radio value={'tencent'}><FormattedMessage id='tencent cloud'/></Radio>
+                                                <Radio value={'aliyun'}><FormattedMessage id='aliyun'/></Radio>
+                                                <Radio value={'amazon'}><FormattedMessage id='amazon cloud'/></Radio>
+                                            </RadioGroup>
+
+                                        </div>
+                                        <div style={{marginTop: 20}}>
+                                            <div className={'schema-name'}><FormattedMessage id='DB Choose'/></div>
+                                            <RadioGroup onChange={(e) => {
+                                                this.setState({dbKind: e.target.value})
+                                            }} value={this.state.dbKind}>
+                                                <Radio value='fc-db'>fc-db</Radio>
+                                                <Radio value='mongodb'>mongodb</Radio>
+                                            </RadioGroup>
+                                        </div>
+                                        {
+                                            disableDeployButton ?
+                                                <Spin/>
+                                                :
+                                                <Button style={{marginTop: 20}} type='primary' onClick={() => {
+                                                    if (appId && secretID && secretKey) {
+                                                        this.setState({
+                                                            disableDeployButton: true
+                                                        });
+
+                                                        // store *.edn to cos
+                                                        let deployConf = dbKind === 'mongodb' ?
+                                                            ` {:secretId "${secretID}"\n` +
+                                                            ` :secretKey "${secretKey}"\n` +
+                                                            ` :appId "${appId}"\n` +
+                                                            ' :region "ap-beijing" \n' +
+                                                            ' }\n'
+                                                            :
+                                                            ` {:secretId "${secretID}"\n` +
+                                                            ` :secretKey "${secretKey}"\n` +
+                                                            ` :appId "${appId}"\n` +
+                                                            ' :region "ap-beijing"\n' +
+                                                            ' :bucket "fc-db"\n' +
+                                                            ' :trustStore "/etc/ssl/certs/java/cacerts"\n' +
+                                                            ` :fc-db-store "save/${bucketName}.dat"\n` +
+                                                            ' :fc-db-dir "fc-db"\n' +
+                                                            ' :graphql-url "http://orderfcdb.ioobot.cn/graphql"\n' +
+                                                            ' :local-tmp-dir "/tmp"\n' +
+                                                            ' :local-db-file "fcdb.dat"\n' +
+                                                            ' :update-tx? true \n' +
+                                                            ' :force-down? true\n' +
+                                                            ' }';
+
+                                                        let a = axios.post(storeFile, {
+                                                            'file-name': `${bucketName}/${dbKind}/${userID}/deploy-conf.edn`,
+                                                            bucket: 'case',
+                                                            cont: deployConf
+                                                        });
+
+                                                        let cont = '{:uri {\n' +
+                                                            ':auth {:admin-db   "order"\n' +
+                                                            ' :u    "ly"\n' +
+                                                            ' :p   "autorunC1705"\n' +
+                                                            ' :host "119.27.174.13"}}\n' +
+                                                            ' :db-name "order"}';
+
+                                                        let b = dbKind === 'mongodb' ?
+                                                            axios.post(storeFile, {
+                                                                'file-name': `${bucketName}/${dbKind}/${userID}/mongo-config.edn`,
+                                                                bucket: 'case',
+                                                                cont
+                                                            })
+                                                            :
+                                                            Promise.resolve({status: 200});
+
+                                                        Promise.all([a, b]).then(value => {
+                                                            if (value.every(res => res.status === 200)) {
+                                                                console.log('store file success , start deploying');
+                                                                this.deploy();
+                                                            }
+                                                        });
+                                                    } else {
+                                                        notification['warning']({
+                                                            message: '需要填写配置',
+                                                            description: '后续使用,需要先填写配置',
+                                                        });
+
+                                                        this.props.history.push({
+                                                            pathname: `/login/cloud`
+                                                        })
+                                                    }
+                                                }}>部署</Button>
+                                        }
+                                    </div>
+                            }
+                        </div>
+                    </Content>
+                </Layout>
+            </div>
+        )
+    }
+}
+
+export default DeployCloudChoose

+ 1 - 0
src/gql.js

@@ -1088,6 +1088,7 @@ const SHOW_ALL_CASE = `
                     user_id {
                         id
                         avatar
+                        email
                     }
                     like
                     schema_id {