Browse Source

komodod param dropdown on addcoin

all-modes
pbca26 8 years ago
parent
commit
93c317fb5a
  1. 30
      react/src/actions/actions/addCoin.js
  2. 33
      react/src/components/addcoin/addcoin.js
  3. 14
      react/src/components/addcoin/coin-selectors.render.js

30
react/src/actions/actions/addCoin.js

@ -19,12 +19,11 @@ import {
checkAC
} from '../../components/addcoin/payload';
export function addCoin(coin, mode, syncOnly, port) {
export function addCoin(coin, mode, syncOnly, port, startupParams) {
if (mode === '-1' ||
mode === -1) {
mode = '-1';
return dispatch => {
dispatch(shepherdGetConfig(coin, mode));
dispatch(shepherdGetConfig(coin, '-1', startupParams));
}
} else {
if (checkCoinType(coin) === 'currency_ac') {
@ -154,7 +153,7 @@ export function iguanaAddCoin(coin, mode, acData, port) {
}
}
export function shepherdHerd(coin, mode, path) {
export function shepherdHerd(coin, mode, path, startupParams) {
let acData;
let herdData = {
'ac_name': coin,
@ -186,6 +185,15 @@ export function shepherdHerd(coin, mode, path) {
};
}
if (startupParams) {
herdData['ac_custom_param'] = startupParams.type;
if (startupParams.value) {
herdData['ac_custom_param_value'] = startupParams.value;
}
}
// TODO: switch statement
if (checkCoinType(coin) === 'crypto') {
acData = startCrypto(
path.result,
@ -193,6 +201,7 @@ export function shepherdHerd(coin, mode, path) {
mode
);
}
if (checkCoinType(coin) === 'currency_ac') {
acData = startCurrencyAssetChain(
path.result,
@ -280,7 +289,7 @@ export function addCoinResult(coin, mode) {
}
}
export function _shepherdGetConfig(coin, mode) {
export function _shepherdGetConfig(coin, mode, startupParams) {
return dispatch => {
return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/getconf`, {
method: 'POST',
@ -305,7 +314,8 @@ export function _shepherdGetConfig(coin, mode) {
shepherdHerd(
coin,
mode,
json
json,
startupParams
)
)
);
@ -339,7 +349,7 @@ export function iguanaActiveHandleBypass() {
}
}
export function shepherdGetConfig(coin, mode) {
export function shepherdGetConfig(coin, mode, startupParams) {
if (coin === 'KMD' &&
mode === '-1') {
return dispatch => {
@ -366,7 +376,8 @@ export function shepherdGetConfig(coin, mode) {
shepherdHerd(
coin,
mode,
json
json,
startupParams
)
)
)
@ -396,7 +407,8 @@ export function shepherdGetConfig(coin, mode) {
shepherdHerd(
coin,
mode,
json
json,
startupParams
)
)
);

33
react/src/components/addcoin/addcoin.js

@ -35,6 +35,7 @@ class AddCoin extends React.Component {
},
mode: -2,
syncOnly: false,
daemonParam: null,
},
display: false,
actionsMenu: false,
@ -89,6 +90,18 @@ class AddCoin extends React.Component {
}));
}
updateDaemonParam(e, index) {
let _coins = this.state.coins;
_coins[index] = Object.assign({}, _coins[index], {
[e.target.name]: e.target.value,
});
this.setState(Object.assign({}, this.state, {
coins: _coins,
}));
}
toggleActionsMenu() {
this.setState(Object.assign({}, this.state, {
actionsMenu: !this.state.actionsMenu,
@ -193,11 +206,21 @@ class AddCoin extends React.Component {
return;
}
Store.dispatch(addCoin(
coin,
this.state.coins[0].mode,
this.state.coins[0].syncOnly
));
if (!this.state.coins[0].daemonParam) {
Store.dispatch(addCoin(
coin,
this.state.coins[0].mode,
this.state.coins[0].syncOnly,
));
} else {
Store.dispatch(addCoin(
coin,
this.state.coins[0].mode,
this.state.coins[0].syncOnly,
null,
{ type: this.state.coins[0].daemonParam }
));
}
this.removeCoin();
this.addNewItem();

14
react/src/components/addcoin/coin-selectors.render.js

@ -133,6 +133,20 @@ const CoinSelectorsRender = function(item, coin, i) {
<i className="fa fa-trash-o"></i>
</button>
</div>
<div className={ item.mode === '-1' || item.mode === -1 ? 'col-sm-5' : 'hide' }>
<div className="toggle-box padding-top-3 padding-bottom-10">
<select
className="form-control form-material"
name="daemonParam"
onChange={ (event) => this.updateDaemonParam(event, i) }
autoFocus>
<option>Daemon param: none</option>
<option value="silent">Daemon param: background process</option>
<option value="reindex">Daemon param: reindex</option>
<option value="rescan">Daemon param: rescan</option>
</select>
</div>
</div>
<div className={ item.mode === '1' || item.mode === 1 ? 'col-sm-12' : 'hide' }>
<div className="toggle-box padding-top-3 padding-bottom-10">
<span className="pointer">

Loading…
Cancel
Save