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. 40
      react/src/components/dashboard/walletsProgress/walletsProgress.js
  4. 15
      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>
);
};

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

@ -3,6 +3,7 @@ import {
SyncErrorLongestChainRender,
SyncErrorBlocksRender,
SyncPercentageRender,
LoadingBlocksRender,
TranslationComponentsRender,
CoinIsBusyRender,
ChainActivationNotificationRender,
@ -35,28 +36,37 @@ 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)) {
return ChainActivationNotificationRender.call(this);
}
} else {
return null;
}
}
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) {
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);
}
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 &&
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) {
return TranslationComponentsRender.call(this, translationID);
}
@ -64,7 +74,9 @@ class WalletsProgress extends React.Component {
renderActivatingBestChainProgress() {
if (this.props.Settings &&
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(' ');
let currentBestChain;
let currentProgress;
@ -82,14 +94,21 @@ class WalletsProgress extends React.Component {
if (this.props.Dashboard.progress.remoteKMDNode &&
!this.props.Dashboard.progress.remoteKMDNode.blocks) {
return (
`: ${currentProgress}%`
`: ${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) {
}
} 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;
@ -100,11 +119,11 @@ class WalletsProgress extends React.Component {
}
return (
`: ${currentProgress}%`
`: ${currentProgress}% (rescanning blocks)`
);
} else {
return (
<span>...</span>
<span> (downloading blocks)</span>
);
}
}
@ -113,8 +132,7 @@ class WalletsProgress extends React.Component {
render() {
if (this.props &&
this.props.ActiveCoin &&
(this.isFullMode() || this.isNativeMode()) &&
this.props.Dashboard.progress) {
(this.isFullMode() || this.isNativeMode())) {
if (this.props.Dashboard.progress &&
this.props.Dashboard.progress.error) {
return CoinIsBusyRender.call(this);

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

@ -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) {
const translationComponents = translate(translationID).split('<br>');
return translationComponents.map((translation, idx) =>
@ -41,7 +51,7 @@ export const CoinIsBusyRender = function() {
return (
<div className="text-align-center padding-10">{ translate('INDEX.COIN_IS_BUSY') }</div>
);
}
};
export const ChainActivationNotificationRender = function() {
return (
@ -52,7 +62,8 @@ export const ChainActivationNotificationRender = function() {
<span>×</span>
</button>
<h4>
{ translate('INDEX.ACTIVATING_CHAIN') }{ this.renderActivatingBestChainProgress() }
{ translate('INDEX.ACTIVATING_CHAIN') }
{ this.renderActivatingBestChainProgress() }
</h4>
<p>{ this.renderLB('INDEX.KMD_STARTED') }</p>
</div>

Loading…
Cancel
Save