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

Addition of a new SNP Distance Search function for the Cov2Tree #592

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
26 changes: 26 additions & 0 deletions taxonium_component/src/components/SearchPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import classNames from "classnames";

import SearchDisplayToggle from "./SearchDisplayToggle";

import SNPOutputModal from "./snpModal";

const prettify_x_types = { x_dist: "Distance", x_time: "Time" };

const formatNumber = (num) => {
Expand Down Expand Up @@ -72,6 +74,14 @@ function SearchPanel({
}, [selectedDetails.nodeDetails]);

const [listOutputModalOpen, setListOutputModalOpen] = useState(false);
const [snpSearchModalOpen, setSnpSearchModalOpen] = useState(false);
const [showSNPButton, setShowSNPButton] = useState(false);
useEffect(() => {
// Check if the current URL includes "api.cov2tree.org"
if (window.location.href.includes("api.cov2tree.org")) {
setShowSNPButton(true);
}
}, []);

const handleDownloadJson = () => {
if (selectedDetails.nodeDetails) {
Expand Down Expand Up @@ -418,6 +428,22 @@ function SearchPanel({
<RiAddCircleLine className="mr-1 h-4 w-4 text-gray-500" />
<span>Add a new search</span>
</Button>
{showSNPButton && (
<Button
className="mx-auto flex items-center font-medium leading-6 mt-2"
style={{ transform: "translateY(-10px) translateX(10px)" }}
onClick={() => setSnpSearchModalOpen(true)}
title="Search for samples within a given SNP distance of the inputted node"
>
SNP Distance Search
</Button>
)}
{showSNPButton && (
<SNPOutputModal
snpOutputModalOpen={snpSearchModalOpen}
setSnpOutputModalOpen={setSnpSearchModalOpen}
/>
)}
</div>
</div>
{selectedDetails.nodeDetails && (
Expand Down
Loading
Loading