Newer
Older
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
//
import React, { Component } from 'react';
import { inject, observer } from 'mobx-react';
import { STATUS } from '../stores/healthStore';
@inject('healthStore')
@observer
class Health extends Component {
<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
*/
const {
healthStore: {
health: { status }
}
} = this.props;
case STATUS.DOWNLOADING:
case STATUS.RUNNING:
case STATUS.SYNCING:
return '-syncing';
default:
return '-bad';
}
};
const {
healthStore: {
health: { status, payload }
}
} = this.props;
switch (status) {
case STATUS.CANTCONNECT:
return "Can't connect to Parity";
case STATUS.CLOCKNOTSYNC:
return 'Clock not sync';
case STATUS.DOWNLOADING:
return `Downloading... (${payload.percentage}%)`;
case STATUS.NOINTERNET:
return 'No Internet connection';
case STATUS.NOPEERS:
return 'Not connected to any peers';
case STATUS.RUNNING:
return 'Running...';
case STATUS.SYNCING:
payload && payload.percentage && payload.percentage.gt(0)
? ` (${payload.percentage.toFixed(0)}%)`
: ''
default:
return JSON.stringify(payload); // Just in case payload is an object
}
};