Browse Source

Wallets progress - fix merge issues

all-modes
petitPapillon 7 years ago
parent
commit
5143455eee
  1. 139
      react/src/components/dashboard/walletsNativeSyncProgress/walletsNativeSyncProgress.js
  2. 34
      react/src/components/dashboard/walletsNativeSyncProgress/walletsNativeSyncProgress.render.js
  3. 60
      react/src/components/dashboard/walletsProgress/walletsProgress.js
  4. 17
      react/src/components/dashboard/walletsProgress/walletsProgress.render.js

139
react/src/components/dashboard/walletsNativeSyncProgress/walletsNativeSyncProgress.js

@ -1,139 +0,0 @@
import React from 'react';
import { translate } from '../../../translate/translate';
import {
ChainActivationNotificationRender,
WalletsNativeSyncProgressRender
} from './walletsNativeSyncProgress.render';
class WalletsNativeSyncProgress extends React.Component {
renderSyncPercentagePlaceholder() {
if (this.props.Dashboard.progress &&
this.props.Dashboard.progress.blocks > 0 &&
this.props.Dashboard.progress.longestchain === 0) {
return (
<div className="progress-bar progress-bar-info progress-bar-striped active full-width font-size-80-percent">
<span className="full-width">{ translate('INDEX.SYNC_ERR_LONGESTCHAIN') }</span>
</div>
);
} else if (this.props.Dashboard.progress && this.props.Dashboard.progress.blocks === 0) {
return (
<div className="progress-bar progress-bar-info progress-bar-striped active full-width font-size-80-percent">
<span className="full-width">{ translate('INDEX.SYNC_ERR_BLOCKS') }</span>
</div>
);
} else {
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);
return (
<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 }
</div>
);
} else {
return (
<div
className="progress-bar progress-bar-info progress-bar-striped active font-size-80-percent"
style={{ width: '100%' }}>
<span style={{ width: '100%' }}>Loading blocks...it can take up to 15 min to load blocks</span>
</div>
);
}
}
}
renderActivatingBestChainProgress() {
if (this.props.Settings &&
this.props.Settings.debugLog) {
console.log('debugLog');
if (this.props.Settings.debugLog.indexOf('UpdateTip') > -1 &&
!this.props.Dashboard.progress &&
!this.props.Dashboard.progress.blocks) {
const temp = this.props.Settings.debugLog.split(' ');
let currentBestChain;
let currentProgress;
for (let i = 0; i < temp.length; i++) {
if (temp[i].indexOf('height=') > -1) {
currentBestChain = temp[i].replace('height=', '');
}
if (temp[i].indexOf('progress=') > -1) {
currentProgress = Number(temp[i].replace('progress=', '')) * 100;
}
}
// fallback to local data if remote node is inaccessible
if (this.props.Dashboard.progress.remoteKMDNode &&
!this.props.Dashboard.progress.remoteKMDNode.blocks) {
return (
`: ${currentProgress}% (activating)`
);
} else {
if (this.props.Dashboard.progress.remoteKMDNode &&
this.props.Dashboard.progress.remoteKMDNode.blocks) {
return(
`: ${Math.floor(currentBestChain * 100 / this.props.Dashboard.progress.remoteKMDNode.blocks)}% (blocks ${currentBestChain} / ${this.props.Dashboard.progress.remoteKMDNode.blocks})`
);
}
}
} else if (
this.props.Settings.debugLog.indexOf('Still rescanning') > -1 &&
!this.props.Dashboard.progress ||
!this.props.Dashboard.progress.blocks
) {
const temp = this.props.Settings.debugLog.split(' ');
let currentProgress;
for (let i = 0; i < temp.length; i++) {
if (temp[i].indexOf('Progress=') > -1) {
currentProgress = Number(temp[i].replace('Progress=', '')) * 100;
}
}
return (
`: ${currentProgress}% (rescanning blocks)`
);
} else {
return (
<span> (downloading blocks)</span>
);
}
}
}
renderLB(_translationID) {
const _translationComponents = translate(_translationID).split('<br>');
return _translationComponents.map((_translation) =>
<span>
{ _translation }
<br />
</span>
);
}
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)) {
return ChainActivationNotificationRender.call(this);
}
} else {
return null;
}
}
render() {
if (this.props &&
this.props.Dashboard) {
return WalletsNativeSyncProgressRender.call(this);
}
return null;
}
}
export default WalletsNativeSyncProgress;

34
react/src/components/dashboard/walletsNativeSyncProgress/walletsNativeSyncProgress.render.js

@ -1,34 +0,0 @@
import React from 'react';
import { translate } from '../../../translate/translate';
export const ChainActivationNotificationRender = function() {
return (
<div className="alert alert-info alert-dismissible margin-bottom-40">
<button
className="close"
type="button">
<span>×</span>
</button>
<h4>
{ translate('INDEX.ACTIVATING_CHAIN') }
{ this.renderActivatingBestChainProgress() }
</h4>
<p>{ this.renderLB('INDEX.KMD_STARTED') }</p>
</div>
);
};
export const WalletsNativeSyncProgressRender = function() {
return (
<div>
{ this.renderChainActivationNotification() }
<div className="row sync-progress-container">
<div className="col-xs-12">
<div className="progress">
{ this.renderSyncPercentagePlaceholder() }
</div>
</div>
</div>
</div>
);
};

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

@ -3,6 +3,7 @@ import {
SyncErrorLongestChainRender, SyncErrorLongestChainRender,
SyncErrorBlocksRender, SyncErrorBlocksRender,
SyncPercentageRender, SyncPercentageRender,
LoadingBlocksRender,
TranslationComponentsRender, TranslationComponentsRender,
CoinIsBusyRender, CoinIsBusyRender,
ChainActivationNotificationRender, ChainActivationNotificationRender,
@ -35,26 +36,35 @@ class WalletsProgress extends React.Component {
} }
renderChainActivationNotification() { renderChainActivationNotification() {
if ((!this.props.Dashboard.progress.blocks && !this.props.Dashboard.progress.longestchain) || if (this.props.Dashboard.progress) {
(this.props.Dashboard.progress.blocks < this.props.Dashboard.progress.longestchain)) { if ((!this.props.Dashboard.progress.blocks && !this.props.Dashboard.progress.longestchain) ||
return ChainActivationNotificationRender.call(this); (this.props.Dashboard.progress.blocks < this.props.Dashboard.progress.longestchain)) {
return ChainActivationNotificationRender.call(this);
}
} else {
return null;
} }
return null;
} }
renderSyncPercentagePlaceholder() { renderSyncPercentagePlaceholder() {
if (this.props.Dashboard.progress.blocks > 0 && if (this.props.Dashboard.progress &&
this.props.Dashboard.progress.blocks > 0 &&
this.props.Dashboard.progress.longestchain === 0) { this.props.Dashboard.progress.longestchain === 0) {
return SyncErrorLongestChainRender.call(this); return SyncErrorLongestChainRender.call(this);
} }
if (this.props.Dashboard.progress.blocks === 0) { if (this.props.Dashboard.progress && this.props.Dashboard.progress.blocks === 0) {
return SyncErrorBlocksRender.call(this); return SyncErrorBlocksRender.call(this);
} }
const syncPercentage = (parseFloat(parseInt(this.props.Dashboard.progress.blocks, 10) * 100 / parseInt(this.props.Dashboard.progress.longestchain, 10)).toFixed(2) + '%').replace('NaN', 0); if (this.props.Dashboard.progress &&
return SyncPercentageRender.call(this, syncPercentage); 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);
return SyncPercentageRender.call(this, syncPercentage);
}
return LoadingBlocksRender.call(this);
} }
renderLB(translationID) { renderLB(translationID) {
@ -63,8 +73,10 @@ class WalletsProgress extends React.Component {
renderActivatingBestChainProgress() { renderActivatingBestChainProgress() {
if (this.props.Settings && if (this.props.Settings &&
this.props.Settings.debugLog) { this.props.Settings.debugLog) {
if (this.props.Settings.debugLog.indexOf('UpdateTip') > -1) { if (this.props.Settings.debugLog.indexOf('UpdateTip') > -1 &&
!this.props.Dashboard.progress &&
!this.props.Dashboard.progress.blocks) {
const temp = this.props.Settings.debugLog.split(' '); const temp = this.props.Settings.debugLog.split(' ');
let currentBestChain; let currentBestChain;
let currentProgress; let currentProgress;
@ -80,16 +92,23 @@ class WalletsProgress extends React.Component {
// fallback to local data if remote node is inaccessible // fallback to local data if remote node is inaccessible
if (this.props.Dashboard.progress.remoteKMDNode && if (this.props.Dashboard.progress.remoteKMDNode &&
!this.props.Dashboard.progress.remoteKMDNode.blocks) { !this.props.Dashboard.progress.remoteKMDNode.blocks) {
return ( return (
`: ${currentProgress}%` `: ${currentProgress}% (activating)`
); );
} else { } else {
return( if (this.props.Dashboard.progress.remoteKMDNode &&
`: ${Math.floor(currentBestChain * 100 / this.props.Dashboard.progress.remoteKMDNode.blocks)}% (blocks ${currentBestChain} / ${this.props.Dashboard.progress.remoteKMDNode.blocks})` this.props.Dashboard.progress.remoteKMDNode.blocks) {
); return(
`: ${Math.floor(currentBestChain * 100 / this.props.Dashboard.progress.remoteKMDNode.blocks)}% (blocks ${currentBestChain} / ${this.props.Dashboard.progress.remoteKMDNode.blocks})`
);
}
} }
} else if (this.props.Settings.debugLog.indexOf('Still rescanning') > -1) { } else if (
this.props.Settings.debugLog.indexOf('Still rescanning') > -1 &&
!this.props.Dashboard.progress ||
!this.props.Dashboard.progress.blocks
) {
const temp = this.props.Settings.debugLog.split(' '); const temp = this.props.Settings.debugLog.split(' ');
let currentProgress; let currentProgress;
@ -100,11 +119,11 @@ class WalletsProgress extends React.Component {
} }
return ( return (
`: ${currentProgress}%` `: ${currentProgress}% (rescanning blocks)`
); );
} else { } else {
return ( return (
<span>...</span> <span> (downloading blocks)</span>
); );
} }
} }
@ -113,8 +132,7 @@ class WalletsProgress extends React.Component {
render() { render() {
if (this.props && if (this.props &&
this.props.ActiveCoin && this.props.ActiveCoin &&
(this.isFullMode() || this.isNativeMode()) && (this.isFullMode() || this.isNativeMode())) {
this.props.Dashboard.progress) {
if (this.props.Dashboard.progress && if (this.props.Dashboard.progress &&
this.props.Dashboard.progress.error) { this.props.Dashboard.progress.error) {
return CoinIsBusyRender.call(this); return CoinIsBusyRender.call(this);

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

@ -17,7 +17,7 @@ export const SyncErrorBlocksRender = function() {
); );
}; };
export const SyncPercentageRender = function(syncPercentage) { export const SyncPercentageRender = function(syncPercentage) {
return ( return (
<div <div
className="progress-bar progress-bar-info progress-bar-striped active font-size-80-percent" className="progress-bar progress-bar-info progress-bar-striped active font-size-80-percent"
@ -27,6 +27,16 @@ export const SyncPercentageRender = function(syncPercentage) {
); );
}; };
export const LoadingBlocksRender = function() {
return (
<div
className="progress-bar progress-bar-info progress-bar-striped active font-size-80-percent"
style={{ width: '100%' }}>
<span style={{ width: '100%' }}>Loading blocks...it can take up to 15 min to load blocks</span>
</div>
);
};
export const TranslationComponentsRender = function(translationID) { export const TranslationComponentsRender = function(translationID) {
const translationComponents = translate(translationID).split('<br>'); const translationComponents = translate(translationID).split('<br>');
return translationComponents.map((translation, idx) => return translationComponents.map((translation, idx) =>
@ -41,7 +51,7 @@ export const CoinIsBusyRender = function() {
return ( return (
<div className="text-align-center padding-10">{ translate('INDEX.COIN_IS_BUSY') }</div> <div className="text-align-center padding-10">{ translate('INDEX.COIN_IS_BUSY') }</div>
); );
} };
export const ChainActivationNotificationRender = function() { export const ChainActivationNotificationRender = function() {
return ( return (
@ -52,7 +62,8 @@ export const ChainActivationNotificationRender = function() {
<span>×</span> <span>×</span>
</button> </button>
<h4> <h4>
{ translate('INDEX.ACTIVATING_CHAIN') }{ this.renderActivatingBestChainProgress() } { translate('INDEX.ACTIVATING_CHAIN') }
{ this.renderActivatingBestChainProgress() }
</h4> </h4>
<p>{ this.renderLB('INDEX.KMD_STARTED') }</p> <p>{ this.renderLB('INDEX.KMD_STARTED') }</p>
</div> </div>

Loading…
Cancel
Save