diff --git a/react/src/actions/actionCreators.js b/react/src/actions/actionCreators.js index 06f076d..dd1f06d 100644 --- a/react/src/actions/actionCreators.js +++ b/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) diff --git a/react/src/components/addcoin/addcoinOptionsCrypto.js b/react/src/components/addcoin/addcoinOptionsCrypto.js index f5c930a..f87c8f4 100644 --- a/react/src/components/addcoin/addcoinOptionsCrypto.js +++ b/react/src/components/addcoin/addcoinOptionsCrypto.js @@ -4,11 +4,11 @@ import { translate } from '../../translate/translate'; class AddCoinOptionsCrypto extends React.Component { render() { // - // // // return ( + diff --git a/react/src/components/app/app.js b/react/src/components/app/app.js index 9c5c998..75b3992 100644 --- a/react/src/components/app/app.js +++ b/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, }; } diff --git a/react/src/components/login/login.js b/react/src/components/login/login.js index 93c645c..7805837 100644 --- a/react/src/components/login/login.js +++ b/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 { SuperNET Iguana +
+ + Display sync only coins progress + +
+
diff --git a/react/src/components/main/walletMain.js b/react/src/components/main/walletMain.js index 179f0be..d53d560 100644 --- a/react/src/components/main/walletMain.js +++ b/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 (
+ diff --git a/react/src/reducers/index.js b/react/src/reducers/index.js index e69c68b..e18c9b1 100644 --- a/react/src/reducers/index.js +++ b/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, }); diff --git a/react/src/styles/index.scss b/react/src/styles/index.scss index d3ded81..cd16870 100644 --- a/react/src/styles/index.scss +++ b/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; }