| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- 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 TrialCase extends Component {
- constructor(props) {
- super(props);
- console.log('TrialCase props',props);
- this.state = {
- 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,
- });
- };
- render() {
- let schemaID = this.props.history.location.state ? this.props.history.location.state.schemaId : "schema_1542243424669_92094965";
- console.log('schemaID',schemaID);
- 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} schemaID={schemaID}/>;
- case 'deploy':
- return <Deploy userID={this.state.userID} schemaID={schemaID}/>;
- case 'graphql':
- return <GenerateJs/>;
- case 'graphiql':
- return <Graphql/>;
- case 'metabase':
- return <CaseMetabase/>;
- default:
- return <Graphql/>
- }
- })()
- }
- </Content>
- </Layout>
- </div>
- )
- }
- }
- export default TrialCase;
|