Skip to content

Commit

Permalink
proxy input (#563)
Browse files Browse the repository at this point in the history
* update

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* update

* update

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* remove check yaml

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
theosanderson and pre-commit-ci[bot] authored Nov 28, 2023
1 parent 74989f9 commit 178ae01
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 40 deletions.
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ repos:
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v2.7.1" # Use the sha / tag you want to point at
Expand Down
38 changes: 19 additions & 19 deletions proxy/kube.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Deployment
metadata:
name: taxonium-proxy-deployment
spec:
replicas: 1 # Number of replicas
replicas: 1 # Number of replicas
selector:
matchLabels:
app: taxonium-proxy
Expand All @@ -13,10 +13,10 @@ spec:
app: taxonium-proxy
spec:
containers:
- name: taxonium-proxy
image: theosanderson/taxonium_proxy:master
ports:
- containerPort: 3000
- name: taxonium-proxy
image: theosanderson/taxonium_proxy:master
ports:
- containerPort: 3000

---
apiVersion: v1
Expand All @@ -36,20 +36,20 @@ kind: Ingress
metadata:
name: taxonium-proxy-ingress
annotations:
kubernetes.io/ingress.class: "nginx" # assuming you are using nginx ingress controller
kubernetes.io/ingress.class: "nginx" # assuming you are using nginx ingress controller
spec:
rules:
- host: proxy.taxonium.org
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: taxonium-proxy-service
port:
number: 80
- host: proxy.taxonium.org
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: taxonium-proxy-service
port:
number: 80
tls:
- hosts:
- proxy.taxonium.org
secretName: tls-proxy2
- hosts:
- proxy.taxonium.org
secretName: tls-proxy2
1 change: 0 additions & 1 deletion proxy/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const corsOptions = {

app.use(cors(corsOptions));


// Rate limiting middleware
const limiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
Expand Down
23 changes: 14 additions & 9 deletions taxonium_component/src/utils/processNextstrain.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,26 +419,31 @@ async function json_to_tree(json) {
console.log("META PROV", json.meta.data_provenance);
config.source = "";
if (json.meta && json.meta.data_provenance) {
config.source = config.source +
json.meta.data_provenance.map((source) => source.name).join(" & ")

config.source =
config.source +
json.meta.data_provenance.map((source) => source.name).join(" & ");
}

config.overlay = `<p>This is a tree generated from a <a href='//nextstrain.org'>Nextstrain</a> JSON file, being visualised in Taxonium.</p>.`;

if (json.meta && json.meta.updated) {
config.source = config.source + " on " +
json.meta.updated ;
config.source = config.source + " on " + json.meta.updated;
}
if (json.meta && json.meta.maintainers) {
config.source = config.source + " in a build maintained by " +
config.source =
config.source +
" in a build maintained by " +
json.meta.maintainers.map((source) => source.name).join(" & ");

const maintainerLinks = json.meta.maintainers.map((source) => `<a class='underline' href='${source.url}'>${source.name}</a>`).join(" & ");

const maintainerLinks = json.meta.maintainers
.map(
(source) =>
`<a class='underline' href='${source.url}'>${source.name}</a>`
)
.join(" & ");
config.overlay += `<p>The Nextstrain build is maintained by ${maintainerLinks}.</p>`;
}


if (json.meta.build_url) {
config.overlay += `<p>The Nextstrain build is available <a class='underline' href='${json.meta.build_url}'>here</a>.</p>`;
}
Expand Down
29 changes: 22 additions & 7 deletions taxonium_website/src/components/InputSupplier.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,24 @@ export const InputSupplier = ({ inputHelper, className }) => {
});

const [tempURL, setTempURL] = useState("");
const [useProxy, setUseProxy] = useState(true); // New state for proxy usage

const { inputs, setInputs } = inputHelper;
const [addingText, setAddingText] = useState(false);
const [text, setText] = useState("");

const addFromTempURL = useCallback(() => {
if (tempURL) {
inputHelper.addFromURL(tempURL);
let finalURL = tempURL;
if (useProxy) {
finalURL = `https://proxy.taxonium.org/proxy?url=${encodeURIComponent(
tempURL
)}`;
}
if (finalURL) {
inputHelper.addFromURL(finalURL);
setTempURL("");
}
}, [tempURL, inputHelper]);
}, [tempURL, useProxy, inputHelper]); // Include useProxy in the dependency array

return (
<div className={className}>
Expand Down Expand Up @@ -185,17 +192,25 @@ export const InputSupplier = ({ inputHelper, className }) => {
value={tempURL}
className="border p-1 mr-1 text-sm "
onChange={(e) => {
setTempURL(
e.target.value

);
setTempURL(e.target.value);
}}
onKeyUp={(e) => {
if (e.key === "Enter") {
addFromTempURL();
}
}}
/>{" "}
{tempURL !== "" && (
<>
<input
type="checkbox"
checked={useProxy}
className="mr-2 text-sm text-gray-600"
onChange={(e) => setUseProxy(e.target.checked)}
/>{" "}
Use Proxy
</>
)}
<Button onClick={addFromTempURL} className="">
Add
</Button>
Expand Down
4 changes: 1 addition & 3 deletions taxonium_website/src/hooks/useInputHelper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,7 @@ export const useInputHelper = ({

function addFromURL(url) {
const file_obj = { name: url, supplyType: "url" };
window.alert(
"Please note: URL based loading will only work if the web server supports CORS. If the tree does not load please download the tree to your own computer and load the file into Taxonium from there."
);

addInput(file_obj);
}

Expand Down

1 comment on commit 178ae01

@vercel
Copy link

@vercel vercel bot commented on 178ae01 Nov 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.