Skip to content

Commit

Permalink
Fix Travis CI linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Vang Le-Quy committed May 30, 2020
1 parent 5521106 commit e260df2
Show file tree
Hide file tree
Showing 3 changed files with 235 additions and 236 deletions.
120 changes: 60 additions & 60 deletions src/components/download/downloadModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,17 @@ class DownloadModal extends React.Component {
};
};
this.dismissModal = this.dismissModal.bind(this);
let path = `${getServerAddress()}/getGenomeData`;
const path = `${getServerAddress()}/getGenomeData`;
this.state = {isGenomeAvailable: false};
const p = fetch(path, {method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ids: [], prefix: window.location.pathname})})
.then((res) => {
if (res.status !== 200) {
throw new Error(res.statusText);
}
res.json().then(json => {
this.setState({isGenomeAvailable: json.result});
});
});
fetch(path, {method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ids: [], prefix: window.location.pathname})})
.then((res) => {
if (res.status !== 200) {
throw new Error(res.statusText);
}
res.json().then((json) => {
this.setState({isGenomeAvailable: json.result});
});
});
}
componentDidMount() {
Mousetrap.bind('d', () => {
Expand All @@ -138,25 +138,25 @@ class DownloadModal extends React.Component {
}
formatPublications(pubs) {
return (
<span>
<span>
<ul>
{pubs.map((pub) => (
{pubs.map((pub) => (
<li key={pub.href}>
<a href={pub.href} target="_blank" rel="noreferrer noopener">
{pub.author}, {pub.title}, <i>{pub.journal}</i> ({pub.year})
</a>
<a href={pub.href} target="_blank" rel="noreferrer noopener">
{pub.author}, {pub.title}, <i>{pub.journal}</i> ({pub.year})
</a>
</li>
))}
</ul>
</span>
))}
</ul>
</span>
);
}
getFilePrefix() {
return "nextstrain_" +
window.location.pathname
.replace(/^\//, '') // Remove leading slashes
.replace(/:/g, '-') // Change ha:na to ha-na
.replace(/\//g, '_'); // Replace slashes with spaces
.replace(/^\//, '') // Remove leading slashes
.replace(/:/g, '-') // Change ha:na to ha-na
.replace(/\//g, '_'); // Replace slashes with spaces
}
makeTextStringsForSVGExport() {
const x = [];
Expand All @@ -176,7 +176,7 @@ class DownloadModal extends React.Component {
}
getNumUniqueAuthors(nodes) {
const authors = nodes.map((n) => getFullAuthorInfoFromNode(n))
.filter((a) => a && a.value);
.filter((a) => a && a.value);
const uniqueAuthors = new Set(authors.map((a) => a.value));
return uniqueAuthors.size;
}
Expand Down Expand Up @@ -233,21 +233,21 @@ class DownloadModal extends React.Component {
const buttonTextStyle = Object.assign({}, materialButton, {backgroundColor: "rgba(0,0,0,0)", paddingLeft: "10px", color: "white", minWidth: "300px", textAlign: "left" });
const buttonLabelStyle = { fontStyle: "italic", fontSize: "14px", color: "lightgray" };
return (
<div style={{display: "block", justifyContent: "space-around", marginLeft: "25px", width: "100%" }}>
<div style={{display: "block", justifyContent: "space-around", marginLeft: "25px", width: "100%" }}>
<div style={{ width: "100%" }}>
{buttons.map((data) => (
{buttons.map((data) => (
<div key={data[0]} onClick={data[3]} style={{cursor: 'pointer' }}>
{data[2]}
<button style={buttonTextStyle} name={data[0]}>
{data[0]}
</button>
<div style={{ display: "inline-block", height: "30px", verticalAlign: "top", paddingTop: "6px" }}>
<label style={buttonLabelStyle} htmlFor={data[0]}>{data[1]}</label>
</div>
{data[2]}
<button style={buttonTextStyle} name={data[0]}>
{data[0]}
</button>
<div style={{ display: "inline-block", height: "30px", verticalAlign: "top", paddingTop: "6px" }}>
<label style={buttonLabelStyle} htmlFor={data[0]}>{data[1]}</label>
</div>
))}
</div>
</div>
))}
</div>
</div>
);
}
dismissModal() {
Expand Down Expand Up @@ -279,42 +279,42 @@ class DownloadModal extends React.Component {

const meta = this.props.metadata;
return (
<div style={infoPanelStyles.modalContainer} onClick={this.dismissModal}>
<div style={infoPanelStyles.modalContainer} onClick={this.dismissModal}>
<div style={panelStyle} onClick={(e) => stopProp(e)}>
<p style={infoPanelStyles.topRightMessage}>
({t("click outside this box to return to the app")})
</p>
<p style={infoPanelStyles.topRightMessage}>
({t("click outside this box to return to the app")})
</p>

<div style={infoPanelStyles.modalSubheading}>
{meta.title} ({t("last updated")} {meta.updated})
</div>
<div style={infoPanelStyles.modalSubheading}>
{meta.title} ({t("last updated")} {meta.updated})
</div>

<div>
{this.createSummaryWrapper()}
</div>
<div style={infoPanelStyles.break}/>
{" " + t("A full list of sequence authors is available via the TSV files below")}
<div style={infoPanelStyles.break}/>
{getAcknowledgments({}, {preamble: {fontWeight: 300}, acknowledgments: {fontWeight: 300}})}
<div>
{this.createSummaryWrapper()}
</div>
<div style={infoPanelStyles.break}/>
{" " + t("A full list of sequence authors is available via the TSV files below")}
<div style={infoPanelStyles.break}/>
{getAcknowledgments({}, {preamble: {fontWeight: 300}, acknowledgments: {fontWeight: 300}})}

<div style={infoPanelStyles.modalSubheading}>
{t("Data usage policy")}
</div>
{t("Data usage part 1") + " " + t("Data usage part 2")}
<div style={infoPanelStyles.modalSubheading}>
{t("Data usage policy")}
</div>
{t("Data usage part 1") + " " + t("Data usage part 2")}

<div style={infoPanelStyles.modalSubheading}>
{t("Please cite the authors who contributed genomic data (where relevant), as well as")+":"}
</div>
{this.formatPublications(this.getRelevantPublications())}
<div style={infoPanelStyles.modalSubheading}>
{t("Please cite the authors who contributed genomic data (where relevant), as well as")+":"}
</div>
{this.formatPublications(this.getRelevantPublications())}


<div style={infoPanelStyles.modalSubheading}>
{t("Download data")}:
</div>
{this.downloadButtons()}
<div style={infoPanelStyles.modalSubheading}>
{t("Download data")}:
</div>
{this.downloadButtons()}

</div>
</div>
</div>
);
}
}
Expand Down
37 changes: 18 additions & 19 deletions src/components/download/helperFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { NODE_VISIBLE, getServerAddress } from "../../util/globals";
export const isPaperURLValid = (d) => {
return (
Object.prototype.hasOwnProperty.call(d, "paper_url") &&
!d.paper_url.endsWith('/') &&
d.paper_url !== "?"
!d.paper_url.endsWith('/') &&
d.paper_url !== "?"
);
};

Expand Down Expand Up @@ -109,21 +109,21 @@ export const authorTSV = (dispatch, filePrefix, tree) => {
export const strainTSV = (dispatch, filePrefix, nodes, colorings, selectedNodesOnly, nodeVisibilities) => {

/* traverse the tree & store tip information. We cannot write this out as we go as we don't know
exactly which header fields we want until the tree has been traversed. */
exactly which header fields we want until the tree has been traversed. */
const tipTraitValues = {};
const headerFields = ["Strain"];

for (const [i, node] of nodes.entries()) {
if (node.hasChildren) continue; /* we only consider tips */

if (selectedNodesOnly && nodeVisibilities &&
(nodeVisibilities[i] !== NODE_VISIBLE || !node.inView)) {continue;} /* skip unselected nodes if requested */
(nodeVisibilities[i] !== NODE_VISIBLE || !node.inView)) {continue;} /* skip unselected nodes if requested */

tipTraitValues[node.name] = {Strain: node.name};
if (!node.node_attrs) continue; /* if this is not set then we don't have any node info! */

/* collect values (as writable strings) of the same "traits" as can be viewed by the modal displayed
when clicking on tips. Note that "num_date", "author" and "vaccine" are considered seperately below */
when clicking on tips. Note that "num_date", "author" and "vaccine" are considered seperately below */
const nodeAttrsToIgnore = ["author", "div", "num_date", "vaccine", "accession"];
const traits = Object.keys(node.node_attrs).filter((k) => !nodeAttrsToIgnore.includes(k));
for (const trait of traits) {
Expand Down Expand Up @@ -203,7 +203,6 @@ export const strainTSV = (dispatch, filePrefix, nodes, colorings, selectedNodesO
* Create & write a FASTA file containing genome sequences of strains in the tree
*/
export const strainGenome = (dispatch, filePrefix, nodes, colorings, selectedNodesOnly, nodeVisibilities) => {
console.log('strainGenome');
const tipGenomes = [];

for (const [i, node] of nodes.entries()) {
Expand All @@ -214,18 +213,18 @@ export const strainGenome = (dispatch, filePrefix, nodes, colorings, selectedNod
tipGenomes.push(node.name);

}
let path = `${getServerAddress()}/getGenomeData`;
const p = fetch(path, {method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ids: tipGenomes, prefix: window.location.pathname})})
.then((res) => {
if (res.status !== 200) {
throw new Error(res.statusText);
}
res.text().then(body => {
const filename = `${filePrefix}${selectedNodesOnly ? "_selected_" : "_"}genomes.fasta`;
write(filename, MIME.text, body);
dispatch(infoNotification({message: `Genomes exported to ${filename}`}));
});
});
const path = `${getServerAddress()}/getGenomeData`;
fetch(path, {method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ids: tipGenomes, prefix: window.location.pathname})})
.then((res) => {
if (res.status !== 200) {
throw new Error(res.statusText);
}
res.text().then((body) => {
const filename = `${filePrefix}${selectedNodesOnly ? "_selected_" : "_"}genomes.fasta`;
write(filename, MIME.text, body);
dispatch(infoNotification({message: `Genomes exported to ${filename}`}));
});
});
};

export const newick = (dispatch, filePrefix, root, temporal) => {
Expand Down Expand Up @@ -257,7 +256,7 @@ const processXMLString = (input) => {
};

/* take the panels (see processXMLString for struct) and calculate the overall size of the SVG
as well as the offsets (x, y) to position panels appropriately within this */
as well as the offsets (x, y) to position panels appropriately within this */
const createBoundingDimensionsAndPositionPanels = (panels, panelLayout, numLinesOfText) => {
const padding = 50;
let width = 0;
Expand Down
Loading

0 comments on commit e260df2

Please sign in to comment.