-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathDashboard.tsx
246 lines (241 loc) · 8.59 KB
/
Dashboard.tsx
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
import {
Box,
Container,
Grid,
IconButton,
Stack,
Tab,
Tabs,
Typography
} from '@mui/material'
import CountWidget from './widgets/CountWidgetWidget'
import {
Layers,
NotificationAdd,
NotificationsOff,
Person
} from '@mui/icons-material'
import { pink } from '@mui/material/colors'
import MandU from './widgets/MandUWidget'
import BetaFscore from './widgets/BetaFscoreWidget'
import ConfusionMatrix from './widgets/ConfusionMatrixWidget'
import { useState } from 'react'
import { ImportProcessWidget } from './widgets/ImportProcessWidget'
import { useDashboardData } from 'hooks/useDashboardData'
import { useNavigate } from 'react-router-dom'
interface TabPanelProps {
children?: React.ReactNode
index: number
value: number
}
const CustomTabPanel = (props: TabPanelProps) => {
const { children, value, index, ...other } = props
return (
<Box
component={'div'}
role="tabpanel"
hidden={value !== index}
id={`dashboard-tabpanel-${index}`}
aria-labelledby={`dashboard-tab-${index}`}
{...other}
>
{value === index && children}
</Box>
)
}
const tabProps = (index: number) => {
return {
id: `dashboard-tab-${index}`,
'aria-controls': `dashboard-tabpanel-${index}`
}
}
const Dashboard = () => {
const dashboardData = useDashboardData()
const [currentTabIndex, setCurrentTabIndex] = useState(0)
const navigate = useNavigate()
const handleChangeTab = (event: React.SyntheticEvent, newValue: number) => {
setCurrentTabIndex(newValue)
}
return (
<Container maxWidth={false}>
<Stack
padding={{
lg: '0rem 1rem 1rem 1rem',
xs: '1rem 0rem 0rem 0rem',
backgroundColor: '#fff',
borderRadius: '1rem'
}}
minHeight={'80vh'}
>
<Tabs
value={currentTabIndex}
onChange={handleChangeTab}
sx={{
paddingY: { lg: '2rem', xs: ' 0.5rem' }
}}
aria-label="dashboard tabs"
variant="scrollable"
scrollButtons
allowScrollButtonsMobile
>
<Tab
label={<Typography variant="h5">Confusion Matrix</Typography>}
{...tabProps(0)}
/>
<Tab
label={<Typography variant="h5">M & U Values</Typography>}
{...tabProps(1)}
/>
<Tab
label={<Typography variant="h5"> Import Process Status</Typography>}
{...tabProps(2)}
/>
</Tabs>
<Box padding={'1rem 1rem 1rem 1rem'}>
<CustomTabPanel value={currentTabIndex} index={0}>
<Grid container spacing={{ xs: 2, md: 5 }}>
<Grid item xs={12} lg={6}>
<Grid container spacing={2}>
<Grid item xs={12}>
<Box component="fieldset">
<legend>Records</legend>
<Grid container spacing={2}>
<Grid item xs={12} lg={6}>
<CountWidget
label="Golden Record"
value={
/* TODO: Improve */ dashboardData.isReady
? dashboardData?.data?.dashboardData
?.dashboardData?.linker_stats
?.goldenRecordCount
: 0
}
icon={<Person sx={{ fontSize: '3.5rem' }} />}
iconBackgroundColor={'#FFD700'}
/>
</Grid>
<Grid item xs={12} lg={6}>
<CountWidget
label="Interactions "
value={
/* TODO: Improve */ dashboardData.isReady
? dashboardData?.data?.dashboardData
?.dashboardData?.linker_stats
?.interactionsCount
: 0
}
icon={<Layers sx={{ fontSize: '3.5rem' }} />}
iconBackgroundColor={'primary.main'}
/>
</Grid>
</Grid>
</Box>
</Grid>
<Grid item xs={12}>
<Box component="fieldset">
<legend> Notifications </legend>
<Grid container spacing={2}>
<Grid item xs={12} lg={6}>
<CountWidget
label="New/Open"
value={
/* TODO: Improve */ dashboardData.isReady
? dashboardData.data?.sqlDashboardData
?.dashboardData?.notificationStats
?.openNotifications
: 0
}
icon={
<IconButton
onClick={() => {
navigate('/notifications')
}}
sx={{
backgroundColor: '#76ff03',
'&:hover': {
backgroundColor: '#64dd17'
}
}}
>
<NotificationAdd sx={{ fontSize: '3.5rem' }} />
</IconButton>
}
iconBackgroundColor={'#76ff03'}
/>
</Grid>
<Grid item xs={12} lg={6}>
<CountWidget
label="Closed"
value={
/* TODO: Improve */ dashboardData.isReady
? dashboardData.data?.sqlDashboardData
?.dashboardData?.notificationStats
?.closedNotifications
: 0
}
icon={
<NotificationsOff sx={{ fontSize: '3.5rem' }} />
}
iconBackgroundColor={pink[600]}
/>
</Grid>
</Grid>
</Box>
</Grid>
<Grid item xs={12}>
<BetaFscore
data={
/* TODO: Improve */ dashboardData.isReady
? dashboardData?.data?.dashboardData?.dashboardData
?.tptn?.tptnfScore
: null
}
/>
</Grid>
</Grid>
</Grid>
<Grid item xs={12} lg={6}>
<Box component="fieldset" minHeight={'550px'}>
<legend>Confusion Matrix</legend>
<ConfusionMatrix
data={
/* TODO: Improve */ dashboardData.isReady
? dashboardData?.data?.dashboardData?.dashboardData
?.tptn
: null
}
/>
</Box>
</Grid>
</Grid>
</CustomTabPanel>
<CustomTabPanel value={currentTabIndex} index={1}>
<Grid container sx={{ minHeight: { lg: '450px' } }}>
<Grid item xs={6}>
<MandU
data={
/* TODO: Improve */ dashboardData.isReady
? dashboardData?.data?.dashboardData?.dashboardData
?.m_and_u
: null
}
/>
</Grid>
</Grid>
</CustomTabPanel>
<CustomTabPanel value={currentTabIndex} index={2}>
<ImportProcessWidget
data={
/* TODO: Improve */ dashboardData.isReady
? dashboardData?.data?.dashboardData?.dashboardData
?.linker_stats?.linkerProgressStats
: null
}
/>
</CustomTabPanel>
</Box>
</Stack>
</Container>
)
}
export default Dashboard