-
Notifications
You must be signed in to change notification settings - Fork 12
/
ConceptTable.jsx
118 lines (112 loc) · 3.79 KB
/
ConceptTable.jsx
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
import React from 'react';
import { Table, TableHead, TableBody, TableRow, TableCell, IconButton, Tooltip, Badge, CircularProgress, Chip } from '@mui/material';
import {
QueryStats as HierarchyIcon,
} from '@mui/icons-material'
import { map, get } from 'lodash';
import ConceptDisplayName from './ConceptDisplayName';
import ConceptCascadeVisualizeDialog from './ConceptCascadeVisualizeDialog';
const ConceptStatus = ({ status, added, onVisualize }) => {
let color = 'success'
const isSuccess = status === 200
if(isSuccess && !added)
color = 'warning'
if(!isSuccess)
color = 'error'
return (
<Badge badgeContent={added} color={color} showZero style={{margin: '5px 0'}}>
{
(isSuccess && added) ?
<Tooltip title='Visualize (Beta)' placement='right'>
<IconButton size='small' color='primary' onClick={onVisualize}>
<HierarchyIcon fontSize='inherit'/>
</IconButton>
</Tooltip> :
<Chip size='small' label={status === 200 ? 'Success' : 'Failed'} variant='outlined' color={color}/>
}
</Badge>
)
}
const ConceptTable = ({ concepts, showProgress, showStatus, visualFilters }) => {
const [visualize, setVisualize] = React.useState(false);
const [isClonedConcept, setIsClonedConcept] = React.useState(false)
let headers = ["Owner", "ID", "Display Name", "Class", "DataType", ""]
if(showStatus)
headers = ["Status", ...headers]
const getClonedConcept = concept => get(concept, 'bundle.entry.0')
const onVisualize = (concept, isClonedConcept) => {
setVisualize(concept)
setIsClonedConcept(Boolean(isClonedConcept))
}
return (
<React.Fragment>
<Table stickyHeader size='small'>
<TableHead>
<TableRow>
{
headers.map(header => (
<TableCell style={{backgroundColor: 'rgba(0, 0, 0, 0.09)'}} key={header}>
<b>{header}</b>
</TableCell>
))
}
</TableRow>
</TableHead>
<TableBody>
{
map(concepts, concept => (
<TableRow key={concept.id}>
{
showStatus &&
<TableCell>
{
showProgress &&
<CircularProgress />
}
{
!showProgress && concept.status &&
<ConceptStatus status={concept.status} added={concept.total} onVisualize={() => onVisualize(getClonedConcept(concept), true)}/>
}
</TableCell>
}
<TableCell>
{concept.owner}/{concept.source}
</TableCell>
<TableCell>
{concept.id}
</TableCell>
<TableCell>
<ConceptDisplayName concept={concept} />
</TableCell>
<TableCell>
{concept.concept_class}
</TableCell>
<TableCell>
{concept.datatype}
</TableCell>
<TableCell align='right'>
<Tooltip title='Visualize (Beta)' placement='right'>
<IconButton size='small' color='secondary' onClick={() => setVisualize(concept)}>
<HierarchyIcon fontSize='inherit'/>
</IconButton>
</Tooltip>
</TableCell>
</TableRow>
))
}
</TableBody>
</Table>
{
visualize &&
<ConceptCascadeVisualizeDialog
open
onClose={() => setVisualize(false)}
concept={visualize}
filters={isClonedConcept ? false : visualFilters}
noBreadcrumbs={isClonedConcept}
/>
}
</React.Fragment>
)
}
export default ConceptTable