Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adaptable MOTD #639

Merged
merged 3 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,6 @@ workflow_main/notebooks/**

# SnapGene - temp files
static_data/flu/alignments/.sglock/**

# MOTD
MOTD*.html
1 change: 1 addition & 0 deletions config/config_flu_genbank.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ prod_hostname:

site_title: "Flu PathMut"
data_provider: "NCBI GenBank"
motd_url: "https://storage.googleapis.com/ve-public/MOTD.html"

# Default references for each subtype
default_references:
Expand Down
1 change: 1 addition & 0 deletions config/config_flu_gisaid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ prod_hostname:

site_title: "Flu PathMut"
data_provider: "GISAID"
motd_url: "https://storage.googleapis.com/ve-public/MOTD_FLU_GISAID.html"

# Default references for each subtype
default_references:
Expand Down
1 change: 1 addition & 0 deletions config/config_flu_gisaid_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ prod_hostname:

site_title: "Flu PathMut"
data_provider: "GISAID"
motd_url: "https://storage.googleapis.com/ve-public/MOTD_FLU_GISAID.html"

# Default references for each subtype
default_references:
Expand Down
1 change: 1 addition & 0 deletions config/config_rsv_custom.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ prod_hostname:

site_title: "RSV PathMut"
data_provider: "Custom"
motd_url: "https://storage.googleapis.com/ve-public/MOTD.html"

# Default references for each subtype
default_references:
Expand Down
1 change: 1 addition & 0 deletions config/config_rsv_genbank.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ prod_hostname:

site_title: "RSV PathMut"
data_provider: "NCBI GenBank"
motd_url: "https://storage.googleapis.com/ve-public/MOTD.html"

# Default references for each subtype
default_references:
Expand Down
1 change: 1 addition & 0 deletions config/config_sars2_alpha.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ prod_hostname:

site_title: "COVID CG - Alpha"
data_provider: "GISAID"
motd_url: "https://storage.googleapis.com/ve-public/MOTD_SARS2_GISAID.html"

# Default references for each subtype
default_references:
Expand Down
1 change: 1 addition & 0 deletions config/config_sars2_custom.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ prod_hostname:

site_title: "COVID CG"
data_provider: "Custom"
motd_url: "https://storage.googleapis.com/ve-public/MOTD.html"

# Default references for each subtype
default_references:
Expand Down
1 change: 1 addition & 0 deletions config/config_sars2_genbank.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ prod_hostname:

site_title: "COVID CG Genbank"
data_provider: "NCBI GenBank"
motd_url: "https://storage.googleapis.com/ve-public/MOTD_SARS2_GENBANK.html"

# Default references for each subtype
default_references:
Expand Down
1 change: 1 addition & 0 deletions config/config_sars2_genbank_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ prod_hostname:

site_title: "COVID CG Genbank"
data_provider: "NCBI GenBank"
motd_url: "https://storage.googleapis.com/ve-public/MOTD_SARS2_GENBANK.html"

# Default references for each subtype
default_references:
Expand Down
1 change: 1 addition & 0 deletions config/config_sars2_gisaid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ prod_hostname:

site_title: "COVID CG"
data_provider: "GISAID"
motd_url: "https://storage.googleapis.com/ve-public/MOTD_SARS2_GISAID.html"

# Default references for each subtype
default_references:
Expand Down
1 change: 1 addition & 0 deletions config/config_sars2_gisaid_private.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ prod_hostname:

site_title: "COVID CG"
data_provider: "GISAID"
motd_url: "https://storage.googleapis.com/ve-public/MOTD_SARS2_GISAID.html"

# Default references for each subtype
default_references:
Expand Down
13 changes: 4 additions & 9 deletions src/components/Pages/HomeTab.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React, { useState } from 'react';
import { observer } from 'mobx-react';
import { useStores } from '../../stores/connect';
import useDimensions from 'react-use-dimensions';

import ExternalLink from '../Common/ExternalLink';

import WalkthroughList from '../Example/WalkthroughList';
import SurveillancePlot from '../Viz/SurveillancePlot';
import GlobalSeqPlot from '../Viz/GlobalSeqPlot';
Expand All @@ -20,19 +19,15 @@ import {
} from './HomeTab.styles';

const HomeTab = observer(() => {
const { UIStore } = useStores();
const [ref, { width }] = useDimensions();
const [showBanner, setShowBanner] = useState(config['show_home_banner']);

return (
<HomeTabContainer ref={ref}>
{showBanner && (
{showBanner && UIStore.motd.length > 0 && (
<PubBanner>
<p>
COVID CG is{' '}
<ExternalLink href="https://doi.org/10.7554/eLife.63409">
published in eLife
</ExternalLink>
</p>
<div dangerouslySetInnerHTML={{ __html: UIStore.motd }} />
<CloseButton onClick={setShowBanner.bind(this, false)}>
Dismiss
</CloseButton>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Pages/HomeTab.styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const PubBanner = styled.div`
padding: 5px;
border-bottom: 1px solid #aaa;

p {
div {
margin: 0px;
margin-left: auto;
}
Expand Down
28 changes: 27 additions & 1 deletion src/stores/UIStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { observable, action, toJS } from 'mobx';
import { ASYNC_STATES, TABS } from '../constants/defs.json';
import { rootStoreInstance } from './rootStore';
import { updateURLFromParams } from '../utils/updateQueryParam';
import { config } from '../config';

export const initialValues = {
caseDataState: ASYNC_STATES.STARTED,
Expand Down Expand Up @@ -34,7 +35,32 @@ export class UIStore {
@observable activeTab = initialValues.activeTab;
@observable keysPressed = initialValues.keysPressed;

init() {}
@observable motd = '';

init() {
// Get the MOTD
fetch(config.motd_url, { cache: 'no-cache' })
.then((res) => {
if (!res.ok) {
throw res;
}
return res.text();
})
.then((data) => {
this.motd = data;
})
.catch((err) => {
let prefix = 'Error getting MOTD';
if (!(typeof err.text === 'function')) {
console.error(prefix, err);
} else {
err.text().then((errMsg) => {
console.error(prefix, errMsg);
});
}
this.motd = '';
});
}

@action
resetValues = (values) => {
Expand Down
Loading