datajunction-ui 0.0.1-a109 → 0.0.1-a110
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -2
- package/src/app/icons/AlertIcon.jsx +1 -0
- package/src/app/icons/InvalidIcon.jsx +5 -3
- package/src/app/icons/NodeIcon.jsx +49 -0
- package/src/app/icons/ValidIcon.jsx +5 -3
- package/src/app/index.tsx +6 -0
- package/src/app/pages/OverviewPage/ByStatusPanel.jsx +69 -0
- package/src/app/pages/OverviewPage/DimensionNodeUsagePanel.jsx +48 -0
- package/src/app/pages/OverviewPage/GovernanceWarningsPanel.jsx +107 -0
- package/src/app/pages/OverviewPage/Loadable.jsx +16 -0
- package/src/app/pages/OverviewPage/NodesByTypePanel.jsx +63 -0
- package/src/app/pages/OverviewPage/OverviewPanel.jsx +94 -0
- package/src/app/pages/OverviewPage/TrendsPanel.jsx +66 -0
- package/src/app/pages/OverviewPage/__tests__/ByStatusPanel.test.jsx +36 -0
- package/src/app/pages/OverviewPage/__tests__/DimensionNodeUsagePanel.test.jsx +76 -0
- package/src/app/pages/OverviewPage/__tests__/GovernanceWarningsPanel.test.jsx +77 -0
- package/src/app/pages/OverviewPage/__tests__/NodesByTypePanel.test.jsx +86 -0
- package/src/app/pages/OverviewPage/__tests__/OverviewPanel.test.jsx +78 -0
- package/src/app/pages/OverviewPage/__tests__/TrendsPanel.test.jsx +120 -0
- package/src/app/pages/OverviewPage/__tests__/index.test.jsx +54 -0
- package/src/app/pages/OverviewPage/index.jsx +22 -0
- package/src/app/pages/RegisterTablePage/__tests__/__snapshots__/RegisterTablePage.test.jsx.snap +3 -2
- package/src/app/services/DJService.js +122 -0
- package/src/app/services/__tests__/DJService.test.jsx +364 -0
- package/src/styles/overview.css +72 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "datajunction-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1a110",
|
|
4
4
|
"description": "DataJunction Metrics Platform UI",
|
|
5
5
|
"module": "src/index.tsx",
|
|
6
6
|
"repository": {
|
|
@@ -83,6 +83,7 @@
|
|
|
83
83
|
"react-syntax-highlighter": "^15.5.0",
|
|
84
84
|
"react-test-renderer": "18.2.0",
|
|
85
85
|
"reactflow": "^11.7.0",
|
|
86
|
+
"recharts": "3.0.2",
|
|
86
87
|
"redux-injectors": "2.1.0",
|
|
87
88
|
"redux-saga": "1.2.1",
|
|
88
89
|
"rimraf": "3.0.2",
|
|
@@ -97,7 +98,7 @@
|
|
|
97
98
|
"stylelint-config-recommended": "9.0.0",
|
|
98
99
|
"ts-loader": "9.4.2",
|
|
99
100
|
"ts-node": "10.9.1",
|
|
100
|
-
"typescript": "
|
|
101
|
+
"typescript": "5.8.3",
|
|
101
102
|
"unidiff": "1.0.4",
|
|
102
103
|
"web-vitals": "2.1.4",
|
|
103
104
|
"webpack": "5.81.0",
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
const InvalidIcon =
|
|
1
|
+
const InvalidIcon = ({ width = '25px', height = '25px', style = {} }) => (
|
|
2
2
|
<svg
|
|
3
3
|
xmlns="http://www.w3.org/2000/svg"
|
|
4
|
-
width=
|
|
5
|
-
height=
|
|
4
|
+
width={width}
|
|
5
|
+
height={height}
|
|
6
|
+
style={style}
|
|
6
7
|
fill="currentColor"
|
|
7
8
|
className="bi bi-x-circle-fill"
|
|
8
9
|
viewBox="0 0 16 16"
|
|
10
|
+
data-testid="invalid-icon"
|
|
9
11
|
>
|
|
10
12
|
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM5.354 4.646a.5.5 0 1 0-.708.708L7.293 8l-2.647 2.646a.5.5 0 0 0 .708.708L8 8.707l2.646 2.647a.5.5 0 0 0 .708-.708L8.707 8l2.647-2.646a.5.5 0 0 0-.708-.708L8 7.293 5.354 4.646z" />
|
|
11
13
|
</svg>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const NodeIcon = ({
|
|
2
|
+
width = '45px',
|
|
3
|
+
height = '45px',
|
|
4
|
+
color = '#cccccc',
|
|
5
|
+
style = {},
|
|
6
|
+
}) => (
|
|
7
|
+
<svg
|
|
8
|
+
width={width}
|
|
9
|
+
height={height}
|
|
10
|
+
viewBox="0 0 30 30"
|
|
11
|
+
fill="none"
|
|
12
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
13
|
+
style={style}
|
|
14
|
+
data-testid="node-icon"
|
|
15
|
+
>
|
|
16
|
+
<path
|
|
17
|
+
opacity="0.317243"
|
|
18
|
+
fillRule="evenodd"
|
|
19
|
+
clipRule="evenodd"
|
|
20
|
+
d="M15 30C23.2843 30 30 23.2843 30 15C30 6.71573 23.2843 0 15 0C6.71573 0 0 6.71573 0 15C0 23.2843 6.71573 30 15 30Z"
|
|
21
|
+
fill={color}
|
|
22
|
+
></path>
|
|
23
|
+
<path
|
|
24
|
+
fillRule="evenodd"
|
|
25
|
+
clipRule="evenodd"
|
|
26
|
+
d="M16.3333 7.6665C16.5144 7.6665 16.6787 7.73873 16.7988 7.85594C16.9229 7.97702 17 8.1461 17 8.33317V9.94265L18.7239 11.6665H20.3333C20.7015 11.6665 21 11.965 21 12.3332V20.3332C21 21.4377 20.1046 22.3332 19 22.3332H11C9.89543 22.3332 9 21.4377 9 20.3332V9.6665C9 8.56193 9.89543 7.6665 11 7.6665H16.3333ZM11 8.99984H15.6667L19.6667 12.9998V20.3332C19.6667 20.7014 19.3682 20.9998 19 20.9998H11C10.6318 20.9998 10.3333 20.7014 10.3333 20.3332V9.6665C10.3333 9.29831 10.6318 8.99984 11 8.99984ZM12.3333 14.9998H17.6667C18.0349 14.9998 18.3333 15.2983 18.3333 15.6665C18.3333 16.0347 18.0349 16.3332 17.6667 16.3332H12.3333C11.9651 16.3332 11.6667 16.0347 11.6667 15.6665C11.6667 15.2983 11.9651 14.9998 12.3333 14.9998ZM17.6667 17.6665H12.3333C11.9651 17.6665 11.6667 17.965 11.6667 18.3332C11.6667 18.7014 11.9651 18.9998 12.3333 18.9998H17.6667C18.0349 18.9998 18.3333 18.7014 18.3333 18.3332C18.3333 17.965 18.0349 17.6665 17.6667 17.6665ZM12.3333 12.3332H13.6667C14.0349 12.3332 14.3333 12.6316 14.3333 12.9998C14.3333 13.368 14.0349 13.6665 13.6667 13.6665H12.3333C11.9651 13.6665 11.6667 13.368 11.6667 12.9998C11.6667 12.6316 11.9651 12.3332 12.3333 12.3332Z"
|
|
27
|
+
fill={color}
|
|
28
|
+
></path>
|
|
29
|
+
<mask
|
|
30
|
+
id="mask0"
|
|
31
|
+
type="alpha"
|
|
32
|
+
maskUnits="userSpaceOnUse"
|
|
33
|
+
x="9"
|
|
34
|
+
y="7"
|
|
35
|
+
width="12"
|
|
36
|
+
height="16"
|
|
37
|
+
>
|
|
38
|
+
<path
|
|
39
|
+
fillRule="evenodd"
|
|
40
|
+
clipRule="evenodd"
|
|
41
|
+
d="M16.3333 7.6665C16.5144 7.6665 16.6787 7.73873 16.7988 7.85594C16.9229 7.97702 17 8.1461 17 8.33317V9.94265L18.7239 11.6665H20.3333C20.7015 11.6665 21 11.965 21 12.3332V20.3332C21 21.4377 20.1046 22.3332 19 22.3332H11C9.89543 22.3332 9 21.4377 9 20.3332V9.6665C9 8.56193 9.89543 7.6665 11 7.6665H16.3333ZM11 8.99984H15.6667L19.6667 12.9998V20.3332C19.6667 20.7014 19.3682 20.9998 19 20.9998H11C10.6318 20.9998 10.3333 20.7014 10.3333 20.3332V9.6665C10.3333 9.29831 10.6318 8.99984 11 8.99984ZM12.3333 14.9998H17.6667C18.0349 14.9998 18.3333 15.2983 18.3333 15.6665C18.3333 16.0347 18.0349 16.3332 17.6667 16.3332H12.3333C11.9651 16.3332 11.6667 16.0347 11.6667 15.6665C11.6667 15.2983 11.9651 14.9998 12.3333 14.9998ZM17.6667 17.6665H12.3333C11.9651 17.6665 11.6667 17.965 11.6667 18.3332C11.6667 18.7014 11.9651 18.9998 12.3333 18.9998H17.6667C18.0349 18.9998 18.3333 18.7014 18.3333 18.3332C18.3333 17.965 18.0349 17.6665 17.6667 17.6665ZM12.3333 12.3332H13.6667C14.0349 12.3332 14.3333 12.6316 14.3333 12.9998C14.3333 13.368 14.0349 13.6665 13.6667 13.6665H12.3333C11.9651 13.6665 11.6667 13.368 11.6667 12.9998C11.6667 12.6316 11.9651 12.3332 12.3333 12.3332Z"
|
|
42
|
+
fill="white"
|
|
43
|
+
></path>
|
|
44
|
+
</mask>
|
|
45
|
+
<g mask="url(#mask0)"></g>
|
|
46
|
+
</svg>
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
export default NodeIcon;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
const ValidIcon =
|
|
1
|
+
const ValidIcon = ({ width = '25px', height = '25px', style = {} }) => (
|
|
2
2
|
<svg
|
|
3
3
|
xmlns="http://www.w3.org/2000/svg"
|
|
4
|
-
width=
|
|
5
|
-
height=
|
|
4
|
+
width={width}
|
|
5
|
+
height={height}
|
|
6
|
+
style={style}
|
|
6
7
|
fill="currentColor"
|
|
7
8
|
className="bi bi-check-circle-fill"
|
|
8
9
|
viewBox="0 0 16 16"
|
|
10
|
+
data-testid="valid-icon"
|
|
9
11
|
>
|
|
10
12
|
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z" />
|
|
11
13
|
</svg>
|
package/src/app/index.tsx
CHANGED
|
@@ -8,6 +8,7 @@ import { Helmet } from 'react-helmet-async';
|
|
|
8
8
|
import { BrowserRouter, Routes, Route } from 'react-router-dom';
|
|
9
9
|
|
|
10
10
|
import { NamespacePage } from './pages/NamespacePage/Loadable';
|
|
11
|
+
import { OverviewPage } from './pages/OverviewPage/Loadable';
|
|
11
12
|
import { NodePage } from './pages/NodePage/Loadable';
|
|
12
13
|
import RevisionDiff from './pages/NodePage/RevisionDiff';
|
|
13
14
|
import { SQLBuilderPage } from './pages/SQLBuilderPage/Loadable';
|
|
@@ -116,6 +117,11 @@ export function App() {
|
|
|
116
117
|
<Route path="tags" key="tags">
|
|
117
118
|
<Route path=":name" element={<TagPage />} />
|
|
118
119
|
</Route>
|
|
120
|
+
<Route
|
|
121
|
+
path="overview"
|
|
122
|
+
key="overview"
|
|
123
|
+
element={<OverviewPage />}
|
|
124
|
+
/>
|
|
119
125
|
</>
|
|
120
126
|
}
|
|
121
127
|
/>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { useContext, useEffect, useState } from 'react';
|
|
2
|
+
import DJClientContext from '../../providers/djclient';
|
|
3
|
+
|
|
4
|
+
import ValidIcon from '../../icons/ValidIcon';
|
|
5
|
+
import InvalidIcon from '../../icons/InvalidIcon';
|
|
6
|
+
|
|
7
|
+
const COLOR_MAPPING = {
|
|
8
|
+
valid: '#00b368',
|
|
9
|
+
invalid: '#FF91A3', // '#b34b00',
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const ByStatusPanel = () => {
|
|
13
|
+
const djClient = useContext(DJClientContext).DataJunctionAPI;
|
|
14
|
+
const [nodesByStatus, setNodesByStatus] = useState(null);
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const fetchData = async () => {
|
|
18
|
+
setNodesByStatus(await djClient.system.node_counts_by_status());
|
|
19
|
+
};
|
|
20
|
+
fetchData().catch(console.error);
|
|
21
|
+
}, [djClient]);
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<>
|
|
25
|
+
<div className="chart-box" style={{ flex: '0 0 2%' }}>
|
|
26
|
+
<div className="horiz-box">
|
|
27
|
+
<div className="chart-title">Nodes By Status</div>
|
|
28
|
+
{nodesByStatus?.map(entry => (
|
|
29
|
+
<div
|
|
30
|
+
className="jss316 badge"
|
|
31
|
+
style={{ color: '#000', margin: '0.2em' }}
|
|
32
|
+
key={entry.name}
|
|
33
|
+
>
|
|
34
|
+
<span style={{ color: COLOR_MAPPING[entry.name.toLowerCase()] }}>
|
|
35
|
+
{entry.name === 'VALID' ? (
|
|
36
|
+
<ValidIcon
|
|
37
|
+
width={'45px'}
|
|
38
|
+
height={'45px'}
|
|
39
|
+
style={{ marginTop: '0.75em' }}
|
|
40
|
+
/>
|
|
41
|
+
) : (
|
|
42
|
+
<InvalidIcon
|
|
43
|
+
width={'45px'}
|
|
44
|
+
height={'45px'}
|
|
45
|
+
style={{ marginTop: '0.75em' }}
|
|
46
|
+
/>
|
|
47
|
+
)}
|
|
48
|
+
</span>
|
|
49
|
+
|
|
50
|
+
<div style={{ display: 'inline-grid', alignItems: 'center' }}>
|
|
51
|
+
<strong
|
|
52
|
+
className="horiz-box-value"
|
|
53
|
+
style={{
|
|
54
|
+
color: COLOR_MAPPING[entry.name.toLowerCase()],
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
{entry.value}
|
|
58
|
+
</strong>
|
|
59
|
+
<span className={'horiz-box-label'}>
|
|
60
|
+
{entry.name.toLowerCase()} nodes
|
|
61
|
+
</span>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
))}
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
</>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useContext, useEffect, useState } from 'react';
|
|
2
|
+
import DJClientContext from '../../providers/djclient';
|
|
3
|
+
|
|
4
|
+
export const DimensionNodeUsagePanel = () => {
|
|
5
|
+
const djClient = useContext(DJClientContext).DataJunctionAPI;
|
|
6
|
+
const [dimensionNodes, setDimensionNodes] = useState(null);
|
|
7
|
+
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const fetchData = async () => {
|
|
10
|
+
setDimensionNodes(await djClient.system.dimensions());
|
|
11
|
+
};
|
|
12
|
+
fetchData().catch(console.error);
|
|
13
|
+
}, [djClient]);
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<>
|
|
17
|
+
<div className="chart-box">
|
|
18
|
+
<div className="chart-title">Dimension Node Usage</div>
|
|
19
|
+
<table className="card-inner-table table" style={{ marginTop: '0' }}>
|
|
20
|
+
<thead className="fs-7 fw-bold text-gray-400 border-bottom-0">
|
|
21
|
+
<tr>
|
|
22
|
+
<th className="text-start">Dimension</th>
|
|
23
|
+
<th className="a">Links</th>
|
|
24
|
+
<th className="a">Cubes</th>
|
|
25
|
+
</tr>
|
|
26
|
+
</thead>
|
|
27
|
+
<tbody>
|
|
28
|
+
{dimensionNodes
|
|
29
|
+
?.sort(
|
|
30
|
+
(a, b) =>
|
|
31
|
+
b.cube_count + b.indegree - (a.cube_count + a.indegree),
|
|
32
|
+
)
|
|
33
|
+
.slice(0, 6)
|
|
34
|
+
.map((dim, index) => (
|
|
35
|
+
<tr key={index}>
|
|
36
|
+
<td className="a">
|
|
37
|
+
<a href={`/nodes/${dim.name}`}>{dim.name}</a>
|
|
38
|
+
</td>
|
|
39
|
+
<td className="a">{dim.indegree}</td>
|
|
40
|
+
<td className="a">{dim.cube_count}</td>
|
|
41
|
+
</tr>
|
|
42
|
+
))}
|
|
43
|
+
</tbody>
|
|
44
|
+
</table>
|
|
45
|
+
</div>
|
|
46
|
+
</>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { useContext, useEffect, useState } from 'react';
|
|
2
|
+
import DJClientContext from '../../providers/djclient';
|
|
3
|
+
import '../../../styles/node-creation.scss';
|
|
4
|
+
const COLOR_MAPPING = {
|
|
5
|
+
source: '#00C49F',
|
|
6
|
+
dimension: '#FFBB28', //'#FF8042',
|
|
7
|
+
transform: '#0088FE',
|
|
8
|
+
metric: '#ff91a3', //'#FFBB28',
|
|
9
|
+
cube: '#AA46BE',
|
|
10
|
+
valid: '#00b368',
|
|
11
|
+
invalid: '#b34b00',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const GovernanceWarningsPanel = () => {
|
|
15
|
+
const djClient = useContext(DJClientContext).DataJunctionAPI;
|
|
16
|
+
const [nodesWithoutDescription, setNodesWithoutDescription] = useState(null);
|
|
17
|
+
const [dimensionNodes, setDimensionNodes] = useState(null);
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const fetchData = async () => {
|
|
21
|
+
setNodesWithoutDescription(
|
|
22
|
+
await djClient.system.nodes_without_description(),
|
|
23
|
+
);
|
|
24
|
+
setDimensionNodes(await djClient.system.dimensions());
|
|
25
|
+
};
|
|
26
|
+
fetchData().catch(console.error);
|
|
27
|
+
}, [djClient]);
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div className="chart-box" style={{ flex: '1 1 10%', maxWidth: '470px' }}>
|
|
31
|
+
<div className="chart-title">Governance Warnings</div>
|
|
32
|
+
<div
|
|
33
|
+
className="horiz-box"
|
|
34
|
+
style={{
|
|
35
|
+
padding: '5px 10px',
|
|
36
|
+
marginTop: '10px',
|
|
37
|
+
border: '1px solid #AA46BE30',
|
|
38
|
+
}}
|
|
39
|
+
>
|
|
40
|
+
<span style={{ color: '#FF804255', fontSize: '30px' }}>⚠</span>
|
|
41
|
+
<span style={{ padding: '10px 12px', fontSize: '18px' }}>
|
|
42
|
+
Missing Description
|
|
43
|
+
</span>
|
|
44
|
+
<div style={{ display: 'block' }}>
|
|
45
|
+
{nodesWithoutDescription?.map(entry => (
|
|
46
|
+
<div
|
|
47
|
+
className="jss316 badge"
|
|
48
|
+
style={{
|
|
49
|
+
margin: '5px 10px',
|
|
50
|
+
fontSize: '14px',
|
|
51
|
+
padding: '10px',
|
|
52
|
+
color: COLOR_MAPPING[entry.name.toLowerCase()],
|
|
53
|
+
backgroundColor: COLOR_MAPPING[entry.name.toLowerCase()] + '10',
|
|
54
|
+
}}
|
|
55
|
+
key={entry.name}
|
|
56
|
+
>
|
|
57
|
+
<strong>{Math.round(entry.value * 100)}%</strong>{' '}
|
|
58
|
+
<span>{entry.name.toLowerCase()}s</span>
|
|
59
|
+
</div>
|
|
60
|
+
))}
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
<div
|
|
64
|
+
className="horiz-box"
|
|
65
|
+
style={{
|
|
66
|
+
padding: '5px 10px',
|
|
67
|
+
marginTop: '10px',
|
|
68
|
+
border: '1px solid #AA46BE30',
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
<div
|
|
72
|
+
style={{ width: '100%', display: 'inline-flex', marginTop: '-10px' }}
|
|
73
|
+
>
|
|
74
|
+
<span style={{ color: '#FF804255', fontSize: '40px' }}>∅</span>
|
|
75
|
+
<span
|
|
76
|
+
style={{
|
|
77
|
+
padding: '10px 12px',
|
|
78
|
+
fontSize: '18px',
|
|
79
|
+
marginTop: '10px',
|
|
80
|
+
}}
|
|
81
|
+
>
|
|
82
|
+
Orphaned Dimensions
|
|
83
|
+
</span>
|
|
84
|
+
</div>
|
|
85
|
+
<div style={{ display: 'block' }}>
|
|
86
|
+
<div
|
|
87
|
+
className="jss316 badge"
|
|
88
|
+
style={{
|
|
89
|
+
margin: '5px 10px',
|
|
90
|
+
fontSize: '14px',
|
|
91
|
+
padding: '10px',
|
|
92
|
+
color: COLOR_MAPPING.dimension,
|
|
93
|
+
backgroundColor: COLOR_MAPPING.dimension + '10',
|
|
94
|
+
}}
|
|
95
|
+
>
|
|
96
|
+
<strong>
|
|
97
|
+
{dimensionNodes?.filter(
|
|
98
|
+
dim => dim.indegree === 0 || dim.cube_count === 0,
|
|
99
|
+
).length || '...'}
|
|
100
|
+
</strong>
|
|
101
|
+
<span> dimension nodes</span>
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asynchronously loads the component for the Overview page
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import { lazyLoad } from '../../../utils/loadable';
|
|
7
|
+
|
|
8
|
+
export const OverviewPage = props => {
|
|
9
|
+
return lazyLoad(
|
|
10
|
+
() => import('./index'),
|
|
11
|
+
module => module.OverviewPage,
|
|
12
|
+
{
|
|
13
|
+
fallback: <div></div>,
|
|
14
|
+
},
|
|
15
|
+
)(props);
|
|
16
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { useContext, useEffect, useState } from 'react';
|
|
2
|
+
import DJClientContext from '../../providers/djclient';
|
|
3
|
+
import NodeIcon from '../../icons/NodeIcon';
|
|
4
|
+
import '../../../styles/overview.css';
|
|
5
|
+
|
|
6
|
+
const COLOR_MAPPING = {
|
|
7
|
+
source: '#00C49F',
|
|
8
|
+
dimension: '#FFBB28', //'#FF8042',
|
|
9
|
+
transform: '#0088FE',
|
|
10
|
+
metric: '#FF91A3', //'#FFBB28',
|
|
11
|
+
cube: '#AA46BE',
|
|
12
|
+
valid: '#00B368',
|
|
13
|
+
invalid: '#B34B00',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const NodesByTypePanel = () => {
|
|
17
|
+
const djClient = useContext(DJClientContext).DataJunctionAPI;
|
|
18
|
+
const [nodesByType, setNodesByType] = useState(null);
|
|
19
|
+
const [materializationsByType, setMaterializationsByType] = useState(null);
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const fetchData = async () => {
|
|
23
|
+
setNodesByType(await djClient.system.node_counts_by_type());
|
|
24
|
+
setMaterializationsByType(
|
|
25
|
+
await djClient.system.materialization_counts_by_type(),
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
fetchData().catch(console.error);
|
|
29
|
+
}, [djClient]);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<>
|
|
33
|
+
<div className="chart-box" style={{ flex: '0 0 30%', maxWidth: '350px' }}>
|
|
34
|
+
<div className="chart-title">Nodes by Type</div>
|
|
35
|
+
<div className="horiz-box">
|
|
36
|
+
{nodesByType?.map(entry => (
|
|
37
|
+
<div className="vert-box" key={entry.name}>
|
|
38
|
+
<NodeIcon color={COLOR_MAPPING[entry.name]} />
|
|
39
|
+
<strong style={{ color: COLOR_MAPPING[entry.name] }}>
|
|
40
|
+
{entry.value}
|
|
41
|
+
</strong>
|
|
42
|
+
<span>{entry.name}s</span>
|
|
43
|
+
</div>
|
|
44
|
+
))}
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
<div className="chart-box" style={{ flex: '0 0 30%', maxWidth: '350px' }}>
|
|
48
|
+
<div className="chart-title">Materializations by Type</div>
|
|
49
|
+
<div className="horiz-box">
|
|
50
|
+
{materializationsByType?.map(entry => (
|
|
51
|
+
<div className="vert-box" key={entry.name}>
|
|
52
|
+
<NodeIcon color={COLOR_MAPPING[entry.name]} />
|
|
53
|
+
<strong style={{ color: COLOR_MAPPING[entry.name] }}>
|
|
54
|
+
{entry.value}
|
|
55
|
+
</strong>
|
|
56
|
+
<span>{entry.name}s</span>
|
|
57
|
+
</div>
|
|
58
|
+
))}
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
</>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { useContext, useEffect, useState } from 'react';
|
|
2
|
+
import DJClientContext from '../../providers/djclient';
|
|
3
|
+
import NodeIcon from '../../icons/NodeIcon';
|
|
4
|
+
|
|
5
|
+
import ValidIcon from '../../icons/ValidIcon';
|
|
6
|
+
import InvalidIcon from '../../icons/InvalidIcon';
|
|
7
|
+
|
|
8
|
+
const COLOR_MAPPING = {
|
|
9
|
+
valid: '#00b368',
|
|
10
|
+
invalid: '#FF91A3', // '#b34b00',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const OverviewPanel = () => {
|
|
14
|
+
const djClient = useContext(DJClientContext).DataJunctionAPI;
|
|
15
|
+
const [nodesByActive, setNodesByActive] = useState(null);
|
|
16
|
+
const [nodesByStatus, setNodesByStatus] = useState(null);
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const fetchData = async () => {
|
|
20
|
+
setNodesByActive(await djClient.system.node_counts_by_active());
|
|
21
|
+
setNodesByStatus(await djClient.system.node_counts_by_status());
|
|
22
|
+
};
|
|
23
|
+
fetchData().catch(console.error);
|
|
24
|
+
}, [djClient]);
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div className="chart-box" style={{ flex: '0 0 2%' }}>
|
|
28
|
+
<div className="chart-title">Overview</div>
|
|
29
|
+
<div className="horiz-box">
|
|
30
|
+
{nodesByActive
|
|
31
|
+
?.filter(entry => entry.name === 'true')
|
|
32
|
+
.map(entry => (
|
|
33
|
+
<div
|
|
34
|
+
className="jss316 badge"
|
|
35
|
+
style={{ color: '#000', margin: '0.2em' }}
|
|
36
|
+
>
|
|
37
|
+
<NodeIcon color="#FFBB28" style={{ marginTop: '0.75em' }} />
|
|
38
|
+
<div style={{ display: 'inline-grid', alignItems: 'center' }}>
|
|
39
|
+
<strong className="horiz-box-value">{entry.value}</strong>
|
|
40
|
+
<span className={'horiz-box-label'}>
|
|
41
|
+
{entry.name === 'true' ? 'Active Nodes' : 'Deactivated'}
|
|
42
|
+
</span>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
))}
|
|
46
|
+
</div>
|
|
47
|
+
<div className="horiz-box">
|
|
48
|
+
{nodesByStatus?.map(entry => (
|
|
49
|
+
<div
|
|
50
|
+
className="jss316 badge"
|
|
51
|
+
style={{ color: '#000', margin: '0.2em', marginLeft: '1.2em' }}
|
|
52
|
+
>
|
|
53
|
+
↳
|
|
54
|
+
<span
|
|
55
|
+
style={{
|
|
56
|
+
color: COLOR_MAPPING[entry.name.toLowerCase()],
|
|
57
|
+
margin: '0 0.2em 0 0.4em',
|
|
58
|
+
}}
|
|
59
|
+
>
|
|
60
|
+
{entry.name === 'VALID' ? (
|
|
61
|
+
<ValidIcon
|
|
62
|
+
width={'25px'}
|
|
63
|
+
height={'25px'}
|
|
64
|
+
style={{ marginTop: '0.2em' }}
|
|
65
|
+
/>
|
|
66
|
+
) : (
|
|
67
|
+
<InvalidIcon
|
|
68
|
+
width={'25px'}
|
|
69
|
+
height={'25px'}
|
|
70
|
+
style={{ marginTop: '0.2em' }}
|
|
71
|
+
/>
|
|
72
|
+
)}
|
|
73
|
+
</span>
|
|
74
|
+
<div style={{ display: 'inline-flex', alignItems: 'center' }}>
|
|
75
|
+
<strong
|
|
76
|
+
style={{
|
|
77
|
+
color: COLOR_MAPPING[entry.name.toLowerCase()],
|
|
78
|
+
margin: '0 2px',
|
|
79
|
+
fontSize: '16px',
|
|
80
|
+
textAlign: 'left',
|
|
81
|
+
}}
|
|
82
|
+
>
|
|
83
|
+
{entry.value}
|
|
84
|
+
</strong>
|
|
85
|
+
<span style={{ fontSize: 'smaller', padding: '5px 2px' }}>
|
|
86
|
+
{entry.name.toLowerCase()}
|
|
87
|
+
</span>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
))}
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { useContext, useEffect, useState } from 'react';
|
|
2
|
+
import DJClientContext from '../../providers/djclient';
|
|
3
|
+
import {
|
|
4
|
+
Legend,
|
|
5
|
+
Tooltip,
|
|
6
|
+
ResponsiveContainer,
|
|
7
|
+
BarChart,
|
|
8
|
+
CartesianGrid,
|
|
9
|
+
XAxis,
|
|
10
|
+
YAxis,
|
|
11
|
+
Bar,
|
|
12
|
+
} from 'recharts';
|
|
13
|
+
|
|
14
|
+
const COLOR_MAPPING = {
|
|
15
|
+
source: '#00C49F',
|
|
16
|
+
dimension: '#FFBB28',
|
|
17
|
+
transform: '#0088FE',
|
|
18
|
+
metric: '#FF91A3',
|
|
19
|
+
cube: '#AA46BE',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const TrendsPanel = () => {
|
|
23
|
+
const djClient = useContext(DJClientContext).DataJunctionAPI;
|
|
24
|
+
const [nodeTrends, setNodeTrends] = useState([]);
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const fetchData = async () => {
|
|
28
|
+
setNodeTrends(await djClient.system.node_trends());
|
|
29
|
+
};
|
|
30
|
+
fetchData().catch(console.error);
|
|
31
|
+
}, [djClient]);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<div className="chart-box" style={{ maxWidth: '60%', flex: '1 1 20%' }}>
|
|
35
|
+
<div className="chart-title">Trends</div>
|
|
36
|
+
<ResponsiveContainer width="100%" height={400}>
|
|
37
|
+
<BarChart
|
|
38
|
+
width={1000}
|
|
39
|
+
height={400}
|
|
40
|
+
data={nodeTrends}
|
|
41
|
+
margin={{
|
|
42
|
+
top: 20,
|
|
43
|
+
right: 30,
|
|
44
|
+
left: 20,
|
|
45
|
+
bottom: 5,
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
49
|
+
<XAxis dataKey="date" />
|
|
50
|
+
<YAxis />
|
|
51
|
+
<Tooltip />
|
|
52
|
+
<Legend />
|
|
53
|
+
{Object.entries(COLOR_MAPPING).map(([key, color]) => (
|
|
54
|
+
<Bar
|
|
55
|
+
key={key}
|
|
56
|
+
dataKey={key}
|
|
57
|
+
stackId="nodeCount"
|
|
58
|
+
fill={color}
|
|
59
|
+
name={key.charAt(0).toUpperCase() + key.slice(1)}
|
|
60
|
+
/>
|
|
61
|
+
))}
|
|
62
|
+
</BarChart>
|
|
63
|
+
</ResponsiveContainer>
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
2
|
+
import { ByStatusPanel } from '../ByStatusPanel';
|
|
3
|
+
import DJClientContext from '../../../providers/djclient';
|
|
4
|
+
|
|
5
|
+
describe('<ByStatusPanel />', () => {
|
|
6
|
+
it('fetches nodes by status and displays them correctly', async () => {
|
|
7
|
+
const mockNodeCounts = [
|
|
8
|
+
{ name: 'VALID', value: 10 },
|
|
9
|
+
{ name: 'INVALID', value: 5 },
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
const mockDjClient = {
|
|
13
|
+
system: {
|
|
14
|
+
node_counts_by_status: jest.fn().mockResolvedValue(mockNodeCounts),
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
render(
|
|
19
|
+
<DJClientContext.Provider value={{ DataJunctionAPI: mockDjClient }}>
|
|
20
|
+
<ByStatusPanel />
|
|
21
|
+
</DJClientContext.Provider>,
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
await waitFor(() => {
|
|
25
|
+
expect(mockDjClient.system.node_counts_by_status).toHaveBeenCalled();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Check that counts are rendered
|
|
29
|
+
expect(screen.getByText('10')).toBeInTheDocument();
|
|
30
|
+
expect(screen.getByText('5')).toBeInTheDocument();
|
|
31
|
+
|
|
32
|
+
// Check that labels are rendered
|
|
33
|
+
expect(screen.getByText('valid nodes')).toBeInTheDocument();
|
|
34
|
+
expect(screen.getByText('invalid nodes')).toBeInTheDocument();
|
|
35
|
+
});
|
|
36
|
+
});
|