TrialCase.jsx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. console.log('schemaID',schemaID);
  45. return (
  46. <div>
  47. <Menu
  48. mode="horizontal"
  49. defaultSelectedKeys={['schema']}
  50. style={{padding: '0 24px', position: 'fixed', width: '100%', zIndex: '1',lineHeight:'50px',fontWeight:600}}
  51. onClick={(e) => this.switchMenu('menuLevel2', e)}
  52. selectedKeys={[this.state.menuLevel2]}
  53. >
  54. <Menu.Item key="schema">schema</Menu.Item>
  55. <Menu.Item key="deploy">deploy</Menu.Item>
  56. <Menu.Item key="graphql">graphql</Menu.Item>
  57. <Menu.Item key="graphiql">graphql IDE</Menu.Item>
  58. <Menu.Item key="metabase">metabase</Menu.Item>
  59. </Menu>
  60. <Layout style={{padding: '24px', zIndex: '0'}}>
  61. <Content style={{padding: '24px', minHeight: 280, background: '#fff', marginTop: '48px'}}>
  62. {
  63. (() => {
  64. switch (this.state.menuLevel2) {
  65. case 'schema':
  66. return <Schema userID={this.state.userID} schemaID={schemaID}/>;
  67. case 'deploy':
  68. return <Deploy userID={this.state.userID} schemaID={schemaID}/>;
  69. case 'graphql':
  70. return <GenerateJs/>;
  71. case 'graphiql':
  72. return <Graphql/>;
  73. case 'metabase':
  74. return <CaseMetabase/>;
  75. default:
  76. return <Graphql/>
  77. }
  78. })()
  79. }
  80. </Content>
  81. </Layout>
  82. </div>
  83. )
  84. }
  85. }
  86. export default TrialCase;