Browse Source

added cli settings tab

all-modes
pbca26 8 years ago
parent
commit
a6a1744514
  1. 3
      react/src/actions/actions/cli.js
  2. 60
      react/src/components/dashboard/settings.js

3
react/src/actions/actions/cli.js

@ -52,12 +52,11 @@ export function shepherdCli(mode, chain, cmd) {
dispatch(triggerToaster(true, 'shepherdCli', 'Error', 'error')); dispatch(triggerToaster(true, 'shepherdCli', 'Error', 'error'));
}) })
.then(response => response.json()) .then(response => response.json())
.then(json => cliResponseState(json)) .then(json => dispatch(cliResponseState(json)))
} }
} }
export function cliResponseState(json) { export function cliResponseState(json) {
console.log('cliResponseState', json);
return { return {
type: CLI, type: CLI,
data: json, data: json,

60
react/src/components/dashboard/settings.js

@ -68,12 +68,10 @@ class Settings extends React.Component {
tabElId: this.state.tabElId, tabElId: this.state.tabElId,
})); }));
} }
console.log('settings props', props);
} }
execCliCmd() { execCliCmd() {
Store.dispatch(shepherdCli('passthru', null, 'getinfo')); Store.dispatch(shepherdCli('passthru', this.state.cliCoin, this.state.cliCmd));
} }
openTab(elemId, tab) { openTab(elemId, tab) {
@ -351,15 +349,63 @@ class Settings extends React.Component {
} }
renderCliResponse() { 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 ( return (
1234 <div>
<div>
<strong>CLI response:</strong>
</div>
{ JSON.stringify(_cliResponseParsed, null, '\t') }
</div>
); );
} else { } else {
return null; 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(
<option value={ coin } key={ coin }>{ coin } ({ mode })</option>
);
});
});
} else {
allCoins[mode].map(function(coin) {
items.push(
<option value={ coin } key={ coin }>{ coin } ({ mode })</option>
);
});
}
return items;
} else {
return null;
}
}
render() { render() {
return ( return (
<div className="margin-left-0"> <div className="margin-left-0">
@ -765,7 +811,8 @@ class Settings extends React.Component {
name="cliCoin" name="cliCoin"
id="settingsCliOptions" id="settingsCliOptions"
onChange={ this.updateInput }> onChange={ this.updateInput }>
<option value="komodo">Komodo</option> <option value="">Select coin</option>
{ this.renderActiveCoinsList('native') }
</select> </select>
<label <label
className="floating-label" className="floating-label"
@ -787,6 +834,7 @@ class Settings extends React.Component {
<button <button
type="button" type="button"
className="btn btn-primary waves-effect waves-light" className="btn btn-primary waves-effect waves-light"
disabled={ !this.state.cliCoin || !this.state.cliCmd }
onClick={ () => this.execCliCmd() }>Execute</button> onClick={ () => this.execCliCmd() }>Execute</button>
</div> </div>
<div className="col-sm-12 col-xs-12 text-align-left"> <div className="col-sm-12 col-xs-12 text-align-left">

Loading…
Cancel
Save