TrialCase.jsx 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import React, {Component} from 'react';
  2. import {Layout, Menu} from 'antd';
  3. import GenerateJs from "../common/generateJs/GenerateJs";
  4. import Deploy from '../common/deploy/Deploy';
  5. import Schema from '../common/schema/Schema';
  6. import Graphql from "../common/graphql/Graphql";
  7. import CaseMetabase from "../common/caseMetabase/CaseMetabase";
  8. import axios from 'axios';
  9. axios.defaults.withCredentials = true;
  10. const {Content} = Layout;
  11. class TrialCase extends Component {
  12. constructor(props) {
  13. super(props);
  14. console.log('TrialCase props',props);
  15. this.state = {
  16. menuLevel2: "schema",
  17. // default user
  18. userID: "ioobot",
  19. getID_url: 'http://123.206.193.98:8999/getuserid',
  20. }
  21. }
  22. componentWillMount() {
  23. let _this = this;
  24. axios.get(this.state.getID_url)
  25. .then((res) => {
  26. if (res.data !== '') {
  27. _this.setState({
  28. userID: res.data
  29. })
  30. }
  31. })
  32. .catch(function (err) {
  33. console.log(err);
  34. });
  35. }
  36. switchMenu = (menuName, e) => {
  37. // console.log('menuName', menuName, 'e', e);
  38. this.setState({
  39. [menuName]: e.key,
  40. });
  41. };
  42. render() {
  43. let schemaID = this.props.history.location.state ? this.props.history.location.state.schemaID : "schema_1542243424669_92094965";
  44. let schemaName = this.props.history.location.state ? this.props.history.location.state.schemaName : "ecommerce";
  45. console.log('schemaID0',schemaID,'schemaName0',schemaName);
  46. return (
  47. <div>
  48. <Menu
  49. mode="horizontal"
  50. defaultSelectedKeys={['schema']}
  51. style={{padding: '0 24px', position: 'fixed', width: '100%', zIndex: '1',lineHeight:'50px',fontWeight:600}}
  52. onClick={(e) => this.switchMenu('menuLevel2', e)}
  53. selectedKeys={[this.state.menuLevel2]}
  54. >
  55. <Menu.Item key="schema">schema</Menu.Item>
  56. <Menu.Item key="deploy">deploy</Menu.Item>
  57. <Menu.Item key="graphql">graphql</Menu.Item>
  58. <Menu.Item key="graphiql">graphql IDE</Menu.Item>
  59. <Menu.Item key="metabase">metabase</Menu.Item>
  60. </Menu>
  61. <Layout style={{padding: '24px', zIndex: '0'}}>
  62. <Content style={{padding: '24px', minHeight: 280, background: '#fff', marginTop: '48px'}}>
  63. {
  64. (() => {
  65. switch (this.state.menuLevel2) {
  66. case 'schema':
  67. return <Schema userID={this.state.userID} schemaName={schemaName} schemaID={schemaID} location={this.props.location}/>;
  68. case 'deploy':
  69. return <Deploy userID={this.state.userID} schemaID={schemaID} schemaName={schemaName}/>;
  70. case 'graphql':
  71. return <GenerateJs/>;
  72. case 'graphiql':
  73. return <Graphql/>;
  74. case 'metabase':
  75. return <CaseMetabase/>;
  76. default:
  77. return <Graphql/>
  78. }
  79. })()
  80. }
  81. </Content>
  82. </Layout>
  83. </div>
  84. )
  85. }
  86. }
  87. export default TrialCase;