Skip to content

Commit

Permalink
Merge pull request #63 from janash/dec-2023-edits
Browse files Browse the repository at this point in the history
Dec 2023 edits
  • Loading branch information
janash authored Jan 15, 2024
2 parents 958582d + 3acb3a5 commit b619707
Show file tree
Hide file tree
Showing 7 changed files with 188 additions and 269 deletions.
8 changes: 8 additions & 0 deletions frontend/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ const theme = createTheme({
main: "#393536",
}
},

typography: {
h2: {
textAlign: 'center',
paddingBottom: '3rem',
paddingTop: '3rem',
},
}
});

const Search = lazy(() => import('./pages/SearchHook'));
Expand Down
18 changes: 15 additions & 3 deletions frontend/src/common/MoleculeUtils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ function dynamicGrid( svgs ) {
<Item sx={{border: 3, borderColor: '#ed1c24'}}>
<img alt='' src={`data:image/svg+xml;utf8,${encodeURIComponent(result.svg)}`} />
<Typography sx={{ wordBreak: "break-word" }}> <strong>SMILES: </strong> { result.smiles }</Typography>
<Button variant="contained" sx={{ m: 0.5 }} onClick={() => moleculePage(result.molecule_id)}>View Details</Button>
<Button variant="contained" sx={{ m: 0.5 }} onClick={() => moleculePage(result.molecule_id)}>
<span style={{ textTransform: 'capitalize', fontSize: '16px' }}>
View Details
</span>
</Button>
</Item>
// False condition - render Item without border if distance is not 0.
:
Expand All @@ -85,8 +89,16 @@ function dynamicGrid( svgs ) {
<strong>Distance: </strong> {result.distance.toFixed(2)}
</Typography>
)}
<Button variant="contained" sx={{ m: 0.5 }} onClick={() => moleculePage(result.molecule_id)}>View Details</Button>
<Button variant="contained" sx={{ m: 0.5 }} onClick={() => neighborPage(result.molecule_id)}>View Neighbors</Button>
<Button variant="contained" sx={{ m: 0.5 }} onClick={() => moleculePage(result.molecule_id)}>
<span style={{ textTransform: 'capitalize', fontSize: '16px' }}>
View Details
</span>
</Button>
<Button variant="contained" sx={{ m: 0.5 }} onClick={() => neighborPage(result.molecule_id)}>
<span style={{ textTransform: 'capitalize', fontSize: '16px' }}>
View Neighbors
</span>
</Button>
</Item>}
</Grid>
))
Expand Down
241 changes: 127 additions & 114 deletions frontend/src/common/Navbar.jsx
Original file line number Diff line number Diff line change
@@ -1,134 +1,147 @@
import React from 'react';
import * as React from 'react';
import PropTypes from 'prop-types';
import AppBar from '@mui/material/AppBar';
import Box from '@mui/material/Box';
import Toolbar from '@mui/material/Toolbar';
import CssBaseline from '@mui/material/CssBaseline';
import Divider from '@mui/material/Divider';
import Drawer from '@mui/material/Drawer';
import IconButton from '@mui/material/IconButton';
import Typography from '@mui/material/Typography';
import Menu from '@mui/material/Menu';
import List from '@mui/material/List';
import ListItem from '@mui/material/ListItem';
import ListItemButton from '@mui/material/ListItemButton';
import ListItemText from '@mui/material/ListItemText';
import MenuIcon from '@mui/icons-material/Menu';
import Container from '@mui/material/Container';
import Toolbar from '@mui/material/Toolbar';
import Typography from '@mui/material/Typography';
import Button from '@mui/material/Button';
import MenuItem from '@mui/material/MenuItem';
import { NavLink, useLocation } from 'react-router-dom';

import '../assets/custom.css'
import { Link } from 'react-router-dom';

import { Link } from 'react-router-dom'
import OriginalKraken from './OriginalKraken.js'

import OriginalKraken from './OriginalKraken.js';
const drawerWidth = 240;

const ResponsiveAppBar = ({pages}) => {
const [anchorElNav, setAnchorElNav] = React.useState(null);
function DrawerAppBar(props) {
const { window, pages } = props;
const [mobileOpen, setMobileOpen] = React.useState(false);

const handleOpenNavMenu = (event) => {
setAnchorElNav(event.currentTarget);
const handleDrawerToggle = () => {
setMobileOpen(prevState => !prevState);
};

const handleCloseNavMenu = () => {
setAnchorElNav(null);
};
const location = useLocation();

return (
<AppBar position="static" sx={{mb: 2}} >
<Container maxWidth="xl">
<Toolbar disableGutters>
<OriginalKraken sx={{ display: { xs: 'none', md: 'flex' }, mr: 1, fontSize: '60px' }} />
<Typography
variant="h6"
noWrap
component={Link}
to="/"
sx={{
display: { xs: 'none', md: 'flex' },
fontFamily: 'monospace',
fontWeight: 700,
letterSpacing: '.3rem',
color: 'inherit',
textDecoration: 'none',
}}
>
kraken
</Typography>
const getButtonStyles = (itemPath) => {
const isHome = (location.pathname === '/' && itemPath === 'home') || location.pathname === `/${itemPath}`;
return isHome ? { backgroundColor: '#ed1c2477', color: '#fff' } : { color: '#fff' };
};


<Box sx={{ flexGrow: 1, display: { xs: 'flex', md: 'none' } }}>
<IconButton
size="large"
aria-label="account of current user"
aria-controls="menu-appbar"
aria-haspopup="true"
onClick={handleOpenNavMenu}
color="inherit"
>
<MenuIcon />
</IconButton>
<Menu
id="menu-appbar"
anchorEl={anchorElNav}
anchorOrigin={{
vertical: 'bottom',
horizontal: 'left',
}}
keepMounted
transformOrigin={{
vertical: 'top',
horizontal: 'left',
}}
open={Boolean(anchorElNav)}
onClose={handleCloseNavMenu}
sx={{
display: { xs: 'block', md: 'none' },
}}
>
{Object.keys(pages).map((page) => (
<MenuItem id={page} key={page} onClick={handleCloseNavMenu}>
<Link to={page.toLowerCase()} id={page} className="NavbarLink"><Typography textAlign="center">{page}</Typography></Link>
</MenuItem>
))}
</Menu>
</Box>
<OriginalKraken sx={{ display: { xs: 'flex', md: 'none' }, mr: 1, fontSize: '60px' }} />
<Typography
variant="h5"
noWrap
component={Link}
to="/"
sx={{
mr: 2,
display: { xs: 'flex', md: 'none' },
flexGrow: 1,
fontFamily: 'monospace',
fontWeight: 700,
letterSpacing: '.3rem',
color: 'inherit',
textDecoration: 'none',
}}
const drawer = (
<Box onClick={handleDrawerToggle} sx={{ textAlign: 'center' }}>
<Typography variant="h6" sx={{ my: 2 }}>
kraken
</Typography>
<Divider />
<List>
{Object.keys(pages).map(item => {
const itemPath = item.replace(" ", "_").toLowerCase();
return (
<ListItem key={item} disablePadding>
<NavLink
to={itemPath}
style={{ textDecoration: 'none', color: 'inherit' }}
>
kraken
</Typography>
<Box sx={{ flexGrow: 1, display: { xs: 'none', md: 'flex' } }}>
{Object.keys(pages).map((page) => (
<Link to={page.replace(" ", "_").toLowerCase()} id={page.replace(" ", "_").toLowerCase()} className="NavbarLink" style={{ textDecoration: 'none' }} >
<Button
key={page}
onClick={handleCloseNavMenu}
sx={{ my: 2, color: 'white', display: 'block' }}
>
{page}
</Button>
</Link>
))}
<ListItemButton sx={{ textAlign: 'center' }}>
<ListItemText primary={item} />
</ListItemButton>
</NavLink>
</ListItem>
);
})}
<ListItem key="documentation" disablePadding>
<Link to="/docs/" id="documentation" className="NavbarLink" reloadDocument style={{ textDecoration: 'none' }} >
<ListItemButton sx={{ textAlign: 'center' }}>
<ListItemText primary="Documentation" />
</ListItemButton>
</Link>
</ListItem>
</List>
</Box>
);

<Link to="/docs/" id="documentation" className="NavbarLink" reloadDocument style={{ textDecoration: 'none' }} >
<Button
key="documentation"
sx={{ my: 2, color: 'white', display: 'block' }}>
Documentation
</Button>
</Link>
const container = window !== undefined ? () => window().document.body : undefined;

</Box>
</Toolbar>
</Container>
return (
<Box sx={{ display: 'flex' }}>
<CssBaseline />
<AppBar component="nav">
<Toolbar>
<OriginalKraken sx={{ display: { xs: 'none', md: 'flex' }, mr: 1, fontSize: '60px' }} />
<IconButton
color="inherit"
aria-label="open drawer"
edge="start"
onClick={handleDrawerToggle}
sx={{ mr: 2, display: { sm: 'none' } }}
>
<MenuIcon />
</IconButton>
<Typography
variant="h6"
component="div"
sx={{ flexGrow: 1, display: { xs: 'none', sm: 'block' } }}
>
kraken
</Typography>
<Box sx={{ display: { xs: 'none', sm: 'block' } }}>
{Object.keys(pages).map(item => {
const itemPath = item.replace(" ", "_").toLowerCase();
return (
<NavLink
to={itemPath}
key={item}
style={{ textDecoration: 'none' }}
>
<Button sx={getButtonStyles(itemPath)}>
<span style={{ textTransform: 'capitalize', fontSize: '16px' }}>{item}</span>
</Button>
</NavLink>
);
})}
<Link to="/docs/" id="documentation" className="NavbarLink" reloadDocument style={{ textDecoration: 'none' }} >
<Button sx={getButtonStyles('documentation')}>
<span style={{ textTransform: 'capitalize', fontSize: '16px' }}>Documentation</span>
</Button>
</Link>
</Box>
</Toolbar>
</AppBar>
<nav>
<Drawer
container={container}
variant="temporary"
open={mobileOpen}
onClose={handleDrawerToggle}
ModalProps={{
keepMounted: true, // Better open performance on mobile.
}}
sx={{
display: { xs: 'block', sm: 'none' },
'& .MuiDrawer-paper': { boxSizing: 'border-box', width: drawerWidth },
}}
>
{drawer}
</Drawer>
</nav>
<Toolbar />
</Box>
);
}

DrawerAppBar.propTypes = {
window: PropTypes.func, // Injected by the documentation to work in an iframe. You won't need it on your project.
};
export default ResponsiveAppBar;

export default DrawerAppBar;
2 changes: 2 additions & 0 deletions frontend/src/components/KetcherPopup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export default function FullScreenDialog({ ketcherCallBack }) {
return (
<div>
<Button variant="contained" sx={{ mb: 5 }} onClick={handleClickOpen}>
<span style={{ textTransform: 'capitalize', fontSize: '16px' }}>
Open Molecular Sketcher
</span>
</Button>
<Dialog
fullWidth={true}
Expand Down
20 changes: 16 additions & 4 deletions frontend/src/pages/Neighbors.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export default function NeighborSearchHook () {
return (
<Container maxWidth="lg">
<Typography variant="h2" textAlign="center">Neighbor Search</Typography>
<Box sx={{p:4}}>
<Box sx={{pb:1}}>
<Typography textAlign="center">Neighbors are identified by Euclidian distance in 4 principal component space.</Typography>
</Box>

Expand Down Expand Up @@ -210,8 +210,16 @@ export default function NeighborSearchHook () {
<Box display="flex" justifyContent="center">
{ (isLoading || isLoadingMore) ? <CircularProgress /> :
<>
<Button disabled={updatedParameters} variant="contained" sx={{ my: 3 }} onClick={ () => loadMore() } >Load More</Button>
<Button variant="contained" sx={{ my: 3, ml: 2 }} onClick={() => downloadMoleculeData(moleculeIDs, "pca_neighbors")}>Download Search Results</Button>
<Button disabled={updatedParameters} variant="contained" sx={{ my: 3 }} onClick={ () => loadMore() } >
<span style={{ textTransform: 'capitalize', fontSize: '16px' }}>
Load More
</span>
</Button>
<Button variant="contained" sx={{ my: 3, ml: 2 }} onClick={() => downloadMoleculeData(moleculeIDs, "pca_neighbors")}>
<span style={{ textTransform: 'capitalize', fontSize: '16px' }}>
Download Search Results
</span>
</Button>

</>
}
Expand All @@ -232,7 +240,11 @@ export default function NeighborSearchHook () {
{isLoadingMore ? (
<CircularProgress />
) : (
<Button disabled={updatedParameters} variant="contained" sx={{ m: 0.5 }} onClick={ () => loadMore() }>Load More</Button>
<Button disabled={updatedParameters} variant="contained" sx={{ m: 0.5 }} onClick={ () => loadMore() }>
<span style={{ textTransform: 'capitalize', fontSize: '16px' }}>
Load More
</span>
</Button>
)}
</Box>
}
Expand Down
Loading

0 comments on commit b619707

Please sign in to comment.