Skip to content

Commit

Permalink
Dev (#442)
Browse files Browse the repository at this point in the history
* fix: use correct indication attribute name (#408)

* fix: add URL cites back (#409)

* add release information component for footer

* run prettier

* cleanup: make about links consistent (#413)

* make footer no longer sticky

* fix: correct source versioning (#421)

* fix: clean up GtoP import (#419)

* fix: use latest GO address (#424)

* feat: bump drugbank version (#422)

* feat: alphabetize sources

* refactor: alphabetize sources

* style: running prettier to prettify the sort data function

* fix: sort on pmid and source columns

* feat: add sources to interaction page

* feat: reduce precision of interaction score on interaction page to 2 decimal places

---------

Co-authored-by: James Stevenson <james.stevenson@nationwidechildrens.org>
Co-authored-by: Adam Coffman <acoffman@wustl.edu>
  • Loading branch information
3 people authored Oct 10, 2023
1 parent b00b120 commit ace432d
Show file tree
Hide file tree
Showing 26 changed files with 439 additions and 175 deletions.
15 changes: 11 additions & 4 deletions client/src/components/Browse/Sources/BrowseSources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,17 @@ export const BrowseSources = () => {
'POTENTIALLY_DRUGGABLE'
);

let geneSources = geneData?.sources?.nodes;
let drugSources = drugData?.sources?.nodes;
let interactionSources = interactionData?.sources?.nodes;
let potentiallyDruggableSources = potentiallyDruggableData?.sources?.nodes;
const getSortedData = (data: any) => {
return data?.sources?.nodes?.sort(
(a: { sourceDbName: string }, b: { sourceDbName: any }) =>
a.sourceDbName.localeCompare(b.sourceDbName)
);
};

let geneSources = getSortedData(geneData);
let drugSources = getSortedData(drugData);
let interactionSources = getSortedData(interactionData);
let potentiallyDruggableSources = getSortedData(potentiallyDruggableData);

const sectionsMap = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import AccordionSummary from '@mui/material/AccordionSummary';
import AccordionDetails from '@mui/material/AccordionDetails';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import ArrowRightIcon from '@mui/icons-material/ArrowRight';
import { truncateDecimals } from 'utils/format';

export const InteractionRecord: React.FC = () => {
const interactionId = useParams().id;
Expand Down Expand Up @@ -61,7 +62,7 @@ export const InteractionRecord: React.FC = () => {
Interaction Score:
</TableCell>
<TableCell className="attribute-value">
{data?.interaction?.interactionScore}
{truncateDecimals(data?.interaction?.interactionScore, 2)}
</TableCell>
</TableRow>

Expand Down Expand Up @@ -116,6 +117,30 @@ export const InteractionRecord: React.FC = () => {
</Box>
),
},
{
name: 'Sources',
sectionContent: (
<Box className="box-content">
<Table>
<TableBody>
{data?.interaction?.sources.length
? data?.interaction?.sources?.map(
(source: any, index: number) => {
return (
<TableRow key={index}>
<TableCell className="attribute-name">
{source.fullName}
</TableCell>
</TableRow>
);
}
)
: noData}
</TableBody>
</Table>
</Box>
),
},
];

return (
Expand Down
2 changes: 0 additions & 2 deletions client/src/components/Layout/MainLayout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ header {

footer {
background-color: var(--theme-primary);
position: fixed;
bottom: 0;
color: white;
margin-top: auto;
width: 100%;
Expand Down
38 changes: 22 additions & 16 deletions client/src/components/Layout/MainLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { GlobalClientContext } from 'stores/Global/GlobalClient';
import './MainLayout.scss';
import { Box, Button, IconButton, Menu, MenuItem } from '@mui/material';
import HighlightOffIcon from '@mui/icons-material/HighlightOff';
import ReleaseInformation from 'components/Shared/ReleaseInformation/ReleaseInformation';

type MainLayoutProps = {
children: React.ReactNode;
Expand Down Expand Up @@ -80,24 +81,29 @@ const Header: React.FC = () => {
};

const Footer: React.FC = () => {
const { dispatch } = useContext(GlobalClientContext);
const { state, dispatch } = useContext(GlobalClientContext);

return (
<footer>
Disclaimer: This resource is intended for purely research purposes. It
should not be used for emergencies or medical or professional advice.
<IconButton
style={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
marginLeft: '10px',
fontSize: '25px',
}}
onClick={() => dispatch({ type: ActionTypes.HideDisclaimer })}
>
<HighlightOffIcon />
</IconButton>
{state.themeSettings.showDisclaimer && (
<div>
Disclaimer: This resource is intended for purely research purposes. It
should not be used for emergencies or medical or professional advice.
<IconButton
style={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
marginLeft: '10px',
fontSize: '25px',
}}
onClick={() => dispatch({ type: ActionTypes.HideDisclaimer })}
>
<HighlightOffIcon />
</IconButton>
</div>
)}
<ReleaseInformation />
</footer>
);
};
Expand Down Expand Up @@ -127,7 +133,7 @@ export const MainLayout = ({ children }: MainLayoutProps) => {
<div className="content-container">
<Box className="content">{children}</Box>
</div>
{state.themeSettings.showDisclaimer && <Footer />}
<Footer />
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ export const InteractionTable: React.FC<Props> = ({
headerName: 'PMIDs',
flex: 0.4,
minWidth: 0,
valueGetter: (params: any) => {
return params.row.pmids?.length;
},
renderCell: (params: any) => (
<PublicationsTooltip
displayText={params.row.pmids?.length}
Expand All @@ -127,6 +130,9 @@ export const InteractionTable: React.FC<Props> = ({
headerName: 'Sources',
flex: 0.4,
minWidth: 0,
valueGetter: (params: any) => {
return params.row.sources?.length;
},
renderCell: (params: any) => (
<SourcesTooltip
hoverTexts={params.row.sources}
Expand Down Expand Up @@ -200,8 +206,6 @@ export const InteractionTable: React.FC<Props> = ({
}
);

console.log(rows);

return !isLoading ? (
<Box className="interaction-table-container">
<Box width="100%" height="500px" display="flex">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.release-info {
font-size: 16px;

a {
color: white;
text-decoration: underline;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import './ReleaseInformation.scss';
import React, { useState, useEffect } from 'react';

const ReleaseInformation: React.FC = () => {
interface GithubRelease {
html_url: string;
name: string;
published_at: string;
}

const [currentRelease, setCurrentRelease] = useState<
GithubRelease | undefined
>(undefined);

const fetchRelease = async () => {
const response = await fetch(
'https://api.github.com/repos/dgidb/dgidb-v5/releases?per_page=1'
);
if (response.ok) {
const body = await response.json();
setCurrentRelease(body[0]);
} else {
setCurrentRelease(undefined);
}
};

useEffect(() => {
fetchRelease();
}, []);

return (
<div>
{currentRelease && (
<div className="release-info">
DGIdb {currentRelease.name} (
{new Date(currentRelease.published_at).toLocaleString().split(',')[0]}
)&nbsp; &bull; &nbsp;
<a href={currentRelease.html_url} target="_blank">
Release Notes
</a>
&nbsp; &bull; &nbsp;
<a href="https://github.com/dgidb/dgidb-v5/releases/" target="_blank">
History
</a>
</div>
)}
</div>
);
};

export default ReleaseInformation;
3 changes: 3 additions & 0 deletions client/src/hooks/queries/useGetInteractionRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ const getInteractionRecordQuery = gql`
pmid
citation
}
sources {
fullName
}
interactionAttributes {
name
value
Expand Down
1 change: 1 addition & 0 deletions client/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
--header-gradient-2: #180a20;
--logo-gradient-1: #f7f7f8;
--logo-gradient-2: #ada7bd;
--link: #2589bd;
}

[data-theme='light-home'] {
Expand Down
21 changes: 13 additions & 8 deletions client/src/pages/About/About.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
.about-page-container {
a {
color: var(--link) !important;
}

h3 {
font-size: 2rem;
margin-bottom: 15px;
Expand Down Expand Up @@ -42,17 +46,12 @@
}

.about-citation {
color: #8075ff;
font-size: 0.8rem;
font-weight: 400;
}
}
}

.ant-anchor-link-title {
color: var(--text-content) !important;
}

span {
color: red !important;
}
Expand All @@ -61,6 +60,12 @@
font-size: 0.89rem;
}

.publications-section-container {
.about-pub-item {
padding-bottom: 0.5em;
}
}

.contact-section-container {
.left-section {
float: left;
Expand All @@ -75,6 +80,9 @@
.spacing {
min-height: 700px;
}
svg {
fill: var(--text-primary);
}
}

.faq-section-container {
Expand All @@ -91,8 +99,5 @@
li {
list-style-type: none;
}
a {
color: var(--text-accent);
}
}
}
Loading

0 comments on commit ace432d

Please sign in to comment.