From 953d9a4d751db2c73d957dfe9acdbe30011729a4 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Thu, 8 Jun 2017 08:39:06 +0300 Subject: [PATCH] extended settings wifkeys export --- react/src/actions/actions/settings.js | 2 +- react/src/components/dashboard/settings.js | 80 ++++++++++++++++++---- 2 files changed, 68 insertions(+), 14 deletions(-) diff --git a/react/src/actions/actions/settings.js b/react/src/actions/actions/settings.js index 6f61fe4..21a01a3 100644 --- a/react/src/actions/actions/settings.js +++ b/react/src/actions/actions/settings.js @@ -42,7 +42,7 @@ export function getAppInfo() { export function settingsWifkeyState(json, coin) { return { type: GET_WIF_KEY, - wifkey: json[`${coin}wif`], + wifkey: json, address: json[coin], } } diff --git a/react/src/components/dashboard/settings.js b/react/src/components/dashboard/settings.js index 98e8f9a..8c6d9ac 100644 --- a/react/src/components/dashboard/settings.js +++ b/react/src/components/dashboard/settings.js @@ -39,6 +39,7 @@ class Settings extends React.Component { cliCmdString: null, cliCoin: null, cliResponse: null, + exportWifKeysRaw: false, }; this.exportWifKeys = this.exportWifKeys.bind(this); this.updateInput = this.updateInput.bind(this); @@ -50,6 +51,7 @@ class Settings extends React.Component { this.renderPeersList = this.renderPeersList.bind(this); this.renderSNPeersList = this.renderSNPeersList.bind(this); this._saveAppConfig = this._saveAppConfig.bind(this); + this.exportWifKeysRaw = this.exportWifKeysRaw.bind(this); } componentDidMount() { @@ -406,6 +408,60 @@ class Settings extends React.Component { } } + renderExportWifKeysRaw() { + const _wifKeysResponse = this.props.Settings.wifkey; + + if (_wifKeysResponse && + this.state.exportWifKeysRaw) { + return ( +
{ JSON.stringify(_wifKeysResponse, null, '\t') }
+ ); + } else { + return null; + } + } + + renderWifKeys() { + let items = []; + + if (this.props.Settings.wifkey) { + const _wifKeys = this.props.Settings.wifkey; + + for (let i = 0; i < 2; i++) { + items.push( + + + { i === 0 ? 'Address list' : 'Wif key list' } + + + + ); + + for (let _key in _wifKeys) { + if ((i === 0 && _key.length === 3 && _key !== 'tag') || + (i === 1 && _key.indexOf('wif') > -1)) { + items.push( + + { _key } + { _wifKeys[_key] } + + ); + } + } + } + + return items; + } else { + return null; + } + } + + exportWifKeysRaw() { + this.setState(Object.assign({}, this.state, { + exportWifKeysRaw: !this.state.exportWifKeysRaw, + })); + } + render() { return (
@@ -625,20 +681,18 @@ class Settings extends React.Component {
- - - - - - - - - +
- { this.props.ActiveCoin.coin } - { this.props.Settings.address }
- { this.props.ActiveCoin.coin }Wif - { this.props.Settings.wifkey }
+ { this.renderWifKeys() }
+
+ +
+
+ { this.renderExportWifKeysRaw() } +