ソースを参照

增加一堆提示

kulley 7 年 前
コミット
db2bc8776b

+ 126 - 48
src/app/basicVersion/caseShow/UserCustom.js

@@ -1,5 +1,5 @@
 import React, {Component} from 'react';
-import { Link } from 'react-router-dom';
+import {Link} from 'react-router-dom';
 import {deployAll, graphqlUrl, storeFile} from "../../../config";
 import {ADD_APIGROUP, ADD_APIGWPATH, ADD_DEPLOY, ADD_PROJECT, SHOW_CLOUD} from "../../../gql";
 import {CloudConfig} from "../../../login/CloudConfig";
@@ -24,6 +24,7 @@ class UserCustom extends Component {
             dbKind: 'fc-db', // mongodb fc-db
             check: 0,
             disableDeployButton: false,
+            deployFailed: false
         };
 
         this.cloudState = {
@@ -196,6 +197,9 @@ class UserCustom extends Component {
                             });
                     } else {
                         console.log('deployAll 失败');
+                        _this.setState({
+                            deployFailed: true
+                        })
                     }
 
                 })
@@ -214,7 +218,7 @@ class UserCustom extends Component {
     }
 
     render() {
-        let {cloudName, customName, disableDeployButton, userID, check, dbKind, bucketName} = this.state;
+        let {cloudName, customName, disableDeployButton, userID, check, dbKind, bucketName, deployFailed} = this.state;
         let {appId, secretID, secretKey} = this.cloudState;
         return (
             <div>
@@ -240,6 +244,7 @@ class UserCustom extends Component {
                 <div style={{marginTop: 20}}>
                     <div className={'schema-name'}><FormattedMessage id='Cloud Setting'/></div>
                     <p><Link to="/common/communication">阿里云、华为云、亚马逊请联系我们</Link></p>
+                    <p style={{color: 'red'}}>该项配置填写错误将导致部署失败,你也可以忽略此项配置!</p>
                     <br/>
                     <RadioGroup
                         onChange={(e) => {
@@ -274,27 +279,102 @@ class UserCustom extends Component {
                         {/*<Radio value='mongodb'>mongodb</Radio>*/}
                     </RadioGroup>
                 </div>
-                {
-                    disableDeployButton ?
-                        <Spin tip="部署大约需要几分钟..."/>
-                        :
-                        <Button style={{margin: '20px 0'}} type='primary' onClick={() => {
-                            if (appId && secretID && secretKey) {
+                <div>
+                    {
+                        deployFailed?
+                            '部署失败!'
+                            :
+                            ''
+                    }
+                </div>
+                <div>
+                    {
+                        disableDeployButton ?
+                            <Spin tip="部署大约需要几分钟..."/>
+                            :
+                            <Button style={{margin: '20px 0'}} 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`
+                                //     })
+                                // }
+
                                 this.setState({
                                     disableDeployButton: true
                                 });
 
                                 // store *.edn to cos
                                 let deployConf = dbKind === 'mongodb' ?
-                                    ` {:secretId "${secretID}"\n` +
-                                    ` :secretKey "${secretKey}"\n` +
+                                    ` {:secretId "${secretID ? secretID : 'AKIDkYBvY0LOJ2bzCDmnMjz4xgFertmVJlVE'}"\n` +
+                                    ` :secretKey "${secretKey ? secretKey : 'zwjKk29TdcYP8g2FG5kCSWmz3wcH92lN'}"\n` +
                                     ` :appId "${appId}"\n` +
                                     ' :region "ap-beijing" \n' +
                                     ' }\n'
                                     :
-                                    ` {:secretId "${secretID}"\n` +
-                                    ` :secretKey "${secretKey}"\n` +
-                                    ` :appId "${appId}"\n` +
+                                    ` {:secretId "${secretID ? secretID : 'AKIDkYBvY0LOJ2bzCDmnMjz4xgFertmVJlVE'}"\n` +
+                                    ` :secretKey "${secretKey ? secretKey : 'zwjKk29TdcYP8g2FG5kCSWmz3wcH92lN'}"\n` +
+                                    ` :appId "${appId ? appId : '1254337200'}"\n` +
                                     ' :region "ap-beijing"\n' +
                                     ' :bucket "fc-db"\n' +
                                     ' :trustStore "/etc/ssl/certs/java/cacerts"\n' +
@@ -335,18 +415,9 @@ class UserCustom extends Component {
                                         this.deploy();
                                     }
                                 });
-                            } else {
-                                notification['warning']({
-                                    message: '需要填写配置',
-                                    description: '后续使用,需要先填写配置',
-                                });
-
-                                this.props.history.push({
-                                    pathname: `/login/cloud`
-                                })
-                            }
-                        }}>部署</Button>
-                }
+                            }}>部署</Button>
+                    }
+                </div>
             </div>
         )
     }
@@ -364,7 +435,7 @@ class CloudQueryAndConfig extends Component {
             secretID: '',
             secretKey: '',
             appId: '',
-            showCloudConfigTip: false,
+            exitCloudInfo: false,
 
             visible: false,
             confirmLoading: false,
@@ -381,22 +452,22 @@ class CloudQueryAndConfig extends Component {
                 if (clouds.length === 1) {
                     let cloud = clouds[0];
                     let {id, secretId, secretKey, appId} = cloud;
-                    if(this._isMounted) {
+                    if (this._isMounted) {
                         this.setState({
                             cloudID: id,
                             secretID: secretId,
                             secretKey,
                             appId,
-                            showCloudConfigTip: false
+                            exitCloudInfo: false
                         });
                     }
                     this.props.getCloudDetail(id, secretId, secretKey, appId);
                 } else if (clouds.length > 1) {
                     console.log('数据库有多个同一云服务商的 key');
                 } else {
-                    if(this._isMounted) {
+                    if (this._isMounted) {
                         this.setState({
-                            showCloudConfigTip: true
+                            exitCloudInfo: true
                         })
                     }
                 }
@@ -434,27 +505,34 @@ class CloudQueryAndConfig extends Component {
     }
 
     render() {
-        let {showCloudConfigTip, visible, confirmLoading, cloudName} = this.state;
+        let {exitCloudInfo, visible, confirmLoading, cloudName} = this.state;
         return (
             <div>
                 {
-                    showCloudConfigTip ?
-                        <div>
-                            <Button type="danger" size="small" onClick={this.showModal}>
-                                <FormattedMessage id='no this cloud, click to save'/>
-                            </Button>
-                            <Modal
-                                title="设置 cloud"
-                                visible={visible}
-                                confirmLoading={confirmLoading}
-                                footer={null}
-                                onCancel={this.handleCancel}
-                            >
-                                <CloudConfig cloudName={cloudName}/>
-                            </Modal>
-                        </div>
-                        :
-                        ''
+
+                    <div>
+                        {
+                            exitCloudInfo ?
+                                <Button type="danger" size="small" onClick={this.showModal}>
+                                    <FormattedMessage id='no this cloud, click to save'/>
+                                </Button>
+                                :
+                                <Button size="small" onClick={this.showModal}>
+                                    <FormattedMessage id='there is this cloud, click to check'/>
+                                </Button>
+                        }
+
+                        <Modal
+                            title="设置 cloud"
+                            visible={visible}
+                            confirmLoading={confirmLoading}
+                            footer={null}
+                            onCancel={this.handleCancel}
+                        >
+                            <CloudConfig cloudName={cloudName}/>
+                        </Modal>
+                    </div>
+
                 }
             </div>
         )

+ 2 - 4
src/app/basicVersion/myDeploy/TencentDeploy.js

@@ -82,8 +82,7 @@ class TencentDeployRender extends Component {
                             <div className={'schema-name'}><FormattedMessage id='new'/></div>
                             <div className={'schema-table-list-title'}>
                                 <Row>
-                                    <Col span={15}><span className={'schema-table-title'}><FormattedMessage
-                                        id='defaultDomain'/></span></Col>
+                                    <Col span={15}><span className={'schema-table-title'}><FormattedMessage id='defaultDomain'/></span></Col>
                                 </Row>
                             </div>
                             <div className={'schema-table-list-content'}>
@@ -160,8 +159,7 @@ class TencentDeployRender extends Component {
                                     deployed.length === 0 ?
                                         <Row>
                                             <Col span={15} offset={5}>
-                                                        <span className={'schema-table-content'}><FormattedMessage
-                                                            id='nothing'/> </span>
+                                                <span className={'schema-table-content'}><FormattedMessage id='nothing'/> </span>
                                             </Col>
                                         </Row> :
                                         ''

+ 1 - 0
src/language/en_US.js

@@ -175,6 +175,7 @@ const en_US = {
     'aliyun': 'Aliyun',
     'amazon cloud': 'AWS',
     'no this cloud, click to save': 'no this cloud, click to save',
+    'there is this cloud, click to check': 'there is this cloud, click to check',
     'back to case show': 'back to case show',
     'back to all case show': 'back to case store',
     'scan and use': 'scan and try',

+ 1 - 0
src/language/zh_CN.js

@@ -176,6 +176,7 @@ const zh_CN = {
     'aliyun': '阿里云',
     'amazon cloud': 'AWS',
     'no this cloud, click to save': '没有该服务商的 key,点我设置',
+    'there is this cloud, click to check': '存在该服务商的 key,点我检查',
     'back to case show': '返回该案例',
     'back to all case show': '返回案例商城',
     'scan and use': '案例商城,扫码体验',

+ 33 - 11
src/login/CloudConfig.js

@@ -1,6 +1,6 @@
 import React, {Component} from 'react';
 import {FormattedMessage} from 'react-intl';
-import {Button, Input, Spin, Icon} from 'antd';
+import {Button, Input, Spin, Icon, Collapse} from 'antd';
 
 import {SHOW_CLOUD, ADD_CLOUD, UPDATE_CLOUD} from "../gql";
 import {request} from 'graphql-request'
@@ -8,6 +8,8 @@ import {getCookie} from '../cookie';
 import {idGen} from "../func";
 import {graphqlUrl} from "../config";
 
+const Panel = Collapse.Panel;
+
 class CloudConfig extends Component {
     constructor(props) {
         super(props);
@@ -129,11 +131,36 @@ class CloudConfig extends Component {
     render() {
         let {show, tenID, tenAppID, tenKey, tencentCLoudID, aliyunCLoudID, aliAppID, aliID, aliKey, showOK, showNotOK} = this.state;
         let {cloudName} = this.props;
+
+        const customPanelStyle = {
+            background: '#f7f7f7',
+            borderRadius: 4,
+            marginBottom: 24,
+            border: 0,
+            overflow: 'hidden',
+        };
         return (
             <div>
                 {
                     show ?
                         <div>
+                            <Collapse
+                                bordered={false}
+                                expandIcon={({ isActive }) => <Icon type="caret-right" rotate={isActive ? 90 : 0} />}
+                            >
+                                <Panel header="我为什么要填写这项配置?" key="1" style={customPanelStyle}>
+                                    <p>如不填写,默认使用 ioobot 提供的账户进行体验。</p>
+                                    <p>但我们会不定期进行删除您部署的函数和数据库。</p>
+                                    <p>使用自己账户的优点:</p>
+                                    <p>1. 完全体验数据库自有</p>
+                                    <p> 2. 稳定长期存在</p>
+                                </Panel>
+                                <Panel header="我该如何获得这项配置?" key="2" style={customPanelStyle}>
+                                    <p>腾讯云请到:<a href="https://console.cloud.tencent.com/cam/capi" rel="noopener noreferrer" target='_blank'>腾讯云API</a></p>
+                                    <p>阿里云请到:<a href="https://console.cloud.tencent.com/cam/capi" rel="noopener noreferrer" target='_blank'>阿里云API</a></p>
+                                    <p>其他云请联系我们</p>
+                                </Panel>
+                            </Collapse>
                             {
                                 (cloudName === 'all' || cloudName === 'tencent')?
                                     <div style={{marginTop: 15}}>
@@ -142,18 +169,15 @@ class CloudConfig extends Component {
                                             <div>
                                                 <div style={{marginBottom: 20}}>
                                                     <span className='item-title-cloud'>APPID:</span>
-                                                    <Input style={{width: 250}} value={tenAppID}
-                                                           onChange={this.inputChange('tenAppID')}/>
+                                                    <Input style={{width: 250}} value={tenAppID} placeholder={'不保存默认使用 ioobot 账户'} onChange={this.inputChange('tenAppID')}/>
                                                 </div>
                                                 <div style={{marginBottom: 20}}>
                                                     <span className='item-title-cloud'>SecretId:</span>
-                                                    <Input style={{width: 250}} value={tenID}
-                                                           onChange={this.inputChange('tenID')}/>
+                                                    <Input style={{width: 250}} value={tenID} placeholder={'不保存默认使用 ioobot 账户'} onChange={this.inputChange('tenID')}/>
                                                 </div>
                                                 <div style={{marginBottom: 20}}>
                                                     <span className='item-title-cloud'>SecretKey:</span>
-                                                    <Input style={{width: 250}} value={tenKey}
-                                                           onChange={this.inputChange('tenKey')}/>
+                                                    <Input style={{width: 250}} value={tenKey} placeholder={'不保存默认使用 ioobot 账户'} onChange={this.inputChange('tenKey')}/>
                                                 </div>
                                                 {
                                                     this.state.showOK === 'tencent' ?
@@ -181,13 +205,11 @@ class CloudConfig extends Component {
                                             <div>
                                                 <div style={{marginBottom: 10}}>
                                                     <span className='item-title-cloud'>ID:</span>
-                                                    <Input style={{width: 250}} value={aliID}
-                                                           onChange={this.inputChange('aliID')}/>
+                                                    <Input style={{width: 250}} value={aliID} placeholder={'不保存默认使用 ioobot 账户'} onChange={this.inputChange('aliID')}/>
                                                 </div>
                                                 <div style={{marginBottom: 10}}>
                                                     <span className='item-title-cloud'>Key:</span>
-                                                    <Input style={{width: 250}} value={aliKey}
-                                                           onChange={this.inputChange('aliKey')}/>
+                                                    <Input style={{width: 250}} value={aliKey} placeholder={'不保存默认使用 ioobot 账户'} onChange={this.inputChange('aliKey')}/>
                                                 </div>
 
                                                 {

+ 1 - 1
src/login/LoginInput.js

@@ -24,7 +24,7 @@ class LoginInput extends Component {
             userID: '',
             hasLogin: false,
             hasRegister: false,
-            nickname: 'its a default nickname',
+            nickname: 'loading...',
             avatar: '',
             register_username: '',
             register_password: '',