Analytics.js
9.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import cx from 'classnames';
import { Col, Row, Progress } from 'reactstrap';
import Widget from '../../components/Widget';
import RevenueChart from './components/Charts/RevenueChart';
import LineChart from './components/Charts/LineChart';
import MainChart from './components/Charts/MainChart';
import TaskContainer from './components/TaskContainer/TaskContainer';
import BigStat from './components/BigStat/BigStat';
import TableContainer from './components/TableContainer/TableContainer';
import Calendar from '../dashboard/components/calendar/Calendar';
import mock from './mock';
import s from './Analitycs.module.scss';
import { receiveDataRequest } from '../../actions/analytics';
class Analytics extends Component {
static propTypes = {
visits: PropTypes.any,
performance: PropTypes.any,
server: PropTypes.any,
revenue: PropTypes.any,
mainChart: PropTypes.any,
isReceiving: PropTypes.bool,
dispatch: PropTypes.func.isRequired,
};
static defaultProps = {
visits: {},
performance: {},
server: {},
revenue: [],
mainChart: [],
isReceiving: false
};
componentDidMount() {
this.props.dispatch(receiveDataRequest());
}
render() {
const { visits, isReceiving, performance, server, revenue, mainChart } = this.props;
return (
<div>
<h1 className="page-title mb-xlg mt-lg">Analytics <small>Company performance</small></h1>
<div className={s.sidesWrapper}>
<div className={s.analyticsSide}>
<Row>
<Col xs={12} xl={3} md={6}>
<div className="pb-xlg h-100">
<Widget
className="mb-0 h-100"
close
bodyClass="mt-lg"
fetchingData={isReceiving}
title={<h5 style={{ color: "#757575" }}>Visits Today</h5>}
>
<div className="d-flex justify-content-between align-items-center mb">
<h2 style={{fontSize: '2.1rem'}}>{visits.count}</h2>
<i className="la la-arrow-right text-success rotate-315"/>
</div>
<div className="d-flex flex-wrap justify-content-between">
<div className={cx('mt', s.visitElement)}>
<h6>+{visits.logins}</h6>
<p className="text-muted mb-0 mr">
<small>Logins</small>
</p>
</div>
<div className={cx('mt', s.visitElement)}>
<h6>{visits.sign_out_pct}%</h6>
<p className="text-muted mb-0">
<small>Sign Out</small>
</p>
</div>
<div className={cx('mt', s.visitElement)}>
<h6>{visits.rate_pct}%</h6>
<p className="text-muted mb-0 mr">
<small>Rate</small>
</p>
</div>
</div>
</Widget>
</div>
</Col>
<Col xs={12} xl={3} md={6}>
<div className="pb-xlg h-100">
<Widget
bodyClass="mt"
close
className="mb-0 h-100"
fetchingData={isReceiving}
title={<h5 style={{ color: "#757575" }}>Revenue Breakdown</h5>}
>
<RevenueChart data={revenue} />
</Widget>
</div>
</Col>
<Col xs={12} xl={3} md={6}>
<div className="pb-xlg h-100">
<Widget
bodyClass="mt"
close
className="mb-0 h-100"
fetchingData={isReceiving}
title={<h5 style={{ color: "#757575" }}>App Performance</h5>}
>
<p className="text-muted d-flex flex-wrap">
<small className="mr-lg d-flex align-items-center">
<span className="circle bg-success text-success mr-xs" style={{ fontSize: '4px' }}>.</span>
This Period
</small>
<small className="mr-lg d-flex align-items-center">
<span className="circle bg-warning text-warning mr-xs" style={{ fontSize: '4px' }}>.</span>
Last Period
</small>
</p>
<h6 className="fs-sm text-muted">SDK</h6>
<Progress color="success" className="progress-xs" style={{height: '3px', marginBottom: '5px'}}
value={performance.sdk?.this_period_pct}/>
<Progress color="warning" className="progress-xs" style={{height: '3px'}}
value={performance.sdk?.last_period_pct}/>
<h6 className="mt fs-sm text-muted">Integration</h6>
<Progress color="success" className="progress-xs" style={{height: '3px', marginBottom: '5px'}}
value={performance.integration?.this_period_pct}/>
<Progress color="warning" className="progress-xs" style={{height: '3px'}}
value={performance.integration?.last_period_pct}/>
</Widget>
</div>
</Col>
<Col xs={12} xl={3} md={6}>
<div className="pb-xlg h-100">
<Widget
bodyClass="mt-lg"
close
className="mb-0 h-100"
fetchingData={isReceiving}
title={<h5 style={{ color: "#757575" }}>Server Overview</h5>}
>
<div className="d-flex justify-content-between flex-wrap mb-sm">
<p className="width-150"><small>{server[1]?.pct}% <span style={{ color: '#a3aeb7' }}>/</span> {server[1]?.temp}°С <span style={{ color: '#a3aeb7' }}>/</span> {server[1]?.frequency} Ghz</small></p>
<div className={s.sparklineWrapper}>
<LineChart color="#ffc247" />
</div>
</div>
<div className="d-flex justify-content-between flex-wrap mb-sm">
<p className="width-150"><small>{server[2]?.pct}% <span style={{ color: '#a3aeb7' }}>/</span> {server[2]?.temp}°С <span style={{ color: '#a3aeb7' }}>/</span> {server[2]?.frequency} Ghz</small></p>
<div className={s.sparklineWrapper}>
<LineChart color="#9964e3" />
</div>
</div>
</Widget>
</div>
</Col>
<Col xs={12}>
<MainChart data={mainChart} isReceiving={isReceiving} />
</Col>
<Col xs={12} lg={6} xl={4}>
<BigStat {...mock.bigStat[0]} />
</Col>
<Col xs={12} lg={6} xl={4}>
<BigStat {...mock.bigStat[1]} />
</Col>
<Col xs={12} lg={6} xl={4}>
<BigStat {...mock.bigStat[2]} />
</Col>
<Col xs={12} className="mb-lg">
<Widget
className="pb-0"
bodyClass="p-0 mt"
title={<h4> Support <strong>Requests</strong></h4>}
close settings
>
<TableContainer data={mock.table} />
</Widget>
</Col>
</Row>
</div>
<div className={s.analyticsSide}>
<Row>
<Col xs={12} md={6} xl={12} className={s.lastSideElement}>
<Widget className="mb-xlg" bodyClass="pb-0 mt-0">
<Calendar white />
</Widget>
</Col>
<Col xs={12} md={6} xl={12} className={s.lastSideElement}>
<TaskContainer data={mock.tasks} />
</Col>
<Col xs={12} md={6} xl={12} className={s.lastSideElement}>
<Widget
className="widget"
bodyClass={cx(s.notifications, 'w-100 mt-lg')}
title={
<h4>Notifications <span className="badge badge-pill badge-success fw-normal pull-right mt-xs">{mock.notifications.length}</span></h4>
}
>
{mock.notifications.map(({ id, icon, color, content }) => (
<div className="d-flex align-items-start" key={id}>
<i className={`la la-${icon} mr text-${color}`} />
<p
className={cx({ 'mb-0': id === mock.notifications.length - 1 })}
dangerouslySetInnerHTML={{ __html: content }}
/>
</div>
))}
</Widget>
</Col>
</Row>
</div>
</div>
</div>
);
}
}
function mapStateToProps(state) {
return {
visits: state.analytics.visits,
isReceiving: state.analytics.isReceiving,
performance: state.analytics.performance,
revenue: state.analytics.revenue,
server: state.analytics.server,
mainChart: state.analytics.mainChart,
}
}
export default connect(mapStateToProps)(Analytics);