Skip to content

Commit

Permalink
Make things prettier
Browse files Browse the repository at this point in the history
Former-commit-id: 8bba113
  • Loading branch information
theosanderson committed Jul 5, 2021
1 parent b86277f commit 54cdc2d
Show file tree
Hide file tree
Showing 9 changed files with 912 additions and 759 deletions.
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tabWidth": 2,
"useTabs": false
}
114 changes: 50 additions & 64 deletions src/App.js → src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "./App.css";
import React, { useEffect, useState, useCallback } from "react";
import Deck from "./Deck";
import SearchPanel from "./components/SearchPanel";
import axios from 'axios'
import axios from "axios";
import AboutOverlay from "./components/AboutOverlay";
import { BrowserRouter as Router } from "react-router-dom";
import { CgListTree } from "react-icons/cg";
Expand All @@ -20,85 +20,66 @@ function App() {
},
]);

const setSearchItems = useCallback(
(x) => {

setSearchItemsBasic(x);
},
[]
);

const setSearchItems = useCallback((x) => {
setSearchItemsBasic(x);
}, []);

const [colourBy, setColourBy] = useState("lineage");
const setColourByWithCheck = useCallback(
(x) => {

setColourBy(x);
},
[]
);
const setColourByWithCheck = useCallback((x) => {
setColourBy(x);
}, []);
const [nodeData, setNodeData] = useState({
status: "not_attempted",
data: { node_data: { ids: [] } },
});

const [selectedNode, setSelectedNode] = useState(null);


const [aboutEnabled, setAboutEnabled] = useState(false);

useEffect(() => {
if (nodeData.status === "not_attempted") {
console.log("starting dl")
console.log("starting dl");
setNodeData({
status: "loading",
progress: 0,
data: { node_data: { ids: [] } },
})


protobuf.load("./tree.proto")
.then(function (root) {


axios.get('/nodelist.pb', {
responseType: 'arraybuffer', onDownloadProgress: progressEvent => {
let percentCompleted = Math.floor(1 * (progressEvent.loaded / 100000000) * 100)
});

protobuf.load("./tree.proto").then(function (root) {
axios
.get("/nodelist.pb", {
responseType: "arraybuffer",
onDownloadProgress: (progressEvent) => {
let percentCompleted = Math.floor(
1 * (progressEvent.loaded / 100000000) * 100
);
setNodeData({
status: "loading",
progress: percentCompleted,
data: { node_data: { ids: [] } },
})
}
});
},
})
.then(function (response) {

return response.data;
})
.then(function (buffer) {
console.log("buffer loaded")
var NodeList = root.lookupType("AllData");
window.buffer = buffer
window.NodeList = NodeList
var message = NodeList.decode(new Uint8Array(buffer));
var result = NodeList.toObject(message);
result.node_data.ids = [...Array(result.node_data.x.length).keys()]
console.log("hi")
console.log(result)
window.b = result
setNodeData({ status: 'loaded', data: result })
});
});



.then(function (response) {
return response.data;
})
.then(function (buffer) {
console.log("buffer loaded");
var NodeList = root.lookupType("AllData");
window.buffer = buffer;
window.NodeList = NodeList;
var message = NodeList.decode(new Uint8Array(buffer));
var result = NodeList.toObject(message);
result.node_data.ids = [...Array(result.node_data.x.length).keys()];
console.log("hi");
console.log(result);
window.b = result;
setNodeData({ status: "loaded", data: result });
});
});
}
}
, [nodeData.status]);




}, [nodeData.status]);

return (
<Router>
Expand All @@ -115,12 +96,12 @@ function App() {
</span>
</h1>
<div className="inline-block p-4">

<button
onClick={() => setAboutEnabled(true)}
className="mr-10 text-white font-bold hover:underline"
>
<BsInfoSquare className="inline-block h-7 w-8" /> About / Acknowledgements
<BsInfoSquare className="inline-block h-7 w-8" /> About /
Acknowledgements
</button>
{/*<a className="text-white" href="https://github.com/theosanderson/taxodium">
<FaGithub className="inline-block text-white h-7 w-8" />
Expand All @@ -134,19 +115,24 @@ function App() {
<Deck
setSelectedNode={setSelectedNode}
searchItems={searchItems}

data={nodeData.status === "loaded" ? nodeData.data : { node_data: { ids: [] } }}
data={
nodeData.status === "loaded"
? nodeData.data
: { node_data: { ids: [] } }
}
progress={nodeData.progress}
colourBy={colourBy}
/>
</div>
<div className="md:col-span-4 h-full bg-white border-gray-600 pl-5 shadow-xl">
<SearchPanel


selectedNode={selectedNode}
searchItems={searchItems}
data={nodeData.status === "loaded" ? nodeData.data : { node_data: { ids: [] } }}
data={
nodeData.status === "loaded"
? nodeData.data
: { node_data: { ids: [] } }
}
setSearchItems={setSearchItems}
colourBy={colourBy}
setColourBy={setColourByWithCheck}
Expand Down
Loading

0 comments on commit 54cdc2d

Please sign in to comment.