Skip to content

Commit 2b692ac

Browse files
committed
currently working on the comparison dropdowns
1 parent cf86f11 commit 2b692ac

File tree

3 files changed

+101
-92
lines changed

3 files changed

+101
-92
lines changed

src/app/components/StateRoute/PerformanceVisx/BarGraphComparison.tsx

Lines changed: 78 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Select from '@mui/material/Select';
1515
import MenuItem from '@mui/material/MenuItem';
1616
import FormControl from '@mui/material/FormControl';
1717
import { useTheme } from '@mui/material/styles';
18-
import { Button } from '@mui/material';
18+
import { Button, InputLabel } from '@mui/material';
1919
import { onHover, onHoverExit, deleteSeries, setCurrentTabInApp } from '../../../actions/actions';
2020
import { useStoreContext } from '../../../store';
2121
import {
@@ -144,12 +144,12 @@ const BarGraphComparison = (props: BarGraphComparisonProps): JSX.Element => {
144144

145145
const StyledFormControl = styled(FormControl)(({ theme }) => ({
146146
margin: theme.spacing(1),
147-
minWidth: 80,
147+
minWidth: 160,
148148
height: 30,
149149
}));
150150

151151
const StyledSelect = styled(Select)({
152-
minWidth: 80,
152+
minWidth: 160,
153153
fontSize: '.75rem',
154154
fontWeight: 200,
155155
height: 30,
@@ -231,79 +231,84 @@ const BarGraphComparison = (props: BarGraphComparisonProps): JSX.Element => {
231231
return (
232232
<div>
233233
<div className='series-options-container'>
234-
<div className='dropdown-and-delete-series-container'>
235-
<Button
236-
variant='contained'
237-
sx={{ p: 2, color: 'white' }}
238-
// type='button'
239-
className='delete-button'
240-
onClick={() => {
241-
setButtonLoad(true);
242-
dispatch(deleteSeries());
234+
{/* <div className='dropdown-and-delete-series-container'> */}
235+
<Button
236+
variant='contained'
237+
sx={{ p: 2, color: 'white' }}
238+
// type='button'
239+
className='delete-button'
240+
onClick={() => {
241+
setButtonLoad(true);
242+
dispatch(deleteSeries());
243243

244-
setTimeout(() => {
245-
setButtonLoad(false);
246-
}, 1000);
247-
}}
248-
style={
249-
buttonLoad
250-
? { backgroundColor: theme.palette.primary.main }
251-
: { backgroundColor: theme.palette.secondary.main }
252-
}
253-
>
254-
{buttonLoad ? 'Deleted' : 'Clear Series'}
255-
</Button>
256-
<h4 className='compare-series-box' style={{ padding: '0 1rem' }}>
244+
setTimeout(() => {
245+
setButtonLoad(false);
246+
}, 1000);
247+
}}
248+
style={
249+
buttonLoad
250+
? { backgroundColor: theme.palette.secondary.main }
251+
: { backgroundColor: theme.palette.primary.main }
252+
}
253+
>
254+
{buttonLoad ? 'Deleted' : 'Clear Series'}
255+
</Button>
256+
{/* <h4 className='compare-series-box' style={{ padding: '0 1rem' }}>
257257
Compare Series:{' '}
258-
</h4>
259-
<StyledFormControl
260-
id='selectSeries'
261-
variant='outlined'
262-
sx={{ backgroundColor: theme.palette.primary.main }}
258+
</h4> */}
259+
<StyledFormControl
260+
sx={{ m: 1, minwidth: 160 }}
261+
size='medium'
262+
id='selectSeries'
263+
variant='outlined'
264+
label='compares series'
265+
// sx={{ backgroundColor: theme.palette.primary.main }}
266+
>
267+
<InputLabel id='selectSeries'>Compare Series</InputLabel>
268+
<StyledSelect
269+
// labelId='simple-select-outlined-label'
270+
// id='simple-select-outlined'
271+
open={open}
272+
onClose={handleClose}
273+
onOpen={handleOpen}
274+
value={series}
275+
onChange={handleSeriesChange}
276+
>
277+
{!comparison.length ? (
278+
<MenuItem>No series available</MenuItem>
279+
) : (
280+
comparison.map((tabElem, index) => (
281+
<MenuItem key={`MenuItem${tabElem.name}`} value={index}>
282+
{tabElem.name}
283+
</MenuItem>
284+
))
285+
)}
286+
</StyledSelect>
287+
</StyledFormControl>
288+
{/* <h4 style={{ padding: '0 1rem' }}>Compare Actions </h4> */}
289+
<StyledFormControl variant='outlined'>
290+
<InputLabel>Compare Actions</InputLabel>
291+
<StyledSelect
292+
style={{ color: 'white' }}
293+
labelId='snapshot-select'
294+
id='snapshot-select'
295+
open={picOpen}
296+
onClose={picHandleClose}
297+
onOpen={picHandleOpen}
298+
value='' // snapshots
299+
onChange={handleActionChange}
263300
>
264-
<StyledSelect
265-
style={{ color: 'red' }}
266-
labelId='simple-select-outlined-label'
267-
open={open}
268-
onClose={handleClose}
269-
onOpen={handleOpen}
270-
value={series}
271-
onChange={handleSeriesChange}
272-
>
273-
{!comparison.length ? (
274-
<MenuItem>No series available</MenuItem>
275-
) : (
276-
comparison.map((tabElem, index) => (
277-
<MenuItem key={`MenuItem${tabElem.name}`} value={index}>
278-
{tabElem.name}
279-
</MenuItem>
280-
))
281-
)}
282-
</StyledSelect>
283-
</StyledFormControl>
284-
<h4 style={{ padding: '0 1rem' }}>Compare Actions </h4>
285-
<StyledFormControl variant='outlined'>
286-
<StyledSelect
287-
style={{ color: 'white' }}
288-
labelId='snapshot-select'
289-
id='snapshot-select'
290-
open={picOpen}
291-
onClose={picHandleClose}
292-
onOpen={picHandleOpen}
293-
value='' // snapshots
294-
onChange={handleActionChange}
295-
>
296-
{!comparison[snapshots] ? (
297-
<MenuItem>No snapshots available</MenuItem>
298-
) : (
299-
finalList.map((elem) => (
300-
<MenuItem value={elem}>{elem}</MenuItem>
301-
// <MenuItem value="test">{}</MenuItem>
302-
))
303-
)}
304-
</StyledSelect>
305-
</StyledFormControl>
306-
</div>
301+
{!comparison[snapshots] ? (
302+
<MenuItem>No snapshots available</MenuItem>
303+
) : (
304+
finalList.map((elem) => (
305+
<MenuItem value={elem}>{elem}</MenuItem>
306+
// <MenuItem value="test">{}</MenuItem>
307+
))
308+
)}
309+
</StyledSelect>
310+
</StyledFormControl>
311+
{/* </div> */}
307312
</div>
308313

309314
<svg ref={containerRef} width={width} height={height}>

src/app/containers/ActionContainer.tsx

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { emptySnapshots, changeView, changeSlider } from '../actions/actions';
99
import { useStoreContext } from '../store';
1010
import RouteDescription from '../components/RouteDescription';
1111
import { Obj } from '../FrontendTypes';
12+
import { Button } from '@mui/material';
1213

1314
/*
1415
This file renders the 'ActionContainer'. The action container is the leftmost column in the application. It includes the button that shrinks and expands the action container, a dropdown to select the active site, a clear button, the current selected Route, and a list of selectable snapshots with timestamps.
@@ -24,7 +25,6 @@ const resetSlider = () => {
2425
}
2526
};
2627

27-
2828
function ActionContainer(props): JSX.Element {
2929
const [{ tabs, currentTab, port }, dispatch] = useStoreContext(); // we destructure the returned context object from the invocation of the useStoreContext function. Properties not found on the initialState object (dispatch) are from the useReducer function invocation in the App component
3030
const { currLocation, hierarchy, sliderIndex, viewIndex } = tabs[currentTab]; // we destructure the currentTab object
@@ -57,7 +57,8 @@ function ActionContainer(props): JSX.Element {
5757
obj.stateSnapshot.children[0].state && // with a 'state'
5858
obj.stateSnapshot.children[0].name // and a 'name'
5959
) {
60-
const newObj: Record<string, unknown> = { // we create a new Record object (whose property keys are Keys and whose property values are Type. This utility can be used to map the properties of a type to another type) and populate it's properties with relevant values from our argument 'obj'.
60+
const newObj: Record<string, unknown> = {
61+
// we create a new Record object (whose property keys are Keys and whose property values are Type. This utility can be used to map the properties of a type to another type) and populate it's properties with relevant values from our argument 'obj'.
6162
index: obj.index,
6263
displayName: `${obj.name}.${obj.branch}`,
6364
state: obj.stateSnapshot.children[0].state,
@@ -71,7 +72,8 @@ function ActionContainer(props): JSX.Element {
7172
hierarchyArr.push(newObj); // we push our record object into 'hiearchyArr' defined on line 35
7273
}
7374

74-
if (obj.children) { // if argument has a 'children' array, we iterate through it and run 'displayArray' on each element
75+
if (obj.children) {
76+
// if argument has a 'children' array, we iterate through it and run 'displayArray' on each element
7577
obj.children.forEach((element): void => {
7678
displayArray(element);
7779
});
@@ -84,28 +86,27 @@ function ActionContainer(props): JSX.Element {
8486
// This function allows us to use our arrow keys to jump between snapshots. It passes an event and the index of each action-component. Using the arrow keys allows us to highligh snapshots and the enter key jumps to the selected snapshot
8587
function handleOnKeyDown(e: KeyboardEvent, i: number): void {
8688
let currIndex = i;
87-
88-
if (e.key === 'ArrowUp') { // up arrow key pressed
89+
90+
if (e.key === 'ArrowUp') {
91+
// up arrow key pressed
8992
currIndex -= 1;
9093
if (currIndex < 0) return;
9194
dispatch(changeView(currIndex));
92-
}
93-
94-
else if (e.key === 'ArrowDown') { // down arrow key pressed
95+
} else if (e.key === 'ArrowDown') {
96+
// down arrow key pressed
9597
currIndex += 1;
9698
if (currIndex > hierarchyArr.length - 1) return;
9799
dispatch(changeView(currIndex));
98-
}
99-
100-
else if (e.key === 'Enter') { // enter key pressed
100+
} else if (e.key === 'Enter') {
101+
// enter key pressed
101102
e.stopPropagation(); // prevents further propagation of the current event in the capturing and bubbling phases
102103
e.preventDefault(); // needed or will trigger onClick right after
103104
dispatch(changeSlider(currIndex));
104105
}
105106
}
106107

107108
// Sort hierarchyArr by index property of each object. This will be useful when later when we build our components so that our components will be displayed in index/chronological order
108-
hierarchyArr.sort((a:Obj, b:Obj):number => a.index - b.index);
109+
hierarchyArr.sort((a: Obj, b: Obj): number => a.index - b.index);
109110

110111
// we create a map of components that are constructed from "hierarchyArr's" elements/snapshots
111112
actionsArr = hierarchyArr.map(
@@ -168,11 +169,12 @@ function ActionContainer(props): JSX.Element {
168169
};
169170

170171
const routes: {} = {}; // Logic to create the route description components begin
171-
172-
for (let i = 0; i < actionsArr.length; i += 1) { // iterate through our actionsArr
172+
173+
for (let i = 0; i < actionsArr.length; i += 1) {
174+
// iterate through our actionsArr
173175
if (!routes.hasOwnProperty(actionsArr[i].props.routePath)) {
174-
routes[actionsArr[i].props.routePath] = [actionsArr[i]]; // if 'routes' doesn't have a property key that is the same as the current component at index[i] routePath we create an array with the first element being the component at index [i].
175-
} else {
176+
routes[actionsArr[i].props.routePath] = [actionsArr[i]]; // if 'routes' doesn't have a property key that is the same as the current component at index[i] routePath we create an array with the first element being the component at index [i].
177+
} else {
176178
routes[actionsArr[i].props.routePath].push(actionsArr[i]); // If it does exist, we push the component at index [i] to the apporpriate routes[routePath]
177179
}
178180
}
@@ -202,7 +204,8 @@ function ActionContainer(props): JSX.Element {
202204
<div className='action-button-wrapper'>
203205
<SwitchAppDropdown />
204206
<div className='action-component exclude'>
205-
<button
207+
<Button
208+
variant='contained'
206209
className='empty-button'
207210
onClick={() => {
208211
dispatch(emptySnapshots());
@@ -212,7 +215,7 @@ function ActionContainer(props): JSX.Element {
212215
type='button'
213216
>
214217
Clear
215-
</button>
218+
</Button>
216219
</div>
217220
{/* Rendering of route description components */}
218221
{Object.keys(routes).map((route, i) => (

src/app/styles/components/_buttons.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@
289289

290290
.series-options-container {
291291
display: flex;
292-
justify-content: space-between;
292+
justify-content: space-evenly;
293293
align-items: center;
294294
margin: 0 1rem;
295295
}
@@ -301,6 +301,7 @@
301301
.dropdown-and-delete-series-container {
302302
display: flex;
303303
align-items: center;
304+
justify-content: center;
304305
}
305306

306307
.close-button-container {

0 commit comments

Comments
 (0)