Skip to content

Commit 61b0aed

Browse files
authored
Merge pull request #9 from oslabs-beta/kevin/david-filter
Kevin / David Filter
2 parents 93187c9 + c5748f1 commit 61b0aed

File tree

5 files changed

+93
-25
lines changed

5 files changed

+93
-25
lines changed

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,15 @@
130130
"webpack-cli": "^3.3.12"
131131
},
132132
"dependencies": {
133-
"@emotion/react": "^11.7.1",
133+
"@emotion/react": "^11.9.0",
134+
"@emotion/styled": "^11.8.1",
134135
"@fortawesome/fontawesome-free": "^5.15.1",
135136
"@fortawesome/fontawesome-svg-core": "^1.2.32",
136137
"@fortawesome/free-regular-svg-icons": "^5.15.1",
137138
"@fortawesome/free-solid-svg-icons": "^5.15.1",
138139
"@fortawesome/react-fontawesome": "^0.1.12",
139140
"@material-ui/core": "^4.11.2",
141+
"@mui/material": "^5.8.2",
140142
"@types/react-dom": "^17.0.14",
141143
"@types/react-router-dom": "^5.3.3",
142144
"@visx/axis": "^1.0.0",
@@ -173,14 +175,14 @@
173175
"prop-types": "^15.7.2",
174176
"rc-slider": "^8.7.1",
175177
"rc-tooltip": "^3.7.3",
176-
"react": "^16.13.1",
178+
"react": "^16.14.0",
177179
"react-apexcharts": "^1.3.7",
178180
"react-dom": "^16.13.1",
179181
"react-hover": "^2.0.0",
180182
"react-html-parser": "^2.0.2",
181183
"react-json-tree": "^0.11.2",
182184
"react-router-dom": "^5.2.0",
183-
"react-select": "^3.1.0",
185+
"react-select": "^3.2.0",
184186
"react-spinners": "^0.11.0",
185187
"react-split": "^2.0.14",
186188
"recoil": "0.0.10",

src/app/components/BarGraph.tsx

Lines changed: 23 additions & 7 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, allRoutes, filteredSnapshots } = props;
6566
const [ seriesNameInput, setSeriesNameInput ] = useState(`Series ${comparison.length + 1}`);
6667
const {
6768
tooltipOpen,
@@ -131,17 +132,15 @@ 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 (
142143
<div className="bargraph-position">
143-
144-
{/* <input type="text" id ="seriesname" placeholder="Series Name" /> */}
145144
<div className="saveSeriesContainer">
146145
{textbox}
147146
<button
@@ -152,6 +151,23 @@ const BarGraph = props => {
152151
Save Series
153152
</button>
154153
</div>
154+
<FormControl className="routesForm" id="routes-formcontrol" size="small">
155+
<InputLabel id="routes-dropdown">Select Route</InputLabel>
156+
<Select
157+
labelId="demo-simple-select-label"
158+
id="routes-select"
159+
onChange={e => setRoute(e.target.value)}
160+
>
161+
<MenuItem value={null}>
162+
All Visited Routes
163+
</MenuItem>
164+
{allRoutes.map(route => (
165+
<MenuItem value={route} className="routes">
166+
{route}
167+
</MenuItem>
168+
))}
169+
</Select>
170+
</FormControl>
155171
<svg ref={containerRef} width={width} height={height}>
156172
<rect
157173
x={0}

src/app/components/PerformanceVisx.tsx

Lines changed: 37 additions & 9 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
@@ -39,10 +40,10 @@ const collectNodes = (snaps, componentName) => {
3940
const renderResult = [];
4041
let trackChanges = 0;
4142
let newChange = true;
42-
for (let x = 0; x < snaps.length; x++) {
43+
for (let x = 0; x < snaps.length; x += 1) {
4344
const snapshotList = [];
4445
snapshotList.push(snaps[x]);
45-
for (let i = 0; i < snapshotList.length; i++) {
46+
for (let i = 0; i < snapshotList.length; i += 1) {
4647
const cur = snapshotList[i];
4748
if (cur.name === componentName) {
4849
const renderTime = Number(
@@ -118,7 +119,7 @@ const traverse = (snapshot, data, snapshots, currTotalRender = 0) => {
118119
}
119120
// increment render frequencies
120121
if (renderTime > 0) {
121-
data.componentData[componentName].renderFrequency++;
122+
data.componentData[componentName].renderFrequency += 1;
122123
}
123124

124125
// add to total render time
@@ -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]);
@@ -188,7 +191,7 @@ const PerformanceVisx = (props: BarStackProps) => {
188191
const actionsArr = [];
189192

190193
if (seriesArr.length) {
191-
for (let i = 0; i < seriesArr.length; i++) {
194+
for (let i = 0; i < seriesArr.length; i += 1) {
192195
for (const actionObj of seriesArr[i].data.barStack) {
193196
if (actionObj.name === action) {
194197
actionObj.seriesName = seriesArr[i].name;
@@ -227,9 +230,37 @@ const PerformanceVisx = (props: BarStackProps) => {
227230
);
228231
};
229232

233+
const allRoutes = [];
234+
const filteredSnapshots = [];
235+
236+
for (let i = 0; i < data.barStack.length; i += 1) {
237+
const url = new URL(data.barStack[i].route);
238+
if (!allRoutes.includes(url.pathname)) {
239+
allRoutes.push(url.pathname);
240+
}
241+
if (route && route === url.pathname) {
242+
filteredSnapshots.push(data.barStack[i]);
243+
}
244+
}
245+
if (route) {
246+
data.barStack = filteredSnapshots;
247+
}
248+
230249
const renderBargraph = () => {
231250
if (hierarchy) {
232-
return <BarGraph data={data} width={width} height={height} comparison={allStorage()} />;
251+
return (
252+
<div>
253+
<BarGraph
254+
data={data}
255+
width={width}
256+
height={height}
257+
comparison={allStorage()}
258+
setRoute={setRoute}
259+
allRoutes={allRoutes}
260+
filteredSnapshots={filteredSnapshots}
261+
/>
262+
</div>
263+
);
233264
}
234265
};
235266

@@ -252,7 +283,6 @@ const PerformanceVisx = (props: BarStackProps) => {
252283
<div className="performance-nav-bar-container">
253284
<NavLink
254285
className="router-link-performance"
255-
// className="router-link"
256286
activeClassName="is-active"
257287
exact
258288
to="/"
@@ -262,15 +292,13 @@ const PerformanceVisx = (props: BarStackProps) => {
262292
<NavLink
263293
className="router-link-performance"
264294
id="router-link-performance-comparison"
265-
// className="router-link"
266295
activeClassName="is-active"
267296
to="/comparison"
268297
>
269298
Comparison View
270299
</NavLink>
271300
<NavLink
272301
className="router-link-performance"
273-
// className="router-link"
274302
activeClassName="is-active"
275303
to="/componentdetails"
276304
>

src/app/styles/base/_base.scss

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,4 @@ body {
4242
.saveSeriesContainer {
4343
padding-bottom: 15px;
4444
padding-top: 10px;
45-
}
46-
47-
48-
45+
}

src/app/styles/components/_performanceVisx.scss

Lines changed: 27 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,16 +18,39 @@
1618
}
1719

1820
.MuiTypography-body1 {
19-
font-size: 1em !important;
21+
font-size: 2em !important;
22+
}
23+
24+
#routes-formcontrol {
25+
padding: 3px;
26+
margin-left: 50px;
27+
font: 300 13px 'Roboto', sans-serif;
28+
text-align: left;
29+
min-width: 10em;
30+
max-height: 50%;
31+
}
32+
33+
#routes-dropdown {
34+
color: white !important;
35+
background-color: #ff6569 !important;
36+
font: 300 13px 'Roboto', sans-serif;
37+
text-align: left;
38+
}
39+
40+
#routes-select {
41+
color: white !important;
42+
background-color: #ff6569 !important;
43+
font: 300 13px 'Roboto', sans-serif;
44+
text-align: left;
2045
}
2146

2247
#seriesname {
2348
float: right;
2449
width: 220px;
2550
margin-right: 165px;
2651
height: 24px;
27-
2852
}
53+
2954
input:focus, textarea:focus, select:focus{
3055
outline: none;
3156
}

0 commit comments

Comments
 (0)