import React from 'react'; import { translate } from '../../translate/translate'; import { iguanaActiveHandle, encryptWallet, settingsWifkeyState, importPrivKey, getDebugLog, getPeersList, addPeerNode, getAppConfig, saveAppConfig, getAppInfo } from '../../actions/actionCreators'; import Store from '../../store'; import AddCoinOptionsCrypto from '../addcoin/addcoinOptionsCrypto'; import AddCoinOptionsAC from '../addcoin/addcoinOptionsAC'; import AddCoinOptionsACFiat from '../addcoin/addcoinOptionsACFiat'; /* TODO: 1) pre-select active coin in add node tab 2) add fiat section 3) kickstart section 4) batch export/import wallet addresses */ class Settings extends React.Component { constructor(props) { super(props); this.state = { activeTab: 0, debugLinesCount: 10, debugTarget: 'iguana', activeTabHeight: '10px', appSettings: {}, }; this.exportWifKeys = this.exportWifKeys.bind(this); this.updateInput = this.updateInput.bind(this); this.updateInputSettings = this.updateInputSettings.bind(this); this.importWifKey = this.importWifKey.bind(this); this.readDebugLog = this.readDebugLog.bind(this); this.checkNodes = this.checkNodes.bind(this); this.addNode = this.addNode.bind(this); this.renderPeersList = this.renderPeersList.bind(this); this.renderSNPeersList = this.renderSNPeersList.bind(this); this._saveAppConfig = this._saveAppConfig.bind(this); } componentDidMount() { Store.dispatch(iguanaActiveHandle()); Store.dispatch(getAppConfig()); Store.dispatch(getAppInfo()); } openTab(elemId, tab) { const _height = document.querySelector('#' + elemId + ' .panel-collapse .panel-body').offsetHeight; this.setState(Object.assign({}, this.state, { activeTab: tab, activeTabHeight: _height, })); } exportWifKeys() { Store.dispatch(encryptWallet(this.state.wifkeysPassphrase, settingsWifkeyState, this.props.ActiveCoin.coin)); } importWifKey() { Store.dispatch(importPrivKey(this.state.importWifKey)); } readDebugLog() { Store.dispatch(getDebugLog(this.state.debugTarget, this.state.debugLinesCount)); } checkNodes() { if (this.state.getPeersCoin) { Store.dispatch(getPeersList(this.state.getPeersCoin.split('|')[0])); } } addNode() { if (this.state.addNodeCoin) { Store.dispatch(addPeerNode(this.state.addNodeCoin.split('|')[0], this.state.addPeerIP)); } } renderPeersList() { if (this.state.getPeersCoin) { const coin = this.state.getPeersCoin.split('|')[0]; if (this.props.Settings.rawPeers && this.state.getPeersCoin && this.props.Settings.rawPeers[coin]) { return this.props.Settings.rawPeers[coin].map((ip) =>
{ translate('INDEX.KEY') } | { translate('INDEX.VALUE') } |
---|---|
pubkey |
{ this.props.Main.activeHandle.pubkey }
|
btcpubkey |
{ this.props.Main.activeHandle.btcpubkey }
|
rmd160 |
{ this.props.Main.activeHandle.rmd160 }
|
NXT |
{ this.props.Main.activeHandle.NXT }
|
notary |
{ this.props.Main.activeHandle.notary }
|
status |
{ this.props.Main.activeHandle.status }
|
{ translate('INDEX.USE_THIS_SECTION') }
{ this.renderSNPeersList() }
{ this.renderPeersList() }
{ translate('INDEX.USE_THIS_SECTION_PEER') }
{ this.props.ActiveCoin.coin } | { this.props.Settings.address } |
{ this.props.ActiveCoin.coin }Wif | { this.props.Settings.wifkey } |
{ translate('INDEX.DEBUG_LOG_DESC') }
{ translate('SETTINGS.CONFIG_RESTART_REQUIRED') }