Monitor.js 7.9 KB
Newer Older
陈帅 已提交
1
import React, { Component } from 'react';
2
import { connect } from 'dva';
陈小聪 已提交
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';

陈帅 已提交
14 15
const { Secured } = Authorized;

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

J
jim 已提交
18
// use permission as a parameter
J
jim 已提交
19
const havePermissionAsync = new Promise(resolve => {
J
jim 已提交
20
  // Call resolve on behalf of passed
A
afc163 已提交
21
  setTimeout(() => resolve(), 300);
J
jim 已提交
22
});
A
afc163 已提交
23

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

37
  render() {
A
Andreas Cederström 已提交
38
    const { monitor, loading } = this.props;
39 40 41
    const { tags } = monitor;

    return (
J
jim 已提交
42
      <GridContent>
43
        <Row gutter={24}>
N
niko 已提交
44
          <Col xl={18} lg={24} md={24} sm={24} xs={24} style={{ marginBottom: 24 }}>
I
Ilan 已提交
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>
N
niko 已提交
55
                <Col md={6} sm={12} xs={24}>
56
                  <NumberInfo
I
Ilan 已提交
57 58 59 60 61 62
                    subTitle={
                      <FormattedMessage
                        id="app.monitor.total-transactions"
                        defaultMessage="Total transactions today"
                      />
                    }
N
niko 已提交
63
                    suffix=""
64 65 66
                    total={numeral(124543233).format('0,0')}
                  />
                </Col>
N
niko 已提交
67
                <Col md={6} sm={12} xs={24}>
I
Ilan 已提交
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>
N
niko 已提交
78
                <Col md={6} sm={12} xs={24}>
I
Ilan 已提交
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>
N
niko 已提交
89
                <Col md={6} sm={12} xs={24}>
90
                  <NumberInfo
I
Ilan 已提交
91 92 93 94 95 96
                    subTitle={
                      <FormattedMessage
                        id="app.monitor.total-transactions-per-second"
                        defaultMessage="Total transactions per second"
                      />
                    }
N
niko 已提交
97
                    suffix=""
98 99 100 101 102
                    total={numeral(234).format('0,0')}
                  />
                </Col>
              </Row>
              <div className={styles.mapChart}>
I
Ilan 已提交
103 104 105 106 107 108 109 110
                <Tooltip
                  title={
                    <FormattedMessage
                      id="app.monitor.waiting-for-implementation"
                      defaultMessage="Waiting for implementation"
                    />
                  }
                >
N
niko 已提交
111
                  <img
陈帅 已提交
112
                    src="https://gw.alipayobjects.com/zos/antfincdn/h%24wFbzuuzz/HBWnDEUXCnGnGrRfrpKa.png"
N
niko 已提交
113 114
                    alt="map"
                  />
115
                </Tooltip>
116 117 118
              </div>
            </Card>
          </Col>
N
niko 已提交
119
          <Col xl={6} lg={24} md={24} sm={24} xs={24}>
I
Ilan 已提交
120 121 122
            <Card
              title={
                <FormattedMessage
陈帅 已提交
123
                  id="app.monitor.activity-forecast"
I
Ilan 已提交
124 125 126 127 128 129
                  defaultMessage="Activity forecast"
                />
              }
              style={{ marginBottom: 24 }}
              bordered={false}
            >
N
nikogu 已提交
130
              <ActiveChart />
131
            </Card>
132
            <Card
I
Ilan 已提交
133
              title={<FormattedMessage id="app.monitor.efficiency" defaultMessage="Efficiency" />}
134 135 136 137
              style={{ marginBottom: 24 }}
              bodyStyle={{ textAlign: 'center' }}
              bordered={false}
            >
I
Ilan 已提交
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}>
A
afc163 已提交
147
          <Col xl={12} lg={24} sm={24} xs={24} style={{ marginBottom: 24 }}>
I
Ilan 已提交
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}
            >
A
afc163 已提交
158
              <Row style={{ padding: '16px 0' }}>
159 160
                <Col span={8}>
                  <Pie
N
nikogu 已提交
161
                    animate={false}
162
                    percent={28}
I
Ilan 已提交
163 164 165
                    subTitle={
                      <FormattedMessage id="app.monitor.fast-food" defaultMessage="Fast food" />
                    }
166
                    total="28%"
偏右 已提交
167
                    height={128}
A
afc163 已提交
168
                    lineWidth={2}
169 170 171 172
                  />
                </Col>
                <Col span={8}>
                  <Pie
N
nikogu 已提交
173
                    animate={false}
N
niko 已提交
174
                    color="#5DDECF"
175
                    percent={22}
I
Ilan 已提交
176 177 178 179 180 181
                    subTitle={
                      <FormattedMessage
                        id="app.monitor.western-food"
                        defaultMessage="Western food"
                      />
                    }
182
                    total="22%"
偏右 已提交
183
                    height={128}
A
afc163 已提交
184
                    lineWidth={2}
185 186 187 188
                  />
                </Col>
                <Col span={8}>
                  <Pie
N
nikogu 已提交
189
                    animate={false}
N
niko 已提交
190
                    color="#2FC25B"
191
                    percent={32}
I
Ilan 已提交
192 193 194
                    subTitle={
                      <FormattedMessage id="app.monitor.hot-pot" defaultMessage="Hot pot" />
                    }
195
                    total="32%"
偏右 已提交
196
                    height={128}
A
afc163 已提交
197
                    lineWidth={2}
198 199 200 201 202
                  />
                </Col>
              </Row>
            </Card>
          </Col>
A
afc163 已提交
203
          <Col xl={6} lg={12} sm={24} xs={24} style={{ marginBottom: 24 }}>
N
niko 已提交
204
            <Card
I
Ilan 已提交
205 206 207 208 209 210
              title={
                <FormattedMessage
                  id="app.monitor.popular-searches"
                  defaultMessage="Popular Searches"
                />
              }
N
niko 已提交
211 212 213 214 215
              loading={loading}
              bordered={false}
              bodyStyle={{ overflow: 'hidden' }}
            >
              <TagCloud data={tags} height={161} />
216 217
            </Card>
          </Col>
A
afc163 已提交
218
          <Col xl={6} lg={12} sm={24} xs={24} style={{ marginBottom: 24 }}>
N
niko 已提交
219
            <Card
I
Ilan 已提交
220 221 222 223 224 225
              title={
                <FormattedMessage
                  id="app.monitor.resource-surplus"
                  defaultMessage="Resource Surplus"
                />
              }
N
niko 已提交
226 227 228
              bodyStyle={{ textAlign: 'center', fontSize: 0 }}
              bordered={false}
            >
I
Ilan 已提交
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>
J
jim 已提交
239
      </GridContent>
240 241 242
    );
  }
}
陈帅 已提交
243

陈帅 已提交
244
export default Monitor;