2017-01-25 18:51:41 +01:00
|
|
|
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
|
2016-11-05 12:08:14 +01:00
|
|
|
// This file is part of Parity.
|
|
|
|
|
|
|
|
// Parity is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
|
|
|
// Parity is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2017-01-24 17:20:10 +01:00
|
|
|
import { MenuItem } from 'material-ui';
|
|
|
|
import { observer } from 'mobx-react';
|
2016-11-05 12:08:14 +01:00
|
|
|
import React, { Component, PropTypes } from 'react';
|
2016-12-11 17:42:35 +01:00
|
|
|
import { FormattedMessage } from 'react-intl';
|
2016-11-05 12:08:14 +01:00
|
|
|
|
2016-12-11 17:42:35 +01:00
|
|
|
import { Select, Container, LanguageSelector } from '~/ui';
|
2017-01-24 17:20:10 +01:00
|
|
|
import Features, { FeaturesStore, FEATURES } from '~/ui/Features';
|
2016-11-05 12:08:14 +01:00
|
|
|
|
2017-01-24 17:20:10 +01:00
|
|
|
import Store, { LOGLEVEL_OPTIONS } from './store';
|
2016-11-05 12:08:14 +01:00
|
|
|
import layout from '../layout.css';
|
|
|
|
|
2017-01-24 17:20:10 +01:00
|
|
|
@observer
|
2016-11-05 12:08:14 +01:00
|
|
|
export default class Parity extends Component {
|
|
|
|
static contextTypes = {
|
|
|
|
api: PropTypes.object.isRequired
|
2017-01-10 13:26:30 +01:00
|
|
|
};
|
2016-11-05 12:08:14 +01:00
|
|
|
|
2017-01-24 17:20:10 +01:00
|
|
|
store = new Store(this.context.api);
|
|
|
|
features = FeaturesStore.get();
|
2016-11-05 12:08:14 +01:00
|
|
|
|
|
|
|
componentWillMount () {
|
2017-03-13 12:10:53 +01:00
|
|
|
this.store.loadChain();
|
2017-01-24 17:20:10 +01:00
|
|
|
return this.store.loadMode();
|
2016-11-05 12:08:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
return (
|
2017-01-18 13:05:01 +01:00
|
|
|
<Container
|
|
|
|
title={
|
|
|
|
<FormattedMessage id='settings.parity.label' />
|
|
|
|
}
|
|
|
|
>
|
2016-11-05 12:08:14 +01:00
|
|
|
<div className={ layout.layout }>
|
|
|
|
<div className={ layout.overview }>
|
2016-12-11 17:42:35 +01:00
|
|
|
<div>
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.overview_0'
|
2017-03-13 12:10:53 +01:00
|
|
|
defaultMessage='Control the Parity node settings and nature of syncing via this interface.'
|
2017-01-10 13:26:30 +01:00
|
|
|
/>
|
2016-12-11 17:42:35 +01:00
|
|
|
</div>
|
2016-11-05 12:08:14 +01:00
|
|
|
</div>
|
|
|
|
<div className={ layout.details }>
|
2017-03-13 12:10:53 +01:00
|
|
|
{ this.renderChains() }
|
2016-11-05 12:08:14 +01:00
|
|
|
{ this.renderModes() }
|
2017-01-24 17:20:10 +01:00
|
|
|
<Features />
|
|
|
|
<LanguageSelector />
|
2016-11-05 12:08:14 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2017-01-10 13:26:30 +01:00
|
|
|
{ this.renderLogsConfig() }
|
2016-11-05 12:08:14 +01:00
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-03-13 12:10:53 +01:00
|
|
|
renderItem (name, label) {
|
2017-01-24 17:20:10 +01:00
|
|
|
return (
|
|
|
|
<MenuItem
|
2017-03-13 12:10:53 +01:00
|
|
|
key={ name }
|
2017-01-24 17:20:10 +01:00
|
|
|
label={ label }
|
2017-03-13 12:10:53 +01:00
|
|
|
value={ name }
|
2017-01-24 17:20:10 +01:00
|
|
|
>
|
|
|
|
{ label }
|
|
|
|
</MenuItem>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-01-10 13:26:30 +01:00
|
|
|
renderLogsConfig () {
|
2017-01-24 17:20:10 +01:00
|
|
|
if (!this.features.active[FEATURES.LOGLEVELS]) {
|
2017-01-10 13:26:30 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={ layout.layout }>
|
|
|
|
<div className={ layout.overview }>
|
|
|
|
<div>
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.loglevels'
|
|
|
|
defaultMessage='Choose the different logs level.'
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className={ layout.details }>
|
|
|
|
{ this.renderLogsLevels() }
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
renderLogsLevels () {
|
2017-01-24 17:20:10 +01:00
|
|
|
const { logLevels } = this.store;
|
|
|
|
|
|
|
|
return Object
|
|
|
|
.keys(logLevels)
|
|
|
|
.map((key) => {
|
|
|
|
const { level, log } = logLevels[key];
|
2017-02-15 13:37:58 +01:00
|
|
|
const { desc } = log;
|
2017-01-24 17:20:10 +01:00
|
|
|
|
|
|
|
const onChange = (_, index) => {
|
2017-02-15 13:37:58 +01:00
|
|
|
this.store.updateLoggerLevel(log.key, Object.values(LOGLEVEL_OPTIONS)[index].value);
|
2017-01-24 17:20:10 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div key={ key }>
|
|
|
|
<p>{ desc }</p>
|
|
|
|
<Select
|
|
|
|
onChange={ onChange }
|
|
|
|
value={ level }
|
|
|
|
values={ LOGLEVEL_OPTIONS }
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
});
|
2017-01-10 13:26:30 +01:00
|
|
|
}
|
|
|
|
|
2016-11-05 12:08:14 +01:00
|
|
|
renderModes () {
|
2017-01-24 17:20:10 +01:00
|
|
|
const { mode } = this.store;
|
2016-12-11 17:42:35 +01:00
|
|
|
|
2016-11-05 12:08:14 +01:00
|
|
|
return (
|
|
|
|
<Select
|
2017-01-24 17:20:10 +01:00
|
|
|
id='parityModeSelect'
|
2016-12-11 17:42:35 +01:00
|
|
|
hint={
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.modes.hint'
|
2017-03-13 12:10:53 +01:00
|
|
|
defaultMessage='the syncing mode for the Parity node'
|
2017-01-18 13:05:01 +01:00
|
|
|
/>
|
2016-12-11 17:42:35 +01:00
|
|
|
}
|
2017-01-24 17:20:10 +01:00
|
|
|
label={
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.modes.label'
|
|
|
|
defaultMessage='mode of operation'
|
|
|
|
/>
|
|
|
|
}
|
2017-01-18 13:05:01 +01:00
|
|
|
onChange={ this.onChangeMode }
|
2017-01-24 17:20:10 +01:00
|
|
|
value={ mode }
|
2017-01-18 13:05:01 +01:00
|
|
|
>
|
2016-12-11 17:42:35 +01:00
|
|
|
{
|
2017-01-24 17:20:10 +01:00
|
|
|
this.renderItem('active', (
|
2017-01-18 13:05:01 +01:00
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.modes.mode_active'
|
|
|
|
defaultMessage='Parity continuously syncs the chain'
|
|
|
|
/>
|
2017-01-24 17:20:10 +01:00
|
|
|
))
|
2016-12-11 17:42:35 +01:00
|
|
|
}
|
|
|
|
{
|
2017-01-24 17:20:10 +01:00
|
|
|
this.renderItem('passive', (
|
2017-01-18 13:05:01 +01:00
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.modes.mode_passive'
|
|
|
|
defaultMessage='Parity syncs initially, then sleeps and wakes regularly to resync'
|
|
|
|
/>
|
2017-01-24 17:20:10 +01:00
|
|
|
))
|
2016-12-11 17:42:35 +01:00
|
|
|
}
|
|
|
|
{
|
2017-01-24 17:20:10 +01:00
|
|
|
this.renderItem('dark', (
|
2017-01-18 13:05:01 +01:00
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.modes.mode_dark'
|
|
|
|
defaultMessage='Parity syncs only when the RPC is active'
|
|
|
|
/>
|
2017-01-24 17:20:10 +01:00
|
|
|
))
|
2016-12-11 17:42:35 +01:00
|
|
|
}
|
|
|
|
{
|
2017-01-24 17:20:10 +01:00
|
|
|
this.renderItem('offline', (
|
2017-01-18 13:05:01 +01:00
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.modes.mode_offline'
|
|
|
|
defaultMessage="Parity doesn't sync"
|
|
|
|
/>
|
2017-01-24 17:20:10 +01:00
|
|
|
))
|
2016-12-11 17:42:35 +01:00
|
|
|
}
|
2016-11-05 12:08:14 +01:00
|
|
|
</Select>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-03-13 12:10:53 +01:00
|
|
|
renderChains () {
|
|
|
|
const { chain } = this.store;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Select
|
|
|
|
id='parityChainSelect'
|
|
|
|
hint={
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.chains.hint'
|
|
|
|
defaultMessage='the chain for the Parity node to sync to'
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
label={
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.chains.label'
|
|
|
|
defaultMessage='chain/network to sync'
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
onChange={ this.onChangeChain }
|
|
|
|
value={ chain }
|
|
|
|
>
|
|
|
|
{
|
|
|
|
this.renderItem('foundation', (
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.chains.chain_foundation'
|
|
|
|
defaultMessage='Parity syncs to the Ethereum network launched by the Ethereum Foundation'
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
}
|
|
|
|
{
|
|
|
|
this.renderItem('kovan', (
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.chains.chain_kovan'
|
|
|
|
defaultMessage='Parity syncs to the Kovan test network'
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
}
|
|
|
|
{
|
|
|
|
this.renderItem('olympic', (
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.chains.chain_olympic'
|
|
|
|
defaultMessage='Parity syncs to the Olympic test network'
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
}
|
|
|
|
{
|
|
|
|
this.renderItem('morden', (
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.chains.cmorden_kovan'
|
|
|
|
defaultMessage='Parity syncs to Morden (Classic) test network'
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
}
|
|
|
|
{
|
|
|
|
this.renderItem('ropsten', (
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.chains.chain_ropsten'
|
|
|
|
defaultMessage='Parity syncs to the Ropsten test network'
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
}
|
|
|
|
{
|
|
|
|
this.renderItem('classic', (
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.chains.chain_classic'
|
|
|
|
defaultMessage='Parity syncs to the Ethereum Classic network'
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
}
|
|
|
|
{
|
|
|
|
this.renderItem('expanse', (
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.chains.chain_expanse'
|
|
|
|
defaultMessage='Parity syncs to the Expanse network'
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
}
|
|
|
|
{
|
|
|
|
this.renderItem('dev', (
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.chains.chain_dev'
|
|
|
|
defaultMessage='Parity uses a local development chain'
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
}
|
|
|
|
</Select>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-11-05 12:08:14 +01:00
|
|
|
onChangeMode = (event, index, mode) => {
|
2017-01-24 17:20:10 +01:00
|
|
|
this.store.changeMode(mode || event.target.value);
|
2016-11-05 12:08:14 +01:00
|
|
|
}
|
2017-03-13 12:10:53 +01:00
|
|
|
|
|
|
|
onChangeChain = (event, index, chain) => {
|
|
|
|
this.store.changeChain(chain || event.target.value);
|
|
|
|
}
|
2016-11-05 12:08:14 +01:00
|
|
|
}
|