kulley 7 vuotta sitten
vanhempi
commit
cf5cb01ee5

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

@@ -198,7 +198,7 @@ class User extends Component {
                 {
                     ({loading, error, data}) => {
                         if (loading) {
-                            return <Spin style={{marginLeft: 3}}/>
+                            return <Spin className='login-nickname'/>
                         }
                         if (error) {
                             return 'error!';

+ 8 - 3
src/app/basicVersion/exampleShow/DeployCloudChoose.js

@@ -18,6 +18,7 @@ class DeployCloudChoose extends Component {
         this.state = {
             userID: 'demo',
             dbKind: 'mongodb', // mongodb fc-db
+            cloudName: 'tencent',
             cloudID: 'tencent_CloudID',
             secretID: '',
             secretKey: '',
@@ -43,7 +44,8 @@ class DeployCloudChoose extends Component {
                                     cloudID: cloud.id,
                                     secretID: cloud.secretId,
                                     secretKey: cloud.secretKey,
-                                    appId: cloud.appId
+                                    appId: cloud.appId,
+                                    cloudName: 'tencent'
                                 });
                                 break;
                             case 'aliyun':
@@ -113,7 +115,7 @@ class DeployCloudChoose extends Component {
                     'path': "/*"
                 })
                 .then(function (response) {
-                    console.log(response);
+                    console.log('response', response);
                     if(response['data']['apigw-result'] && response['data']['fc-result']) {
                         // 处理数据
                         let result = response['data']['apigw-result'];
@@ -217,7 +219,10 @@ class DeployCloudChoose extends Component {
                                 _this.props.changeTabBar('my-deploy');
                                 _this.props.history.push({
                                     pathname: `/common/deploy`,
-                                    state: {}
+                                    state: {
+                                        // 处理传回数据,直接拼接
+                                        url: `http://${subDomain}/test/graphql`
+                                    }
                                 });
                             })
                             .catch(err => {

+ 1 - 1
src/app/basicVersion/exampleShow/ExampleShow.jsx

@@ -20,7 +20,7 @@ class ExampleShow extends Component {
 
     componentWillMount() {
         request(graphqlUrl, SHOW_CASE, {user_id: 'ioobot'}).then(data => {
-            console.log('eample data',data.case_by_props);
+            // console.log('eample data',data.case_by_props);
             // Object.prototype.toString.call(data.case_by_props) === '[object Array]';
                 if (Object.prototype.toString.call(data.case_by_props).split(' ')[1].slice(0, -1).toLowerCase() === 'array') {
                     this.setState({

+ 148 - 0
src/app/basicVersion/myDeploy/AliyunDeploy.js

@@ -0,0 +1,148 @@
+import React, {Component} from 'react';
+import {FormattedMessage} from 'react-intl';
+import {Alert, Icon, Spin, Row, Col, message, Button} from 'antd';
+import {
+    SHOW_APIGROUP
+} from "../../../gql";
+import {request} from 'graphql-request'
+import copy from 'copy-to-clipboard';
+import axios from 'axios';
+import {graphqlUrl} from "../../../config";
+
+axios.defaults.withCredentials = true;
+
+class TencentDeploy extends Component {
+    constructor(props) {
+        super(props);
+        this.state = {
+            userID: props.userID,
+            url: props.url,
+            show: false,
+            deployed: []
+        }
+    }
+
+    componentWillMount() {
+        let {userID} = this.state;
+        if (userID !== 'demo') {
+            request(graphqlUrl, SHOW_APIGROUP, {userID}).then(res => {
+                console.log(res);
+                let allDeployed = res.apiGWGroupbyprops;
+                let deployed = allDeployed.filter(deployed =>
+                    deployed.cloud_id.cloudName === 'aliyun'
+                );
+                this.setState({
+                    deployed,
+                    show: true
+                })
+            })
+        }
+    }
+
+    render() {
+        let {userID, url, deployed, show} = this.state;
+        return (
+            <div>
+                {
+                    userID === 'demo' && !!url ?
+                        <Alert
+                            message="WARNING"
+                            description="it will be deleted soon, please login to deploy in your owm account"
+                            type="warning"
+                        />
+                        : ''
+                }
+
+                {
+                    !!url ?
+                        <div>
+                            <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>
+                                </Row>
+                            </div>
+                            <div className={'schema-table-list-content'}>
+                                <Row>
+                                    <Col span={15}>
+                                        <span className={'schema-table-content'}>{`http://${url}/test/graphql`} </span>
+                                        <Icon type="copy" theme="twoTone" onClick={() => {
+                                            copy(url);
+                                            message.success('复制成功.');
+                                        }}/>
+                                    </Col>
+                                </Row>
+                            </div>
+                        </div>
+                        :
+                        ''
+                }
+                {
+                    userID === 'demo' ?
+                        <div style={{marginTop: 50}}>
+                            <FormattedMessage id='go to deploy,then see more'/>
+                        </div>
+
+                        :
+                        <div>
+                            <div className={'schema-name'}><FormattedMessage id='service manage'/></div>
+                            <div className={'schema-table-list-title'}>
+                                <Row>
+                                    <Col span={5}><span className={'schema-table-title'}><FormattedMessage
+                                        id='groupName'/></span></Col>
+                                    <Col span={15}><span className={'schema-table-title'}><FormattedMessage
+                                        id='defaultDomain'/></span></Col>
+                                    <Col span={4}><span className={'schema-table-title'}><FormattedMessage
+                                        id='operation'/></span></Col>
+                                </Row>
+                            </div>
+                            {
+                                show ?
+                                    <div className={'schema-table-list-content'}>
+                                        {
+                                            deployed.map(deploy => (
+                                                <Row key={deploy.id}>
+                                                    <Col span={5}>
+                                                        <span
+                                                            className={'schema-table-content'}>{deploy.serviceId}</span>
+                                                    </Col>
+                                                    <Col span={15}>
+                                                        <span
+                                                            className={'schema-table-content'}>{`http://${deploy.defaultDomain}/test/graphql`} </span>
+                                                        <Icon type="copy" theme="twoTone" onClick={() => {
+                                                            copy(url);
+                                                            message.success('复制成功.');
+                                                        }}/>
+                                                    </Col>
+                                                    <Col span={4}>
+                                                        <Button type={'danger'} size={'small'}
+                                                                style={{marginTop: 10}}><FormattedMessage id='delete'/></Button>
+                                                    </Col>
+                                                </Row>
+                                            ))
+                                        }
+                                        {
+                                            deployed.length === 0 ?
+                                                <Row>
+                                                    <Col span={15} offset={5}>
+                                                        <span className={'schema-table-content'}><FormattedMessage
+                                                            id='nothing'/> </span>
+                                                    </Col>
+                                                </Row> :
+                                                ''
+                                        }
+                                    </div>
+                                    :
+                                    <Spin/>
+                            }
+
+                        </div>
+
+                }
+            </div>
+        )
+    }
+}
+
+export default TencentDeploy;

+ 148 - 0
src/app/basicVersion/myDeploy/AmazonDeploy.js

@@ -0,0 +1,148 @@
+import React, {Component} from 'react';
+import {FormattedMessage} from 'react-intl';
+import {Alert, Icon, Spin, Row, Col, message, Button} from 'antd';
+import {
+    SHOW_APIGROUP
+} from "../../../gql";
+import {request} from 'graphql-request'
+import copy from 'copy-to-clipboard';
+import axios from 'axios';
+import {graphqlUrl} from "../../../config";
+
+axios.defaults.withCredentials = true;
+
+class TencentDeploy extends Component {
+    constructor(props) {
+        super(props);
+        this.state = {
+            userID: props.userID,
+            url: props.url,
+            show: false,
+            deployed: []
+        }
+    }
+
+    componentWillMount() {
+        let {userID} = this.state;
+        if (userID !== 'demo') {
+            request(graphqlUrl, SHOW_APIGROUP, {userID}).then(res => {
+                console.log(res);
+                let allDeployed = res.apiGWGroupbyprops;
+                let deployed = allDeployed.filter(deployed =>
+                    deployed.cloud_id.cloudName === 'amazon'
+                );
+                this.setState({
+                    deployed,
+                    show: true
+                })
+            })
+        }
+    }
+
+    render() {
+        let {userID, url, deployed, show} = this.state;
+        return (
+            <div>
+                {
+                    userID === 'demo' && !!url ?
+                        <Alert
+                            message="WARNING"
+                            description="it will be deleted soon, please login to deploy in your owm account"
+                            type="warning"
+                        />
+                        : ''
+                }
+
+                {
+                    !!url ?
+                        <div>
+                            <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>
+                                </Row>
+                            </div>
+                            <div className={'schema-table-list-content'}>
+                                <Row>
+                                    <Col span={15}>
+                                        <span className={'schema-table-content'}>{`http://${url}/test/graphql`} </span>
+                                        <Icon type="copy" theme="twoTone" onClick={() => {
+                                            copy(url);
+                                            message.success('复制成功.');
+                                        }}/>
+                                    </Col>
+                                </Row>
+                            </div>
+                        </div>
+                        :
+                        ''
+                }
+                {
+                    userID === 'demo' ?
+                        <div style={{marginTop: 50}}>
+                            <FormattedMessage id='go to deploy,then see more'/>
+                        </div>
+
+                        :
+                        <div>
+                            <div className={'schema-name'}><FormattedMessage id='service manage'/></div>
+                            <div className={'schema-table-list-title'}>
+                                <Row>
+                                    <Col span={5}><span className={'schema-table-title'}><FormattedMessage
+                                        id='groupName'/></span></Col>
+                                    <Col span={15}><span className={'schema-table-title'}><FormattedMessage
+                                        id='defaultDomain'/></span></Col>
+                                    <Col span={4}><span className={'schema-table-title'}><FormattedMessage
+                                        id='operation'/></span></Col>
+                                </Row>
+                            </div>
+                            {
+                                show ?
+                                    <div className={'schema-table-list-content'}>
+                                        {
+                                            deployed.map(deploy => (
+                                                <Row key={deploy.id}>
+                                                    <Col span={5}>
+                                                        <span
+                                                            className={'schema-table-content'}>{deploy.serviceId}</span>
+                                                    </Col>
+                                                    <Col span={15}>
+                                                        <span
+                                                            className={'schema-table-content'}>{`http://${deploy.defaultDomain}/test/graphql`} </span>
+                                                        <Icon type="copy" theme="twoTone" onClick={() => {
+                                                            copy(url);
+                                                            message.success('复制成功.');
+                                                        }}/>
+                                                    </Col>
+                                                    <Col span={4}>
+                                                        <Button type={'danger'} size={'small'}
+                                                                style={{marginTop: 10}}><FormattedMessage id='delete'/></Button>
+                                                    </Col>
+                                                </Row>
+                                            ))
+                                        }
+                                        {
+                                            deployed.length === 0 ?
+                                                <Row>
+                                                    <Col span={15} offset={5}>
+                                                        <span className={'schema-table-content'}><FormattedMessage
+                                                            id='nothing'/> </span>
+                                                    </Col>
+                                                </Row> :
+                                                ''
+                                        }
+                                    </div>
+                                    :
+                                    <Spin/>
+                            }
+
+                        </div>
+
+                }
+            </div>
+        )
+    }
+}
+
+export default TencentDeploy;

+ 70 - 8
src/app/basicVersion/myDeploy/MyDeploy.jsx

@@ -1,26 +1,88 @@
 import React, {Component} from 'react';
+import {FormattedMessage} from 'react-intl';
+import {Card, Layout} from 'antd';
 
-import {Layout} from 'antd';
+import TencentDeploy from './TencentDeploy';
+import AliyunDeploy from './AliyunDeploy';
+import AmazonDeploy from './AmazonDeploy';
+import {getCookie} from "../../../cookie";
 
 const {Content} = Layout;
 
-class MyDeploy extends Component{
-    constructor(){
-        super();
-        this.state={
 
+const tabListNoTitle =
+    [{
+        key: 'tencent',
+        tab: <FormattedMessage id='Tencent'/>,
+    }, {
+        key: 'aliyun',
+        tab: <FormattedMessage id='Aliyun'/>,
+    }, {
+        key: 'amazon',
+        tab: <FormattedMessage id='AWS'/>,
+    }];
+
+
+class MyDeploy extends Component {
+    constructor(props) {
+        super(props);
+        this.state = {
+            cloud: 'tencent',
+            userID: 'demo',
+            url: ''
+        };
+    }
+
+    componentWillMount() {
+        let userID = getCookie('user_id') || this.state.userID;
+        if (userID !== undefined && userID !== '') {
+            this.setState({
+                userID
+            });
+        }
+
+        if(this.props.location && this.props.location.state) {
+            this.setState({
+                url: this.props.location.state.url
+            })
         }
     }
 
-    render(){
-        return(
+    render() {
+        let {url, userID} = this.state;
+        const contentListNoTitle = {
+            tencent: <TencentDeploy userID={userID} url={url}/>,
+            aliyun: <AliyunDeploy userID={userID} url={url}/>,
+            amazon: <AmazonDeploy userID={userID} url={url}/>,
+        };
+
+        return (
             <div>
                 <Layout style={{ padding: '24px',minHeight:'300px' }}>
                     <Content style={{ padding: '20px 50px', background: '#fff' }}>
-                        MyDeploy
+                        {
+                            // 登录用户与非登录用户区别对待
+                            this.state.userID === 'demo'?
+                                <TencentDeploy userID={userID} url={url}/>
+                                :
+                                <Card
+                                    style={{width: '100%'}}
+                                    tabList={tabListNoTitle}
+                                    activeTabKey={this.state.cloud}
+                                    onTabChange={(cloud) => {
+                                        this.setState({
+                                            cloud
+                                        })
+                                    }}
+                                >
+                                    {contentListNoTitle[this.state.cloud]}
+                                </Card>
+                        }
+
                     </Content>
                 </Layout>
             </div>
+
         )
     }
 }

+ 148 - 0
src/app/basicVersion/myDeploy/TencentDeploy.js

@@ -0,0 +1,148 @@
+import React, {Component} from 'react';
+import {FormattedMessage} from 'react-intl';
+import {Alert, Icon, Spin, Row, Col, message, Button} from 'antd';
+import {
+    SHOW_APIGROUP
+} from "../../../gql";
+import {request} from 'graphql-request'
+import copy from 'copy-to-clipboard';
+import axios from 'axios';
+import {graphqlUrl} from "../../../config";
+
+axios.defaults.withCredentials = true;
+
+class TencentDeploy extends Component {
+    constructor(props) {
+        super(props);
+        this.state = {
+            userID: props.userID,
+            url: props.url,
+            show: false,
+            deployed: []
+        }
+    }
+
+    componentWillMount() {
+        let {userID} = this.state;
+        if (userID !== 'demo') {
+            request(graphqlUrl, SHOW_APIGROUP, {userID}).then(res => {
+                console.log(res);
+                let allDeployed = res.apiGWGroupbyprops;
+                let deployed = allDeployed.filter(deployed =>
+                    deployed.cloud_id.cloudName === 'tencent'
+                );
+                this.setState({
+                    deployed,
+                    show: true
+                })
+            })
+        }
+    }
+
+    render() {
+        let {userID, url, deployed, show} = this.state;
+        return (
+            <div>
+                {
+                    userID === 'demo' && !!url ?
+                        <Alert
+                            message="WARNING"
+                            description="it will be deleted soon, please login to deploy in your owm account"
+                            type="warning"
+                        />
+                        : ''
+                }
+
+                {
+                    !!url ?
+                        <div>
+                            <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>
+                                </Row>
+                            </div>
+                            <div className={'schema-table-list-content'}>
+                                <Row>
+                                    <Col span={15}>
+                                        <span className={'schema-table-content'}>{`http://${url}/test/graphql`} </span>
+                                        <Icon type="copy" theme="twoTone" onClick={() => {
+                                            copy(url);
+                                            message.success('复制成功.');
+                                        }}/>
+                                    </Col>
+                                </Row>
+                            </div>
+                        </div>
+                        :
+                        ''
+                }
+                {
+                    userID === 'demo' ?
+                        <div style={{marginTop: 50}}>
+                            <FormattedMessage id='go to deploy,then see more'/>
+                        </div>
+
+                        :
+                        <div>
+                            <div className={'schema-name'}><FormattedMessage id='service manage'/></div>
+                            <div className={'schema-table-list-title'}>
+                                <Row>
+                                    <Col span={5}><span className={'schema-table-title'}><FormattedMessage
+                                        id='groupName'/></span></Col>
+                                    <Col span={15}><span className={'schema-table-title'}><FormattedMessage
+                                        id='defaultDomain'/></span></Col>
+                                    <Col span={4}><span className={'schema-table-title'}><FormattedMessage
+                                        id='operation'/></span></Col>
+                                </Row>
+                            </div>
+                            {
+                                show ?
+                                    <div className={'schema-table-list-content'}>
+                                        {
+                                            deployed.map(deploy => (
+                                                <Row key={deploy.id}>
+                                                    <Col span={5}>
+                                                        <span
+                                                            className={'schema-table-content'}>{deploy.serviceId}</span>
+                                                    </Col>
+                                                    <Col span={15}>
+                                                        <span
+                                                            className={'schema-table-content'}>{`http://${deploy.defaultDomain}/test/graphql`} </span>
+                                                        <Icon type="copy" theme="twoTone" onClick={() => {
+                                                            copy(url);
+                                                            message.success('复制成功.');
+                                                        }}/>
+                                                    </Col>
+                                                    <Col span={4}>
+                                                        <Button type={'danger'} size={'small'}
+                                                                style={{marginTop: 10}}><FormattedMessage id='delete'/></Button>
+                                                    </Col>
+                                                </Row>
+                                            ))
+                                        }
+                                        {
+                                            deployed.length === 0 ?
+                                                <Row>
+                                                    <Col span={15} offset={5}>
+                                                        <span className={'schema-table-content'}><FormattedMessage
+                                                            id='nothing'/> </span>
+                                                    </Col>
+                                                </Row> :
+                                                ''
+                                        }
+                                    </div>
+                                    :
+                                    <Spin/>
+                            }
+
+                        </div>
+
+                }
+            </div>
+        )
+    }
+}
+
+export default TencentDeploy;

+ 1 - 1
src/app/developVersion/DevelopVersion.jsx

@@ -626,7 +626,7 @@ class User extends Component {
                 {
                     ({loading, error, data}) => {
                         if (loading) {
-                            return <Spin style={{marginLeft: 3}}/>
+                            return <Spin className='login-nickname'/>
                         }
                         if (error) {
                             return 'error!';

+ 22 - 0
src/gql.js

@@ -561,6 +561,27 @@ const UPDATE_DEPLOY = `
             }
         `;
 
+const SHOW_APIGROUP = `
+    query apiGWGroupbyprops($user_id: ID) {
+          apiGWGroupbyprops: apiGWGroup_by_props(user_id: $user_id) {
+                environmentName
+                userStatus
+                defaultDomain
+                updatedAt
+                userDomain
+                groupName
+                createdAt
+                frontType
+                region
+                serviceId
+                status
+                id
+                cloud_id {
+                  cloudName
+                }
+          }
+    }
+`;
 
 const ADD_APIGROUP = `
             mutation GROUP($serviceId: String, $environmentName: String, $userStatus: String, $defaultDomain: String, $updatedAt: String, $userDomain: String, $groupName: String, $createdAt: String, $frontType: String, $region: String, $status: String, $id: ID!, $cloud_id: ID, $user_id: ID) {
@@ -1047,6 +1068,7 @@ export {
     UPDATE_CLOUD,
     ADD_DEPLOY,
     UPDATE_DEPLOY,
+    SHOW_APIGROUP,
     ADD_APIGROUP,
     UPDATE_APIGROUP,
     DELETE_APIGROUP,

+ 4 - 1
src/language/en_US.js

@@ -161,6 +161,9 @@ const en_US = {
     'Example': 'Example',
     'My deploy': 'My deploy',
     'Communication': 'Communication',
-    'loading': 'loading...'
+    'loading': 'loading...',
+    'nothing': 'nothing...',
+    'new': 'new!',
+    'go to deploy,then see more': 'go to deploy,then see more'
 };
 export default en_US;

+ 4 - 1
src/language/zh_CN.js

@@ -162,6 +162,9 @@ const zh_CN = {
     'Example': '例子',
     'My deploy': '我的部署',
     'Communication': '交流',
-    'loading': '加载中...'
+    'loading': '加载中...',
+    'nothing': '这里什么都没有...',
+    'new': '新!',
+    'go to deploy,then see more': '部署以查看更多'
 };
 export default zh_CN;

+ 0 - 1
src/login/LoginInput.js

@@ -39,7 +39,6 @@ class LoginInput extends Component {
 
     login = () => {
         let _this = this;
-        this._isMounted = true;
         // let loginUrl = `http://localhost:8999/login`;
 
         if (this.state.login_username !== '' && this.state.login_password !== '' ) {