Skip to content

Commit

Permalink
Fix sending the identity of the tree and subtree in the js files.
Browse files Browse the repository at this point in the history
The "node id" nid was written wrongly if we were referring to the root
(it would write "0," rather than "0").

This commit fixes #723
  • Loading branch information
jordibc committed Nov 3, 2023
1 parent 5ed8efa commit b577e19
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ete4/smartview/gui/static/js/contextmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async function add_node_options(box, name, properties, node_id) {
add_button("Download branch as newick", () => download_newick(node_id),
"Download subtree starting at this node as a newick file.",
"download", false);
const nid = get_tid() + "," + node_id;
const nid = get_tid() + (node_id.length > 0 ? ("," + node_id) : "");
const nseq = Number(await api(`/trees/${nid}/nseq`));
if (nseq > 0)
add_button("Download " + (nseq === 1 ? "sequence" : `leaf sequences (${nseq})`),
Expand Down
4 changes: 2 additions & 2 deletions ete4/smartview/gui/static/js/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ export { download_newick, download_seqs, download_svg, download_pdf };

// Download a file with the newick representation of the tree.
async function download_newick(node_id) {
const nid = get_tid() + (node_id ? "," + node_id : "");
const nid = get_tid() + (node_id.length > 0 ? ("," + node_id) : "");
const newick = await api(`/trees/${nid}/newick`);
download(view.tree + ".tree", "data:text/plain;charset=utf-8," + newick);
}


async function download_seqs(node_id) {
const nid = get_tid() + (node_id ? "," + node_id : "");
const nid = get_tid() + (node_id.length > 0 ? ("," + node_id) : "");
const fasta = await api(`/trees/${nid}/seq`);
download(view.tree + ".fasta", "data:text/plain;charset=utf-8," + fasta);
}
Expand Down
2 changes: 1 addition & 1 deletion ete4/smartview/gui/static/js/gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ async function on_box_click(event, box, node_id, properties) {
activate_node(node_id, properties, "nodes")
}
else if (event.shiftKey && node_id.length) {
const nid = get_tid() + "," + node_id;
const nid = get_tid() + (node_id.length > 0 ? ("," + node_id) : "");
const active = await api(`/trees/${nid}/active`);
if (active === "active_clade")
deactivate_node(node_id, "clades")
Expand Down

0 comments on commit b577e19

Please sign in to comment.