Browse Source

syncOnly component(wip)

all-modes
pbca26 8 years ago
parent
commit
465cf5a39e
  1. 57
      react/src/actions/actionCreators.js
  2. 2
      react/src/components/addcoin/addcoinOptionsCrypto.js
  3. 1
      react/src/components/app/app.js
  4. 23
      react/src/components/login/login.js
  5. 2
      react/src/components/main/walletMain.js
  6. 2
      react/src/reducers/index.js
  7. 11
      react/src/styles/index.scss

57
react/src/actions/actionCreators.js

@ -47,9 +47,20 @@ export const DASHBOARD_GET_NOTARIES_LIST = 'DASHBOARD_GET_NOTARIES_LIST';
export const DASHBOARD_DISPLAY_NOTARIES_MODAL = 'DASHBOARD_DISPLAY_NOTARIES_MODAL';
export const DASHBOARD_CONNECT_NOTARIES = 'DASHBOARD_CONNECT_NOTARIES';
export const VIEW_CACHE_DATA = 'VIEW_CACHE_DATA';
export const SYNC_ONLY_MODAL_TOGGLE = 'SYNC_ONLY_MODAL_TOGGLE';
export const SYNC_ONLY_DATA = 'SYNC_ONLY_DATA';
export const LOAD_APP_CONFIG = 'LOAD_APP_CONFIG';
export const SAVE_APP_CONFIG = 'SAVE_APP_CONFIG';
var iguanaForks = {}; // forks in mem array
export function toggleSyncOnlyModal(display) {
return {
type: SYNC_ONLY_MODAL_TOGGLE,
display,
}
}
export function toggleViewCacheModal(display) {
return {
type: VIEW_CACHE_DATA,
@ -343,8 +354,10 @@ export function addCoin(coin, mode, syncOnly) {
return dispatch => {
startIguanaInstance(modeToValue[mode] + '/sync', coin)
.then(function(json) {
console.log('started ' + coin + ' / ' + modeToValue[mode] + ' fork', json);
dispatch(iguanaAddCoin(coin, mode, _acData));
setTimeout(function() {
console.log('started ' + coin + ' / ' + modeToValue[mode] + ' fork', json);
dispatch(iguanaAddCoin(coin, mode, _acData, json.result));
}, 2000);
});
}
} else {
@ -356,9 +369,9 @@ export function addCoin(coin, mode, syncOnly) {
}
}
export function iguanaAddCoin(coin, mode, acData) {
export function iguanaAddCoin(coin, mode, acData, port) {
function _iguanaAddCoin(dispatch) {
return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
return fetch('http://127.0.0.1:' + (port ? port : Config.iguanaCorePort), {
method: 'POST',
body: JSON.stringify(acData),
})
@ -2433,10 +2446,8 @@ export function edexGetTransaction(data) {
function getAppConfigState(json) {
return {
type: DASHBOARD_CONNECT_NOTARIES,
total: json.length - 1,
current: 0,
name: json[0],
type: LOAD_APP_CONFIG,
config: json,
}
}
@ -2457,6 +2468,36 @@ export function getAppConfig() {
}
}
function getSyncOnlyForksState(json) {
/*try {
JSON.parse(json.result);
} catch(e) {
console.log(e);
}*/
return {
type: SYNC_ONLY_DATA,
forks: JSON.parse(json.result),
}
}
export function getSyncOnlyForks() {
return dispatch => {
return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/forks/info/show', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'getSyncOnlyForks', 'Error', 'error'));
})
.then(response => response.json())
.then(json => dispatch(getSyncOnlyForksState(json)))
}
}
/*function Shepherd_SendPendValue() {
Shepherd_SysInfo().then(function(result){
var ram_data = formatBytes(result.totalmem_bytes)

2
react/src/components/addcoin/addcoinOptionsCrypto.js

@ -4,11 +4,11 @@ import { translate } from '../../translate/translate';
class AddCoinOptionsCrypto extends React.Component {
render() {
//<option value="ANC|full" data-full-mode="true">AnonCoin (ANC)</option>
//<option value="BTCD|full">BitcoinDark (BTCD)</option>
//<option value="MZC|full">MazaCoin (MZC)</option>
//<option value="SYS|full">SysCoin (SYS)</option>
return (
<optgroup label="Crypto Currencies">
<option value="BTCD|full">BitcoinDark (BTCD)</option>
<option value="BTC|full|basilisk">Bitcoin (BTC)</option>
<option value="BTM|full">Bitmark (BTM)</option>
<option value="CARB|full">Carboncoin (CARB)</option>

1
react/src/components/app/app.js

@ -13,6 +13,7 @@ function mapStateToProps(state) {
Atomic: state.Atomic,
Settings: state.Settings,
Interval: state.Interval,
SyncOnly: state.SyncOnly,
};
}

23
react/src/components/login/login.js

@ -4,7 +4,10 @@ import {
toggleAddcoinModal,
iguanaWalletPassphrase,
createNewWallet,
iguanaActiveHandle
iguanaActiveHandle,
toggleSyncOnlyModal,
startInterval,
getSyncOnlyForks
} from '../../actions/actionCreators';
import Store from '../../store';
import { PassPhraseGenerator } from '../../util/crypto/passphrasegenerator';
@ -27,6 +30,18 @@ class Login extends React.Component {
this.loginSeed = this.loginSeed.bind(this);
this.toggleSeedInputVisibility = this.toggleSeedInputVisibility.bind(this);
this.handleRegisterWallet = this.handleRegisterWallet.bind(this);
this.openSyncOnlyModal = this.openSyncOnlyModal.bind(this);
}
openSyncOnlyModal() {
Store.dispatch(getSyncOnlyForks());
var _iguanaActiveHandle = setInterval(function() {
Store.dispatch(getSyncOnlyForks());
}.bind(this), 3000);
Store.dispatch(startInterval('syncOnly', _iguanaActiveHandle));
Store.dispatch(toggleSyncOnlyModal(true));
}
componentDidMount() {
@ -115,6 +130,12 @@ class Login extends React.Component {
<img className="brand-img" src="assets/images/easydex-logo-big.png" alt="SuperNET Iguana" />
</div>
<div style={{padding: '20px 0'}}>
<span className="display-sync-only-coins-toggle" onClick={this.openSyncOnlyModal}>
<i className="fa fa-cubes"></i> Display sync only coins progress
</span>
</div>
<div id="section-ie-warning" className={this.state.activeLoginSection === 'ieWarning' ? 'show' : 'hide'}>
<div className="panel">
<div className="panel-heading">

2
react/src/components/main/walletMain.js

@ -3,11 +3,13 @@ import Toaster from '../toaster/toaster';
import AddCoin from '../addcoin/addcoin';
import Login from '../login/login';
import Dashboard from '../dashboard/dashboard';
import SyncOnly from '../dashboard/syncOnly';
class WalletMain extends React.Component {
render() {
return (
<div style={{height: '100%'}}>
<SyncOnly {...this.props} />
<Dashboard {...this.props} />
<AddCoin {...this.props.AddCoin} />
<Login {...this.props} />

2
react/src/reducers/index.js

@ -9,6 +9,7 @@ import { ActiveCoin } from './activeCoin';
import { Atomic } from './atomic';
import { Settings } from './settings';
import { Interval } from './interval';
import { SyncOnly } from './syncOnly';
const rootReducer = combineReducers({
AddCoin,
@ -19,6 +20,7 @@ const rootReducer = combineReducers({
Atomic,
Settings,
Interval,
SyncOnly,
routing: routerReducer,
});

11
react/src/styles/index.scss

@ -154,6 +154,17 @@ body {
height: 100%;
}
.display-sync-only-coins-toggle {
cursor: pointer;
}
.display-sync-only-coins-toggle:hover {
color: #ffa726;
}
.sync-only-forks {
color: #757575;
}
/*.toaster .single-toast:nth-child(0) {
bottom: 12px;
}

Loading…
Cancel
Save