|
|
@@ -2,24 +2,26 @@ import React, {Component} from 'react';
|
|
|
import Deploy from '../common/deploy/Deploy';
|
|
|
import Schema from '../common/schema/Schema';
|
|
|
import Graphql from "../common/graphql/Graphql";
|
|
|
-import {Layout, Menu, Input, Button, Spin,Breadcrumb, Icon } from 'antd';
|
|
|
+
|
|
|
+import {Layout, Menu, Input, Button, Spin, Breadcrumb, Icon} from 'antd';
|
|
|
+import {BrowserRouter as Router, Route, Link} from "react-router-dom";
|
|
|
+
|
|
|
+import {Query} from "react-apollo";
|
|
|
+import gql from "graphql-tag";
|
|
|
|
|
|
import '../common/graphql/index.css';
|
|
|
import logo from '../../images/logo.png';
|
|
|
import './index.css'
|
|
|
-import gql from "graphql-tag";
|
|
|
-import {Query} from "react-apollo";
|
|
|
|
|
|
-const { SubMenu } = Menu;
|
|
|
-const { Header, Content, Sider } = Layout;
|
|
|
+const {SubMenu} = Menu;
|
|
|
+const {Header, Content, Sider} = Layout;
|
|
|
|
|
|
class App extends Component {
|
|
|
constructor() {
|
|
|
super();
|
|
|
this.state = {
|
|
|
- menuLevel1:"cloud-function",
|
|
|
- menuLevel2:"schema",
|
|
|
- sideBar:"e-commerce",
|
|
|
+ menuLevel1: "cloud-function",
|
|
|
+ sideBar: "e-commerce",
|
|
|
userID: '',
|
|
|
hasLogin: false,
|
|
|
user: {
|
|
|
@@ -27,16 +29,17 @@ class App extends Component {
|
|
|
avatar: ''
|
|
|
},
|
|
|
collapsed: false,
|
|
|
- inlineCollapsed:false
|
|
|
+ inlineCollapsed: false
|
|
|
};
|
|
|
}
|
|
|
+
|
|
|
onCollapse = (collapsed) => {
|
|
|
console.log(collapsed);
|
|
|
- this.setState({ collapsed });
|
|
|
+ this.setState({collapsed});
|
|
|
};
|
|
|
|
|
|
- switchMenu = (menuName,e) => {
|
|
|
- console.log('menuName',menuName,'e',e);
|
|
|
+ switchMenu = (menuName, e) => {
|
|
|
+ console.log('menuName', menuName, 'e', e);
|
|
|
this.setState({
|
|
|
[menuName]: e.key,
|
|
|
});
|
|
|
@@ -65,10 +68,10 @@ class App extends Component {
|
|
|
if (data.user_by_id === null)
|
|
|
return (
|
|
|
<div>
|
|
|
- <span style={{marginRight: '10px'}}>no such person</span>
|
|
|
- <Button onClick={() => {
|
|
|
- this.setState({hasLogin: false})
|
|
|
- }}>relogin</Button>
|
|
|
+ <span style={{marginRight: '10px'}}>no such person</span>
|
|
|
+ <Button onClick={() => {
|
|
|
+ this.setState({hasLogin: false})
|
|
|
+ }}>relogin</Button>
|
|
|
</div>
|
|
|
);
|
|
|
else {
|
|
|
@@ -82,10 +85,10 @@ class App extends Component {
|
|
|
console.log(data);
|
|
|
return (
|
|
|
<div>
|
|
|
- <span style={{marginRight: '10px'}}>welcome, {data.user_by_id.nickname}</span>
|
|
|
- <Button onClick={() => {
|
|
|
- this.setState({hasLogin: false})
|
|
|
- }}>exit</Button>
|
|
|
+ <span style={{marginRight: '10px'}}>welcome, {data.user_by_id.nickname}</span>
|
|
|
+ <Button onClick={() => {
|
|
|
+ this.setState({hasLogin: false})
|
|
|
+ }}>exit</Button>
|
|
|
</div>
|
|
|
);
|
|
|
}
|
|
|
@@ -97,182 +100,249 @@ class App extends Component {
|
|
|
|
|
|
render() {
|
|
|
return (
|
|
|
- <Layout style={{ minHeight: '100vh' }}>
|
|
|
- <Header className="header" style={{ position: 'fixed', zIndex: 1, width: '100%' }}>
|
|
|
- <div className="logo" />
|
|
|
+ <Router>
|
|
|
+ <Layout style={{minHeight: '100vh'}}>
|
|
|
+
|
|
|
+ <Header className="header" style={{position: 'fixed', zIndex: 1, width: '100%'}}>
|
|
|
+ <div className="logo"/>
|
|
|
+ <Menu
|
|
|
+ theme="dark"
|
|
|
+ mode="horizontal"
|
|
|
+ defaultSelectedKeys={['cloud-function']}
|
|
|
+ style={{lineHeight: '64px'}}
|
|
|
+ onClick={(e) => this.switchMenu('menuLevel1', e)}
|
|
|
+ >
|
|
|
+ <Menu.Item key="cloud-function"><Link to="/cloud-function/">Cloud Function</Link></Menu.Item>
|
|
|
+ <Menu.Item key="data-storage"><Link to="/data-storage/">Data Storage</Link></Menu.Item>
|
|
|
+ <Menu.Item key="data-analysis"><Link to="/data-analysis/">Data Analysis</Link></Menu.Item>
|
|
|
+ <Menu.Item key="monitor-notification"><Link to="/monitor-notification/">Monitor Notification</Link></Menu.Item>
|
|
|
+ </Menu>
|
|
|
+
|
|
|
+ {/*<div className='login'>*/}
|
|
|
+ {/*{*/}
|
|
|
+ {/*this.state.hasLogin ?*/}
|
|
|
+ {/*this.login(this.state.userID)*/}
|
|
|
+ {/*:*/}
|
|
|
+ {/*<div>*/}
|
|
|
+ {/*<span style={{marginRight: 20}}>login:</span>*/}
|
|
|
+ {/*<Input*/}
|
|
|
+ {/*placeholder="id, eg: 'xy_1'"*/}
|
|
|
+ {/*onChange={(e) => {*/}
|
|
|
+ {/*// antd 获取不到 target,百度来的下面这句代码*/}
|
|
|
+ {/*e.persist();*/}
|
|
|
+ {/*this.setState({userID: e.target.value});*/}
|
|
|
+ {/*}}*/}
|
|
|
+ {/*onPressEnter={() => {*/}
|
|
|
+ {/*this.setState({hasLogin: true})*/}
|
|
|
+ {/*}}*/}
|
|
|
+ {/*style={{width: 200}}*/}
|
|
|
+ {/*/>*/}
|
|
|
+ {/*</div>*/}
|
|
|
+ {/*}*/}
|
|
|
+ {/*</div>*/}
|
|
|
+ </Header>
|
|
|
+
|
|
|
+ <Layout>
|
|
|
+ <Sider
|
|
|
+ width={200}
|
|
|
+ style={{background: '#fff', marginTop: '64px', zIndex: '0'}}
|
|
|
+ collapsible
|
|
|
+ collapsed={this.state.collapsed}
|
|
|
+ onCollapse={this.onCollapse}
|
|
|
+ >
|
|
|
+ <Menu
|
|
|
+ theme="dark"
|
|
|
+ mode="inline"
|
|
|
+ inlineCollapsed={this.state.inlineCollapsed}
|
|
|
+ defaultSelectedKeys={['e-commerce']}
|
|
|
+ defaultOpenKeys={['trial-case']}
|
|
|
+ // openKeys={['cloud-function']}
|
|
|
+ onClick={(e) => this.switchMenu('sideBar', e)}
|
|
|
+ selectedKeys={[this.state.sideBar]}
|
|
|
+ style={{
|
|
|
+ borderRight: 0,
|
|
|
+ overflow: 'auto',
|
|
|
+ height: '100vh',
|
|
|
+ left: '0',
|
|
|
+ width: '200px',
|
|
|
+ position: 'fixed'
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <SubMenu key="trial-case" title={<span><Icon type="appstore" theme="twoTone"/><span>Trial Case</span></span>}>
|
|
|
+ <Menu.Item key="e-commerce">e-commerce</Menu.Item>
|
|
|
+ <Menu.Item key="keep accounts">keep accounts</Menu.Item>
|
|
|
+ <Menu.Item key="appointment">appointment</Menu.Item>
|
|
|
+ </SubMenu>
|
|
|
+
|
|
|
+ {(() => {
|
|
|
+ switch (this.state.menuLevel1) {
|
|
|
+ case 'cloud-function':
|
|
|
+ return (
|
|
|
+ <SubMenu
|
|
|
+ key="cloud-function"
|
|
|
+ title={<span><Icon type="cloud"
|
|
|
+ theme="twoTone"/><span>Cloud Function</span></span>}>
|
|
|
+ <Menu.Item key="wechat-service">wechat-service</Menu.Item>
|
|
|
+ <Menu.Item key="graphql-service">graphql-service</Menu.Item>
|
|
|
+ <Menu.Item
|
|
|
+ key="quantization-service">quantization-service</Menu.Item>
|
|
|
+ </SubMenu>
|
|
|
+ );
|
|
|
+ case 'data-storage':
|
|
|
+ return (
|
|
|
+ <SubMenu
|
|
|
+ key="data-storage"
|
|
|
+ title={<span><Icon type="database"
|
|
|
+ theme="twoTone"/><span>Data Storage</span></span>}>
|
|
|
+ <Menu.Item key="snbl-mongo">snbl-mongo</Menu.Item>
|
|
|
+ </SubMenu>
|
|
|
+ );
|
|
|
+ case 'data-analysis':
|
|
|
+ return (
|
|
|
+ <SubMenu
|
|
|
+ key="data-analysis"
|
|
|
+ title={<span><Icon type="fund"
|
|
|
+ theme="twoTone"/><span>data Analysis</span></span>}>
|
|
|
+ <Menu.Item key="metabase">metabase</Menu.Item>
|
|
|
+ </SubMenu>
|
|
|
+ );
|
|
|
+ case 'monitor-notification':
|
|
|
+ return (
|
|
|
+ <SubMenu
|
|
|
+ key="monitor-notification"
|
|
|
+ title={<span><Icon type="alert" theme="twoTone"/><span>Monitor Notification</span></span>}>
|
|
|
+ <Menu.Item key="monitor">monitor</Menu.Item>
|
|
|
+ <Menu.Item key="graphql-events">graphql-events</Menu.Item>
|
|
|
+ <Menu.Item key="stock-signal">stock-signal</Menu.Item>
|
|
|
+ </SubMenu>
|
|
|
+ );
|
|
|
+ default:
|
|
|
+ return (
|
|
|
+ <SubMenu
|
|
|
+ key="cloud-function"
|
|
|
+ title={<span><Icon type="cloud"
|
|
|
+ theme="twoTone"/><span>Cloud Function</span></span>}>
|
|
|
+ <Menu.Item key="wechat-service">wechat-service</Menu.Item>
|
|
|
+ <Menu.Item key="graphql-service">graphql-service</Menu.Item>
|
|
|
+ <Menu.Item
|
|
|
+ key="quantization-service">quantization-service</Menu.Item>
|
|
|
+ </SubMenu>
|
|
|
+ );
|
|
|
+ }
|
|
|
+ })()}
|
|
|
+ <SubMenu key="my-create"
|
|
|
+ title={<span><Icon type="user"
|
|
|
+ theme="outlined"/><span>My Create</span></span>}>
|
|
|
+ <Menu.Item key="8">option9</Menu.Item>
|
|
|
+ </SubMenu>
|
|
|
+ </Menu>
|
|
|
+ </Sider>
|
|
|
+
|
|
|
+ <Layout style={{marginTop: '64px'}}>
|
|
|
+ <Route path="/" exact component={CloudFunction}/>
|
|
|
+ <Route path="/cloud-function/" component={CloudFunction}/>
|
|
|
+ <Route path="/data-storage/" component={DataStorge}/>
|
|
|
+ <Route path="/data-analysis/" component={DataAnalysis}/>
|
|
|
+ <Route path="/monitor-notification/" component={MonitorNntification}/>
|
|
|
+ </Layout>
|
|
|
+
|
|
|
+ </Layout>
|
|
|
+ </Layout>
|
|
|
+ </Router>
|
|
|
+ );
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+export default App;
|
|
|
+
|
|
|
+class CloudFunction extends Component {
|
|
|
+ constructor() {
|
|
|
+ super();
|
|
|
+ this.state = {
|
|
|
+ menuLevel2: "schema",
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ switchMenu = (menuName, e) => {
|
|
|
+ console.log('menuName', menuName, 'e', e);
|
|
|
+ this.setState({
|
|
|
+ [menuName]: e.key,
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ render() {
|
|
|
+ return (
|
|
|
+ <div>
|
|
|
<Menu
|
|
|
- theme="dark"
|
|
|
mode="horizontal"
|
|
|
- defaultSelectedKeys={['cloud-function']}
|
|
|
- style={{ lineHeight: '64px' }}
|
|
|
- onClick={(e)=>this.switchMenu('menuLevel1',e)}
|
|
|
- >
|
|
|
- <Menu.Item key="cloud-function">Cloud Function</Menu.Item>
|
|
|
- <Menu.Item key="data-storage">Data Storage</Menu.Item>
|
|
|
- <Menu.Item key="data-analysis">Data Analysis</Menu.Item>
|
|
|
- <Menu.Item key="monitor-notification">Monitor Notification</Menu.Item>
|
|
|
- </Menu>
|
|
|
- {/*<div className='login'>*/}
|
|
|
- {/*{*/}
|
|
|
- {/*this.state.hasLogin ?*/}
|
|
|
- {/*this.login(this.state.userID)*/}
|
|
|
- {/*:*/}
|
|
|
- {/*<div>*/}
|
|
|
- {/*<span style={{marginRight: 20}}>login:</span>*/}
|
|
|
- {/*<Input*/}
|
|
|
- {/*placeholder="id, eg: 'xy_1'"*/}
|
|
|
- {/*onChange={(e) => {*/}
|
|
|
- {/*// antd 获取不到 target,百度来的下面这句代码*/}
|
|
|
- {/*e.persist();*/}
|
|
|
- {/*this.setState({userID: e.target.value});*/}
|
|
|
- {/*}}*/}
|
|
|
- {/*onPressEnter={() => {*/}
|
|
|
- {/*this.setState({hasLogin: true})*/}
|
|
|
- {/*}}*/}
|
|
|
- {/*style={{width: 200}}*/}
|
|
|
- {/*/>*/}
|
|
|
- {/*</div>*/}
|
|
|
- {/*}*/}
|
|
|
- {/*</div>*/}
|
|
|
- </Header>
|
|
|
-
|
|
|
- <Layout>
|
|
|
- <Sider
|
|
|
- width={200}
|
|
|
- style={{ background: '#fff',marginTop:'64px'}}
|
|
|
- collapsible
|
|
|
- collapsed={this.state.collapsed}
|
|
|
- onCollapse={this.onCollapse}
|
|
|
+ defaultSelectedKeys={['schema']}
|
|
|
+ style={{padding: '0 24px', position: 'fixed', width: '100%', zIndex: '1'}}
|
|
|
+ onClick={(e) => this.switchMenu('menuLevel2', e)}
|
|
|
+ selectedKeys={[this.state.menuLevel2]}
|
|
|
>
|
|
|
- <Menu
|
|
|
- theme="dark"
|
|
|
- mode="inline"
|
|
|
- inlineCollapsed={this.state.inlineCollapsed}
|
|
|
- defaultSelectedKeys={['e-commerce']}
|
|
|
- defaultOpenKeys={['trial-case']}
|
|
|
- // openKeys={['cloud-function']}
|
|
|
- onClick={(e)=>this.switchMenu('sideBar',e)}
|
|
|
- selectedKeys={[this.state.sideBar]}
|
|
|
- style={{
|
|
|
- borderRight: 0,
|
|
|
- overflow: 'auto',
|
|
|
- height: '100vh',
|
|
|
- left: '0',
|
|
|
- width: '200px',
|
|
|
- position: 'fixed'}}
|
|
|
- >
|
|
|
- <SubMenu key="trial-case" title={<span><Icon type="appstore" theme="twoTone" /><span>Trial Case</span></span>}>
|
|
|
- <Menu.Item key="e-commerce">e-commerce</Menu.Item>
|
|
|
- <Menu.Item key="keep accounts">keep accounts</Menu.Item>
|
|
|
- <Menu.Item key="appointment">appointment</Menu.Item>
|
|
|
- </SubMenu>
|
|
|
- {(() => {
|
|
|
- switch (this.state.menuLevel1) {
|
|
|
- case 'cloud-function':
|
|
|
- return (
|
|
|
- <SubMenu
|
|
|
- key="cloud-function"
|
|
|
- title={<span><Icon type="cloud" theme="twoTone" /><span>Cloud Function</span></span>}>
|
|
|
- <Menu.Item key="wechat-service">wechat-service</Menu.Item>
|
|
|
- <Menu.Item key="graphql-service">graphql-service</Menu.Item>
|
|
|
- <Menu.Item key="quantization-service">quantization-service</Menu.Item>
|
|
|
- </SubMenu>
|
|
|
- );
|
|
|
- case 'data-storage':
|
|
|
- return (
|
|
|
- <SubMenu
|
|
|
- key="data-storage"
|
|
|
- title={<span><Icon type="database" theme="twoTone" /><span>Data Storage</span></span>}>
|
|
|
- <Menu.Item key="snbl-mongo">snbl-mongo</Menu.Item>
|
|
|
- </SubMenu>
|
|
|
- );
|
|
|
- case 'data-analysis':
|
|
|
- return (
|
|
|
- <SubMenu
|
|
|
- key="data-analysis"
|
|
|
- title={<span><Icon type="fund" theme="twoTone" /><span>data Analysis</span></span>}>
|
|
|
- <Menu.Item key="metabase">metabase</Menu.Item>
|
|
|
- </SubMenu>
|
|
|
- );
|
|
|
- case 'monitor-notification':
|
|
|
- return (
|
|
|
- <SubMenu
|
|
|
- key="monitor-notification"
|
|
|
- title={<span><Icon type="alert" theme="twoTone" /><span>Monitor Notification</span></span>}>
|
|
|
- <Menu.Item key="monitor">monitor</Menu.Item>
|
|
|
- <Menu.Item key="graphql-events">graphql-events</Menu.Item>
|
|
|
- <Menu.Item key="stock-signal">stock-signal</Menu.Item>
|
|
|
- </SubMenu>
|
|
|
- );
|
|
|
- default:
|
|
|
- return (
|
|
|
- <SubMenu
|
|
|
- key="cloud-function"
|
|
|
- title={<span><Icon type="cloud" theme="twoTone" /><span>Cloud Function</span></span>}>
|
|
|
- <Menu.Item key="wechat-service">wechat-service</Menu.Item>
|
|
|
- <Menu.Item key="graphql-service">graphql-service</Menu.Item>
|
|
|
- <Menu.Item key="quantization-service">quantization-service</Menu.Item>
|
|
|
- </SubMenu>
|
|
|
- );
|
|
|
- }
|
|
|
- })()}
|
|
|
- <SubMenu key="my-create" title={<span><Icon type="user" theme="outlined" /><span>My Create</span></span>}>
|
|
|
- <Menu.Item key="8">option9</Menu.Item>
|
|
|
- </SubMenu>
|
|
|
- </Menu>
|
|
|
- </Sider>
|
|
|
-
|
|
|
- <Layout style={{marginTop: '64px' }}>
|
|
|
- <Menu
|
|
|
- mode="horizontal"
|
|
|
- defaultSelectedKeys={['schema']}
|
|
|
- style={{padding: '0 24px',position: 'fixed', width: '100%', zIndex: '1' }}
|
|
|
- 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">graphiql</Menu.Item>
|
|
|
<Menu.Item key="metabase">metabase</Menu.Item>
|
|
|
<Menu.Item key="notification">notification</Menu.Item>
|
|
|
- </Menu>
|
|
|
+ </Menu>
|
|
|
|
|
|
- <Layout style={{ padding: '24px', zIndex: '0'}}>
|
|
|
- {/*<Sider width={200} style={{ background: '#fff' }}>*/}
|
|
|
- {/*<Menu*/}
|
|
|
- {/*mode="inline"*/}
|
|
|
- {/*defaultSelectedKeys={['1']}*/}
|
|
|
- {/*defaultOpenKeys={['sub1']}*/}
|
|
|
- {/*style={{ height: '100%' }}*/}
|
|
|
- {/*>*/}
|
|
|
- {/*<Menu.Item key="1">Query</Menu.Item>*/}
|
|
|
- {/*<Menu.Item key="2">Mutation</Menu.Item>*/}
|
|
|
- {/*</Menu>*/}
|
|
|
- {/*</Sider>*/}
|
|
|
- <Content style={{ padding: '24px', minHeight: 280, background: '#fff',marginTop: '48px' }}>
|
|
|
- <div>
|
|
|
- {(() => {
|
|
|
- switch (this.state.menuLevel2) {
|
|
|
- case 'schema':
|
|
|
- return <Schema userID={this.state.userID}/>;
|
|
|
- case 'deploy':
|
|
|
- return <Deploy />;
|
|
|
- case 'graphiql':
|
|
|
- return <Graphql />;
|
|
|
- default:
|
|
|
- return <Graphql />
|
|
|
- }
|
|
|
- })()}
|
|
|
- </div>
|
|
|
+ <Layout style={{padding: '24px', zIndex: '0'}}>
|
|
|
+ {/*<Sider width={200} style={{ background: '#fff' }}>*/}
|
|
|
+ {/*<Menu*/}
|
|
|
+ {/*mode="inline"*/}
|
|
|
+ {/*defaultSelectedKeys={['1']}*/}
|
|
|
+ {/*defaultOpenKeys={['sub1']}*/}
|
|
|
+ {/*style={{ height: '100%' }}*/}
|
|
|
+ {/*>*/}
|
|
|
+ {/*<Menu.Item key="1">Query</Menu.Item>*/}
|
|
|
+ {/*<Menu.Item key="2">Mutation</Menu.Item>*/}
|
|
|
+ {/*</Menu>*/}
|
|
|
+ {/*</Sider>*/}
|
|
|
+ <Content
|
|
|
+ style={{padding: '24px', minHeight: 280, background: '#fff', marginTop: '48px'}}>
|
|
|
+ <div>
|
|
|
+ {(() => {
|
|
|
+ switch (this.state.menuLevel2) {
|
|
|
+ case 'schema':
|
|
|
+ return <Schema userID={this.state.userID}/>;
|
|
|
+ case 'deploy':
|
|
|
+ return <Deploy/>;
|
|
|
+ case 'graphiql':
|
|
|
+ return <Graphql/>;
|
|
|
+ default:
|
|
|
+ return <Graphql/>
|
|
|
+ }
|
|
|
+ })()}
|
|
|
+ </div>
|
|
|
</Content>
|
|
|
- </Layout>
|
|
|
-
|
|
|
</Layout>
|
|
|
- </Layout>
|
|
|
- </Layout>
|
|
|
- );
|
|
|
+ </div>
|
|
|
+ )
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-export default App;
|
|
|
+function DataStorge() {
|
|
|
+ return (
|
|
|
+ <div>
|
|
|
+ DataStorge
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+function DataAnalysis() {
|
|
|
+ return (
|
|
|
+ <div>
|
|
|
+ DataAnalysis
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+function MonitorNntification() {
|
|
|
+ return (
|
|
|
+ <div>
|
|
|
+ MonitorNntification
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+}
|