layout and arrangement for the visualizer in the ui (#107)

This commit is contained in:
Michael Quigley 2022-12-21 12:18:54 -05:00
parent fe1c118a0a
commit f15b0a2952
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
6 changed files with 49 additions and 5 deletions

View File

@ -1,7 +1,8 @@
import {Container, Nav, Navbar, NavDropdown} from "react-bootstrap";
import {Container, Nav, Navbar, NavDropdown, Row} from "react-bootstrap";
import {useState} from "react";
import NewEnable from "./NewEnable";
import NewVersion from "./NewVersion";
import Visualizer from "./visualizer/Visualizer";
import NewEnable from "./modals/NewEnable";
import NewVersion from "./modals/NewVersion";
const NewConsole = (props) => {
const [showEnableModal, setShowEnableModal] = useState(false);
@ -32,6 +33,7 @@ const NewConsole = (props) => {
</Navbar.Collapse>
</Container>
</Navbar>
<Visualizer />
<NewEnable show={showEnableModal} onHide={closeEnableModal} token={props.user.token}/>
<NewVersion show={showVersionModal} onHide={closeVersionModal} />
</Container>

View File

@ -14,6 +14,17 @@ code, pre {
padding: 15px 50px 20px;
}
.visualizer-container {
padding: 10px;
background: #3b2693;
border-radius: 15px;
margin-top: 15px;
}
.visualizer-controls {
text-align: right;
margin-top: 5px;
}
.header-title {
font-family: 'Russo One', sans-serif;
font-size: 3em;

View File

@ -1,5 +1,5 @@
import {useEffect, useState} from "react";
import * as metadata from "./api/metadata";
import * as metadata from "../api/metadata";
import Modal from "react-bootstrap/Modal";
const NewVersion = (props) => {

View File

@ -1,5 +1,6 @@
import {withSize} from "react-sizeme";
import {useRef} from "react";
import {ForceGraph2D} from "react-force-graph";
const Network = (props) => {
const targetRef = useRef();
@ -14,7 +15,7 @@ const Network = (props) => {
width={props.size.width}
height={500}
linkOpacity={.75}
backgroundColor={"#30205d"}
backgroundColor={"#3b2693"}
/>
)
}

View File

@ -0,0 +1,30 @@
import React, {useState} from "react";
import {Button, Container, Row} from "react-bootstrap";
import Network from "./Network";
const Visualizer = (props) => {
const [networkGraph, setNetworkGraph] = useState({nodes: [{id: 1}], links: []});
const [fgRef, setFgRef] = useState(() => {});
const centerFocus = () => {
if(fgRef != null) {
fgRef.current.zoomToFit(200);
}
}
return (
<div>
<div className={"visualizer-container"}>
<Network
networkGraph={networkGraph}
setRef={setFgRef}
/>
</div>
<div className={"visualizer-controls"}>
<Button onClick={centerFocus}>Zoom to Fit</Button>
</div>
</div>
)
}
export default Visualizer;