1
1
import React , { useState , useEffect } from 'react'
2
- import { addMonths , subMonths } from 'date-fns'
2
+ import { subMonths } from 'date-fns'
3
3
import moment from 'moment'
4
4
import CustomPieGraph from './CustomPieGraph'
5
+ import CustomLineChart from './CustomLineChart'
6
+ import ActiveUsersGraph from './ActiveUsersGraph'
5
7
import DatePicker from 'react-datepicker'
6
8
import 'react-datepicker/dist/react-datepicker.css'
7
9
import GluuLoader from '../Apps/Gluu/GluuLoader'
@@ -25,24 +27,27 @@ import {
25
27
STAT_READ ,
26
28
STAT_JANS_READ ,
27
29
} from '../../utils/PermChecker'
28
- import {
29
- LineChart ,
30
- XAxis ,
31
- YAxis ,
32
- Line ,
33
- CartesianGrid ,
34
- Tooltip ,
35
- Legend ,
36
- ResponsiveContainer ,
37
- } from 'recharts'
38
30
import { useTranslation } from 'react-i18next'
39
31
import { connect } from 'react-redux'
40
32
41
33
function DashboardPage ( { statData, permissions, loading, dispatch } ) {
42
- statData . push ( { month : 202201 , mau : 5 , cc_at : 68 , ac_at : 785 , ac_id : 567 } )
34
+ statData . push ( {
35
+ month : 202111 ,
36
+ mau : 5 ,
37
+ client_credentials_access_token_count : 68 ,
38
+ authz_code_access_token_count : 785 ,
39
+ authz_code_idtoken_count : 567 ,
40
+ } )
41
+ statData . push ( {
42
+ month : 202112 ,
43
+ mau : 5 ,
44
+ client_credentials_access_token_count : 28 ,
45
+ authz_code_access_token_count : 75 ,
46
+ authz_code_idtoken_count : 257 ,
47
+ } )
43
48
const { t } = useTranslation ( )
44
- const [ startDate , setStartDate ] = useState ( subMonths ( new Date ( ) , 2 ) )
45
- const [ endDate , setEndDate ] = useState ( addMonths ( new Date ( ) , 2 ) )
49
+ const [ startDate , setStartDate ] = useState ( subMonths ( new Date ( ) , 3 ) )
50
+ const [ endDate , setEndDate ] = useState ( new Date ( ) )
46
51
const userAction = { }
47
52
const options = { }
48
53
useEffect ( ( ) => {
@@ -66,9 +71,9 @@ function DashboardPage({ statData, permissions, loading, dispatch }) {
66
71
let newEntry = new Object ( )
67
72
newEntry [ 'month' ] = parseInt ( getYearMonth ( new Date ( ele ) ) , 10 )
68
73
newEntry [ 'mau' ] = 0
69
- newEntry [ 'cc_at ' ] = 0
70
- newEntry [ 'ac_at ' ] = 0
71
- newEntry [ 'ac_id ' ] = 0
74
+ newEntry [ 'client_credentials_access_token_count ' ] = 0
75
+ newEntry [ 'authz_code_access_token_count ' ] = 0
76
+ newEntry [ 'authz_code_idtoken_count ' ] = 0
72
77
stat . push ( newEntry )
73
78
}
74
79
}
@@ -169,57 +174,14 @@ function DashboardPage({ statData, permissions, loading, dispatch }) {
169
174
< FormGroup row />
170
175
< FormGroup row />
171
176
< FormGroup row >
172
- < ResponsiveContainer className = "mau" width = "80%" height = { 350 } >
173
- < LineChart height = { 400 } data = { doDataAugmentation ( statData ) } >
174
- < XAxis dataKey = "month" />
175
- < YAxis />
176
- < CartesianGrid stroke = "#eee" strokeDasharray = "5 5" />
177
- < Line
178
- name = { t ( 'fields.monthly_active_users' ) }
179
- type = "monotone"
180
- dataKey = "mau"
181
- stroke = "#8884d8"
182
- />
183
- < Tooltip />
184
- < Legend />
185
- </ LineChart >
186
- </ ResponsiveContainer >
177
+ < ActiveUsersGraph data = { doDataAugmentation ( statData ) } />
187
178
</ FormGroup >
188
179
< FormGroup row >
189
180
< Col sm = { 6 } >
190
181
< CustomPieGraph data = { statData } />
191
182
</ Col >
192
183
< Col sm = { 6 } >
193
- < ResponsiveContainer className = "bar" width = "100%" height = { 400 } >
194
- < LineChart
195
- width = { 400 }
196
- height = { 400 }
197
- data = { doDataAugmentation ( statData ) }
198
- >
199
- < XAxis dataKey = "month" />
200
- < YAxis />
201
- < CartesianGrid stroke = "#eee" strokeDasharray = "5 5" />
202
- < Line
203
- name = "Client credentials access token"
204
- type = "monotone"
205
- dataKey = "cc_at"
206
- stroke = "#8884d8"
207
- />
208
- < Line
209
- name = "Authorization code access token"
210
- type = "monotone"
211
- dataKey = "ac_at"
212
- stroke = "#82ca9d"
213
- />
214
- < Line
215
- name = "Authorization code id token"
216
- type = "monotone"
217
- dataKey = "ac_id"
218
- stroke = "#00C9FF"
219
- />
220
- < Legend />
221
- </ LineChart >
222
- </ ResponsiveContainer >
184
+ < CustomLineChart data = { doDataAugmentation ( statData ) } />
223
185
</ Col >
224
186
</ FormGroup >
225
187
< FormGroup row >
0 commit comments