Monitor.js 8.03 KB
Newer Older
陈帅's avatar
陈帅 committed
1 2
import React, { Component } from 'react';
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 7 8 9
import { Pie, WaterWave, Gauge, TagCloud } from '@/components/Charts';
import NumberInfo from '@/components/NumberInfo';
import CountDown from '@/components/CountDown';
import ActiveChart from '@/components/ActiveChart';
10
import numeral from 'numeral';
11
import GridContent from '@/components/PageHeaderWrapper/GridContent';
12
import Authorized from '@/utils/Authorized';
13 14
import styles from './Monitor.less';

陈帅's avatar
陈帅 committed
15 16
const { Secured } = Authorized;

17 18
const targetTime = new Date().getTime() + 3900000;

jim's avatar
jim committed
19
// use permission as a parameter
jim's avatar
jim committed
20
const havePermissionAsync = new Promise(resolve => {
jim's avatar
jim committed
21
  // Call resolve on behalf of passed
afc163's avatar
afc163 committed
22
  setTimeout(() => resolve(), 300);
jim's avatar
jim committed
23
});
afc163's avatar
afc163 committed
24

jim's avatar
jim committed
25
@Secured(havePermissionAsync)
Andreas Cederström's avatar
Andreas Cederström committed
26 27 28
@connect(({ monitor, loading }) => ({
  monitor,
  loading: loading.models.monitor,
29
}))
陈帅's avatar
陈帅 committed
30
class Monitor extends Component {
31
  componentDidMount() {
陈帅's avatar
陈帅 committed
32 33
    const { dispatch } = this.props;
    dispatch({
34 35
      type: 'monitor/fetchTags',
    });
nikogu's avatar
nikogu committed
36
  }
nikogu's avatar
nikogu committed
37

38
  render() {
Andreas Cederström's avatar
Andreas Cederström committed
39
    const { monitor, loading } = this.props;
40 41 42
    const { tags } = monitor;

    return (
jim's avatar
jim committed
43
      <GridContent>
44
        <Row gutter={24}>
niko's avatar
niko committed
45
          <Col xl={18} lg={24} md={24} sm={24} xs={24} style={{ marginBottom: 24 }}>
46 47 48 49 50 51 52 53 54
            <Card
              title={
                <FormattedMessage
                  id="app.monitor.trading-activity"
                  defaultMessage="Real-Time Trading Activity"
                />
              }
              bordered={false}
            >
55
              <Row>
niko's avatar
niko committed
56
                <Col md={6} sm={12} xs={24}>
57
                  <NumberInfo
58 59 60 61 62 63
                    subTitle={
                      <FormattedMessage
                        id="app.monitor.total-transactions"
                        defaultMessage="Total transactions today"
                      />
                    }
niko's avatar
niko committed
64
                    suffix=""
65 66 67
                    total={numeral(124543233).format('0,0')}
                  />
                </Col>
niko's avatar
niko committed
68
                <Col md={6} sm={12} xs={24}>
69 70 71 72 73 74 75 76 77
                  <NumberInfo
                    subTitle={
                      <FormattedMessage
                        id="app.monitor.sales-target"
                        defaultMessage="Sales target completion rate"
                      />
                    }
                    total="92%"
                  />
78
                </Col>
niko's avatar
niko committed
79
                <Col md={6} sm={12} xs={24}>
80 81 82 83 84 85 86 87 88
                  <NumberInfo
                    subTitle={
                      <FormattedMessage
                        id="app.monitor.remaining-time"
                        defaultMessage="Remaining time of activity"
                      />
                    }
                    total={<CountDown target={targetTime} />}
                  />
89
                </Col>
niko's avatar
niko committed
90
                <Col md={6} sm={12} xs={24}>
91
                  <NumberInfo
92 93 94 95 96 97
                    subTitle={
                      <FormattedMessage
                        id="app.monitor.total-transactions-per-second"
                        defaultMessage="Total transactions per second"
                      />
                    }
niko's avatar
niko committed
98
                    suffix=""
99 100 101 102 103
                    total={numeral(234).format('0,0')}
                  />
                </Col>
              </Row>
              <div className={styles.mapChart}>
104 105 106 107 108 109 110 111
                <Tooltip
                  title={
                    <FormattedMessage
                      id="app.monitor.waiting-for-implementation"
                      defaultMessage="Waiting for implementation"
                    />
                  }
                >
niko's avatar
niko committed
112
                  <img
陈帅's avatar
陈帅 committed
113
                    src="https://gw.alipayobjects.com/zos/antfincdn/h%24wFbzuuzz/HBWnDEUXCnGnGrRfrpKa.png"
niko's avatar
niko committed
114 115
                    alt="map"
                  />
116
                </Tooltip>
117 118 119
              </div>
            </Card>
          </Col>
niko's avatar
niko committed
120
          <Col xl={6} lg={24} md={24} sm={24} xs={24}>
121 122 123
            <Card
              title={
                <FormattedMessage
陈帅's avatar
陈帅 committed
124
                  id="app.monitor.activity-forecast"
125 126 127 128 129 130
                  defaultMessage="Activity forecast"
                />
              }
              style={{ marginBottom: 24 }}
              bordered={false}
            >
nikogu's avatar
nikogu committed
131
              <ActiveChart />
132
            </Card>
133
            <Card
134
              title={<FormattedMessage id="app.monitor.efficiency" defaultMessage="Efficiency" />}
135 136 137 138
              style={{ marginBottom: 24 }}
              bodyStyle={{ textAlign: 'center' }}
              bordered={false}
            >
139 140 141 142 143
              <Gauge
                title={formatMessage({ id: 'app.monitor.ratio', defaultMessage: 'Ratio' })}
                height={180}
                percent={87}
              />
144 145 146 147
            </Card>
          </Col>
        </Row>
        <Row gutter={24}>
afc163's avatar
afc163 committed
148
          <Col xl={12} lg={24} sm={24} xs={24} style={{ marginBottom: 24 }}>
149 150 151 152 153 154 155 156 157 158
            <Card
              title={
                <FormattedMessage
                  id="app.monitor.proportion-per-category"
                  defaultMessage="Proportion Per Category"
                />
              }
              bordered={false}
              className={styles.pieCard}
            >
afc163's avatar
afc163 committed
159
              <Row style={{ padding: '16px 0' }}>
160 161
                <Col span={8}>
                  <Pie
nikogu's avatar
nikogu committed
162
                    animate={false}
163
                    percent={28}
164 165 166
                    subTitle={
                      <FormattedMessage id="app.monitor.fast-food" defaultMessage="Fast food" />
                    }
167
                    total="28%"
偏右's avatar
偏右 committed
168
                    height={128}
afc163's avatar
afc163 committed
169
                    lineWidth={2}
170 171 172 173
                  />
                </Col>
                <Col span={8}>
                  <Pie
nikogu's avatar
nikogu committed
174
                    animate={false}
niko's avatar
niko committed
175
                    color="#5DDECF"
176
                    percent={22}
177 178 179 180 181 182
                    subTitle={
                      <FormattedMessage
                        id="app.monitor.western-food"
                        defaultMessage="Western food"
                      />
                    }
183
                    total="22%"
偏右's avatar
偏右 committed
184
                    height={128}
afc163's avatar
afc163 committed
185
                    lineWidth={2}
186 187 188 189
                  />
                </Col>
                <Col span={8}>
                  <Pie
nikogu's avatar
nikogu committed
190
                    animate={false}
niko's avatar
niko committed
191
                    color="#2FC25B"
192
                    percent={32}
193 194 195
                    subTitle={
                      <FormattedMessage id="app.monitor.hot-pot" defaultMessage="Hot pot" />
                    }
196
                    total="32%"
偏右's avatar
偏右 committed
197
                    height={128}
afc163's avatar
afc163 committed
198
                    lineWidth={2}
199 200 201 202 203
                  />
                </Col>
              </Row>
            </Card>
          </Col>
afc163's avatar
afc163 committed
204
          <Col xl={6} lg={12} sm={24} xs={24} style={{ marginBottom: 24 }}>
niko's avatar
niko committed
205
            <Card
206 207 208 209 210 211
              title={
                <FormattedMessage
                  id="app.monitor.popular-searches"
                  defaultMessage="Popular Searches"
                />
              }
niko's avatar
niko committed
212 213 214 215 216
              loading={loading}
              bordered={false}
              bodyStyle={{ overflow: 'hidden' }}
            >
              <TagCloud data={tags} height={161} />
217 218
            </Card>
          </Col>
afc163's avatar
afc163 committed
219
          <Col xl={6} lg={12} sm={24} xs={24} style={{ marginBottom: 24 }}>
niko's avatar
niko committed
220
            <Card
221 222 223 224 225 226
              title={
                <FormattedMessage
                  id="app.monitor.resource-surplus"
                  defaultMessage="Resource Surplus"
                />
              }
niko's avatar
niko committed
227 228 229
              bodyStyle={{ textAlign: 'center', fontSize: 0 }}
              bordered={false}
            >
230 231 232 233 234 235 236
              <WaterWave
                height={161}
                title={
                  <FormattedMessage id="app.monitor.fund-surplus" defaultMessage="Fund Surplus" />
                }
                percent={34}
              />
237 238 239
            </Card>
          </Col>
        </Row>
jim's avatar
jim committed
240
      </GridContent>
241 242 243
    );
  }
}
陈帅's avatar
陈帅 committed
244

陈帅's avatar
陈帅 committed
245 246 247 248 249
export default props => (
  <AsyncLoadBizCharts>
    <Monitor {...props} />
  </AsyncLoadBizCharts>
);