Skip to content

Commit 08e07c3

Browse files
committed
Finished Filter Routes on Performance Tab
Co-authored-by: Chris LeBrett <[email protected]> Co-authored-by: Robby Tipton <[email protected]> Co-authored-by: Joseph Park <[email protected]> Co-authored-by: David Kim <[email protected]> Co-authored-by: Kevin HoEun Lee <[email protected]>
1 parent 61bd748 commit 08e07c3

File tree

4 files changed

+115
-11
lines changed

4 files changed

+115
-11
lines changed

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,15 @@
129129
"webpack-cli": "^3.3.12"
130130
},
131131
"dependencies": {
132-
"@emotion/react": "^11.7.1",
132+
"@emotion/react": "^11.9.0",
133+
"@emotion/styled": "^11.8.1",
133134
"@fortawesome/fontawesome-free": "^5.15.1",
134135
"@fortawesome/fontawesome-svg-core": "^1.2.32",
135136
"@fortawesome/free-regular-svg-icons": "^5.15.1",
136137
"@fortawesome/free-solid-svg-icons": "^5.15.1",
137138
"@fortawesome/react-fontawesome": "^0.1.12",
138139
"@material-ui/core": "^4.11.2",
140+
"@mui/material": "^5.8.2",
139141
"@types/react-dom": "^17.0.14",
140142
"@types/react-router-dom": "^5.3.3",
141143
"@visx/axis": "^1.0.0",
@@ -172,7 +174,7 @@
172174
"prop-types": "^15.7.2",
173175
"rc-slider": "^8.7.1",
174176
"rc-tooltip": "^3.7.3",
175-
"react": "^16.13.1",
177+
"react": "^16.14.0",
176178
"react-apexcharts": "^1.3.7",
177179
"react-dom": "^16.13.1",
178180
"react-hover": "^2.0.0",

src/app/components/BarGraph.tsx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// @ts-nocheck
22
import React, { useEffect, useState } from 'react';
3+
import { FormControl, InputLabel, Select, MenuItem } from '@mui/material';
34
import { BarStack } from '@visx/shape';
45
import { SeriesPoint } from '@visx/shape/lib/types';
56
import { Group } from '@visx/group';
@@ -61,7 +62,7 @@ const tooltipStyles = {
6162

6263
const BarGraph = props => {
6364
const [{ tabs, currentTab }, dispatch] = useStoreContext();
64-
const { width, height, data, comparison } = props;
65+
const { width, height, data, comparison, setRoute, devRoutes } = props;
6566
const [ seriesNameInput, setSeriesNameInput ] = useState(`Series ${comparison.length + 1}`);
6667
const {
6768
tooltipOpen,
@@ -131,11 +132,11 @@ const BarGraph = props => {
131132
toStorage.data.barStack[i].name = actionNames[i].value;
132133
}
133134
dispatch(save(toStorage, seriesNameInput));
134-
setSeriesNameInput(`Series ${comparison.length}`)
135-
return
135+
setSeriesNameInput(`Series ${comparison.length}`);
136+
return;
136137
}
137-
dispatch(save(toStorage))
138-
}
138+
dispatch(save(toStorage));
139+
};
139140

140141
const textbox = tabs[currentTab].seriesSavedStatus === 'inputBoxOpen' ? <input type="text" id="seriesname" placeholder="Enter Series Name" onChange={e => setSeriesNameInput(e.target.value)} /> : null;
141142
return (
@@ -151,6 +152,21 @@ const BarGraph = props => {
151152
>
152153
Save Series
153154
</button>
155+
<FormControl id="routes-formcontrol">
156+
<InputLabel id="routes-dropdown">Routes</InputLabel>
157+
<Select
158+
labelId="demo-simple-select-label"
159+
id="routes-select"
160+
label="Routes"
161+
onChange={e => setRoute(e.target.value)}
162+
>
163+
{devRoutes.map(route => { return (
164+
<MenuItem value={route} className="routes">
165+
{route}
166+
</MenuItem>
167+
)})}
168+
</Select>
169+
</FormControl>
154170
</div>
155171
<svg ref={containerRef} width={width} height={height}>
156172
<rect

src/app/components/PerformanceVisx.tsx

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import BarGraphComparison from './BarGraphComparison';
1616
import BarGraphComparisonActions from './BarGraphComparisonActions';
1717
import { useStoreContext } from '../store';
1818
import { setCurrentTabInApp } from '../actions/actions';
19+
1920
/* NOTES
2021
Issue - Not fully compatible with recoil apps. Reference the recoil-todo-test.
2122
Barstacks display inconsistently...however, almost always displays upon initial test app load or
@@ -159,7 +160,7 @@ const getPerfMetrics = (snapshots, snapshotsIds): {} => {
159160
maxTotalRender: 0,
160161
};
161162
snapshots.forEach((snapshot, i) => {
162-
perfData.barStack.push({ snapshotId: snapshotsIds[i] });
163+
perfData.barStack.push({ snapshotId: snapshotsIds[i], route: snapshot.route.url });
163164
traverse(snapshot, perfData, snapshots);
164165
});
165166
return perfData;
@@ -177,6 +178,8 @@ const PerformanceVisx = (props: BarStackProps) => {
177178
const [series, setSeries] = useState(true);
178179
const [action, setAction] = useState(false);
179180

181+
const [route, setRoute] = useState(null);
182+
180183
useEffect(() => {
181184
dispatch(setCurrentTabInApp('performance'));
182185
}, [dispatch]);
@@ -227,9 +230,39 @@ const PerformanceVisx = (props: BarStackProps) => {
227230
);
228231
};
229232

233+
// Logic for routeArr - DropDown
234+
// Create an Arr to hold our routes for the dropDown.
235+
const devRoutes: string[] = [];
236+
// Use a for loop to itereate over data and add the prospective routes to our devRoutes arr.
237+
for (let i = 0; i < data.barStack.length; i += 1) {
238+
const url:string = new URL(data.barStack[i].route);
239+
// Making sure devRoutes does not include any additional routes as barStack carries the same Route for every action/state snapshot.
240+
if (!devRoutes.includes(url.pathname)) {
241+
devRoutes.push(url.pathname);
242+
}
243+
}
244+
245+
const userInputRoutes: string[] = [];
246+
for (let i = 0; i < data.barStack.length; i += 1) {
247+
const url:string = new URL(data.barStack[i].route);
248+
// console.log('route is', route);
249+
// console.log('url.pathname is', url.pathname);
250+
if (route && route === url.pathname) {
251+
userInputRoutes.push(data.barStack[i]);
252+
}
253+
}
254+
if (route) {
255+
data.barStack = userInputRoutes;
256+
}
257+
230258
const renderBargraph = () => {
231259
if (hierarchy) {
232-
return <BarGraph data={data} width={width} height={height} comparison={allStorage()} />;
260+
return (
261+
<div>
262+
<BarGraph data={data} width={width} height={height} comparison={allStorage()} setRoute={setRoute} devRoutes={devRoutes} />
263+
{/* <input type="text" onChange={e => setRoute(e.target.value)} /> */}
264+
</div>
265+
);
233266
}
234267
};
235268

src/app/styles/components/_performanceVisx.scss

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap');
2+
13
#RenderContainer {
24
display: flex;
35
justify-content: center;
@@ -16,7 +18,23 @@
1618
}
1719

1820
.MuiTypography-body1 {
19-
font-size: 1em !important;
21+
font-size: 2em !important;
22+
}
23+
24+
#routes-formcontrol {
25+
width: 10em;
26+
margin-left: 50px;
27+
}
28+
29+
#routes-dropdown {
30+
color: white !important;
31+
margin-bottom: 10px;
32+
}
33+
34+
#routes-select {
35+
color: white !important;
36+
background-color: #ff6569 !important;
37+
font: 300 'Roboto', sans-serif;
2038
}
2139

2240
#seriesname {
@@ -26,6 +44,41 @@
2644
height: 24px;
2745

2846
}
47+
2948
input:focus, textarea:focus, select:focus{
3049
outline: none;
31-
}
50+
}
51+
52+
// .routes {
53+
// position: absolute;
54+
// align-items: center;
55+
// text-align: center;
56+
// justify-content: center;
57+
// width: 100px;
58+
// }
59+
60+
// .devRoutes {
61+
// padding: 3px;
62+
// outline: transparent;
63+
// color: white;
64+
// display: flex;
65+
// justify-content: center;
66+
// align-items: center;
67+
// text-align: center;
68+
// border-style: solid;
69+
// border-color: transparent;
70+
// border-radius: 3px;
71+
// cursor: pointer;
72+
// line-height: 1.5em;
73+
// font: 300 28px 'Roboto', sans-serif;
74+
// font-size: $button-text-size;
75+
// width: 80px;
76+
// background: $red-color-gradient;
77+
// height: 30px;
78+
// position: absolute;
79+
// left: 2.5rem;
80+
81+
// &.animate {
82+
// background: rgb(41, 164, 41);
83+
// }
84+
// }

0 commit comments

Comments
 (0)