This repository was archived by the owner on Sep 10, 2024. It is now read-only.
forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.tsx
123 lines (111 loc) · 3.79 KB
/
app.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
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import React, { useState } from 'react';
import ReactDOM from 'react-dom';
import { AppMountParameters } from 'kibana/public';
import {
EuiPage,
EuiPageBody,
EuiPageContent,
EuiPageContentBody,
EuiSpacer,
EuiTabbedContent,
} from '@elastic/eui';
import { TopNContext } from './components/contexts/topn';
import { StackTraceNavigation } from './components/stacktrace-nav';
import { StackedBarChart } from './components/stacked-bar-chart';
import { ChartGrid } from './components/chart-grid';
import { FlameGraphContext } from './components/contexts/flamegraph';
import { FlameGraphNavigation } from './components/flamegraph-nav';
import { FlameGraph } from './components/flamegraph';
import { PixiFlamechart } from './components/PixiFlamechart';
import { Services } from './services';
type Props = Services;
function App({ fetchTopN, fetchElasticFlamechart, fetchPixiFlamechart, fetchTopNData }: Props) {
const [topn, setTopN] = useState({
samples: [],
series: new Map(),
});
const [topnData, setTopNData] = useState({
samples: [],
series: new Map(),
});
const [elasticFlamegraph, setElasticFlamegraph] = useState({ leaves: [] });
const [pixiFlamegraph, setPixiFlamegraph] = useState({});
const tabs = [
{
id: 'stacktrace-elastic',
name: 'Stack Traces (API)',
content: (
<>
<EuiSpacer />
<TopNContext.Provider value={topn}>
<StackTraceNavigation fetchTopN={fetchTopN} setTopN={setTopN} />
<StackedBarChart id="topn" name="topn" height={400} x="x" y="y" category="g" />
<ChartGrid maximum={10} />
</TopNContext.Provider>
</>
),
},
{
id: 'stacktrace-elastic-data',
name: 'Stack Traces (Data Plugin)',
content: (
<>
<EuiSpacer />
<TopNContext.Provider value={topnData}>
<StackTraceNavigation fetchTopN={fetchTopNData} setTopN={setTopNData} />
<StackedBarChart id="topn-data" name="topn-data" height={400} x="x" y="y" category="g" />
<ChartGrid maximum={10} />
</TopNContext.Provider>
</>
),
},
{
id: 'flamegraph-elastic',
name: 'FlameGraph (Elastic)',
content: (
<>
<EuiSpacer />
<FlameGraphContext.Provider value={elasticFlamegraph}>
<FlameGraphNavigation getter={fetchElasticFlamechart} setter={setElasticFlamegraph} />
<FlameGraph id="flamechart" height={600} />
</FlameGraphContext.Provider>
</>
),
},
{
id: 'flamegraph-pixi',
name: 'FlameGraph (Pixi)',
content: (
<>
<EuiSpacer />
<FlameGraphContext.Provider value={pixiFlamegraph}>
<FlameGraphNavigation getter={fetchPixiFlamechart} setter={setPixiFlamegraph} />
<PixiFlamechart projectID={'5'} />
</FlameGraphContext.Provider>
</>
),
},
];
return (
<EuiPage>
<EuiPageBody style={{ margin: '0 auto' }}>
<EuiPageContent>
<EuiPageContentBody style={{ margin: '0 auto' }}>
<EuiTabbedContent tabs={tabs} initialSelectedTab={tabs[0]} autoFocus="selected" />
</EuiPageContentBody>
</EuiPageContent>
</EuiPageBody>
</EuiPage>
);
}
export const renderApp = (props: Props, element: AppMountParameters['element']) => {
ReactDOM.render(<App {...props} />, element);
return () => ReactDOM.unmountComponentAtNode(element);
};