Skip to content

Commit 086c081

Browse files
committed
feat: WIP update zoom each graph
1 parent 1b47302 commit 086c081

File tree

10 files changed

+240
-86
lines changed

10 files changed

+240
-86
lines changed

.github/workflows/e2e_testing.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ jobs:
1010
- name: Cypress run
1111
uses: cypress-io/github-action@v6
1212
with:
13-
build: npm run build
14-
start: npm start
13+
build: npm run --max_old_space_size=12288 build
14+
start: npm --max_old_space_size=12288 start
1515
browser: chrome

cypress.config.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
import { defineConfig } from "cypress";
22

33
export default defineConfig({
4+
pageLoadTimeout: 100000,
5+
requestTimeout: 100000,
6+
responseTimeout: 100000,
47
e2e: {
58
setupNodeEvents(on, config) {
69
// implement node event listeners here
710
},
8-
experimentalStudio: true
11+
experimentalStudio: true,
12+
pageLoadTimeout: 100000,
13+
requestTimeout: 100000,
14+
responseTimeout: 100000,
915
},
1016
});

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
},
4242
"scripts": {
4343
"start": "react-scripts --max_old_space_size=12288 start",
44-
"build": "react-scripts --max_old_space_size=4096 build",
44+
"build": "react-scripts --max_old_space_size=12288 build",
4545
"compile": "rm -rf dist && NODE_ENV=production babel --ignore tests,stories ./src --out-dir ./dist",
4646
"test": "react-scripts test --env=jsdom --verbose --testPathIgnorePatterns=./src/__tests__/fixtures/",
4747
"test:coverage": "CI=true react-scripts test --env=jsdom --verbose --testPathIgnorePatterns=./src/__tests__/fixtures/ --coverage",

src/components/cmd_bar/02_zoom.js

+4-12
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,18 @@ const styles = () => (
2222
);
2323

2424
const Zoom = ({
25-
classes, isfocusZoomSt, isfocusZoomSubViewSt, setUiSweepTypeAct, isSubView,
25+
classes, isfocusZoomSt, setUiSweepTypeAct,
2626
}) => {
27-
let onSweepZoomIn = () => setUiSweepTypeAct(LIST_UI_SWEEP_TYPE.ZOOMIN);
28-
let onSweepZoomReset = () => setUiSweepTypeAct(LIST_UI_SWEEP_TYPE.ZOOMRESET);
29-
const isZoomFocus = isSubView ? isfocusZoomSubViewSt : isfocusZoomSt;
30-
if (isSubView) {
31-
onSweepZoomIn = () => setUiSweepTypeAct(LIST_UI_SWEEP_TYPE.ZOOMIN_SUBVIEW);
32-
onSweepZoomReset = () => setUiSweepTypeAct(LIST_UI_SWEEP_TYPE.ZOOMRESET_SUBVIEW);
33-
}
27+
const onSweepZoomIn = () => setUiSweepTypeAct(LIST_UI_SWEEP_TYPE.ZOOMIN);
28+
const onSweepZoomReset = () => setUiSweepTypeAct(LIST_UI_SWEEP_TYPE.ZOOMRESET);
3429

3530
return (
3631
<span className={classes.group} data-testid="Zoom">
3732
<Tooltip title={<span className="txt-sv-tp">Zoom In</span>}>
3833
<MuButton
3934
className={
4035
classNames(
41-
focusStyle(isZoomFocus, classes),
36+
focusStyle(isfocusZoomSt, classes),
4237
'btn-sv-bar-zoomin',
4338
)
4439
}
@@ -66,7 +61,6 @@ const Zoom = ({
6661
const mapStateToProps = (state, _) => ( // eslint-disable-line
6762
{
6863
isfocusZoomSt: state.ui.sweepType === LIST_UI_SWEEP_TYPE.ZOOMIN,
69-
isfocusZoomSubViewSt: state.ui.sweepType === LIST_UI_SWEEP_TYPE.ZOOMIN_SUBVIEW,
7064
}
7165
);
7266

@@ -80,8 +74,6 @@ Zoom.propTypes = {
8074
classes: PropTypes.object.isRequired,
8175
isfocusZoomSt: PropTypes.bool.isRequired,
8276
setUiSweepTypeAct: PropTypes.func.isRequired,
83-
isSubView: PropTypes.bool.isRequired,
84-
isfocusZoomSubViewSt: PropTypes.bool.isRequired,
8577
};
8678

8779
export default compose(

src/components/cmd_bar/08_peak_group.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,20 @@ const styles = () => (
2323

2424
const PeakGroup = ({
2525
classes, feature, isSelectingGroupSt, setUiSweepTypeAct,
26+
graphIndex,
2627
}) => {
2728
const { operation } = feature;
2829
const { layout } = operation;
2930
if (!Format.isLCMsLayout(layout)) {
3031
return null;
3132
}
32-
const onSelectPeakGroup = () => setUiSweepTypeAct(LIST_UI_SWEEP_TYPE.PEAK_GROUP_SELECT);
33+
const onSelectPeakGroup = () => {
34+
const payload = {
35+
graphIndex,
36+
sweepType: LIST_UI_SWEEP_TYPE.PEAK_GROUP_SELECT,
37+
};
38+
setUiSweepTypeAct(payload);
39+
};
3340

3441
return (
3542
<span className={classes.group} data-testid="Zoom">
@@ -67,6 +74,7 @@ PeakGroup.propTypes = {
6774
feature: PropTypes.object.isRequired,
6875
isSelectingGroupSt: PropTypes.bool.isRequired,
6976
setUiSweepTypeAct: PropTypes.func.isRequired,
77+
graphIndex: PropTypes.number.isRequired,
7078
};
7179

7280
export default compose(

src/components/d3_line_rect/index.js

+110-26
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
1-
/* eslint-disable no-mixed-operators */
1+
/* eslint-disable no-mixed-operators, prefer-object-spread, react/function-component-definition */
22
import React from 'react';
33
import { connect } from 'react-redux';
4-
import { bindActionCreators } from 'redux';
4+
import { bindActionCreators, compose } from 'redux';
55
import PropTypes from 'prop-types';
66
import classNames from 'classnames';
7+
import withStyles from '@mui/styles/withStyles';
78
import {
89
Select, MenuItem, FormControl, InputLabel,
10+
Tooltip,
911
} from '@mui/material';
12+
import ZoomInOutlinedIcon from '@mui/icons-material/ZoomInOutlined';
13+
import FindReplaceOutlinedIcon from '@mui/icons-material/FindReplaceOutlined';
14+
import { MuButton, commonStyle, focusStyle } from '../cmd_bar/common';
1015

1116
import {
1217
Topic2Seed, ToThresEndPts,
1318
} from '../../helpers/chem';
1419
import { resetAll } from '../../actions/manager';
15-
import { selectUiSweep, scrollUiWheel, clickUiTarget } from '../../actions/ui';
20+
import {
21+
selectUiSweep, scrollUiWheel, clickUiTarget, setUiSweepType,
22+
} from '../../actions/ui';
1623
import { selectWavelength, changeTic } from '../../actions/hplcms';
1724
import { selectCurve } from '../../actions/curve';
1825
import RectFocus from './rect_focus';
@@ -25,12 +32,72 @@ import {
2532
} from '../common/draw';
2633
import { LIST_UI_SWEEP_TYPE, LIST_NON_BRUSH_TYPES } from '../../constants/list_ui';
2734
import { LIST_ROOT_SVG_GRAPH, LIST_BRUSH_SVG_GRAPH } from '../../constants/list_graph';
28-
import Zoom from '../cmd_bar/02_zoom';
35+
// import Zoom from '../cmd_bar/02_zoom';
2936
import PeakGroup from '../cmd_bar/08_peak_group';
3037

3138
const W = Math.round(window.innerWidth * 0.90 * 9 / 12); // ROI
3239
const H = Math.round(window.innerHeight * 0.90 * 0.85 / 3); // ROI
3340

41+
const styles = () => (
42+
Object.assign(
43+
{},
44+
commonStyle,
45+
)
46+
);
47+
48+
const zoomView = (classes, graphIndex, uiSt, zoomInAct) => {
49+
const onSweepZoomIn = () => {
50+
const payload = {
51+
graphIndex,
52+
sweepType: LIST_UI_SWEEP_TYPE.ZOOMIN,
53+
};
54+
zoomInAct(payload);
55+
};
56+
57+
const onSweepZoomReset = () => {
58+
const payload = {
59+
graphIndex,
60+
sweepType: LIST_UI_SWEEP_TYPE.ZOOMRESET,
61+
};
62+
zoomInAct(payload);
63+
};
64+
65+
const { zoom } = uiSt;
66+
const { sweepTypes } = zoom;
67+
68+
const isZoomFocus = sweepTypes[graphIndex] === LIST_UI_SWEEP_TYPE.ZOOMIN;
69+
70+
return (
71+
<span className={classes.group} data-testid="Zoom">
72+
<Tooltip title={<span className="txt-sv-tp">Zoom In</span>}>
73+
<MuButton
74+
className={
75+
classNames(
76+
focusStyle(isZoomFocus, classes),
77+
'btn-sv-bar-zoomin',
78+
)
79+
}
80+
onClick={onSweepZoomIn}
81+
>
82+
<ZoomInOutlinedIcon className={classNames(classes.icon, classes.iconWp)} />
83+
</MuButton>
84+
</Tooltip>
85+
<Tooltip title={<span className="txt-sv-tp">Reset Zoom</span>}>
86+
<MuButton
87+
className={
88+
classNames(
89+
'btn-sv-bar-zoomreset',
90+
)
91+
}
92+
onClick={onSweepZoomReset}
93+
>
94+
<FindReplaceOutlinedIcon className={classes.icon} />
95+
</MuButton>
96+
</Tooltip>
97+
</span>
98+
);
99+
};
100+
34101
const waveLengthSelect = (classes, hplcMsSt, updateWaveLengthAct) => {
35102
const { uvvis } = hplcMsSt;
36103
const { listWaveLength, selectedWaveLength } = uvvis;
@@ -128,15 +195,18 @@ class ViewerLineRect extends React.Component {
128195
const {
129196
entities, curveSt, seed, cLabel, xLabel, yLabel, feature,
130197
tTrEndPts, layoutSt,
131-
sweepExtentSt, isUiAddIntgSt, isUiNoBrushSt,
132-
isHidden, sweepExtentSubViewSt,
133-
resetAllAct,
198+
isUiAddIntgSt, isUiNoBrushSt,
199+
isHidden,
200+
resetAllAct, uiSt,
134201
} = this.props;
135202
drawDestroy(this.rootKlassMulti);
136203
drawDestroy(this.rootKlassLine);
137204
drawDestroy(this.rootKlassRect);
138205
resetAllAct(feature);
139206

207+
const { zoom } = uiSt;
208+
const { sweepExtent } = zoom;
209+
140210
const uvvisViewFeature = this.extractUvvisView();
141211
const { data } = uvvisViewFeature;
142212
const currentData = data[0];
@@ -151,7 +221,7 @@ class ViewerLineRect extends React.Component {
151221
filterPeak: [],
152222
tTrEndPts,
153223
isUiNoBrushSt: true,
154-
sweepExtentSt: sweepExtentSubViewSt,
224+
sweepExtentSt: sweepExtent[0],
155225
});
156226
drawLabel(this.rootKlassLine, null, 'M/Z', 'Intensity');
157227
drawDisplay(this.rootKlassLine, false);
@@ -165,7 +235,7 @@ class ViewerLineRect extends React.Component {
165235
filterSeed,
166236
tTrEndPts,
167237
layoutSt,
168-
sweepExtentSt,
238+
sweepExtentSt: sweepExtent[1],
169239
isUiAddIntgSt,
170240
isUiNoBrushSt,
171241
});
@@ -178,7 +248,7 @@ class ViewerLineRect extends React.Component {
178248
filterPeak: [],
179249
tTrEndPts,
180250
isUiNoBrushSt: true,
181-
sweepExtentSt: sweepExtentSubViewSt,
251+
sweepExtentSt: sweepExtent[2],
182252
});
183253
drawLabel(this.rootKlassRect, null, 'M/Z', 'Intensity');
184254
drawDisplay(this.rootKlassRect, false);
@@ -188,11 +258,14 @@ class ViewerLineRect extends React.Component {
188258
const {
189259
entities, curveSt, seed, cLabel, xLabel, yLabel,
190260
tTrEndPts, layoutSt,
191-
sweepExtentSt, isUiAddIntgSt, isUiNoBrushSt,
192-
isHidden, sweepExtentSubViewSt,
261+
isUiAddIntgSt, isUiNoBrushSt,
262+
isHidden, uiSt,
193263
} = this.props;
194264
this.normChange(prevProps);
195265

266+
const { zoom } = uiSt;
267+
const { sweepExtent } = zoom;
268+
196269
const uvvisViewFeature = this.extractUvvisView();
197270
if (uvvisViewFeature) {
198271
const { data } = uvvisViewFeature;
@@ -207,7 +280,7 @@ class ViewerLineRect extends React.Component {
207280
filterPeak: [],
208281
tTrEndPts,
209282
isUiNoBrushSt: true,
210-
sweepExtentSt: sweepExtentSubViewSt,
283+
sweepExtentSt: sweepExtent[0],
211284
});
212285
drawLabel(this.rootKlassLine, null, 'M/Z', 'Intensity');
213286
drawDisplay(this.rootKlassLine, false);
@@ -221,7 +294,7 @@ class ViewerLineRect extends React.Component {
221294
filterSeed,
222295
tTrEndPts,
223296
layoutSt,
224-
sweepExtentSt,
297+
sweepExtentSt: sweepExtent[1],
225298
isUiAddIntgSt,
226299
isUiNoBrushSt,
227300
});
@@ -242,7 +315,7 @@ class ViewerLineRect extends React.Component {
242315
filterPeak: [],
243316
tTrEndPts,
244317
isUiNoBrushSt: true,
245-
sweepExtentSt: sweepExtentSubViewSt,
318+
sweepExtentSt: sweepExtent[2],
246319
});
247320
drawLabel(this.rootKlassRect, `${pageValue} min`, xUnit, 'Intensity');
248321
drawDisplay(this.rootKlassRect, false);
@@ -296,29 +369,37 @@ class ViewerLineRect extends React.Component {
296369

297370
render() {
298371
const {
299-
hplcMsSt, selectWavelengthAct, updateTicAct, selectCurveAct,
300-
feature,
372+
classes, hplcMsSt, selectWavelengthAct, updateTicAct, selectCurveAct,
373+
feature, zoomInAct, uiSt,
301374
} = this.props;
302375
const handleTicChanged = (event) => {
303376
updateTicAct(event);
304377
selectCurveAct(event.target.value);
305378
};
306379
return (
307380
<div>
381+
{
382+
zoomView(classNames, 0, uiSt, zoomInAct)
383+
}
308384
<div style={{ textAlign: 'right' }}>
309385
{
310-
waveLengthSelect(classNames, hplcMsSt, selectWavelengthAct)
386+
waveLengthSelect(classes, hplcMsSt, selectWavelengthAct)
311387
}
312388
<div className={LIST_ROOT_SVG_GRAPH.LINE} />
313389
</div>
314-
<PeakGroup feature={feature} />
390+
<PeakGroup feature={feature} graphIndex={1} />
391+
{
392+
zoomView(classes, 1, uiSt, zoomInAct)
393+
}
315394
<div style={{ textAlign: 'right' }}>
316395
{
317-
ticSelect(classNames, hplcMsSt, handleTicChanged)
396+
ticSelect(classes, hplcMsSt, handleTicChanged)
318397
}
319398
<div className={LIST_ROOT_SVG_GRAPH.MULTI} />
320399
</div>
321-
<Zoom isSubView />
400+
{
401+
zoomView(classes, 2, uiSt, zoomInAct)
402+
}
322403
<div className={LIST_ROOT_SVG_GRAPH.RECT} />
323404
</div>
324405
);
@@ -330,8 +411,6 @@ const mapStateToProps = (state, props) => (
330411
curveSt: state.curve,
331412
seed: Topic2Seed(state, props),
332413
tTrEndPts: ToThresEndPts(state, props),
333-
sweepExtentSt: state.ui.sweepExtent,
334-
sweepExtentSubViewSt: state.ui.sweepExtentSubView,
335414
isUiAddIntgSt: state.ui.sweepType === LIST_UI_SWEEP_TYPE.INTEGRATION_ADD,
336415
isUiNoBrushSt: LIST_NON_BRUSH_TYPES.indexOf(state.ui.sweepType) < 0,
337416
uiSt: state.ui,
@@ -348,10 +427,12 @@ const mapDispatchToProps = (dispatch) => (
348427
selectWavelengthAct: selectWavelength,
349428
updateTicAct: changeTic,
350429
selectCurveAct: selectCurve,
430+
zoomInAct: setUiSweepType,
351431
}, dispatch)
352432
);
353433

354434
ViewerLineRect.propTypes = {
435+
classes: PropTypes.object.isRequired,
355436
uiSt: PropTypes.object.isRequired,
356437
curveSt: PropTypes.object.isRequired,
357438
entities: PropTypes.array.isRequired,
@@ -363,8 +444,6 @@ ViewerLineRect.propTypes = {
363444
layoutSt: PropTypes.string.isRequired,
364445
feature: PropTypes.object.isRequired,
365446
tTrEndPts: PropTypes.array.isRequired,
366-
sweepExtentSt: PropTypes.object.isRequired,
367-
sweepExtentSubViewSt: PropTypes.object.isRequired,
368447
isUiAddIntgSt: PropTypes.bool.isRequired,
369448
isUiNoBrushSt: PropTypes.bool.isRequired,
370449
resetAllAct: PropTypes.func.isRequired,
@@ -376,6 +455,11 @@ ViewerLineRect.propTypes = {
376455
selectWavelengthAct: PropTypes.func.isRequired,
377456
updateTicAct: PropTypes.func.isRequired,
378457
selectCurveAct: PropTypes.func.isRequired,
458+
zoomInAct: PropTypes.func.isRequired,
379459
};
380460

381-
export default connect(mapStateToProps, mapDispatchToProps)(ViewerLineRect);
461+
// export default connect(mapStateToProps, mapDispatchToProps)(ViewerLineRect);
462+
export default compose(
463+
connect(mapStateToProps, mapDispatchToProps),
464+
withStyles(styles),
465+
)(ViewerLineRect);

0 commit comments

Comments
 (0)