Monitor.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. import React, { Component } from 'react';
  2. import { AsyncLoadBizCharts } from '@/components/Charts/AsyncLoadBizCharts';
  3. import { connect } from 'dva';
  4. import { formatMessage, FormattedMessage } from 'umi/locale';
  5. import { Row, Col, Card, Tooltip } from 'antd';
  6. import { Pie, WaterWave, Gauge, TagCloud } from '@/components/Charts';
  7. import NumberInfo from '@/components/NumberInfo';
  8. import CountDown from '@/components/CountDown';
  9. import ActiveChart from '@/components/ActiveChart';
  10. import numeral from 'numeral';
  11. import GridContent from '@/components/PageHeaderWrapper/GridContent';
  12. import Authorized from '@/utils/Authorized';
  13. import styles from './Monitor.less';
  14. const { Secured } = Authorized;
  15. const targetTime = new Date().getTime() + 3900000;
  16. // use permission as a parameter
  17. const havePermissionAsync = new Promise(resolve => {
  18. // Call resolve on behalf of passed
  19. setTimeout(() => resolve(), 300);
  20. });
  21. @Secured(havePermissionAsync)
  22. @connect(({ monitor, loading }) => ({
  23. monitor,
  24. loading: loading.models.monitor,
  25. }))
  26. class Monitor extends Component {
  27. componentDidMount() {
  28. const { dispatch } = this.props;
  29. dispatch({
  30. type: 'monitor/fetchTags',
  31. });
  32. }
  33. render() {
  34. const { monitor, loading } = this.props;
  35. const { tags } = monitor;
  36. return (
  37. <GridContent>
  38. <Row gutter={24}>
  39. <Col xl={18} lg={24} md={24} sm={24} xs={24} style={{ marginBottom: 24 }}>
  40. <Card
  41. title={
  42. <FormattedMessage
  43. id="app.monitor.trading-activity"
  44. defaultMessage="Real-Time Trading Activity"
  45. />
  46. }
  47. bordered={false}
  48. >
  49. <Row>
  50. <Col md={6} sm={12} xs={24}>
  51. <NumberInfo
  52. subTitle={
  53. <FormattedMessage
  54. id="app.monitor.total-transactions"
  55. defaultMessage="Total transactions today"
  56. />
  57. }
  58. suffix="元"
  59. total={numeral(124543233).format('0,0')}
  60. />
  61. </Col>
  62. <Col md={6} sm={12} xs={24}>
  63. <NumberInfo
  64. subTitle={
  65. <FormattedMessage
  66. id="app.monitor.sales-target"
  67. defaultMessage="Sales target completion rate"
  68. />
  69. }
  70. total="92%"
  71. />
  72. </Col>
  73. <Col md={6} sm={12} xs={24}>
  74. <NumberInfo
  75. subTitle={
  76. <FormattedMessage
  77. id="app.monitor.remaining-time"
  78. defaultMessage="Remaining time of activity"
  79. />
  80. }
  81. total={<CountDown target={targetTime} />}
  82. />
  83. </Col>
  84. <Col md={6} sm={12} xs={24}>
  85. <NumberInfo
  86. subTitle={
  87. <FormattedMessage
  88. id="app.monitor.total-transactions-per-second"
  89. defaultMessage="Total transactions per second"
  90. />
  91. }
  92. suffix="元"
  93. total={numeral(234).format('0,0')}
  94. />
  95. </Col>
  96. </Row>
  97. <div className={styles.mapChart}>
  98. <Tooltip
  99. title={
  100. <FormattedMessage
  101. id="app.monitor.waiting-for-implementation"
  102. defaultMessage="Waiting for implementation"
  103. />
  104. }
  105. >
  106. <img
  107. src="https://gw.alipayobjects.com/zos/antfincdn/h%24wFbzuuzz/HBWnDEUXCnGnGrRfrpKa.png"
  108. alt="map"
  109. />
  110. </Tooltip>
  111. </div>
  112. </Card>
  113. </Col>
  114. <Col xl={6} lg={24} md={24} sm={24} xs={24}>
  115. <Card
  116. title={
  117. <FormattedMessage
  118. id="app.monitor.activity-forecast"
  119. defaultMessage="Activity forecast"
  120. />
  121. }
  122. style={{ marginBottom: 24 }}
  123. bordered={false}
  124. >
  125. <ActiveChart />
  126. </Card>
  127. <Card
  128. title={<FormattedMessage id="app.monitor.efficiency" defaultMessage="Efficiency" />}
  129. style={{ marginBottom: 24 }}
  130. bodyStyle={{ textAlign: 'center' }}
  131. bordered={false}
  132. >
  133. <Gauge
  134. title={formatMessage({ id: 'app.monitor.ratio', defaultMessage: 'Ratio' })}
  135. height={180}
  136. percent={87}
  137. />
  138. </Card>
  139. </Col>
  140. </Row>
  141. <Row gutter={24}>
  142. <Col xl={12} lg={24} sm={24} xs={24} style={{ marginBottom: 24 }}>
  143. <Card
  144. title={
  145. <FormattedMessage
  146. id="app.monitor.proportion-per-category"
  147. defaultMessage="Proportion Per Category"
  148. />
  149. }
  150. bordered={false}
  151. className={styles.pieCard}
  152. >
  153. <Row style={{ padding: '16px 0' }}>
  154. <Col span={8}>
  155. <Pie
  156. animate={false}
  157. percent={28}
  158. subTitle={
  159. <FormattedMessage id="app.monitor.fast-food" defaultMessage="Fast food" />
  160. }
  161. total="28%"
  162. height={128}
  163. lineWidth={2}
  164. />
  165. </Col>
  166. <Col span={8}>
  167. <Pie
  168. animate={false}
  169. color="#5DDECF"
  170. percent={22}
  171. subTitle={
  172. <FormattedMessage
  173. id="app.monitor.western-food"
  174. defaultMessage="Western food"
  175. />
  176. }
  177. total="22%"
  178. height={128}
  179. lineWidth={2}
  180. />
  181. </Col>
  182. <Col span={8}>
  183. <Pie
  184. animate={false}
  185. color="#2FC25B"
  186. percent={32}
  187. subTitle={
  188. <FormattedMessage id="app.monitor.hot-pot" defaultMessage="Hot pot" />
  189. }
  190. total="32%"
  191. height={128}
  192. lineWidth={2}
  193. />
  194. </Col>
  195. </Row>
  196. </Card>
  197. </Col>
  198. <Col xl={6} lg={12} sm={24} xs={24} style={{ marginBottom: 24 }}>
  199. <Card
  200. title={
  201. <FormattedMessage
  202. id="app.monitor.popular-searches"
  203. defaultMessage="Popular Searches"
  204. />
  205. }
  206. loading={loading}
  207. bordered={false}
  208. bodyStyle={{ overflow: 'hidden' }}
  209. >
  210. <TagCloud data={tags} height={161} />
  211. </Card>
  212. </Col>
  213. <Col xl={6} lg={12} sm={24} xs={24} style={{ marginBottom: 24 }}>
  214. <Card
  215. title={
  216. <FormattedMessage
  217. id="app.monitor.resource-surplus"
  218. defaultMessage="Resource Surplus"
  219. />
  220. }
  221. bodyStyle={{ textAlign: 'center', fontSize: 0 }}
  222. bordered={false}
  223. >
  224. <WaterWave
  225. height={161}
  226. title={
  227. <FormattedMessage id="app.monitor.fund-surplus" defaultMessage="Fund Surplus" />
  228. }
  229. percent={34}
  230. />
  231. </Card>
  232. </Col>
  233. </Row>
  234. </GridContent>
  235. );
  236. }
  237. }
  238. export default props => (
  239. <AsyncLoadBizCharts>
  240. <Monitor {...props} />
  241. </AsyncLoadBizCharts>
  242. );