Newer
Older
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
//
Luke Schoen
committed
import { chainName$, withoutLoading } from '@parity/light.js';
import light from '@parity/light.js-react';
import withHealth from '../utils/withHealth';
@branch(
({
health: {
status: { nodeConnected, syncing }
}
}) => nodeConnected || syncing,
// Only call light.js chainName$ if we're syncing or good
light({
chainName: () => chainName$().pipe(withoutLoading())
})
)
<div className='status'>
<span className={['status_icon', this.statusToClassName()].join(' ')}>
<svg viewBox='0 0 20 20'>
<circle fill='#DDD' cx='10' cy='10' r='10' />
</svg>
<span className='status_text'>{this.statusToFriendlyMessage()}</span>
/**
* Get className from the status icon from the status enum
*/
if (status.good) {
return '-good';
} else if (status.downloading || status.launching || status.syncing) {
return '-syncing';
} else {
return '-bad';
health: { status, payload },
chainName
Luke Schoen
committed
return `Downloading Parity Ethereum... (${
payload.downloading.syncPercentage
}%)`;
} else if (status.launching) {
return 'Launching the node...';
} else if (!status.nodeConnected && !status.internet) {
return 'No internet. No node connected';
} else if (!status.nodeConnected && status.internet) {
return 'Connecting to node...';
} else if (status.nodeConnected && !status.internet) {
return 'No internet. Connected to node';
} else if (!status.clockSync) {
return 'Clock of host not in sync';
} else if (!status.peers) {
Luke Schoen
committed
return 'Connecting to peers...';
} else if (status.syncing) {
return `Syncing...${
Luke Schoen
committed
payload &&
Luke Schoen
committed
payload.syncing &&
payload.syncing.syncPercentage &&
payload.syncing.syncPercentage.gt(0)
? ` (${payload.syncing.syncPercentage.toFixed(0)}%)`
: ''
Luke Schoen
committed
} ${chainName}`;
} else if (status.good) {
Luke Schoen
committed
return `Synced ${chainName}`;
} else {
Luke Schoen
committed
return JSON.stringify(payload) || ''; // Just in case payload is an object