|
|
@@ -18,8 +18,9 @@ import '../common/graphql/index.css';
|
|
|
import './index.css'
|
|
|
import Create from "../common/schema/Create";
|
|
|
|
|
|
-import {SHOW_SCHEMA} from "../gql";
|
|
|
+import {SHOW_ALL_SCHEMA} from "../gql";
|
|
|
import axios from 'axios';
|
|
|
+import {getCookie} from "../cookie";
|
|
|
|
|
|
axios.defaults.withCredentials = true;
|
|
|
|
|
|
@@ -255,8 +256,8 @@ class App extends Component {
|
|
|
key={locale ? locale.locale : 'en'/* Have to refresh for production environment */}>
|
|
|
<Switch>
|
|
|
<Route path="/" exact component={TrialCase}/>
|
|
|
- <Route path="/graphql-service/:sidebar/:caseId" component={TrialCase}/>
|
|
|
- <Route path="/wechat-service/:sidebar/:caseId" component={WechatService}/>
|
|
|
+ <Route path="/graphql-service/:sidebar/:case" component={TrialCase}/>
|
|
|
+ <Route path="/wechat-service/:sidebar/:case" component={WechatService}/>
|
|
|
<Route path="/quant-service/" component={QuantService}/>
|
|
|
<Route path="/table/:name" component={Column}/>
|
|
|
<Route path="/login" component={Login}/>
|
|
|
@@ -276,102 +277,99 @@ class GraphqlSidebar extends Component {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
this.state = {
|
|
|
- getID_url: 'http://123.206.193.98:8999/getuserid',
|
|
|
- userID: '',
|
|
|
+ // 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);
|
|
|
- });
|
|
|
- }
|
|
|
+ // 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() {
|
|
|
console.log('userID',this.state.userID);
|
|
|
return (
|
|
|
- this.state.show ?
|
|
|
- <Query query={gql(SHOW_SCHEMA)} variables={{user_id: this.state.userID}}>
|
|
|
- {
|
|
|
- ({loading, error, data}) => {
|
|
|
- console.log('schema data',data);
|
|
|
- if (loading) return <Spin style={{marginLeft: 3}}/>;
|
|
|
- if (error) return 'error!';
|
|
|
- return (
|
|
|
- <Menu
|
|
|
- theme="dark"
|
|
|
- mode="inline"
|
|
|
- inlineCollapsed={this.props.inlineCollapsed}
|
|
|
- defaultSelectedKeys={['e-commerce']}
|
|
|
- defaultOpenKeys={['trial-case', 'my-create']}
|
|
|
- // openKeys={['cloud-function']}
|
|
|
- onClick={(e) => this.props.switchMenu('sideBar', e)}
|
|
|
- selectedKeys={[this.props.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"><Link
|
|
|
- to="/graphql-service/trial-case/e-commerce">e-commerce</Link></Menu.Item>
|
|
|
- <Menu.Item key="keep accounts"><Link
|
|
|
- to="/graphql-service/trial-case/keep-accounts">keep
|
|
|
- accounts</Link></Menu.Item>
|
|
|
- <Menu.Item key="appointment"><Link
|
|
|
- to="/graphql-service/trial-case/appointment">appointment</Link></Menu.Item>
|
|
|
- </SubMenu>
|
|
|
+ <Query query={gql(SHOW_ALL_SCHEMA)} variables={{user_id: this.state.userID}}>
|
|
|
+ {
|
|
|
+ ({loading, error, data}) => {
|
|
|
+ console.log('user schema data',data);
|
|
|
+ if (loading) return <Spin style={{marginLeft: 3}}/>;
|
|
|
+ if (error) return 'error!';
|
|
|
+ return (
|
|
|
+ <Menu
|
|
|
+ theme="dark"
|
|
|
+ mode="inline"
|
|
|
+ inlineCollapsed={this.props.inlineCollapsed}
|
|
|
+ defaultSelectedKeys={['e-commerce']}
|
|
|
+ defaultOpenKeys={['trial-case', 'my-create']}
|
|
|
+ // openKeys={['cloud-function']}
|
|
|
+ onClick={(e) => this.props.switchMenu('sideBar', e)}
|
|
|
+ selectedKeys={[this.props.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>}>
|
|
|
+ {
|
|
|
+ data.caseSchema.map((schema) =>
|
|
|
+ <Menu.Item key={schema.schemaName}>
|
|
|
+ <Link to={`/graphql-service/trial-case/${schema.schemaName}?id=${schema.id}`}>{schema.schemaName}</Link>
|
|
|
+ </Menu.Item>)
|
|
|
+ }
|
|
|
+ </SubMenu>
|
|
|
|
|
|
- <Menu.Item key="create-graphql" onClick={this.props.showModal}>
|
|
|
- <Icon type="edit" theme="twoTone"/>
|
|
|
- <span>Create</span>
|
|
|
- <Icon type="plus" style={{
|
|
|
- position: 'absolute',
|
|
|
- top: '35%',
|
|
|
- right: '6px',
|
|
|
- color: 'white'
|
|
|
- }}/>
|
|
|
- </Menu.Item>
|
|
|
+ <Menu.Item key="create-graphql" onClick={this.props.showModal}>
|
|
|
+ <Icon type="edit" theme="twoTone"/>
|
|
|
+ <span>Create</span>
|
|
|
+ <Icon type="plus" style={{
|
|
|
+ position: 'absolute',
|
|
|
+ top: '35%',
|
|
|
+ right: '6px',
|
|
|
+ color: 'white'
|
|
|
+ }}/>
|
|
|
+ </Menu.Item>
|
|
|
|
|
|
- <SubMenu key="my-create" title={<span><Icon type="user"
|
|
|
- theme="outlined"/><span>My Create</span></span>}>
|
|
|
- {
|
|
|
- data.schema_by_props.map((schema) => <Menu.Item
|
|
|
- key={schema.schemaName}><Link
|
|
|
- to={`/graphql-service/my-create/${schema.id}`}>{schema.schemaName}</Link></Menu.Item>)
|
|
|
- }
|
|
|
- </SubMenu>
|
|
|
- </Menu>
|
|
|
+ <SubMenu key="my-create" title={<span><Icon type="user" theme="outlined"/><span>My Create</span></span>}>
|
|
|
+ {
|
|
|
+ data.userSchema.map((schema) =>
|
|
|
+ <Menu.Item key={schema.schemaName}>
|
|
|
+ <Link to={`/graphql-service/my-create/${schema.schemaName}?id=${schema.id}`}>{schema.schemaName}</Link>
|
|
|
+ </Menu.Item>)
|
|
|
+ }
|
|
|
+ </SubMenu>
|
|
|
+ </Menu>
|
|
|
|
|
|
- )
|
|
|
- }
|
|
|
+ )
|
|
|
}
|
|
|
- </Query>
|
|
|
- :
|
|
|
- ''
|
|
|
+ }
|
|
|
+ </Query>
|
|
|
)
|
|
|
}
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+// this.state.show ?
|
|
|
+// :''
|