Browse Source

temp

all-modes
Petr Balashov 8 years ago
parent
commit
c153f55018
  1. 2
      assets/scripts/config.js
  2. 15
      react/src/actions/actionCreators.js
  3. 11
      react/src/components/addcoin/addcoin.js

2
assets/scripts/config.js

@ -1,3 +1,3 @@
const config = { const config = {
'iguanaPort': 7772 'iguanaPort': 7778
}; };

15
react/src/actions/actionCreators.js

@ -15,7 +15,8 @@ function triggerToaster(display, message, title, _type) {
export function addCoin(coin, mode) { export function addCoin(coin, mode) {
console.log('coin, mode', coin + ' ' + mode); console.log('coin, mode', coin + ' ' + mode);
return dispatch => { return dispatch => {
dispatch(triggerToaster(true, 'Coin ' + coin + ' added in ' + mode, 'Coin message', 'warning')) dispatch(shepherdGetConfig);
//dispatch(triggerToaster(true, 'Coin ' + coin + ' added in ' + mode, 'Coin message', 'warning'))
/*return fetch(``) /*return fetch(``)
.then(response => response.json()) .then(response => response.json())
.then(json => dispatch(r(json)))*/ .then(json => dispatch(r(json)))*/
@ -25,13 +26,17 @@ export function addCoin(coin, mode) {
export function shepherdGetConfig() { export function shepherdGetConfig() {
return dispatch => { return dispatch => {
return fetch('http://127.0.0.1:17777/shepherd/getconf', { return fetch('http://127.0.0.1:17777/shepherd/getconf', {
method: 'POST'
}) })
//.then(response => response.json()) .then(response => response.json())
//.then(json => dispatch(r(json))) //.then(json => dispatch(r(json)))
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'Failed to get mode config', 'Error', 'error'))
});
} }
function Shepherd_getConf(coin) { /*function Shepherd_getConf(coin) {
var result = [], var result = [],
ajax_data = { 'chain': coin }; ajax_data = { 'chain': coin };
@ -52,5 +57,5 @@ function Shepherd_getConf(coin) {
}); });
return result; return result;
} }*/
} }

11
react/src/components/addcoin/addcoin.js

@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import { translate } from '../../translate/translate'; import { translate } from '../../translate/translate';
import { addCoin } from '../../actions/actionCreators'; import { addCoin, shepherdGetConfig } from '../../actions/actionCreators';
import { startCurrencyAssetChain } from './payload'; import { startCurrencyAssetChain } from './payload';
import Store from '../../store'; import Store from '../../store';
@ -21,7 +21,7 @@ class AddCoin extends React.Component {
disabled: true, disabled: true,
checked: false, checked: false,
}, },
mode: null, mode: -2,
}; };
this.updateSelectedCoin = this.updateSelectedCoin.bind(this); this.updateSelectedCoin = this.updateSelectedCoin.bind(this);
this.updateSelectedMode = this.updateSelectedMode.bind(this); this.updateSelectedMode = this.updateSelectedMode.bind(this);
@ -54,7 +54,7 @@ class AddCoin extends React.Component {
disabled: e.target.value.indexOf('native') > -1 ? false : true, disabled: e.target.value.indexOf('native') > -1 ? false : true,
checked: defaultMode === 'native' ? true : false, checked: defaultMode === 'native' ? true : false,
}, },
mode: modeToValue[defaultMode], mode: modeToValue[defaultMode] !== undefined ? modeToValue[defaultMode] : -2,
})); }));
} }
@ -98,7 +98,8 @@ class AddCoin extends React.Component {
} }
activateCoin() { activateCoin() {
console.log(startCurrencyAssetChain(this.state.selectedCoin.split('|')[0], this.state.mode)); Store.dispatch(shepherdGetConfig());
//console.log(startCurrencyAssetChain(this.state.selectedCoin.split('|')[0], this.state.mode));
//Store.dispatch(addCoin(this.state.selectedCoin.split('|')[0], this.state.mode)); //Store.dispatch(addCoin(this.state.selectedCoin.split('|')[0], this.state.mode));
} }
@ -193,7 +194,7 @@ class AddCoin extends React.Component {
</div> </div>
</div> </div>
<div className="col-sm-4"> <div className="col-sm-4">
<button type="button" className="btn btn-primary mdl_addcoin_done_btn-login" data-toggle="modal" data-dismiss="modal" id="mdl_addcoin_done_btn-login" onClick={this.activateCoin} disabled={this.state.selectedCoin === '-Select-'}>{translate('INDEX.ACTIVATE_COIN')}</button> <button type="button" className="btn btn-primary mdl_addcoin_done_btn-login" data-toggle="modal" data-dismiss="modal" id="mdl_addcoin_done_btn-login" onClick={this.activateCoin} disabled={this.state.mode === -2 }>{translate('INDEX.ACTIVATE_COIN')}</button>
</div> </div>
<div className="col-sm-12 text-center"> <div className="col-sm-12 text-center">
<div className="form-group col-lg-4 col-md-4 col-sm-6 col-xs-6 style-addcoin-lbl-mdl-login"> <div className="form-group col-lg-4 col-md-4 col-sm-6 col-xs-6 style-addcoin-lbl-mdl-login">

Loading…
Cancel
Save