| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- import React, {Component} from 'react';
- import {Layout, Card, Button, Avatar, Spin, Icon} from 'antd';
- import lo from '../../../images/lo.png'
- import './index.css'
- import {graphqlUrl} from "../../../config";
- import {SHOW_ALL_CASE} from "../../../gql";
- import {FormattedMessage} from 'react-intl';
- import {request} from 'graphql-request'
- const {Content} = Layout;
- const {Meta} = Card;
- class CaseShow extends Component {
- constructor(props) {
- super(props);
- this.state = {
- examplesIoobot: [],
- examplesOthers: []
- }
- }
- componentWillMount() {
- this._isMounted = true;
- request(graphqlUrl, SHOW_ALL_CASE, {}).then(data => {
- let cases = data.case_by_props;
- console.log(cases);
- let examplesIoobot = cases.filter(case1 => case1.user_id.id === 'ioobot');
- let examplesOthers = cases.filter(case2 => case2.user_id.id !== 'ioobot');
- if (this._isMounted) {
- this.setState({
- examplesIoobot,
- examplesOthers
- })
- }
- }
- )
- }
- componentWillUnmount() {
- this._isMounted = false;
- }
- render() {
- return (
- <div id="example-show">
- <Layout style={{padding: '24px', minHeight: '300px'}}>
- <Content className="content">
- <div className={'schema-name'} style={{fontSize: 25}}><FormattedMessage id='scan and use'/>
- </div>
- <div>
- <div className={'schema-name'}><FormattedMessage id='ioobot case'/></div>
- <div className="caseAllShow">
- {
- this.state.examplesIoobot.length === 0 ?
- <Spin/>
- :
- this.state.examplesIoobot.map((item, index) => (
- <span key={index} style={{padding: '10px 0'}}>
- <Card
- key={index}
- style={{width: 300}}
- cover={<div className='cover-div'><img className='cover-img' src={item.img}
- alt={item.title + '' + item.description}/>
- </div>}
- actions={[
- <span>已部署: {item.deployedNum}</span>,
- <span><Icon type="like" />: {item.like}</span>,
- <Button type="primary" onClick={() => {
- this.props.history.push({
- pathname: `/common/deploy-cloud-choose`,
- state: {caseID: item.id,}
- });
- }}><FormattedMessage id='step more'/></Button>
- ]}
- >
- <Meta
- avatar={<Avatar src={lo}/>}
- title={item.title}
- description={item.description}
- />
- </Card>
- </span>
- ))
- }
- </div>
- </div>
- <div>
- <div className={'schema-name'}><FormattedMessage id='other developer case'/></div>
- <div className="caseAllShow">
- {
- this.state.examplesOthers.length === 0 ?
- <Spin/>
- :
- this.state.examplesOthers.map((item, index) => (
- <span key={index} style={{padding: '10px 0'}}>
- <Card
- key={index}
- style={{width: 300}}
- cover={<div className='cover-div'><img className='cover-img' src={item.img} alt={item.title + '' + item.description}/></div>}
- actions={[
- <span>已部署: {item.deployedNum}</span>,
- <span><Icon type="like" />: {item.like}</span>,
- <Button type="primary" onClick={() => {
- this.props.history.push({
- pathname: `/common/deploy-cloud-choose`,
- state: {caseID: item.id,}
- });
- }}><FormattedMessage id='step more'/></Button>
- ]}
- >
- <Meta
- avatar={<Avatar src={item.user_id.avatar}/>}
- title={item.title}
- description={item.description}
- />
- </Card>
- </span>
- ))
- }
- </div>
- </div>
- </Content>
- </Layout>
- </div>
- )
- }
- }
- export default CaseShow;
|