import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Row, Col, Card, Descriptions } from 'antd';
import { inject, observer } from 'mobx-react';
import {
CheckCircleTwoTone,
CloseCircleTwoTone,
} from '@ant-design/icons/lib/icons';
import styles from '../style.less';
export class NetworkService extends Component {
componentDidMount() {
this.props.store.getNetworkService();
}
renderAction = (item, index) => (
<Row className={styles['sider-card']} key={`${item.binary}-${index}`}>
<Col
span={8}
style={{ textAlign: 'left', whiteSpace: 'nowrap', overflow: 'hidden' }}
>
{item.binary}
</Col>
<Col span={8} style={{ textAlign: 'center' }}>
{item.host}
</Col>
<Col span={8} style={{ textAlign: 'center' }}>
<span>{item.alive ? t('Up') : t('Down')}</span>
{item.alive ? (
<CheckCircleTwoTone
style={{ marginLeft: 12 }}
twoToneColor="#52c41a"
/>
) : (
<CloseCircleTwoTone
style={{ marginLeft: 12 }}
twoToneColor="#ff4d4f"
/>
)}
</Col>
</Row>
);
render() {
const { networkServiceLoading, networkService = [] } = this.props.store;
return (
<Card
loading={networkServiceLoading}
className={styles.top}
title={t('Network Service')}
bordered={false}
>
<Descriptions column={1}>
<div className="site-card-wrapper">
{networkService.map((item, index) =>
this.renderAction(item, index)
)}
</div>
</Descriptions>
</Card>
);
}
}
NetworkService.propTypes = {
store: PropTypes.object.isRequired,
};
export default inject('rootStore')(observer(NetworkService));