@@ -2,10 +2,8 @@ import React, { useState } from 'react'
2
2
import {
3
3
faBook ,
4
4
faCog ,
5
- faEllipsisH ,
6
5
faLaptopCode ,
7
6
faMailBulk ,
8
- faSearch ,
9
7
faUser ,
10
8
faUserFriends ,
11
9
faUserPlus ,
@@ -16,19 +14,15 @@ import {
16
14
CCol ,
17
15
CCollapse ,
18
16
CDropdown ,
19
- CDropdownHeader ,
20
- CDropdownItem ,
21
17
CDropdownMenu ,
22
18
CDropdownToggle ,
23
19
CLink ,
24
- CNav ,
25
20
CRow ,
26
21
} from '@coreui/react'
27
22
import { useGenericGetRequestQuery } from 'src/store/api/app'
28
23
import { CippContentCard } from 'src/components/layout'
29
24
import Skeleton from 'react-loading-skeleton'
30
25
import { UniversalSearch } from 'src/components/utilities/UniversalSearch'
31
- import { ActionContentCard } from 'src/components/contentcards'
32
26
import { useSelector } from 'react-redux'
33
27
import allStandardsList from 'src/data/standards'
34
28
import Portals from 'src/data/portals'
@@ -37,11 +31,14 @@ import { CChart } from '@coreui/react-chartjs'
37
31
import { getStyle } from '@coreui/utils'
38
32
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
39
33
import { Link } from 'react-router-dom'
40
- import CippPrettyCard from 'src/components/contentcards/CippPrettyCard'
34
+ import { useNavigate } from 'react-router-dom'
35
+ import { cellGenericFormatter } from 'src/components/tables/CellGenericFormat'
36
+ import { ModalService } from 'src/components/utilities'
41
37
42
38
const TenantDashboard = ( ) => {
43
39
const [ visible , setVisible ] = useState ( false )
44
40
const [ domainVisible , setDomainVisible ] = useState ( false )
41
+ const navigate = useNavigate ( )
45
42
46
43
const currentTenant = useSelector ( ( state ) => state . app . currentTenant )
47
44
const theme = useSelector ( ( state ) => state . app . currentTheme )
@@ -174,6 +171,55 @@ const TenantDashboard = () => {
174
171
)
175
172
} )
176
173
}
174
+
175
+ const handleTable = ( data , title ) => {
176
+ const QueryColumns = [ ]
177
+ const columns = Object . keys ( data [ 0 ] ) . map ( ( key ) => {
178
+ QueryColumns . push ( {
179
+ name : key ,
180
+ selector : ( row ) => row [ key ] , // Accessing the property using the key
181
+ sortable : true ,
182
+ exportSelector : key ,
183
+ cell : cellGenericFormatter ( ) ,
184
+ } )
185
+ } )
186
+ ModalService . open ( {
187
+ data : data ,
188
+ componentType : 'table' ,
189
+ componentProps : {
190
+ columns : QueryColumns ,
191
+ keyField : 'id' ,
192
+ } ,
193
+ title : title ,
194
+ size : 'lg' ,
195
+ } )
196
+ }
197
+
198
+ const userChartLegendClickHandler = function ( e , legendItem , legend ) {
199
+ switch ( legendItem . text ) {
200
+ case 'Total Users' :
201
+ navigate ( '/identity/administration/users?customerId=' + currentTenant . customerId )
202
+ break
203
+ case 'Licensed Users' :
204
+ navigate (
205
+ '/identity/administration/users?customerId=' +
206
+ currentTenant . customerId +
207
+ '&tableFilter=Graph%3A+assignedLicenses%2F%24count+ne+0' ,
208
+ )
209
+ break
210
+ case 'Guests' :
211
+ navigate (
212
+ '/identity/administration/users?customerId=' +
213
+ currentTenant . customerId +
214
+ '&tableFilter=Graph%3A+usertype+eq+%27guest%27' ,
215
+ )
216
+ break
217
+ case 'Global Admins' :
218
+ handleTable ( GlobalAdminList . data ?. Results , 'Global Admins' )
219
+ break
220
+ }
221
+ }
222
+
177
223
return (
178
224
< >
179
225
< CRow className = "mb-3" >
@@ -337,6 +383,13 @@ const TenantDashboard = () => {
337
383
labels : {
338
384
color : getStyle ( '--cui-body-color' ) ,
339
385
} ,
386
+ onClick : userChartLegendClickHandler ,
387
+ onHover : ( event ) => {
388
+ event . native . target . style . cursor = 'pointer'
389
+ } ,
390
+ onLeave : ( event ) => {
391
+ event . native . target . style . cursor = 'default'
392
+ } ,
340
393
} ,
341
394
} ,
342
395
} }
0 commit comments