Skip to content

Commit

Permalink
Connected h5web to Domain
Browse files Browse the repository at this point in the history
  • Loading branch information
sergesoroka committed Aug 8, 2024
1 parent e624d02 commit b476c03
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 11 deletions.
10 changes: 7 additions & 3 deletions components/Chart/Chart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useEffect, useRef, useState } from "react";
import { useNavigate } from "react-router-dom";
import useSWR from "swr";

export default function Chart({ imageSelected }) {
export default function Chart({ imageSelected, setDomain }) {
const fetcher = (url) => fetch(url).then((res) => res.json());

const containerRef = useRef();
Expand Down Expand Up @@ -58,7 +58,8 @@ export default function Chart({ imageSelected }) {
const plot = Plot.plot({
// caption: dataset,
grid: true,
color: { scheme: "burd" },
color: "#454545",
stroke: "#454545",
marks: [
Plot.axisY({
label: "Raw Counts",
Expand Down Expand Up @@ -101,7 +102,10 @@ export default function Chart({ imageSelected }) {
<button
className="shareBtn"
style={{ marginLeft: "16px" }}
onClick={() => navigate(`?h5web=${imageSelected}`)}
onClick={() => {
navigate(`?h5web=${imageSelected}`);
setDomain(data.domain);
}}
>
Explore in h5web
</button>
Expand Down
6 changes: 4 additions & 2 deletions components/SearchComp/SearchComp.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable react/prop-types */
import { AnimatePresence, motion } from "framer-motion";
import { useState } from "react";
import { useLocation } from "react-router-dom";
Expand All @@ -14,7 +15,7 @@ import "../../src/App.css";
import Sidebar from "../Sidebar/Sidebar";
const fetcher = (url) => fetch(url).then((res) => res.json());

export default function SearchComp() {
export default function SearchComp({ setDomain }) {
const location = useLocation();
const queryParams = new URLSearchParams(location.search);
const domainParams = queryParams.get("domain");
Expand All @@ -23,6 +24,7 @@ export default function SearchComp() {
let [imageSelected, setImageSelected] = useState(
domainParams ? domainParams : ""
);

let [reference, setReference] = useState("*");
let [provider, setProvider] = useState("*");
let [pages, setPages] = useState("0");
Expand Down Expand Up @@ -147,7 +149,7 @@ export default function SearchComp() {
</div>
}
>
<Chart imageSelected={imageSelected} />
<Chart imageSelected={imageSelected} setDomain={setDomain} />
</ErrorBoundary>
) : (
<div className="errorMessage">
Expand Down
1 change: 1 addition & 0 deletions components/UI/Expander.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default function Expander({ children, title, status }) {
margin: "0 0 0.5rem 0",
overflow: "hidden",
backgroundColor: "#f8fcff",
color: "#454545",
}}
>
<div
Expand Down
8 changes: 5 additions & 3 deletions components/h5web/h5web.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ import "@h5web/app/dist/styles.css";

import { App, HsdsProvider } from "@h5web/app";

export default function H5web() {
// eslint-disable-next-line react/prop-types
export default function H5web({ domain }) {
console.log("h5web", domain);
return (
<div>
<div style={{ height: "90vh" }}>
<HsdsProvider
url="https://hsds.adma.ai"
url="https://hsds-kc.ideaconsult.net"
username="system-public-user"
password="system-public-user"
filepath="/TEST/129aac84-3015-4333-af39-9efa544d54f6.nxs"
filepath={`${domain}`}
>
<App />
</HsdsProvider>
Expand Down
4 changes: 4 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#root {
width: 100%;
background-color: #fff;
}

h1 {
Expand Down Expand Up @@ -230,6 +231,7 @@ h1 {
}
.chartWrap {
margin: 0 0 4rem 0;
color: #454545;
}
.domainInfo {
display: flex;
Expand Down Expand Up @@ -272,6 +274,7 @@ h1 {
font-size: 14px;
font-weight: 500;
margin-left: 0.2rem;
color: #454545;
}

.annotationInfo {
Expand All @@ -298,6 +301,7 @@ h1 {
font-weight: 500;
margin: 0.3rem 0;
display: inline-block;
color: #454545;
}

.footer {
Expand Down
8 changes: 5 additions & 3 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "./App.css";

import { useState } from "react";
import { useLocation } from "react-router-dom";

import SearchComp from "../components/SearchComp/SearchComp";
Expand All @@ -14,16 +14,18 @@ function App() {
const queryParams = new URLSearchParams(location.search);
const h5webParams = queryParams.get("h5web");

let [domain, setDomain] = useState(null);

return (
<>
<Header />
<UnderDevelopent />
<div>
{h5webParams ? (
<H5web />
<H5web domain={domain} />
) : (
<div>
<SearchComp />
<SearchComp setDomain={setDomain} />
<Footer />
</div>
)}
Expand Down

0 comments on commit b476c03

Please sign in to comment.