Monitor.js 7.89 KB
Newer Older
陈帅's avatar
陈帅 committed
1
import React, { Component } from 'react';
2
import { connect } from 'dva';
陈小聪's avatar
陈小聪 committed
3
import { formatMessage, FormattedMessage } from 'umi-plugin-react/locale';
4
import { Row, Col, Card, Tooltip } from 'antd';
5 6 7 8
import { Pie, WaterWave, Gauge, TagCloud } from '@/components/Charts';
import NumberInfo from '@/components/NumberInfo';
import CountDown from '@/components/CountDown';
import ActiveChart from '@/components/ActiveChart';
9
import numeral from 'numeral';
10
import GridContent from '@/components/PageHeaderWrapper/GridContent';
11
import Authorized from '@/utils/Authorized';
12 13
import styles from './Monitor.less';

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

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

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

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

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

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

陈帅's avatar
陈帅 committed
244
export default Monitor;