UserCreate.jsx 3.5 KB

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