xy 7 năm trước cách đây
mục cha
commit
910ce44456

+ 1 - 83
src/components/app/App.jsx

@@ -338,42 +338,6 @@ class GraphqlSidebar extends Component {
                                     </Menu>
                                 </Sider>
                             )
-
-
-                            // <div key={schema.schemaName} className='title'
-                            //             onClick={() => {
-                            //                 this.props.switchSchema(schema.schemaName, schema.id);
-                            //             }}>
-                            //     <Row>
-                            //         <Col span={20}>{schema.schemaName}</Col>
-                            //         <Col span={4}>
-                            //             <Button onClick={() => this.props.switchTable('add')}
-                            //                     type="primary"
-                            //                     shape="circle" icon="plus" size='small'/>
-                            //             <DeleteSchemaButton
-                            //                 schemaName={schema.schemaName}
-                            //                 userID={this.props.userID}
-                            //             />
-                            //         </Col>
-                            //     </Row>
-                            //
-                            //
-                            //     {
-                            //         JSON.parse(schema.schemaData).map(table => (
-                            //             <p
-                            //                 onClick={() => {
-                            //                     this.props.switchTable(table.name)
-                            //                 }}
-                            //                 key={table.name}
-                            //                 className='show'>
-                            //                 <Icon type="ordered-list" theme="outlined"/> {table.name}
-                            //                 <span className='remark'><i>   {table.remark}</i></span>
-                            //             </p>
-                            //         ))
-                            //     }
-                            // </div>
-
-
                         }
                     }
                 </Query>
@@ -381,50 +345,4 @@ class GraphqlSidebar extends Component {
                 ''
         )
     }
-}
-
-//
-// class DeleteSchemaButton extends Component {
-//     constructor(props) {
-//         super(props);
-//         this.state = {
-//             schemaName: props.schemaName
-//         }
-//     }
-//
-//     render() {
-//         let userID = this.props.userID;
-//         return (
-//             <Mutation
-//                 mutation={gql(DELETE_SCHEMA)}
-//                 update={(cache) => {
-//                     let data = cache.readQuery({query: gql(SHOW_SCHEMA), variables: {user_id: userID}});
-//
-//                     data.schema_by_props.splice(data.schema_by_props.findIndex(obj => obj.schemaName === this.state.schemaName), 1);
-//                     cache.writeQuery({
-//                         query: gql(SHOW_SCHEMA),
-//                         variables: {user_id: userID},
-//                         data
-//                     });
-//                 }}
-//             >
-//                 {(delete_schema, {loading, error}) => {
-//                     if (error)
-//                         return 'error';
-//                     if (loading)
-//                         return <Spin style={{marginLeft: 3}}/>;
-//                     return (
-//                         <Button onClick={(e) => {
-//                             delete_schema({variables: {schemaName: this.props.schemaName}});
-//                         }} type="danger" shape="circle" icon="delete" size='small' style={{marginLeft: 3}}/>
-//                     )
-//                 }}
-//             </Mutation>
-//         )
-//     }
-// }
-
-
-
-
-
+}

+ 7 - 7
src/components/cloudFunction/CloudFunction.jsx

@@ -1,11 +1,11 @@
 import React, {Component} from 'react';
 
-import {Layout, Menu  } from 'antd';
+import {Layout, Menu} from 'antd';
 
 import Deploy from '../common/deploy/Deploy';
 import Api from "./api/Api";
 
-const { Content } = Layout;
+const {Content} = Layout;
 
 class CloudFunction extends Component {
     constructor() {
@@ -36,16 +36,16 @@ class CloudFunction extends Component {
                     <Menu.Item key="api">API</Menu.Item>
                 </Menu>
 
-                <Layout style={{ padding: '24px', zIndex: '0'}}>
-                    <Content style={{ padding: '24px', minHeight: 280, background: '#fff',marginTop: '48px'  }}>
+                <Layout style={{padding: '24px', zIndex: '0'}}>
+                    <Content style={{padding: '24px', minHeight: 280, background: '#fff', marginTop: '48px'}}>
                         {(() => {
                             switch (this.state.menuLevel2) {
                                 case 'deploy':
-                                    return <Deploy />;
+                                    return <Deploy/>;
                                 case 'api':
-                                    return <Api />;
+                                    return <Api/>;
                                 default:
-                                    return <Deploy />
+                                    return <Deploy/>
                             }
                         })()}
                     </Content>

+ 2 - 2
src/components/cloudFunction/api/Api.jsx

@@ -1,6 +1,6 @@
 import React, {Component} from 'react';
 
-import {  Pagination } from 'antd';
+import {Pagination} from 'antd';
 
 export default class Api extends Component {
     constructor() {
@@ -15,7 +15,7 @@ export default class Api extends Component {
             <div className="locale-components">
                 <div className="example">
                     antd ui 组件中英切换
-                    <Pagination defaultCurrent={1} total={50} showSizeChanger />
+                    <Pagination defaultCurrent={1} total={50} showSizeChanger/>
                 </div>
             </div>
         );

+ 10 - 7
src/components/common/deploy/Deploy.jsx

@@ -46,7 +46,7 @@ class Deploy extends Component {
             data => {
                 request('http://123.206.193.98:3000/graphql', SEARCH_SCHEMA, {id: this.state.schemaID}).then(
                     _data => {
-                        if(data.fc_by_props.length === 0) {
+                        if (data.fc_by_props.length === 0) {
                             request('http://123.206.193.98:3000/graphql', SHOW_CLOUD, {user_id: this.props.userID}).then(
                                 __data => {
                                     __data.cloud_by_props.forEach(cloud => {
@@ -118,9 +118,12 @@ class Deploy extends Component {
 
     render() {
         const contentListNoTitle = {
-            tencent: <TencentConfig cloudID={this.state.tencentCloudID} fc={this.tencentFC} schemaName={this.state.schemaName} userID={this.props.userID}/>,
-            aliyun: <AliConfig cloudID={this.state.aliyunCloudID} fc={this.aliyunFC} schemaName={this.state.schemaName} userID={this.props.userID}/>,
-            amazon: <AmazonConfig cloudID={this.state.amazonCloudID} fc={this.amazonFC} schemaName={this.state.schemaName} userID={this.props.userID}/>,
+            tencent: <TencentConfig cloudID={this.state.tencentCloudID} fc={this.tencentFC}
+                                    schemaName={this.state.schemaName} userID={this.props.userID}/>,
+            aliyun: <AliConfig cloudID={this.state.aliyunCloudID} fc={this.aliyunFC} schemaName={this.state.schemaName}
+                               userID={this.props.userID}/>,
+            amazon: <AmazonConfig cloudID={this.state.amazonCloudID} fc={this.amazonFC}
+                                  schemaName={this.state.schemaName} userID={this.props.userID}/>,
         };
 
         return (
@@ -138,9 +141,9 @@ class Deploy extends Component {
                     >
                         {
                             this.state.show ?
-                            contentListNoTitle[this.state.cloud]
-                            :
-                            "waiting..."
+                                contentListNoTitle[this.state.cloud]
+                                :
+                                "waiting..."
                         }
                     </Card>
                 </div>

+ 110 - 0
src/components/common/schema/Schema.jsx

@@ -92,3 +92,113 @@ class Schema extends Component {
 export default Schema;
 
 
+// 备用代码
+class ShowSchemaList extends Component {
+    render() {
+        let userID = this.props.userID;
+        return (
+            <Query query={SHOW_SCHEMA} variables={{user_id: userID}}>
+
+                {
+                    ({loading, error, data}) => {
+                        if (loading) {
+                            return <Spin style={{marginLeft: 3}}/>
+                        }
+                        if (error) {
+                            return 'error!';
+                        }
+                        if (data.schema_by_props.length === 0)
+                            return (
+                                <div>
+                                    <span>no schemas, create one</span>
+                                </div>
+                            );
+                        else {
+                            return (
+                                <div>
+                                    {
+                                        data.schema_by_props.map((schema) => {
+                                            return <div key={schema.schemaName} className='title'
+                                                        onClick={() => {
+                                                            this.props.switchSchema(schema.schemaName)
+
+                                                        }}>
+                                                <Row>
+                                                    <Col span={20}>{schema.schemaName}</Col>
+                                                    <Col span={4}>
+                                                        <Button onClick={() => this.props.switchTable('add')}
+                                                                type="primary"
+                                                                shape="circle" icon="plus" size='small'/>
+                                                        <DeleteSchemaButton
+                                                            schemaName={schema.schemaName}
+                                                            userID={this.props.userID}
+                                                        />
+                                                    </Col>
+                                                </Row>
+
+
+                                                {
+                                                    JSON.parse(schema.schemaData).map(table => (
+                                                        <p
+                                                            onClick={() => {
+                                                                this.props.switchTable(table.name)
+                                                            }}
+                                                            key={table.name}
+                                                            className='show'>
+                                                            <Icon type="ordered-list" theme="outlined"/> {table.name}
+                                                            <span className='remark'><i>   {table.remark}</i></span>
+                                                        </p>
+                                                    ))
+                                                }
+                                            </div>
+                                        })
+                                    }
+                                </div>
+                            );
+                        }
+                    }
+                }
+            </Query>
+        )
+    }
+}
+
+class DeleteSchemaButton extends Component {
+    constructor(props) {
+        super(props);
+        this.state = {
+            schemaName: props.schemaName
+        }
+    }
+
+    render() {
+        let userID = this.props.userID;
+        return (
+            <Mutation
+                mutation={DELETE_SCHEMA}
+                update={(cache) => {
+                    let data = cache.readQuery({query: SHOW_SCHEMA, variables: {user_id: userID}});
+
+                    data.schema_by_props.splice(data.schema_by_props.findIndex(obj => obj.schemaName === this.state.schemaName), 1);
+                    cache.writeQuery({
+                        query: SHOW_SCHEMA,
+                        variables: {user_id: userID},
+                        data
+                    });
+                }}
+            >
+                {(delete_schema, {loading, error}) => {
+                    if (error)
+                        return 'error';
+                    if (loading)
+                        return <Spin style={{marginLeft: 3}}/>;
+                    return (
+                        <Button onClick={(e) => {
+                            delete_schema({variables: {schemaName: this.props.schemaName}});
+                        }} type="danger" shape="circle" icon="delete" size='small' style={{marginLeft: 3}}/>
+                    )
+                }}
+            </Mutation>
+        )
+    }
+}

+ 2 - 2
src/components/common/schema/change/SchemaChange.jsx

@@ -18,7 +18,7 @@ class SchemaChange extends Component {
             columns: props.columns,
             newColName: '',
             newColType: 'type',
-            types: ['ID', 'String', 'Int', 'Float','Boolean', 'DateTime'],
+            types: ['ID', 'String', 'Int', 'Float', 'Boolean', 'DateTime'],
             descriptions: ['description', 'key', 'non-null', 'non-null-list', 'list']
         }
     }
@@ -266,7 +266,7 @@ class UpdateTableButton extends Component {
 
                                     // 处理一下description的问题
                                     let cols = this.props.columns;
-                                    cols.map(obj=> {
+                                    cols.map(obj => {
                                         if (obj.description === 'description')
                                             obj.description = '';
                                         return obj