Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/#267-Tabs' into feature/#…
Browse files Browse the repository at this point in the history
…267-Tabs

# Conflicts:
#	js/components/datasets/redux/actions.js
#	js/components/datasets/redux/constants.js
#	js/components/datasets/redux/dispatchActions.js
#	js/components/datasets/redux/reducer.js
#	js/components/preview/Preview.js
  • Loading branch information
tibor-postek-m2ms committed May 11, 2020
2 parents ea8a158 + d0276f7 commit 16f776b
Show file tree
Hide file tree
Showing 34 changed files with 631 additions and 595 deletions.
13 changes: 12 additions & 1 deletion js/components/common/Surfaces/Panel/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { forwardRef, memo, useEffect, useState } from 'react';
import { Paper as MaterialPaper, makeStyles, Grid, IconButton, Typography } from '@material-ui/core';
import { Paper as MaterialPaper, makeStyles, Grid, IconButton, Typography, CircularProgress } from '@material-ui/core';
import ExpandMore from '@material-ui/icons/ExpandMore';
import ExpandLess from '@material-ui/icons/ExpandLess';

Expand Down Expand Up @@ -44,6 +44,9 @@ const useStyles = makeStyles(theme => ({
hidden: {
height: 0,
display: 'none'
},
loading: {
paddingTop: theme.spacing(2)
}
}));

Expand All @@ -60,6 +63,7 @@ export const Panel = memo(
onExpandChange,
children,
bodyOverflow,
isLoading,
...rest
},
ref
Expand Down Expand Up @@ -132,6 +136,13 @@ export const Panel = memo(
</Grid>
</div>
)}
{isLoading && (
<Grid container alignItems="center" justify="center" className={classes.loading}>
<Grid item>
<CircularProgress />
</Grid>
</Grid>
)}
{hasExpansion && <div className={expanded === true ? bodyClass : classes.hidden}>{children}</div>}
{!hasExpansion && <div className={bodyClass}>{children}</div>}
</MaterialPaper>
Expand Down
211 changes: 211 additions & 0 deletions js/components/datasets/redux/dispatchActions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,215 @@
import { deleteObject, loadObject, setOrientation } from '../../../reducers/ngl/dispatchActions';
import {
setFilter,
appendLigandList,
appendProteinList,
appendComplexList,
appendSurfaceList,
removeFromLigandList,
removeFromProteinList,
removeFromComplexList,
removeFromSurfaceList
} from './actions';
import { base_url } from '../../routes/constants';
import {
generateMoleculeId,
generateHitProteinObject,
generateComplexObject,
generateSurfaceObject,
generateMoleculeObject
} from '../../nglView/generatingObjects';
import { VIEWS } from '../../../constants/constants';
import { MOL_ATTRIBUTES } from '../../preview/molecule/redux/constants';

import { addMoleculeList } from './actions';

export const initializeDatasetMoleculeLists = moleculeList => (dispatch, getState) => {
console.log('initializing testing datasets');
const state = getState();
const customDatasets = state.datasetsReducers.datasets;
const testingMoleculeList = moleculeList.slice(0, 6);
// TODO temporarily, just adding testing data
customDatasets.forEach(dataset => {
dispatch(
addMoleculeList(
dataset.id,
(testingMoleculeList => {
const newList = [];
testingMoleculeList.forEach(molecule => {
// molecule.protein_code is used as prefix for element names in display controls
newList.push(Object.assign({}, molecule, { protein_code: dataset.id + '_' + molecule.id }));
});
return newList;
})(testingMoleculeList)
)
);
});
};

export const getListedMolecules = (object_selection, cached_mol_lists) => {
let molecules = [];
if ((object_selection || []).length) {
for (let molgroupId of object_selection) {
// Selected molecule groups
const molGroup = cached_mol_lists[molgroupId];
if (molGroup) {
molecules = molecules.concat(molGroup);
} else {
console.log(`Molecule group ${molgroupId} not found in cached list`);
}
}
}

return molecules;
};

export const initializeFilter = (object_selection, cached_mol_lists) => (dispatch, getState) => {
const state = getState();
if (!object_selection || !cached_mol_lists) {
object_selection = (() => {
let tmp = [];
state.datasetsReducers.datasets.forEach(dataset => {
tmp.push(dataset.id);
});
return tmp;
})(state.datasetsReducers.datasets);
cached_mol_lists = state.datasetsReducers.moleculeLists;
}

let initObject = state.selectionReducers.filter;

if (initObject === undefined) {
initObject = {
active: false,
predefined: 'none',
filter: {},
priorityOrder: MOL_ATTRIBUTES.map(molecule => molecule.key)
};
} else {
initObject = Object.assign({}, initObject);
console.log('using saved filter');
}

for (let attr of MOL_ATTRIBUTES) {
const lowAttr = attr.key.toLowerCase();
let minValue = -999999;
let maxValue = 0;
for (let molecule of getListedMolecules(object_selection, cached_mol_lists)) {
const attrValue = molecule[lowAttr];
if (attrValue > maxValue) maxValue = attrValue;
if (minValue === -999999) minValue = maxValue;
if (attrValue < minValue) minValue = attrValue;
}

initObject.filter[attr.key] = {
priority: 0,
order: 1,
minValue: minValue,
maxValue: maxValue,
isFloat: attr.isFloat
};
}
dispatch(setFilter(initObject));
return initObject;
};

/* ----------------------------------------------- */

export const addProtein = (stage, data, colourToggle, datasetID) => dispatch => {
dispatch(
loadObject(
Object.assign({ display_div: VIEWS.MAJOR_VIEW }, generateHitProteinObject(data, colourToggle, base_url)),
stage,
undefined,
null
)
).finally(() => {
const currentOrientation = stage.viewerControls.getOrientation();
dispatch(setOrientation(VIEWS.MAJOR_VIEW, currentOrientation));
});
dispatch(appendProteinList(datasetID, generateMoleculeId(data)));
};

export const removeProtein = (stage, data, colourToggle, datasetID) => dispatch => {
dispatch(
deleteObject(
Object.assign({ display_div: VIEWS.MAJOR_VIEW }, generateHitProteinObject(data, colourToggle, base_url)),
stage
)
);
dispatch(removeFromProteinList(datasetID, generateMoleculeId(data)));
};

export const addComplex = (stage, data, colourToggle, datasetID) => dispatch => {
dispatch(
loadObject(
Object.assign({ display_div: VIEWS.MAJOR_VIEW }, generateComplexObject(data, colourToggle, base_url)),
stage,
undefined,
null
)
).finally(() => {
const currentOrientation = stage.viewerControls.getOrientation();
dispatch(setOrientation(VIEWS.MAJOR_VIEW, currentOrientation));
});
dispatch(appendComplexList(datasetID, generateMoleculeId(data)));
};

export const removeComplex = (stage, data, colourToggle, datasetID) => dispatch => {
dispatch(
deleteObject(
Object.assign({ display_div: VIEWS.MAJOR_VIEW }, generateComplexObject(data, colourToggle, base_url)),
stage
)
);
dispatch(removeFromComplexList(datasetID, generateMoleculeId(data)));
};

export const addSurface = (stage, data, colourToggle, datasetID) => dispatch => {
dispatch(
loadObject(
Object.assign({ display_div: VIEWS.MAJOR_VIEW }, generateSurfaceObject(data, colourToggle, base_url)),
stage,
undefined,
null
)
).finally(() => {
const currentOrientation = stage.viewerControls.getOrientation();
dispatch(setOrientation(VIEWS.MAJOR_VIEW, currentOrientation));
});
dispatch(appendSurfaceList(datasetID, generateMoleculeId(data)));
};

export const removeSurface = (stage, data, colourToggle, datasetID) => dispatch => {
dispatch(
deleteObject(
Object.assign({ display_div: VIEWS.MAJOR_VIEW }, generateSurfaceObject(data, colourToggle, base_url)),
stage
)
);
dispatch(removeFromSurfaceList(datasetID, generateMoleculeId(data)));
};

export const addLigand = (stage, data, colourToggle, datasetID) => dispatch => {
dispatch(
loadObject(
Object.assign({ display_div: VIEWS.MAJOR_VIEW }, generateMoleculeObject(data, colourToggle)),
stage,
undefined,
null
)
).finally(() => {
const currentOrientation = stage.viewerControls.getOrientation();
dispatch(setOrientation(VIEWS.MAJOR_VIEW, currentOrientation));
});
dispatch(appendLigandList(datasetID, generateMoleculeId(data)));
};

export const removeLigand = (stage, data, colourToggle, datasetID) => dispatch => {
dispatch(deleteObject(Object.assign({ display_div: VIEWS.MAJOR_VIEW }, generateMoleculeObject(data)), stage));
dispatch(removeFromLigandList(datasetID, generateMoleculeId(data)));
};
import { deleteObject, loadObject, setOrientation } from '../../../reducers/ngl/dispatchActions';
import {
setFilter,
appendLigandList,
Expand Down
6 changes: 2 additions & 4 deletions js/components/landing/Landing.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
*/
import { Grid, Link } from '@material-ui/core';
import React, { memo, useContext, useEffect, useState } from 'react';
import TargetList from '../target/targetList';
//import SessionList from '../session/sessionList';
import { TargetList } from '../target/targetList';
import { connect } from 'react-redux';
import * as apiActions from '../../reducers/api/actions';
import * as selectionActions from '../../reducers/selection/actions';
Expand Down Expand Up @@ -50,10 +49,9 @@ const Landing = memo(
return (
<Grid container spacing={2}>
<Grid item xs={4}>
<TargetList key="TARGLIST" />
<TargetList />
</Grid>
<Grid item xs={8}>
{/*<SessionList />*/}
<Projects />
</Grid>
</Grid>
Expand Down
Loading

0 comments on commit 16f776b

Please sign in to comment.