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 { observer } from 'mobx-react';
|
2017-07-17 18:37:33 +02:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2016-12-11 17:42:35 +01:00
|
|
|
import { FormattedMessage } from 'react-intl';
|
2016-11-05 12:08:14 +01:00
|
|
|
|
2017-05-12 12:06:16 +02:00
|
|
|
import { Container, Dropdown, LanguageSelector } from '@parity/ui';
|
|
|
|
import Features, { FeaturesStore, FEATURES } from '@parity/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
|
2017-05-05 15:14:05 +02:00
|
|
|
export default class Node extends Component {
|
2016-11-05 12:08:14 +01:00
|
|
|
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-05-12 17:06:53 +02:00
|
|
|
renderItem (name, label) {
|
2017-05-11 14:02:27 +02:00
|
|
|
return {
|
|
|
|
key: name,
|
|
|
|
text: name,
|
|
|
|
value: name,
|
|
|
|
content: label
|
|
|
|
};
|
2017-01-24 17:20:10 +01:00
|
|
|
}
|
|
|
|
|
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>
|
2017-05-11 14:02:27 +02:00
|
|
|
<Dropdown
|
2017-01-24 17:20:10 +01:00
|
|
|
onChange={ onChange }
|
|
|
|
value={ level }
|
2017-05-15 14:49:47 +02:00
|
|
|
options={ LOGLEVEL_OPTIONS }
|
2017-01-24 17:20:10 +01:00
|
|
|
/>
|
|
|
|
</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 (
|
2017-05-03 12:16:20 +02:00
|
|
|
<div className={ layout.option }>
|
2017-05-12 17:06:53 +02:00
|
|
|
<Dropdown
|
2017-05-05 15:14:05 +02:00
|
|
|
id='parityModeSelect'
|
2017-05-12 17:06:53 +02:00
|
|
|
label={
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.modes.hint'
|
|
|
|
defaultMessage='Choose the syncing mode for the Parity node'
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
onChange={ this.onChangeMode }
|
2017-05-03 12:16:20 +02:00
|
|
|
value={ mode }
|
2017-05-12 17:06:53 +02:00
|
|
|
options={ [
|
|
|
|
this.renderItem('active', (
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.modes.mode_active'
|
|
|
|
defaultMessage='Continuously sync'
|
|
|
|
/>
|
|
|
|
)),
|
|
|
|
this.renderItem('passive', (
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.modes.mode_passive'
|
|
|
|
defaultMessage='Sync on intervals'
|
|
|
|
/>
|
|
|
|
)),
|
|
|
|
this.renderItem('dark', (
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.modes.mode_dark'
|
|
|
|
defaultMessage='Sync when RPC is active'
|
|
|
|
/>
|
|
|
|
)),
|
|
|
|
this.renderItem('offline', (
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.modes.mode_offline'
|
|
|
|
defaultMessage='No Syncing'
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
] }
|
|
|
|
/>
|
2017-05-03 12:16:20 +02:00
|
|
|
</div>
|
2016-11-05 12:08:14 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-03-13 12:10:53 +01:00
|
|
|
renderChains () {
|
|
|
|
const { chain } = this.store;
|
|
|
|
|
|
|
|
return (
|
2017-05-03 12:16:20 +02:00
|
|
|
<div className={ layout.option }>
|
2017-05-12 17:06:53 +02:00
|
|
|
<Dropdown
|
2017-05-05 15:14:05 +02:00
|
|
|
id='parityChainSelect'
|
2017-05-12 17:06:53 +02:00
|
|
|
label={
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.chains.hint'
|
|
|
|
defaultMessage='Choose the chain for the Parity node to sync to'
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
onChange={ this.onChangeChain }
|
2017-05-03 12:16:20 +02:00
|
|
|
value={ chain }
|
2017-05-12 17:06:53 +02:00
|
|
|
options={ [
|
|
|
|
this.renderItem('foundation', (
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.chains.chain_foundation'
|
|
|
|
defaultMessage='Ethereum Foundation'
|
|
|
|
/>
|
|
|
|
)),
|
|
|
|
this.renderItem('kovan', (
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.chains.chain_kovan'
|
|
|
|
defaultMessage='Kovan test network'
|
|
|
|
/>
|
|
|
|
)),
|
|
|
|
this.renderItem('olympic', (
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.chains.chain_olympic'
|
|
|
|
defaultMessage='Olympic test network'
|
|
|
|
/>
|
|
|
|
)),
|
|
|
|
this.renderItem('morden', (
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.chains.cmorden_kovan'
|
|
|
|
defaultMessage='Morden (Classic) test network'
|
|
|
|
/>
|
|
|
|
)),
|
|
|
|
this.renderItem('ropsten', (
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.chains.chain_ropsten'
|
|
|
|
defaultMessage='Ropsten test network'
|
|
|
|
/>
|
|
|
|
)),
|
|
|
|
this.renderItem('classic', (
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.chains.chain_classic'
|
|
|
|
defaultMessage='Ethereum Classic network'
|
|
|
|
/>
|
|
|
|
)),
|
|
|
|
this.renderItem('expanse', (
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.chains.chain_expanse'
|
|
|
|
defaultMessage='Expanse network'
|
|
|
|
/>
|
|
|
|
)),
|
|
|
|
this.renderItem('dev', (
|
|
|
|
<FormattedMessage
|
|
|
|
id='settings.parity.chains.chain_dev'
|
|
|
|
defaultMessage='Local development chain'
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
] }
|
|
|
|
/>
|
2017-05-03 12:16:20 +02:00
|
|
|
</div>
|
2017-03-13 12:10:53 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-05-12 17:06:53 +02:00
|
|
|
onChangeMode = (event, mode) => {
|
2017-05-03 12:16:20 +02:00
|
|
|
this.store.changeMode(mode.name);
|
2016-11-05 12:08:14 +01:00
|
|
|
}
|
2017-03-13 12:10:53 +01:00
|
|
|
|
2017-05-12 17:06:53 +02:00
|
|
|
onChangeChain = (event, chain) => {
|
2017-05-03 12:16:20 +02:00
|
|
|
this.store.changeChain(chain.name);
|
2017-03-13 12:10:53 +01:00
|
|
|
}
|
2016-11-05 12:08:14 +01:00
|
|
|
}
|