Table.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import React, {Component} from 'react';
  2. import {Row, Col, Icon, Spin} from 'antd';
  3. import './index.css';
  4. import Column from './Column';
  5. import {Query} from "react-apollo";
  6. import gql from "graphql-tag";
  7. import {SHOW_TABLE} from '../../gql'
  8. import Schema from "./Schema";
  9. class Table extends Component {
  10. render() {
  11. let userID = this.props.userID;
  12. return (
  13. <Query query={gql(SHOW_TABLE)} variables={{schema_id: this.props.schemaID}}>
  14. {
  15. ({loading, error, data}) => {
  16. if (loading) {
  17. return <Spin style={{marginLeft: 3}}/>
  18. }
  19. if (error) {
  20. return 'error!';
  21. }
  22. return (
  23. <div>
  24. {
  25. JSON.parse(data.schema_by_id.schemaData).map(table => (
  26. <Row key={table.name} className='show'>
  27. <Col span={8}><span>{table.name}</span></Col>
  28. <Col span={8}><span>{table.remark}</span></Col>
  29. <Col span={8}><Icon type="delete"/></Col>
  30. </Row>
  31. ))
  32. }
  33. </div>
  34. );
  35. }
  36. }
  37. </Query>
  38. )
  39. }
  40. }
  41. export default Table;