Skip to content

Commit

Permalink
Merge branch 'jacobfilik:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartcampbell authored Oct 10, 2024
2 parents a792ea9 + 1792905 commit c6d9055
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { createTheme, ThemeProvider } from "@mui/material/styles";
import { MetadataProvider } from "./contexts/MetadataContext.tsx";
import { Routes, Route } from "react-router-dom";
import XDIPage from "./components/XDIPage.tsx";
import PersistentView from "./components/PersistentView.tsx";

function App() {
const prefersDarkMode = useMediaQuery("(prefers-color-scheme: dark)");
Expand Down Expand Up @@ -73,6 +74,7 @@ function App() {
<Route path="/" element={<WelcomePage />} />
<Route path="/view" element={<ViewPage />} />
<Route path="/xdiviewer" element={<XDIPage />} />
<Route path="/xdi/:id/*" element={<PersistentView />} />
</Routes>
</MetadataProvider>
</Stack>
Expand Down
68 changes: 68 additions & 0 deletions src/components/PersistentView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@

import { useState, useContext } from "react";

import axios from "axios";
import MetadataTab from "./MetadataTab.tsx";

import { Grid, Typography } from "@mui/material";
import XDIFile from "../xdifile.ts";

import { XDIFileProvider } from "../contexts/XDIFileContext.tsx";
import XDIChart from "./XDIChart.tsx";

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

import { MetadataContext } from "../contexts/MetadataContext.tsx";



function PersistentView() {

const location = useLocation();
const id = location.pathname.slice(5)

const [xdiFile, setXDIFile] = useState<XDIFile | null>(null);
const allStandards = useContext(MetadataContext);

console.log(id)
console.log(allStandards[1])

const standard = allStandards.find((f) => f.location === id)

useEffect(() => {
axios.get("/webxdiviewer/xdidata/" + id).then((response) => {

let xdi = null;
try {
xdi = XDIFile.parseFile(response.data);

} catch {
console.log("Could not read {}", focus)

}

setXDIFile(xdi);
})}, [id]);



// const onClick = getData();

return (
<XDIFileProvider value={{ xdiFile: xdiFile, setXDIFile: setXDIFile }}>
<Grid height="100%" container>
<Grid item lg={5} md={12} padding={1}>
{standard
? <MetadataTab standard={standard} showDownload={true} />
: <Typography> Could not find {id} </Typography>
}
</Grid>
<Grid item height="100%" lg={7} md={12} padding={1}>
<XDIChart />
</Grid>
</Grid>
</XDIFileProvider>
);
}
export default PersistentView;

0 comments on commit c6d9055

Please sign in to comment.