wly vor 7 Jahren
Ursprung
Commit
aefdda7adf

+ 11 - 37
src/components/app/App.jsx

@@ -1,7 +1,7 @@
 import React, {Component} from 'react';
-import {Layout, Menu, Input, Modal, Button, Spin, Breadcrumb, Icon, Radio, LocaleProvider} from 'antd';
+import {Layout, Menu, Button, Spin, Icon, LocaleProvider} from 'antd';
 import {BrowserRouter as Router, Route, Link, Switch, Redirect} from "react-router-dom";
-import {Mutation, Query} from "react-apollo";
+import {Query} from "react-apollo";
 import gql from "graphql-tag";
 
 import moment from 'moment';
@@ -12,8 +12,8 @@ import zhCN from 'antd/lib/locale-provider/zh_CN';
 import WechatService from "../wechatService/WechatService";
 import QuantService from "../quantService/QuantService";
 import TrialCase from "../trialCase/TrialCase";
+import UserCreate from "../userCreate/UserCreate";
 import Login from "../login/Login";
-import Table from '../common/schema/Table';
 import '../common/graphql/index.css';
 import './index.css'
 import Create from "../common/schema/Create";
@@ -21,7 +21,6 @@ import Create from "../common/schema/Create";
 import {SHOW_ALL_SCHEMA} from "../gql";
 import axios from 'axios';
 import {getCookie} from "../cookie";
-import Schema from "../common/schema/Schema";
 
 //引入案例
 import ShopApp from '../../case/ShopApp/src/App'
@@ -39,7 +38,7 @@ class App extends Component {
         super(props);
         sessionStorage.setItem("language", "English");
         this.state = {
-            menuLevel1: "trail",
+            menuLevel1: "graphql-service",
             sideBar: "e-commerce",
             collapsed: false,
             inlineCollapsed: false,
@@ -63,7 +62,7 @@ class App extends Component {
         });
     };
 
-    switchMenuUser = (menuName, value) => {
+    switchMenuLevel = (menuName, value) => {
         this.setState({
             [menuName]: value,
         });
@@ -111,7 +110,7 @@ class App extends Component {
             <Router>
                 <Layout style={{minHeight: '100vh'}}>
                     <Header className="header" style={{position: 'fixed', zIndex: 1, width: '100%'}}>
-                        <Link to="/">
+                        <Link to="/"   onClick={() => this.switchMenuLevel('menuLevel1', "graphql-service")}>
                             <div className="logo-wrapper">
                                 <div className='logo'/>
                             </div>
@@ -124,10 +123,10 @@ class App extends Component {
                             onClick={(e) => this.switchMenu('menuLevel1', e)}
                         >
                             <Menu.Item key="graphql-service">
-                                <Link to="/"><FormattedMessage id="Graphql Service"/></Link>
+                                <Link to="/graphql-service/trial-case/index"><FormattedMessage id="Graphql Service"/></Link>
                             </Menu.Item>
                             <Menu.Item key="wechat-service">
-                                <Link to="/wechat-service/trial-case/wechat case"><FormattedMessage
+                                <Link to="/wechat-service/trial-case/index"><FormattedMessage
                                     id="Wechat Service"/></Link>
                             </Menu.Item>
                             <Menu.Item key="quantization-service">
@@ -136,7 +135,7 @@ class App extends Component {
                         </Menu>
 
                         <Link to="/login">
-                            <Button className='login-button' type='primary' onClick={()=>this.switchMenuUser('menuLevel1','user')} >Login</Button>
+                            <Button className='login-button' type='primary' onClick={()=>this.switchMenuLevel('menuLevel1','user')} >Login</Button>
                         </Link>
 
                         <div className="change-locale">
@@ -309,10 +308,8 @@ class App extends Component {
                                 key={locale ? locale.locale : 'en'/* Have to refresh for production environment */}>
                             <Switch>
                                 <Route path="/" exact component={TrialCase}/>
-                                <Route path="/ShopApp" component={ShopApp}/>
-                                <Route path="/BillApp" component={BillApp}/>
-                                <Route path="/OrderApp" component={OrderApp}/>
-                                <Route path="/graphql-service/:sidebar/:case" component={TrialCase}/>
+                                <Route path="/graphql-service/trial-case/:case" component={TrialCase}/>
+                                <Route path="/graphql-service/my-create/:case" component={UserCreate}/>
                                 <Route path="/wechat-service/:sidebar/:case" component={WechatService}/>
                                 <Route path="/quant-service/" component={QuantService}/>
                                 <Route path="/login" component={Login}/>
@@ -334,34 +331,11 @@ class GraphqlSidebar extends Component {
     constructor(props) {
         super(props);
         this.state = {
-            // getID_url: 'http://123.206.193.98:8999/getuserid',
             userID: getCookie('user_id'),
             show: false
         }
     }
 
-
-    // componentWillMount() {
-    //     let _this = this;
-    //     axios.get(this.state.getID_url)
-    //         .then((res) => {
-    //             if (res.data !== '') {
-    //                 _this.setState({
-    //                     userID: res.data,
-    //                     show: true
-    //                 })
-    //             } else {
-    //                 _this.setState({
-    //                     show: true
-    //                 })
-    //             }
-    //         })
-    //         .catch((err) => {
-    //             console.log(err);
-    //         });
-    // }
-
-
     render() {
         return (
             <Query query={gql(SHOW_ALL_SCHEMA)} variables={{user_id: this.state.userID}}>

+ 14 - 0
src/components/common/application/Application.js

@@ -0,0 +1,14 @@
+import React, {Component} from 'react';
+
+class Application extends Component {
+
+    render() {
+        return (
+            <div>
+                Application
+            </div>
+        )
+    }
+}
+
+export default Application;

+ 314 - 78
src/components/common/schema/Schema.jsx

@@ -1,12 +1,15 @@
 import React, {Component} from 'react';
 
-import {Row, Col, Input, Icon, Button, Spin} from 'antd';
+import {Button, Col, Icon, Modal, Pagination, Row, Spin, Input} from 'antd';
 import './index.css';
 import {Mutation, Query} from "react-apollo";
 import gql from "graphql-tag";
-import {SHOW_SCHEMA, DELETE_SCHEMA, SHOW_TABLE, UPDATE_SCHEMA} from '../../gql'
+import {DELETE_SCHEMA, SHOW_SCHEMA, SHOW_TABLE, UPDATE_SCHEMA, UPDATE_SCHEMA_NAME, SHOW_ALL_SCHEMA} from '../../gql'
 import Table from "./Table";
 
+const confirm = Modal.confirm;
+const Search = Input.Search;
+
 class Schema extends Component {
     constructor(props) {
         super(props);
@@ -15,6 +18,10 @@ class Schema extends Component {
             // default schemaID and schemaName
             schemaID: props.schemaID || props.location.state.schemaID,
             schemaName: props.schemaName || props.location.state.schemaName,
+            editSchemaName: '',
+            data: '',
+            page: '',
+            pageSize: ''
         };
     }
 
@@ -24,6 +31,18 @@ class Schema extends Component {
         })
     };
 
+    changeEditSchemaName = (e) => {
+        this.setState({
+            editSchemaName: e.target.value
+        })
+    };
+
+    clearEditSchemaName = () => {
+        this.setState({
+            editSchemaName: ''
+        })
+    };
+
     findColumns = data => this.state.currentTable === '' ? [] : data.find(table => table.name === this.state.currentTable) ? data.find(table => table.name === this.state.currentTable).cols : [];
 
     findRemark = data => this.state.currentTable === '' ? '' : data.find(table => table.name === this.state.currentTable) ? data.find(table => table.name === this.state.currentTable).remark : '';
@@ -34,11 +53,29 @@ class Schema extends Component {
         })
     };
 
+    showTablePagination = (page, pageSize, data) => {
+        // console.log(page);
+        // console.log(pageSize);
+        // console.log(data);
+        // 这个之所以这么麻烦,是因为 'apollo 不能存数据' 而 '分页又得用数据展示',
+        // 所以展示 table 的时候分了两个,
+        // 首先进入展示 15个 , 这前 15 个没有任何问题。
+        // 如果数据多于 15个,在按下第二页的时候 将数据通过 antd 的分页组件的回调函数传入 state,之后 table 的展示由 this.state.data 来接管
+        // 但是这又引起一个问题,通过 this.state.data 的展示如果进行删除,是不会通过 apollo 的,这也意味着数据库被删除了,而页面还存在
+        // 于是,在使用 this.state.data 的页面的 deleteTableButton 组件内调用该函数,重新刷新 this.state.data
+        this.setState({
+            page,
+            pageSize,
+            data: data.slice((page - 1) * pageSize, page * pageSize)
+        })
+    };
+
     componentWillReceiveProps(next) {
         this.setState({
             currentTable: next.location.state === undefined ? '' : next.location.state.create ? 'add' : '',
             schemaID: next.schemaID,
-            schemaName: next.schemaName
+            schemaName: next.schemaName,
+            data: ''
         });
     }
 
@@ -61,51 +98,183 @@ class Schema extends Component {
                         if (data.schema_by_id === null) data = [];
                         else data = JSON.parse(data.schema_by_id.schemaData);
 
-
                         return (
                             <div>
                                 {
                                     this.state.currentTable === '' ?
                                         <div>
-                                            <div onClick={() => {
-                                                this.setState({
-                                                    currentTable: ''
-                                                })
-                                            }}>
-                                                {this.state.schemaName}
+                                            {
+                                                this.state.editSchemaName ?
+                                                    <ModifySchemaNameInput
+                                                        editSchemaName={this.state.editSchemaName}
+                                                        changeEditSchemaName={this.changeEditSchemaName}
+                                                        clearEditSchemaName={this.clearEditSchemaName}
+                                                        schemaID={this.state.schemaID}
+                                                        userID={userID}
+                                                        schemaName={this.state.schemaName}
+                                                        history={this.props.history}
+                                                    />
+                                                    :
+                                                    <div className={'schema'}>
+                                                        <span className={'schema-name'}>{this.state.schemaName}</span>
+                                                        {
+                                                            userID === 'ioobot' ?
+                                                                ''
+                                                                :
+                                                                <Icon style={{marginLeft: 15}}
+                                                                      type="edit"
+                                                                      theme="twoTone"
+                                                                      onClick={
+                                                                          () => {
+                                                                              this.setState({editSchemaName: this.state.schemaName})
+                                                                          }
+                                                                      }
+                                                                />
+                                                        }
+                                                    </div>
+                                            }
+
+                                            <div className={'schema-table-list-title'}>
+                                                <Row>
+                                                    <Col span={10}><span
+                                                        className={'schema-table-title'}>Name</span></Col>
+                                                    <Col span={10}><span
+                                                        className={'schema-table-title'}>Remark</span></Col>
+                                                    <Col span={2} offset={2}>
+                                                        {
+                                                            userID === 'ioobot' ?
+                                                                ''
+                                                                :
+                                                                <span
+                                                                    className={'schema-table-title'}
+                                                                    onClick={() => {
+                                                                        this.setState({
+                                                                            currentTable: 'add'
+                                                                        })
+                                                                    }}>
+                                                                    <Icon type="plus"/>
+                                                                </span>
+                                                        }
+
+                                                    </Col>
+                                                </Row>
                                             </div>
                                             <div>
+                                                {
+                                                    this.state.data ?
+                                                        this.state.data.map(table => (
+                                                            <div key={table.name}
+                                                                 className={'schema-table-list-content'}>
+                                                                <Row>
+                                                                    <Col
+                                                                        span={10}
+                                                                        onClick={() => this.switchTable(table.name)}
+                                                                    >
+                                                                        <span className={'schema-table-content name'}>{table.name}</span>
+                                                                    </Col>
+                                                                    <Col span={10}>
+                                                                        <span className={'schema-table-content'}>{table.remark}</span>
+                                                                    </Col>
+                                                                    <Col span={2} offset={2}>
+
+                                                                        <span className={'schema-table-content'}>
+                                                                            {
+                                                                                userID === 'ioobot'?
+                                                                                    ''
+                                                                                    :
+                                                                                    <DeleteTableButton
+                                                                                        currentTable={table.name}
+                                                                                        currentTableIndex={data.findIndex(obj => obj.name === table.name)}
+                                                                                        schemaID={this.state.schemaID}
+                                                                                        userID={userID}
+                                                                                        showTablePagination={this.showTablePagination}
+                                                                                        page={this.state.page}
+                                                                                        pageSize={this.state.pageSize}
+                                                                                    />
+                                                                            }
+
+                                                                        </span>
+                                                                    </Col>
+                                                                </Row>
+                                                            </div>
+
+                                                        ))
+                                                        :
+                                                        data.slice(0, 15).map(table => (
+                                                            <div key={table.name}
+                                                                 className={'schema-table-list-content'}>
+                                                                <Row>
+                                                                    <Col
+                                                                        span={10}
+                                                                        onClick={() => this.switchTable(table.name)}
+                                                                    >
+                                                                <span
+                                                                    className={'schema-table-content name'}>{table.name}</span>
+                                                                    </Col>
+                                                                    <Col span={10}>
+                                                                <span
+                                                                    className={'schema-table-content'}>{table.remark}</span>
+                                                                    </Col>
+                                                                    <Col span={2} offset={2}>
+                                                                <span className={'schema-table-content'}>
+                                                                    {
+                                                                        userID === 'ioobot'?
+                                                                            ''
+                                                                            :
+                                                                            <DeleteTableButton
+                                                                                currentTable={table.name}
+                                                                                currentTableIndex={data.findIndex(obj => obj.name === table.name)}
+                                                                                schemaID={this.state.schemaID}
+                                                                                userID={userID}
+                                                                            />
+                                                                    }
+                                                                </span>
+                                                                    </Col>
+                                                                </Row>
+                                                            </div>
+
+                                                        ))
+                                                }
+                                            </div>
+
+                                            <div className={'schema-bottom'}>
                                                 <Row>
-                                                    <Col span={8}><span>Name</span></Col>
-                                                    <Col span={8}><span>Remark</span></Col>
-                                                    <Col span={8}>
-                                                        <span onClick={() => {
-                                                            this.setState({
-                                                                currentTable: 'add'
-                                                            })
-                                                        }}>
-                                                            <Icon type="plus"/>
-                                                        </span>
+                                                    <Col span={4}>
+                                                        {
+                                                            userID === 'ioobot'?
+                                                                <div className={'delete-schema'}>
+                                                                    <Button
+                                                                        type="primary"
+                                                                        onClick={()=>{
+                                                                            console.log('我还没做');
+                                                                        }}
+                                                                    >copy</Button>
+                                                                </div>
+                                                                :
+                                                                <div className={'delete-schema'}>
+                                                                    <DeleteSchemaButton
+                                                                        userID={userID}
+                                                                        schemaName={this.state.schemaName}
+                                                                    />
+                                                                </div>
+                                                        }
+                                                    </Col>
+                                                    <Col span={4} offset={16}>
+                                                        <div className={'pagination'}>
+                                                            <Pagination
+                                                                simple
+                                                                defaultCurrent={1}
+                                                                hideOnSinglePage={true}
+                                                                defaultPageSize={15}
+                                                                total={data.length}
+                                                                onChange={(page, pageSize) => {
+                                                                    this.showTablePagination(page, pageSize, data)
+                                                                }}
+                                                            />
+                                                        </div>
                                                     </Col>
                                                 </Row>
                                             </div>
-                                            {
-                                                data.map(table => (
-                                                    <Row key={table.name} className='show'>
-                                                        <Col span={8}
-                                                             onClick={() => this.switchTable(table.name)}><span>{table.name}</span></Col>
-                                                        <Col span={8}><span>{table.remark}</span></Col>
-                                                        <Col span={8}>
-                                                            <DeleteTableButton
-                                                                currentTable={table.name}
-                                                                currentTableIndex={data.findIndex(obj => obj.name === table.name)}
-                                                                schemaID={this.state.schemaID}
-                                                                userID={userID}
-                                                            />
-                                                        </Col>
-                                                    </Row>
-                                                ))
-                                            }
                                         </div>
                                         :
                                         this.state.currentTable === 'add' ?
@@ -144,48 +313,62 @@ class Schema extends Component {
 export default Schema;
 
 
-// 备用代码
-
-// 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>
-//         )
-//     }
-// }
+class DeleteSchemaButton extends Component {
+    constructor(props) {
+        super(props);
+        this.state = {
+            schemaName: props.schemaName
+        }
+    }
 
+    showConfirm = (delete_schema, schemaName) => {
+        confirm({
+            title: 'Do you want to delete this schema?',
+            content: 'It cannot be found back!',
+            onOk() {
+                delete_schema({variables: {schemaName}});
+            },
+            onCancel() {
+            },
+        });
+    };
+
+    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
+                            type="danger"
+                            onClick={() => {
+                                this.showConfirm(delete_schema, this.props.schemaName);
+                            }}
+                        >
+                            delete
+                        </Button>
+                    )
+                }}
+            </Mutation>
+        )
+    }
+}
 
 class DeleteTableButton extends Component {
     render() {
@@ -284,6 +467,9 @@ class DeleteTableButton extends Component {
                                                           schemaData: JSON.stringify(schemaCols)
                                                       }
                                                   });
+                                                  this.props.showTablePagination ?
+                                                      this.props.showTablePagination(this.props.page, this.props.pageSize, schemaCols) : (() => {
+                                                      })()
                                               }}>
 
                                         </Icon>
@@ -297,4 +483,54 @@ class DeleteTableButton extends Component {
             </Query>
         )
     }
+}
+
+class ModifySchemaNameInput extends Component {
+    constructor(props) {
+        super(props);
+        this.state = {}
+    }
+
+    render() {
+        let userID = this.props.userID;
+        let schemaName = this.props.schemaName;
+        return (
+            <Mutation mutation={gql(UPDATE_SCHEMA_NAME)}>
+                {(update_schema, {loading, error}) => {
+                    if (error)
+                        return 'error';
+                    if (loading)
+                        return <Spin style={{marginLeft: 3}}/>;
+                    return (
+                        <div className={'schema'}>
+                            <Search
+                                value={this.props.editSchemaName}
+                                enterButton="Confirm"
+                                style={{width: 500}}
+                                size="large"
+                                onChange={this.props.changeEditSchemaName}
+                                onSearch={value => {
+                                    update_schema({
+                                        variables: {
+                                            id: this.props.schemaID,
+                                            schemaName: value,
+                                            updateAt: new Date().getTime()
+                                        }
+                                    });
+                                    this.props.history.push({
+                                        pathname: `/graphql-service/my-create/${value}`,
+                                        state: {
+                                            schemaName: value,
+                                            schemaID: this.props.schemaID,
+                                        }
+                                    });
+                                    this.props.clearEditSchemaName();
+                                }}
+                            />
+                        </div>
+                    )
+                }}
+            </Mutation>
+        )
+    }
 }

+ 22 - 11
src/components/common/schema/Table.js

@@ -173,7 +173,12 @@ class Table extends Component {
                                                 )
                                             }
                                         </Select>
-                                        <Icon type="delete" theme="twoTone" style={{cursor: 'pointer'}} onClick={this.handleColDelete(index)}/>
+                                        {
+                                            userID === 'ioobot'?
+                                                ''
+                                                :
+                                                <Icon type="delete" theme="twoTone" style={{cursor: 'pointer'}} onClick={this.handleColDelete(index)}/>
+                                        }
                                     </div>
                                 )
                             }
@@ -198,16 +203,22 @@ class Table extends Component {
                             </div>
                         </div>
 
-                        <div style={{marginTop: 20}}>
-                            <UpdateTableButton
-                                currentTable={this.state.currentTable}
-                                columns={this.state.columns}
-                                remark={this.state.remark}
-                                currentTableIndex={this.props.currentTableIndex}
-                                schemaID={schemaID}
-                                userID={userID}
-                            />
-                        </div>
+                        {
+                            userID === 'ioobot'?
+                                ''
+                                :
+                                <div style={{marginTop: 20}}>
+                                    <UpdateTableButton
+                                        currentTable={this.state.currentTable}
+                                        columns={this.state.columns}
+                                        remark={this.state.remark}
+                                        currentTableIndex={this.props.currentTableIndex}
+                                        schemaID={schemaID}
+                                        userID={userID}
+                                    />
+                                </div>
+                        }
+
                     </Content>
                 </Layout>
             </div>

+ 103 - 49
src/components/common/schema/index.css

@@ -1,86 +1,140 @@
 .current {
-    background-color: #0F83E8;
-    color: white;
-    text-align: center;
-    height: 50px;
-    line-height: 50px;
-    margin-top: 3px;
+  background-color: #0F83E8;
+  color: white;
+  text-align: center;
+  height: 50px;
+  line-height: 50px;
+  margin-top: 3px;
 }
 
 .title {
-    font-weight: bolder;
-    font-size: 18px;
-    margin: 10px 0 0 5px;
+  font-weight: bolder;
+  font-size: 18px;
+  margin: 10px 0 0 5px;
 }
 
 p.show {
-    margin: 5px 0 3px 10px;
-    cursor: pointer;
-    font-size: 16px;
-    font-weight: bold;
+  margin: 5px 0 3px 10px;
+  cursor: pointer;
+  font-size: 16px;
+  font-weight: bold;
 }
 
 .wrapper {
-    position: relative;
+  position: relative;
 }
 
 .add {
-    position: absolute;
-    right: 10px;
-    top: 10px;
-    z-index: 2;
+  position: absolute;
+  right: 10px;
+  top: 10px;
+  z-index: 2;
 }
 
 .add-input {
-    margin-top: 10px;
+  margin-top: 10px;
 }
 
 .column-menu {
-    /*padding: 0 24px;*/
-    /*position: fixed;*/
-    width: 100%;
-    z-index: 1;
-    line-height:50px;
-    font-weight:600;
-    background-color: white;
-    border-bottom: 1px solid #dcdadb;
+  /*padding: 0 24px;*/
+  /*position: fixed;*/
+  width: 100%;
+  z-index: 1;
+  line-height: 50px;
+  font-weight: 600;
+  background-color: white;
+  border-bottom: 1px solid #dcdadb;
+  cursor: pointer;
 }
 
 .column-title {
-    /*padding-left: 10px;*/
-    font-weight: 500;
-    font-size: 16px;
-    display: inline-block;
-    width: 168px;
-    height: 35px;
-    color: #3a76c5;
+  /*padding-left: 10px;*/
+  font-weight: 500;
+  font-size: 16px;
+  display: inline-block;
+  width: 168px;
+  height: 35px;
+  color: #3a76c5;
 }
 
 .column-content {
-    margin-bottom: 20px;
+  margin-bottom: 20px;
 }
 
 .column-details {
-    width: 120px;
-    margin:10px 48px 10px 0 !important;
+  width: 120px;
+  margin: 10px 48px 10px 0 !important;
 }
 
 .table-title {
-    font-weight: 500;
-    font-size: 20px;
-    display: block;
-    height: 35px;
-    margin: 10px 0;
+  font-weight: 500;
+  font-size: 20px;
+  display: block;
+  height: 35px;
+  margin: 10px 0;
 }
 
 .table-title::before {
-    content: '|';
-    display: inline-block;
-    font-weight: 900;
-    color: #3187FA;
-    /*border-right: */
+  content: '|';
+  display: inline-block;
+  font-weight: 900;
+  color: #3187FA;
+  /*border-right: */
 }
+
 .remark {
-    font-weight: lighter;
-    font-size: smaller;
+  font-weight: lighter;
+  font-size: smaller;
+}
+
+.schema {
+  width: 100%;
+  height: 50px;
+  margin-bottom: 10px;
+  cursor: pointer;
+}
+
+.schema-name {
+  color: #3187FA;
+  font-weight: bold;
+  font-size: 20px;
+  line-height: 50px;
+}
+
+.schema-table-list-title {
+  background-color: #f7f7f7;
+  height: 40px;
+  padding-left: 10px;
+}
+
+.schema-table-title {
+  line-height: 40px;
+  font-weight: bold;
+}
+
+.schema-table-list-content {
+  height: 40px;
+  padding-left: 10px;
+  border-bottom: 1px solid #e9e9e9;
+}
+
+.name {
+  color: #3c658a;
+  cursor: pointer;
+}
+
+.schema-table-list-content:last-child {
+  border-bottom: none;
+}
+
+.schema-table-content {
+  line-height: 40px;
+}
+
+.schema-bottom {
+  margin-top: 70px;
+}
+
+.delete-schema {
+
 }

+ 14 - 0
src/components/gql.js

@@ -123,6 +123,19 @@ const UPDATE_SCHEMA = `
             }
         `;
 
+const UPDATE_SCHEMA_NAME = `
+            mutation SCHEMA($id: ID!, $schemaName: String, $updatedAt: String) {
+                update_schema(
+                    id: $id,
+                    updatedAt: $updatedAt,
+                    schemaName: $schemaName,
+                ) {
+                    schemaName,
+                    id
+                }
+            }
+        `;
+
 
 const SHOW_TABLE = `
             query TABLE($schema_id: ID!) {
@@ -364,6 +377,7 @@ export {
     SHOW_ALL_SCHEMA,
     SHOW_SCHEMA,
     UPDATE_SCHEMA,
+    UPDATE_SCHEMA_NAME,
     DELETE_SCHEMA,
     SHOW_TABLE,
     ADD_CLOUD,

+ 14 - 2
src/components/login/Login.js

@@ -46,8 +46,15 @@ class Login extends Component {
     login = () => {
         let _this = this;
         // todo: should be post
-        axios.get(`${this.state.login_url}?user-name=${this.state.login_username}&password=${this.state.login_password}`)
+        // axios.get(`${this.state.login_url}?user-name=${this.state.login_username}&password=${this.state.login_password}`)
+
+        axios.post(this.state.login_url,
+            {
+                'user-name': this.state.login_username,
+                password: this.state.login_password
+            })
             .then((res) => {
+            console.log('login result',res);
                 _this.setState({
                     userID: res.data,
                     loginStatus: 'logined',
@@ -146,7 +153,12 @@ class Login extends Component {
                                                 avatar: ''
                                             }
                                         });
-                                        axios.get(`${this.state.register_url}?user-id=${id}&password=${this.state.register_password}&token=WXgraphql4Io`)
+                                        axios.post(this.state.register_url,
+                                            {
+                                                'user-id': id,
+                                                password: this.state.register_password,
+                                                token:'WXgraphql4Io'
+                                            })
                                             .then(function (response) {
                                                 if (response.status === 200)
                                                     _this.setState({

+ 8 - 22
src/components/trialCase/TrialCase.jsx

@@ -6,6 +6,7 @@ import Deploy from '../common/deploy/Deploy';
 import Schema from '../common/schema/Schema';
 import Graphql from "../common/graphql/Graphql";
 import CaseMetabase from "../common/caseMetabase/CaseMetabase";
+import Application from "../common/application/Application";
 import axios from 'axios';
 
 axios.defaults.withCredentials = true;
@@ -19,27 +20,10 @@ class TrialCase extends Component {
             menuLevel2: "schema",
             // default user
             userID: "ioobot",
-            getID_url: 'http://123.206.193.98:8999/getuserid',
         }
     }
 
-    componentWillMount() {
-        let _this = this;
-        axios.get(this.state.getID_url)
-            .then((res) => {
-                if (res.data !== '') {
-                    _this.setState({
-                        userID: res.data
-                    })
-                }
-            })
-            .catch(function (err) {
-                console.log(err);
-            });
-    }
-
     switchMenu = (menuName, e) => {
-        // console.log('menuName', menuName, 'e', e);
         this.setState({
             [menuName]: e.key,
         });
@@ -49,7 +33,6 @@ class TrialCase extends Component {
     render() {
         let schemaID = this.props.history.location.state ? this.props.history.location.state.schemaID : "schema_1542243424669_92094965";
         let schemaName = this.props.history.location.state ? this.props.history.location.state.schemaName : "ecommerce";
-        // console.log('schemaID0',schemaID,'schemaName0',schemaName);
         return (
             <div>
                 <Menu
@@ -60,9 +43,10 @@ class TrialCase extends Component {
                     selectedKeys={[this.state.menuLevel2]}
                 >
                     <Menu.Item key="schema">schema</Menu.Item>
+                    <Menu.Item key="application">application</Menu.Item>
                     <Menu.Item key="deploy">deploy</Menu.Item>
                     <Menu.Item key="graphql">graphql</Menu.Item>
-                    <Menu.Item key="graphiql">graphql IDE</Menu.Item>
+                    {/*<Menu.Item key="graphiql">graphql IDE</Menu.Item>*/}
                     <Menu.Item key="metabase">metabase</Menu.Item>
                 </Menu>
 
@@ -73,13 +57,15 @@ class TrialCase extends Component {
                             (() => {
                                 switch (this.state.menuLevel2) {
                                     case 'schema':
-                                        return <Schema userID={this.state.userID} schemaName={schemaName} schemaID={schemaID} location={this.props.location}/>;
+                                        return <Schema userID={this.state.userID} schemaName={schemaName} schemaID={schemaID} history={this.props.history} location={this.props.location}/>;
+                                    case 'application':
+                                        return <Application />;
                                     case 'deploy':
                                         return <Deploy userID={this.state.userID} schemaID={schemaID} schemaName={schemaName}/>;
                                     case 'graphql':
                                         return <GenerateJs/>;
-                                    case 'graphiql':
-                                        return <Graphql/>;
+                                    // case 'graphiql':
+                                    //     return <Graphql/>;
                                     case 'metabase':
                                         return <CaseMetabase/>;
                                     default:

+ 96 - 0
src/components/userCreate/UserCreate.jsx

@@ -0,0 +1,96 @@
+import React, {Component} from 'react';
+import {Layout, Menu} from 'antd';
+
+import GenerateJs from "../common/generateJs/GenerateJs";
+import Deploy from '../common/deploy/Deploy';
+import Schema from '../common/schema/Schema';
+import Graphql from "../common/graphql/Graphql";
+import CaseMetabase from "../common/caseMetabase/CaseMetabase";
+import axios from 'axios';
+
+axios.defaults.withCredentials = true;
+
+const {Content} = Layout;
+
+class UserCreate extends Component {
+    constructor(props) {
+        super(props);
+        this.state = {
+            menuLevel2: "schema",
+            userID: "ioobot",
+            getID_url: 'http://123.206.193.98:8999/getuserid',
+        }
+    }
+
+    componentWillMount() {
+        let _this = this;
+        axios.get(this.state.getID_url)
+            .then((res) => {
+                if (res.data !== '') {
+                    _this.setState({
+                        userID: res.data
+                    })
+                }
+            })
+            .catch(function (err) {
+                console.log(err);
+            });
+    }
+
+    switchMenu = (menuName, e) => {
+        this.setState({
+            [menuName]: e.key,
+        });
+    };
+
+
+    render() {
+        let schemaID = this.props.history.location.state ? this.props.history.location.state.schemaID : "schema_1542243424669_92094965";
+        let schemaName = this.props.history.location.state ? this.props.history.location.state.schemaName : "ecommerce";
+        return (
+            <div>
+                <Menu
+                    mode="horizontal"
+                    defaultSelectedKeys={['schema']}
+                    style={{padding: '0 24px', position: 'fixed', width: '100%', zIndex: '1',lineHeight:'50px',fontWeight:600}}
+                    onClick={(e) => this.switchMenu('menuLevel2', e)}
+                    selectedKeys={[this.state.menuLevel2]}
+                >
+                    <Menu.Item key="schema">schema</Menu.Item>
+                    <Menu.Item key="deploy">deploy</Menu.Item>
+                    <Menu.Item key="graphql">graphql</Menu.Item>
+                    <Menu.Item key="graphiql">graphql IDE</Menu.Item>
+                    <Menu.Item key="metabase">metabase</Menu.Item>
+                </Menu>
+
+
+                <Layout style={{padding: '24px', zIndex: '0'}}>
+                    <Content style={{padding: '24px', minHeight: 280, background: '#fff', marginTop: '48px'}}>
+                        {
+                            (() => {
+                                switch (this.state.menuLevel2) {
+                                    case 'schema':
+                                        return <Schema userID={this.state.userID} schemaName={schemaName} schemaID={schemaID} history={this.props.history} location={this.props.location}/>;
+                                    case 'deploy':
+                                        return <Deploy userID={this.state.userID} schemaID={schemaID} schemaName={schemaName}/>;
+                                    case 'graphql':
+                                        return <GenerateJs/>;
+                                    case 'graphiql':
+                                        return <Graphql/>;
+                                    case 'metabase':
+                                        return <CaseMetabase/>;
+                                    default:
+                                        return <Graphql/>
+                                }
+                            })()
+                        }
+
+                    </Content>
+                </Layout>
+            </div>
+        )
+    }
+}
+
+export default UserCreate;
+