From a317d4db63f76c9504298546504a2b95d0f998d7 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Tue, 7 Sep 2021 22:34:36 -0500 Subject: rough in notification icon --- src/web/src/components/App.js | 90 +++++++++++++++++++++++++------------------ 1 file changed, 52 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/web/src/components/App.js b/src/web/src/components/App.js index d6d80492..a461cd60 100644 --- a/src/web/src/components/App.js +++ b/src/web/src/components/App.js @@ -3,6 +3,7 @@ import { Route, Link, Switch } from "react-router-dom"; import { tokenKey, tokenPassthroughValue } from '../config'; import * as session from '../lib/session'; import * as server from '../lib/server'; +import * as application from '../lib/application'; import './App.css'; import Search from './Search/Search'; @@ -30,8 +31,8 @@ const initialState = { pending: false, error: undefined }, - serverStateInterval: undefined, - serverState: {}, + applicationStateInterval: undefined, + applicationState: {}, error: false, }; @@ -42,7 +43,7 @@ class App extends Component { const { login } = this.state; try { - await this.fetchServerState(); + await this.fetchApplicationState(); const securityEnabled = await session.getSecurityEnabled(); if (!securityEnabled) { @@ -55,7 +56,7 @@ class App extends Component { ...login, initialized: true }, - serverStateInterval: window.setInterval(this.fetchServerState, 5000) + applicationStateInterval: window.setInterval(this.fetchApplicationState, 5000) }); await this.checkToken(); @@ -66,8 +67,8 @@ class App extends Component { }; componentWillUnmount = () => { - clearInterval(this.state.serverStateInterval); - this.setState({ serverStateInterval: undefined }); + clearInterval(this.state.applicationStateInterval); + this.setState({ applicationStateInterval: undefined }); }; checkToken = async () => { @@ -106,18 +107,18 @@ class App extends Component { connect = async () => { await server.connect(); - this.fetchServerState(); + this.fetchApplicationState(); }; disconnect = async () => { await server.disconnect(); - this.fetchServerState(); + this.fetchApplicationState(); } - fetchServerState = async () => { + fetchApplicationState = async () => { try { this.setState({ - serverState: await server.getState(), + applicationState: await application.getState(), error: false, }); } catch (err) { @@ -126,7 +127,8 @@ class App extends Component { }; render = () => { - const { token, login, serverState, error } = this.state; + const { token, login, applicationState = {}, error } = this.state; + const { server, updateAvailable } = applicationState return ( <> @@ -182,33 +184,45 @@ class App extends Component { Browse - {serverState.isConnected && this.disconnect()} - > - Connected - } - {(!serverState.isConnected || serverState.isTransitioning) && this.connect()} - > - - - - Disconnected - } - {token !== tokenPassthroughValue && - Log Out - - } - centered - size='mini' - header={
} - content='Are you sure you want to log out?' - actions={['Cancel', { key: 'done', content: 'Log Out', negative: true, onClick: this.logout }]} - />} + + {server.isConnected && this.disconnect()} + > + Connected + } + {(!server.isConnected || server.isTransitioning) && this.connect()} + > + + + + Disconnected + } + { + + + Notifications + } + centered + size='mini' + header={
} + content='A new version is available!' + actions={['Ok']} + />} + {token !== tokenPassthroughValue && + Log Out + + } + centered + size='mini' + header={
} + content='Are you sure you want to log out?' + actions={['Cancel', { key: 'done', content: 'Log Out', negative: true, onClick: this.logout }]} + />} +
-- cgit v1.2.3