diff --git a/agent/agentUi/src/AgentUi.jsx b/agent/agentUi/src/AgentUi.jsx new file mode 100644 index 00000000..1787ebfb --- /dev/null +++ b/agent/agentUi/src/AgentUi.jsx @@ -0,0 +1,35 @@ +import {createBrowserRouter, RouterProvider} from "react-router-dom"; +import Overview from "./Overview.jsx"; +import ShareDetail from "./ShareDetail.jsx"; +import {useEffect, useState} from "react"; +import {AgentApi, ApiClient} from "./api/src/index.js"; + +const AgentUi = (props) => { + const [version, setVersion] = useState(""); + + let api = new AgentApi(new ApiClient(window.location.protocol+'//'+window.location.host)); + + useEffect(() => { + let mounted = true; + api.agentVersion((err, data) => { + if(mounted) { + setVersion(data.v); + } + }); + }, []); + + const router = createBrowserRouter([ + { + path: "/", + element: + }, + { + path: "/share/:token", + element: + } + ]); + + return +} + +export default AgentUi; \ No newline at end of file diff --git a/agent/agentUi/src/NavBar.jsx b/agent/agentUi/src/NavBar.jsx index 01bd66fa..f7d48fab 100644 --- a/agent/agentUi/src/NavBar.jsx +++ b/agent/agentUi/src/NavBar.jsx @@ -1,5 +1,3 @@ -import {useEffect, useState} from "react"; -import {AgentApi, ApiClient} from "./api/src/index.js"; import {AppBar, Button, IconButton, Toolbar, Typography} from "@mui/material"; import MenuIcon from "@mui/icons-material/Menu"; import {Link} from "react-router-dom"; @@ -7,38 +5,25 @@ import ListIcon from "@mui/icons-material/List"; import LanIcon from "@mui/icons-material/Lan"; import ShareIcon from "@mui/icons-material/Share"; -function NavBar() { - const [version, setVersion] = useState(""); - - let api = new AgentApi(new ApiClient(window.location.protocol+'//'+window.location.host)); - - useEffect(() => { - let mounted = true; - api.agentVersion((err, data) => { - if(mounted) { - setVersion(data.v); - } - }); - }, []); - +const NavBar = (props) => { return ( - - zrok Agent { version !== "" ? " | " + version : ""} + + zrok Agent { props.version !== "" ? " | " + props.version : ""} - - - + + + ) diff --git a/agent/agentUi/src/Overview.jsx b/agent/agentUi/src/Overview.jsx index f3f79b13..1104b2bf 100644 --- a/agent/agentUi/src/Overview.jsx +++ b/agent/agentUi/src/Overview.jsx @@ -4,7 +4,7 @@ import {AgentApi, ApiClient} from "./api/src/index.js"; import DataTable from "react-data-table-component"; import NavBar from "./NavBar.jsx"; -function Overview() { +const Overview = (props) => { const [shares, setShares] = useState([]); const [accesses, setAccesses] = useState([]); @@ -67,7 +67,7 @@ function Overview() { return ( <> - +

Shares

diff --git a/agent/agentUi/src/ShareDetail.jsx b/agent/agentUi/src/ShareDetail.jsx index 7136c436..6b5d4910 100644 --- a/agent/agentUi/src/ShareDetail.jsx +++ b/agent/agentUi/src/ShareDetail.jsx @@ -1,12 +1,12 @@ import NavBar from "./NavBar.jsx"; import {useParams} from "react-router-dom"; -function ShareDetail() { +const ShareDetail = (props) => { let params = useParams(); return ( <> - +

Share {params.token}

diff --git a/agent/agentUi/src/main.jsx b/agent/agentUi/src/main.jsx index c98bc90e..2b2787be 100644 --- a/agent/agentUi/src/main.jsx +++ b/agent/agentUi/src/main.jsx @@ -1,23 +1,10 @@ -import './index.css'; -import { StrictMode } from 'react'; -import { createRoot } from 'react-dom/client'; -import { createBrowserRouter, RouterProvider } from "react-router-dom"; -import Overview from "./Overview.jsx"; -import ShareDetail from "./ShareDetail.jsx"; - -const router = createBrowserRouter([ - { - path: "/", - element: - }, - { - path: "/share/:token", - element: - } -]); +import "./index.css"; +import {StrictMode} from "react"; +import {createRoot} from "react-dom/client"; +import AgentUi from "./AgentUi.jsx"; createRoot(document.getElementById('root')).render( - + , )