Browse Source

moved coin progress prop from dashboard to activeCoin reducer

all-modes
pbca26 8 years ago
parent
commit
65cf4fb781
  1. 1
      react/src/components/addcoin/addcoinOptionsAC.js
  2. 4
      react/src/components/dashboard/coindDownModal/coindDownModal.js
  3. 2
      react/src/components/dashboard/coindDownModal/coindDownModal.render.js
  4. 2
      react/src/components/dashboard/loginModal/loginModal.render.js
  5. 4
      react/src/components/dashboard/syncOnly/syncOnly.render.js
  6. 22
      react/src/components/dashboard/walletsBalance/walletsBalance.js
  7. 16
      react/src/components/dashboard/walletsData/walletsData.js
  8. 8
      react/src/components/dashboard/walletsInfo/walletsInfo.js
  9. 38
      react/src/components/dashboard/walletsInfo/walletsInfo.render.js
  10. 81
      react/src/components/dashboard/walletsProgress/walletsProgress.js
  11. 26
      react/src/components/dashboard/walletsProgress/walletsProgress.render.js
  12. 2
      react/src/components/login/swall-modal.render.js
  13. 24
      react/src/reducers/activeCoin.js

1
react/src/components/addcoin/addcoinOptionsAC.js

@ -19,6 +19,7 @@ class AddCoinOptionsAC extends React.Component {
'revs',
'shark',
'supernet',
'wlc'
];
let _items = [];

4
react/src/components/dashboard/coindDownModal/coindDownModal.js

@ -37,6 +37,10 @@ class CoindDownModal extends React.Component {
}
const mapStateToProps = (state) => {
return {
ActiveCoin: {
mode: state.ActiveCoin.mode,
coin: state.ActiveCoin.coin,
},
displayCoindDownModal: state.Dashboard.displayCoindDownModal,
debugLog: state.Settings.debugLog,
};

2
react/src/components/dashboard/coindDownModal/coindDownModal.render.js

@ -1,7 +1,7 @@
import React from 'react';
import { translate } from '../../../translate/translate';
const CoindDownModalRender = function () {
const CoindDownModalRender = function() {
return (
<div>
<div

2
react/src/components/dashboard/loginModal/loginModal.render.js

@ -1,7 +1,7 @@
import React from 'react';
import { translate } from '../../../translate/translate';
const LoginModalRender = function () {
const LoginModalRender = function() {
return (
<div>
<div

4
react/src/components/dashboard/syncOnly/syncOnly.render.js

@ -1,7 +1,7 @@
import React from 'react';
import { translate } from '../../../translate/translate';
export const ProgressRender = function (fork) {
export const ProgressRender = function(fork) {
return (
<div>
<div>
@ -46,7 +46,7 @@ export const ProgressRender = function (fork) {
);
};
export const ForkItemRender = function (forkInfo, port) {
export const ForkItemRender = function(forkInfo, port) {
return (
<div
key={ port }

22
react/src/components/dashboard/walletsBalance/walletsBalance.js

@ -30,11 +30,13 @@ class WalletsBalance extends React.Component {
}
isFullySynced() {
if (this.props.Dashboard.progress &&
(Number(this.props.Dashboard.progress.balances) +
Number(this.props.Dashboard.progress.validated) +
Number(this.props.Dashboard.progress.bundles) +
Number(this.props.Dashboard.progress.utxo)) / 4 === 100) {
const _progress = this.props.ActiveCoin.progress;
if (_progress &&
(Number(_progress.balances) +
Number(_progress.validated) +
Number(_progress.bundles) +
Number(_progress.utxo)) / 4 === 100) {
return true;
} else {
return false;
@ -119,9 +121,9 @@ class WalletsBalance extends React.Component {
}
if (type === 'interest' &&
this.props.Dashboard.progress &&
this.props.Dashboard.progress.interest) {
_balance = this.props.Dashboard.progress.interest;
this.props.ActiveCoin.progress &&
this.props.ActiveCoin.progress.interest) {
_balance = this.props.ActiveCoin.progress.interest;
}
if (type === 'private' &&
@ -199,10 +201,10 @@ const mapStateToProps = (state) => {
balance: state.ActiveCoin.balance,
cache: state.ActiveCoin.cache,
activeSection: state.ActiveCoin.activeSection,
activeAddress: state.ActiveCoin.activeAddress
activeAddress: state.ActiveCoin.activeAddress,
progress: state.ActiveCoin.progress,
},
Dashboard: {
progress: state.Dashboard.progress,
activeHandle: state.Dashboard.activeHandle,
},
};

16
react/src/components/dashboard/walletsData/walletsData.js

@ -365,11 +365,13 @@ class WalletsData extends React.Component {
}
isFullySynced() {
if (this.props.Dashboard.progress &&
(Number(this.props.Dashboard.progress.balances) +
Number(this.props.Dashboard.progress.validated) +
Number(this.props.Dashboard.progress.bundles) +
Number(this.props.Dashboard.progress.utxo)) / 4 === 100) {
const _progress = this.props.ActiveCoin.progress;
if (_progress &&
(Number(_progress.balances) +
Number(_progress.validated) +
Number(_progress.bundles) +
Number(_progress.utxo)) / 4 === 100) {
return true;
} else {
return false;
@ -644,15 +646,15 @@ const mapStateToProps = (state) => {
addresses: state.ActiveCoin.addresses,
txhistory: state.ActiveCoin.txhistory,
showTransactionInfo: state.ActiveCoin.showTransactionInfo,
progress: state.ActiveCoin.progress,
},
Dashboard: {
activeHandle: state.Dashboard.activeHandle,
displayViewCacheModal: state.Dashboard.displayViewCacheModal,
progress: state.Dashboard.progress,
},
Main: {
coins: state.Main.coins,
}
},
};
};

8
react/src/components/dashboard/walletsInfo/walletsInfo.js

@ -16,8 +16,8 @@ class WalletsInfo extends React.Component {
render() {
if (this.props &&
this.props.Dashboard &&
this.props.Dashboard.progress &&
this.props.ActiveCoin &&
this.props.ActiveCoin.progress &&
this.props.ActiveCoin.activeSection === 'settings') {
return WalletsNativeInfoRender.call(this);
}
@ -31,9 +31,7 @@ const mapStateToProps = (state) => {
ActiveCoin: {
coin: state.ActiveCoin.coin,
activeSection: state.ActiveCoin.activeSection,
},
Dashboard: {
progress: state.Dashboard.progress,
progress: state.ActiveCoin.progress,
},
};
};

38
react/src/components/dashboard/walletsInfo/walletsInfo.render.js

@ -3,6 +3,8 @@ import { translate } from '../../../translate/translate';
import ClaimInterestModal from '../claimInterestModal/claimInterestModal';
const WalletsInfoRender = function() {
const _progress = this.props.ActiveCoin.progress;
return (
<div>
<div className="col-xlg-6 col-md-4">
@ -16,13 +18,13 @@ const WalletsInfoRender = function() {
<tr>
<td>{ translate('INDEX.WALLET_VERSION') }</td>
<td>
{ this.props.Dashboard.progress.walletversion }
{ _progress.walletversion }
</td>
</tr>
<tr>
<td>{ translate('INDEX.BALANCE') }</td>
<td>
{ this.props.Dashboard.progress.balance }
{ _progress.balance }
</td>
</tr>
<tr>
@ -65,19 +67,19 @@ const WalletsInfoRender = function() {
<tr>
<td>{ translate('INDEX.VERSION') }</td>
<td>
{ this.props.Dashboard.progress.KMDversion }
{ _progress.KMDversion }
</td>
</tr>
<tr>
<td>{ translate('INDEX.PROTOCOL_VERSION') }</td>
<td>
{ this.props.Dashboard.progress.protocolversion }
{ _progress.protocolversion }
</td>
</tr>
<tr>
<td>{ translate('INDEX.NOTARIZED') }</td>
<td>
{ this.props.Dashboard.progress.notarized }
{ _progress.notarized }
</td>
</tr>
<tr>
@ -85,15 +87,15 @@ const WalletsInfoRender = function() {
{ translate('INDEX.NOTARIZED') } { translate('INDEX.HASH') }
</td>
<td>
{ this.props.Dashboard.progress.notarizedhash ?
this.props.Dashboard.progress.notarizedhash.substring(
{ _progress.notarizedhash ?
_progress.notarizedhash.substring(
0,
Math.floor(this.props.Dashboard.progress.notarizedhash.length / 2)
Math.floor(_progress.notarizedhash.length / 2)
) +
'\t' +
this.props.Dashboard.progress.notarizedhash.substring(
Math.floor(this.props.Dashboard.progress.notarizedhash.length / 2),
this.props.Dashboard.progress.notarizedhash.length
_progress.notarizedhash.substring(
Math.floor(_progress.notarizedhash.length / 2),
_progress.notarizedhash.length
)
: ''
}
@ -108,43 +110,43 @@ const WalletsInfoRender = function() {
<tr>
<td>{ translate('INDEX.BLOCKS') }</td>
<td>
{ this.props.Dashboard.progress.blocks }
{ _progress.blocks }
</td>
</tr>
<tr>
<td>{ translate('INDEX.CONNECTIONS') }</td>
<td>
{ this.props.Dashboard.progress.connections }
{ _progress.connections }
</td>
</tr>
<tr>
<td>{ translate('INDEX.DIFFICULTY') }</td>
<td>
{ this.props.Dashboard.progress.difficulty }
{ _progress.difficulty }
</td>
</tr>
<tr>
<td>Testnet</td>
<td>
{ this.props.Dashboard.progress.testnet }
{ _progress.testnet }
</td>
</tr>
<tr>
<td>{ translate('INDEX.PAY_TX_FEE') }</td>
<td>
{ this.props.Dashboard.progress.paytxfee }
{ _progress.paytxfee }
</td>
</tr>
<tr>
<td>{ translate('INDEX.RELAY_FEE') }</td>
<td>
{ this.props.Dashboard.progress.relayfee }
{ _progress.relayfee }
</td>
</tr>
<tr>
<td>{ translate('INDEX.ERRORS') }</td>
<td>
{ this.props.Dashboard.progress.errors }
{ _progress.errors }
</td>
</tr>
</tbody>

81
react/src/components/dashboard/walletsProgress/walletsProgress.js

@ -19,10 +19,12 @@ class WalletsProgress extends React.Component {
}
isFullySynced() {
if ((Number(this.props.Dashboard.progress.balances) +
Number(this.props.Dashboard.progress.validated) +
Number(this.props.Dashboard.progress.bundles) +
Number(this.props.Dashboard.progress.utxo)) / 4 === 100) {
const _progress = this.props.ActiveCoin.progress;
if ((Number(_progress.balances) +
Number(_progress.validated) +
Number(_progress.bundles) +
Number(_progress.utxo)) / 4 === 100) {
return true;
} else {
return false;
@ -38,9 +40,11 @@ class WalletsProgress extends React.Component {
}
renderChainActivationNotification() {
if (this.props.Dashboard.progress) {
if ((!this.props.Dashboard.progress.blocks && !this.props.Dashboard.progress.longestchain) ||
(this.props.Dashboard.progress.blocks < this.props.Dashboard.progress.longestchain)) {
const _progress = this.props.ActiveCoin.progress;
if (_progress) {
if ((!_progress.blocks && !_progress.longestchain) ||
(_progress.blocks < _progress.longestchain)) {
return ChainActivationNotificationRender.call(this);
}
} else {
@ -86,35 +90,37 @@ class WalletsProgress extends React.Component {
}
renderSyncPercentagePlaceholder() {
const _progress = this.props.ActiveCoin.progress;
// activating best chain
if (this.props.Dashboard.progress &&
this.props.Dashboard.progress.code &&
this.props.Dashboard.progress.code === -28 &&
if (_progress &&
_progress.code &&
_progress.code === -28 &&
this.props.Settings.debugLog) {
const _progress = this.parseActivatingBestChainProgress();
const _parseProgress = this.parseActivatingBestChainProgress();
if (_progress &&
_progress[1]) {
return SyncPercentageRender.call(this, _progress[1] === 1000 ? 100 : _progress[1].toFixed(2));
if (_parseProgress &&
_parseProgress[1]) {
return SyncPercentageRender.call(this, _parseProgress[1] === 1000 ? 100 : _parseProgress[1].toFixed(2));
} else {
return LoadingBlocksRender.call(this);
}
}
if (this.props.Dashboard.progress &&
this.props.Dashboard.progress.blocks > 0 &&
this.props.Dashboard.progress.longestchain === 0) {
if (_progress &&
_progress.blocks > 0 &&
_progress.longestchain === 0) {
return SyncErrorLongestChainRender.call(this);
}
if (this.props.Dashboard.progress &&
this.props.Dashboard.progress.blocks === 0) {
if (_progress &&
_progress.blocks === 0) {
return SyncErrorBlocksRender.call(this);
}
if (this.props.Dashboard.progress &&
this.props.Dashboard.progress.blocks) {
const syncPercentage = (parseFloat(parseInt(this.props.Dashboard.progress.blocks, 10) * 100 / parseInt(this.props.Dashboard.progress.longestchain, 10)).toFixed(2) + '%').replace('NaN', 0);
if (_progress &&
_progress.blocks) {
const syncPercentage = (parseFloat(parseInt(_progress.blocks, 10) * 100 / parseInt(_progress.longestchain, 10)).toFixed(2) + '%').replace('NaN', 0);
return SyncPercentageRender.call(this, syncPercentage === 1000 ? 100 : syncPercentage);
}
@ -129,8 +135,8 @@ class WalletsProgress extends React.Component {
if (this.props.Settings &&
this.props.Settings.debugLog) {
if (this.props.Settings.debugLog.indexOf('UpdateTip') > -1 &&
!this.props.Dashboard.progress &&
!this.props.Dashboard.progress.blocks) {
!this.props.ActiveCoin.progress &&
!this.props.ActiveCoin.progress.blocks) {
const temp = this.props.Settings.debugLog.split(' ');
let currentBestChain;
let currentProgress;
@ -145,23 +151,23 @@ class WalletsProgress extends React.Component {
}
// fallback to local data if remote node is inaccessible
if (this.props.Dashboard.progress.remoteKMDNode &&
!this.props.Dashboard.progress.remoteKMDNode.blocks) {
if (this.props.ActiveCoin.progress.remoteKMDNode &&
!this.props.ActiveCoin.progress.remoteKMDNode.blocks) {
return (
`: ${currentProgress}% (${ translate('INDEX.ACTIVATING_SM') })`
);
} else {
if (this.props.Dashboard.progress.remoteKMDNode &&
this.props.Dashboard.progress.remoteKMDNode.blocks) {
if (this.props.ActiveCoin.progress.remoteKMDNode &&
this.props.ActiveCoin.progress.remoteKMDNode.blocks) {
return(
`: ${Math.floor(currentBestChain * 100 / this.props.Dashboard.progress.remoteKMDNode.blocks)}% (${ translate('INDEX.BLOCKS_SM') } ${currentBestChain} / ${this.props.Dashboard.progress.remoteKMDNode.blocks})`
`: ${Math.floor(currentBestChain * 100 / this.props.ActiveCoin.progress.remoteKMDNode.blocks)}% (${ translate('INDEX.BLOCKS_SM') } ${currentBestChain} / ${this.props.ActiveCoin.progress.remoteKMDNode.blocks})`
);
}
}
} else if (
this.props.Settings.debugLog.indexOf('Still rescanning') > -1 &&
!this.props.Dashboard.progress ||
!this.props.Dashboard.progress.blocks
!this.props.ActiveCoin.progress ||
!this.props.ActiveCoin.progress.blocks
) {
const temp = this.props.Settings.debugLog.split(' ');
let currentProgress;
@ -173,9 +179,9 @@ class WalletsProgress extends React.Component {
}
// activating best chain
if (this.props.Dashboard.progress &&
this.props.Dashboard.progress.code &&
this.props.Dashboard.progress.code === -28 &&
if (this.props.ActiveCoin.progress &&
this.props.ActiveCoin.progress.code &&
this.props.ActiveCoin.progress.code === -28 &&
this.props.Settings.debugLog) {
const _blocks = this.parseActivatingBestChainProgress();
@ -219,8 +225,8 @@ class WalletsProgress extends React.Component {
if (this.props &&
this.props.ActiveCoin &&
(this.isFullMode() || this.isNativeMode())) {
if (this.props.Dashboard.progress &&
this.props.Dashboard.progress.error) {
if (this.props.ActiveCoin.progress &&
this.props.ActiveCoin.progress.error) {
return CoinIsBusyRender.call(this);
}
@ -238,7 +244,8 @@ const mapStateToProps = (state) => {
},
ActiveCoin: {
mode: state.ActiveCoin.mode,
coin: state.coin,
coin: state.ActiveCoin.coin,
progress: state.ActiveCoin.progress,
},
};
};

26
react/src/components/dashboard/walletsProgress/walletsProgress.render.js

@ -22,7 +22,7 @@ export const SyncPercentageRender = function(syncPercentage) {
<div
className="progress-bar progress-bar-info progress-bar-striped active font-size-80-percent"
style={{ width: syncPercentage }}>
<span style={{ width: syncPercentage }}>{ syncPercentage }</span> | { this.props.Dashboard.progress.blocks } / { this.props.Dashboard.progress.longestchain } | { translate('INDEX.CONNECTIONS') }: { this.props.Dashboard.progress.connections }
<span style={{ width: syncPercentage }}>{ syncPercentage }</span> | { this.props.ActiveCoin.progress.blocks } / { this.props.ActiveCoin.progress.longestchain } | { translate('INDEX.CONNECTIONS') }: { this.props.ActiveCoin.progress.connections }
</div>
);
};
@ -77,22 +77,22 @@ export const WalletsProgressRender = function() {
id="edex-footer"
className="margin-bottom-20">
{ !this.isNativeMode() &&
this.props.Dashboard.progress &&
this.props.ActiveCoin.progress &&
<div className="row no-space">
<div id="currency-progressbars">
<div className="progress progress-sm">
<div className={ 'full-width font-size-80-percent '
+ (this.isFullySynced() ? 'progress-bar progress-bar-striped active progress-bar-indicating progress-bar-success' : 'hide') }>
{ translate('INDEX.BUNDLES') }&nbsp;
<span id="currency-bundles-percent">({ this.props.ActiveCoin.coin }) 100.00% - ( { this.props.Dashboard.progress.blocks }
/ { this.props.Dashboard.progress.blocks } ) ==&gt;&gt;
RT{ this.props.Dashboard.progress.RTheight }</span>
<span id="currency-bundles-percent">({ this.props.ActiveCoin.coin }) 100.00% - ( { this.props.ActiveCoin.progress.blocks }
/ { this.props.ActiveCoin.progress.blocks } ) ==&gt;&gt;
RT{ this.props.ActiveCoin.progress.RTheight }</span>
</div>
<div
className={ 'font-size-80-percent '
+ (this.isFullySynced() ? 'hide' : 'progress-bar progress-bar-info progress-bar-striped active') }
style={{ width: `${this.props.Dashboard.progress.bundles}%` }}>
{ translate('INDEX.BUNDLES') } { this.props.Dashboard.progress.bundles }%
style={{ width: `${this.props.ActiveCoin.progress.bundles}%` }}>
{ translate('INDEX.BUNDLES') } { this.props.ActiveCoin.progress.bundles }%
</div>
</div>
</div>
@ -100,22 +100,22 @@ export const WalletsProgressRender = function() {
<div className="progress progress-sm">
<div
className="progress-bar progress-bar-warning progress-bar-striped active font-size-80-percent"
style={{ width: `${this.props.Dashboard.progress.utxo}%` }}>
utxo { this.props.Dashboard.progress.utxo }%
style={{ width: `${this.props.ActiveCoin.progress.utxo}%` }}>
utxo { this.props.ActiveCoin.progress.utxo }%
</div>
</div>
<div className="progress progress-sm">
<div
className="progress-bar progress-bar-danger progress-bar-striped active font-size-80-percent"
style={{ width: `${this.props.Dashboard.progress.balances}%` }}>
{ translate('INDEX.BALANCES') } { this.props.Dashboard.progress.balances }%
style={{ width: `${this.props.ActiveCoin.progress.balances}%` }}>
{ translate('INDEX.BALANCES') } { this.props.ActiveCoin.progress.balances }%
</div>
</div>
<div className="progress progress-sm">
<div
className="progress-bar progress-bar-success progress-bar-striped active font-size-80-percent"
style={{ width: `${this.props.Dashboard.progress.validated}%` }}>
{ translate('INDEX.VALIDATED') } { this.props.Dashboard.progress.validated }%
style={{ width: `${this.props.ActiveCoin.progress.validated}%` }}>
{ translate('INDEX.VALIDATED') } { this.props.ActiveCoin.progress.validated }%
</div>
</div>
</div>

2
react/src/components/login/swall-modal.render.js

@ -1,7 +1,7 @@
import React from 'react';
import { translate } from '../../translate/translate';
const SwallModalRender = function () {
const SwallModalRender = function() {
return (
<div className="swal2-container">
<div className="swal2-overlay full-opacity display-block"></div>

24
react/src/reducers/activeCoin.js

@ -14,6 +14,9 @@ import {
DASHBOARD_ACTIVE_COIN_GET_CACHE,
DASHBOARD_ACTIVE_COIN_MAIN_BASILISK_ADDR,
DASHBOARD_ACTIVE_ADDRESS,
SYNCING_FULL_MODE,
SYNCING_NATIVE_MODE,
DASHBOARD_UPDATE,
} from '../actions/storeType';
// TODO: refactor
@ -34,6 +37,7 @@ export function ActiveCoin(state = {
cache: null,
mainBasiliskAddress: null,
activeAddress: null,
progress: null,
}, action) {
switch (action.type) {
case DASHBOARD_ACTIVE_COIN_CHANGE:
@ -54,6 +58,7 @@ export function ActiveCoin(state = {
mainBasiliskAddress: state.mainBasiliskAddress,
opids: state.opids,
activeBasiliskAddress: state.activeBasiliskAddress,
progress: state.progress,
};
let _coins = state.coins;
_coins[state.coin] = _coinDataToStore;
@ -74,6 +79,7 @@ export function ActiveCoin(state = {
mainBasiliskAddress: _coinData.mainBasiliskAddress,
opids: _coinData.opids,
activeBasiliskAddress: _coinData.activeBasiliskAddress,
progress: _coinData.progress,
});
} else {
if (state.coin) {
@ -92,6 +98,7 @@ export function ActiveCoin(state = {
mainBasiliskAddress: state.mainBasiliskAddress,
opids: state.opids,
activeBasiliskAddress: state.activeBasiliskAddress,
progress: state.progress,
};
let _coins = state.coins;
_coins[state.coin] = _coinData;
@ -107,6 +114,7 @@ export function ActiveCoin(state = {
showTransactionInfo: false,
showTransactionInfoTxIndex: null,
activeSection: 'default',
progress: null,
});
} else {
return Object.assign({}, state, {
@ -119,6 +127,7 @@ export function ActiveCoin(state = {
showTransactionInfo: false,
showTransactionInfoTxIndex: null,
activeSection: 'default',
progress: null,
});
}
}
@ -182,6 +191,21 @@ export function ActiveCoin(state = {
return Object.assign({}, state, {
activeAddress: action.address,
});
case SYNCING_FULL_MODE:
return Object.assign({}, state, {
progress: action.progress,
});
case SYNCING_NATIVE_MODE:
return Object.assign({}, state, {
progress: action.progress,
});
case DASHBOARD_UPDATE:
return Object.assign({}, state, {
progress: action.progress,
opids: action.opids,
txhistory: action.txhistory,
balance: action.balance,
});
default:
return state;
}

Loading…
Cancel
Save