mirror of
https://github.com/openziti/zrok.git
synced 2025-06-19 00:07:04 +02:00
first steps with reagraph (#799)
This commit is contained in:
parent
f394074d5c
commit
67ac8416dd
1037
ui100/package-lock.json
generated
1037
ui100/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -14,7 +14,8 @@
|
|||||||
"@emotion/styled": "^11.13.5",
|
"@emotion/styled": "^11.13.5",
|
||||||
"@mui/material": "^6.1.8",
|
"@mui/material": "^6.1.8",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-dom": "^18.3.1"
|
"react-dom": "^18.3.1",
|
||||||
|
"reagraph": "^4.21.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.13.0",
|
"@eslint/js": "^9.13.0",
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
import {useEffect, useState} from "react";
|
import {useEffect, useState} from "react";
|
||||||
import {MetadataApi} from "./api";
|
import {Configuration, MetadataApi} from "./api";
|
||||||
|
import buildVisualizerGraph from "./model/visualizer.ts";
|
||||||
|
import {GraphCanvas} from "reagraph";
|
||||||
|
import {Box, Grid, Grid2} from "@mui/material";
|
||||||
|
|
||||||
const ApiConsole = () => {
|
const ApiConsole = () => {
|
||||||
const [version, setVersion] = useState("no version set");
|
const [version, setVersion] = useState("no version set");
|
||||||
|
const [nodes, setNodes] = useState([]);
|
||||||
|
const [edges, setEdges] = useState([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let api = new MetadataApi();
|
let api = new MetadataApi();
|
||||||
@ -15,10 +20,41 @@ const ApiConsole = () => {
|
|||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let interval = setInterval(() => {
|
||||||
|
let cfg = new Configuration({
|
||||||
|
headers: {
|
||||||
|
// ignorable token, local development environment
|
||||||
|
"X-TOKEN": "q9bwDQqMQ6K6"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let api = new MetadataApi(cfg);
|
||||||
|
api.overview()
|
||||||
|
.then(d => {
|
||||||
|
console.log(d);
|
||||||
|
let graph = buildVisualizerGraph(d);
|
||||||
|
|
||||||
|
setNodes(graph.nodes);
|
||||||
|
setEdges(graph.edges);
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
console.log(e);
|
||||||
|
});
|
||||||
|
}, 1000);
|
||||||
|
return () => {
|
||||||
|
clearInterval(interval);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h1>zrok</h1>
|
<h1>zrok</h1>
|
||||||
<h2>{version}</h2>
|
<h2>{version}</h2>
|
||||||
|
<Box>
|
||||||
|
<div style={{position: "relative", width: "100%", height: "500px"}}>
|
||||||
|
<GraphCanvas nodes={nodes} edges={edges}/>
|
||||||
|
</div>
|
||||||
|
</Box>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
18
ui100/src/model/visualizer.ts
Normal file
18
ui100/src/model/visualizer.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import {Overview} from "../api";
|
||||||
|
|
||||||
|
const buildVisualizerGraph = (overview: Overview) => {
|
||||||
|
let nodes = [
|
||||||
|
{ id: "1", label: "michael@quigley.com" }
|
||||||
|
]
|
||||||
|
let edges = [];
|
||||||
|
overview.environments?.forEach((env, i) => {
|
||||||
|
nodes.push({ id: (i+1).toString(), label: env.environment?.description! });
|
||||||
|
edges.push({ source: (i+1).toString(), target: "1", id: (i+1)+"-1" });
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
nodes: nodes,
|
||||||
|
edges: edges,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default buildVisualizerGraph;
|
Loading…
x
Reference in New Issue
Block a user