From 7bc7e55208118ea622d72950648d09ccc6c816ee Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 11 Nov 2022 17:40:02 -0600 Subject: add agent navigation ui --- src/web/src/components/App.js | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'src/web') diff --git a/src/web/src/components/App.js b/src/web/src/components/App.js index c55ab830..0439943b 100644 --- a/src/web/src/components/App.js +++ b/src/web/src/components/App.js @@ -5,6 +5,7 @@ import { ToastContainer } from 'react-toastify'; import 'react-toastify/dist/ReactToastify.css'; import * as session from '../lib/session'; +import * as networkAPI from '../lib/network'; import { connect, disconnect } from '../lib/server'; import { urlBase } from '../config'; @@ -128,7 +129,7 @@ class App extends Component { const { isUpdateAvailable, current, latest } = version; const { scanPending: pendingShareRescan } = shares; - const { mode } = network; + const { mode, controller } = network; if (!initialized) { return ; @@ -160,11 +161,9 @@ class App extends Component { const ModeSpecificNavigation = ({ mode }) => { if (mode === 'Agent') { - return - - Agent - - ; + return + Agent Mode + ; } else { return <> @@ -206,9 +205,21 @@ class App extends Component { } }; - const ModeSpecificConnectButton = ({ mode, server }) => { + const ModeSpecificConnectButton = ({ mode, server, controller = {} }) => { if (mode === 'Agent') { - return <>; + const isConnected = controller?.state === 'Connected'; + const isTransitioning = ['Connecting', 'Reconnecting'].includes(controller?.state); + + return <> + isConnected ? networkAPI.connect() : networkAPI.disconnect()} + > + + + {!isConnected && } + Controller {controller?.state} + + ; } else { return <> {server?.isConnected && } - + {isUpdateAvailable && -- cgit v1.2.3