mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Adding warning to Dashboard when Internet is down.
This commit is contained in:
parent
0f232fd533
commit
47b4da1cfe
6 changed files with 28 additions and 27 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import {LoadStatistic, PageContainer, SearchResultsInput, useTitle} from "./components/Common";
|
||||
import {ErrorMessage, LoadStatistic, PageContainer, SearchResultsInput, useTitle} from "./components/Common";
|
||||
import React, {useContext, useState} from "react";
|
||||
import {Media, SettingsContext, StatusContext} from "./contexts/contexts";
|
||||
import {DownloadMenu} from "./components/Download";
|
||||
|
|
@ -40,8 +40,9 @@ function FlagsMessages() {
|
|||
|
||||
let refreshing;
|
||||
let refreshRequired;
|
||||
let dbDown;
|
||||
let kiwixRestart;
|
||||
let dbDown;
|
||||
let internetDown;
|
||||
|
||||
// Do not tell the maintainer to refresh the files if they are already refreshing.
|
||||
if (flags['refreshing']) {
|
||||
|
|
@ -69,13 +70,17 @@ function FlagsMessages() {
|
|||
}
|
||||
|
||||
if (!flags['db_up']) {
|
||||
dbDown = <Message icon error>
|
||||
<Icon name='exclamation'/>
|
||||
<Message.Content>
|
||||
<Message.Header>Database is down</Message.Header>
|
||||
API is unable to connect to the database. Check the server logs.
|
||||
</Message.Content>
|
||||
</Message>
|
||||
dbDown = <ErrorMessage>
|
||||
<Message.Header>Database is down</Message.Header>
|
||||
API is unable to connect to the database. Check the server logs.
|
||||
</ErrorMessage>
|
||||
}
|
||||
|
||||
if (!flags.have_internet) {
|
||||
internetDown = <ErrorMessage icon='globe'>
|
||||
<Message.Header>No Internet</Message.Header>
|
||||
WROLPi has no Internet. Downloads will not start.
|
||||
</ErrorMessage>;
|
||||
}
|
||||
|
||||
return <>
|
||||
|
|
@ -84,6 +89,7 @@ function FlagsMessages() {
|
|||
{settings && settings['ignore_outdated_zims'] === false && flags['outdated_zims'] ?
|
||||
<OutdatedZimsMessage onClick={fetchSettings}/> : null}
|
||||
{kiwixRestart}
|
||||
{status.wrol_mode || internetDown}
|
||||
</>
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1644,19 +1644,19 @@ export function HandPointMessage({children, size = null}) {
|
|||
</Message>
|
||||
}
|
||||
|
||||
export function WarningMessage({children, size = null}) {
|
||||
export function WarningMessage({children, size = null, icon='exclamation'}) {
|
||||
// Use color='yellow' because "warning" does not work.
|
||||
return <Message color='yellow' icon size={size}>
|
||||
<SIcon name='exclamation'/>
|
||||
<SIcon name={icon}/>
|
||||
<Message.Content>
|
||||
{children}
|
||||
</Message.Content>
|
||||
</Message>
|
||||
}
|
||||
|
||||
export function ErrorMessage({children, size = null}) {
|
||||
export function ErrorMessage({children, size = null, icon='exclamation'}) {
|
||||
return <Message error icon size={size}>
|
||||
<SIcon name='exclamation'/>
|
||||
<SIcon name={icon}/>
|
||||
<Message.Content>{children}</Message.Content>
|
||||
</Message>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,16 +155,13 @@ export const OutdatedZimsMessage = ({onClick}) => {
|
|||
}
|
||||
|
||||
export const KiwixRestartMessage = () => {
|
||||
return <Message icon warning>
|
||||
<SIcon name='exclamation'/>
|
||||
<Message.Content>
|
||||
<Message.Header>Kiwix must be restarted</Message.Header>
|
||||
<p>New Zim files have been downloaded; you must restart your containers.</p>
|
||||
return <WarningMessage>
|
||||
<Message.Header>Kiwix must be restarted</Message.Header>
|
||||
<p>New Zim files have been downloaded; you must restart your containers.</p>
|
||||
|
||||
<p>Run the following to restart your containers:</p>
|
||||
<pre> docker-compose restart</pre>
|
||||
</Message.Content>
|
||||
</Message>
|
||||
<p>Run the following to restart your containers:</p>
|
||||
<pre> docker-compose restart</pre>
|
||||
</WarningMessage>
|
||||
}
|
||||
|
||||
const ZimSearchEntry = ({zimId, onTag, onUntag, entry}) => {
|
||||
|
|
|
|||
2
main.py
2
main.py
|
|
@ -327,8 +327,6 @@ async def perpetual_have_internet_worker():
|
|||
await asyncio.sleep(10)
|
||||
except Exception as e:
|
||||
logger.error('Failed to check if internet is up', exc_info=e)
|
||||
|
||||
await asyncio.sleep(10)
|
||||
except asyncio.CancelledError:
|
||||
logger.info('perpetual_check_have_internet_worker was cancelled...')
|
||||
|
||||
|
|
|
|||
|
|
@ -1914,8 +1914,8 @@ def can_connect_to_server(hostname: str, port: int = 80) -> bool:
|
|||
conn = socket.create_connection((hostname, port))
|
||||
conn.close()
|
||||
return True
|
||||
except Exception:
|
||||
pass # We ignore any errors, returning False
|
||||
except Exception as e:
|
||||
logger_.debug('can_connect_to_server encountered error', exc_info=e)
|
||||
return False
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ DOCKERIZED = truthy_arg(os.environ.get('DOCKER', ''))
|
|||
PYTEST = 'pytest' in sys.modules
|
||||
|
||||
# Used to test if the Internet is up.
|
||||
INTERNET_SERVER = "one.one.one.one"
|
||||
INTERNET_SERVER = os.environ.get('INTERNET_SERVER', 'one.one.one.one')
|
||||
|
||||
# running on circlci
|
||||
CIRCLECI = truthy_arg(os.environ.get('CIRCLECI', ''))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue