From a6a174451450148f9e516af5c124c71f337b9458 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Wed, 7 Jun 2017 13:59:46 +0300 Subject: [PATCH] added cli settings tab --- react/src/actions/actions/cli.js | 3 +- react/src/components/dashboard/settings.js | 60 +++++++++++++++++++--- 2 files changed, 55 insertions(+), 8 deletions(-) diff --git a/react/src/actions/actions/cli.js b/react/src/actions/actions/cli.js index 7cfe477..4ac228a 100644 --- a/react/src/actions/actions/cli.js +++ b/react/src/actions/actions/cli.js @@ -52,12 +52,11 @@ export function shepherdCli(mode, chain, cmd) { dispatch(triggerToaster(true, 'shepherdCli', 'Error', 'error')); }) .then(response => response.json()) - .then(json => cliResponseState(json)) + .then(json => dispatch(cliResponseState(json))) } } export function cliResponseState(json) { - console.log('cliResponseState', json); return { type: CLI, data: json, diff --git a/react/src/components/dashboard/settings.js b/react/src/components/dashboard/settings.js index 4367884..452b96b 100644 --- a/react/src/components/dashboard/settings.js +++ b/react/src/components/dashboard/settings.js @@ -68,12 +68,10 @@ class Settings extends React.Component { tabElId: this.state.tabElId, })); } - - console.log('settings props', props); } execCliCmd() { - Store.dispatch(shepherdCli('passthru', null, 'getinfo')); + Store.dispatch(shepherdCli('passthru', this.state.cliCoin, this.state.cliCmd)); } openTab(elemId, tab) { @@ -351,15 +349,63 @@ class Settings extends React.Component { } renderCliResponse() { - if (this.state.cliResponse) { + const _cliResponse = this.props.Settings.cli; + + if (_cliResponse) { + let _cliResponseParsed; + + try { + _cliResponseParsed = JSON.parse(_cliResponse.result) + } catch(e) { + _cliResponseParsed = _cliResponse.result; + } + return ( - 1234 +
+
+ CLI response: +
+ { JSON.stringify(_cliResponseParsed, null, '\t') } +
); } else { return null; } } + renderActiveCoinsList(mode) { + const modes = [ + 'native', + 'basilisk', + 'full' + ]; + + const allCoins = this.props.Main.coins; + let items = []; + + if (allCoins) { + if (mode === 'all') { + modes.map(function(mode) { + allCoins[mode].map(function(coin) { + items.push( + + ); + }); + }); + } else { + allCoins[mode].map(function(coin) { + items.push( + + ); + }); + } + + return items; + } else { + return null; + } + } + render() { return (
@@ -765,7 +811,8 @@ class Settings extends React.Component { name="cliCoin" id="settingsCliOptions" onChange={ this.updateInput }> - + + { this.renderActiveCoinsList('native') }