Monitor.js 7.8 KB
Newer Older
J
jim 已提交
1
import React, { PureComponent } from 'react';
2
import { connect } from 'dva';
I
Ilan 已提交
3
import { formatMessage, FormattedMessage } from 'umi/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';
J
jim 已提交
11

12
import Authorized from '@/utils/Authorized';
13 14
import styles from './Monitor.less';

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

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

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

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

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

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

export default Monitor;