diff --git a/react/src/components/dashboard/walletsNativeSyncProgress/walletsNativeSyncProgress.js b/react/src/components/dashboard/walletsNativeSyncProgress/walletsNativeSyncProgress.js
deleted file mode 100644
index 941e372..0000000
--- a/react/src/components/dashboard/walletsNativeSyncProgress/walletsNativeSyncProgress.js
+++ /dev/null
@@ -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 (
-
- { translate('INDEX.SYNC_ERR_LONGESTCHAIN') }
-
- );
- } else if (this.props.Dashboard.progress && this.props.Dashboard.progress.blocks === 0) {
- return (
-
- { translate('INDEX.SYNC_ERR_BLOCKS') }
-
- );
- } 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 (
-
- { syncPercentage } | { this.props.Dashboard.progress.blocks } / { this.props.Dashboard.progress.longestchain } | { translate('INDEX.CONNECTIONS') }: { this.props.Dashboard.progress.connections }
-
- );
- } else {
- return (
-
- Loading blocks...it can take up to 15 min to load blocks
-
- );
- }
- }
- }
-
- 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 (
-
(downloading blocks)
- );
- }
- }
- }
-
- renderLB(_translationID) {
- const _translationComponents = translate(_translationID).split('
');
-
- return _translationComponents.map((_translation) =>
-
- { _translation }
-
-
- );
- }
-
- 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;
diff --git a/react/src/components/dashboard/walletsNativeSyncProgress/walletsNativeSyncProgress.render.js b/react/src/components/dashboard/walletsNativeSyncProgress/walletsNativeSyncProgress.render.js
deleted file mode 100644
index f01fa71..0000000
--- a/react/src/components/dashboard/walletsNativeSyncProgress/walletsNativeSyncProgress.render.js
+++ /dev/null
@@ -1,34 +0,0 @@
-import React from 'react';
-import { translate } from '../../../translate/translate';
-
-export const ChainActivationNotificationRender = function() {
- return (
-
-
-
- { translate('INDEX.ACTIVATING_CHAIN') }
- { this.renderActivatingBestChainProgress() }
-
-
{ this.renderLB('INDEX.KMD_STARTED') }
-
- );
-};
-
-export const WalletsNativeSyncProgressRender = function() {
- return (
-
- { this.renderChainActivationNotification() }
-
-
-
- { this.renderSyncPercentagePlaceholder() }
-
-
-
-
- );
-};
\ No newline at end of file
diff --git a/react/src/components/dashboard/walletsProgress/walletsProgress.js b/react/src/components/dashboard/walletsProgress/walletsProgress.js
index 6ddfa27..5852757 100644
--- a/react/src/components/dashboard/walletsProgress/walletsProgress.js
+++ b/react/src/components/dashboard/walletsProgress/walletsProgress.js
@@ -1,6 +1,14 @@
import React from 'react';
-import { translate } from '../../../translate/translate';
-import WalletsProgressRender from './walletsProgress.render';
+import {
+ SyncErrorLongestChainRender,
+ SyncErrorBlocksRender,
+ SyncPercentageRender,
+ LoadingBlocksRender,
+ TranslationComponentsRender,
+ CoinIsBusyRender,
+ ChainActivationNotificationRender,
+ WalletsProgressRender
+} from './walletsProgress.render';
class WalletsProgress extends React.Component {
constructor(props) {
@@ -19,16 +27,115 @@ class WalletsProgress extends React.Component {
}
}
+ isNativeMode() {
+ return this.props.ActiveCoin.mode === 'native';
+ }
+
+ isFullMode() {
+ return this.props.ActiveCoin.mode === 'full';
+ }
+
+ 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 &&
+ this.props.Dashboard.progress.blocks > 0 &&
+ this.props.Dashboard.progress.longestchain === 0) {
+ return SyncErrorLongestChainRender.call(this);
+ }
+
+ if (this.props.Dashboard.progress && this.props.Dashboard.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);
+ return SyncPercentageRender.call(this, syncPercentage);
+ }
+
+ return LoadingBlocksRender.call(this);
+ }
+
+ renderLB(translationID) {
+ return TranslationComponentsRender.call(this, translationID);
+ }
+
+ renderActivatingBestChainProgress() {
+ 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) {
+ 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 (
+
(downloading blocks)
+ );
+ }
+ }
+ }
+
render() {
if (this.props &&
this.props.ActiveCoin &&
- this.props.ActiveCoin.mode === 'full' &&
- this.props.Dashboard.progress) {
+ (this.isFullMode() || this.isNativeMode())) {
if (this.props.Dashboard.progress &&
this.props.Dashboard.progress.error) {
- return (
-
{ translate('INDEX.COIN_IS_BUSY') }
- );
+ return CoinIsBusyRender.call(this);
}
return WalletsProgressRender.call(this);
diff --git a/react/src/components/dashboard/walletsProgress/walletsProgress.render.js b/react/src/components/dashboard/walletsProgress/walletsProgress.render.js
index b3b11f7..1f54a47 100644
--- a/react/src/components/dashboard/walletsProgress/walletsProgress.render.js
+++ b/react/src/components/dashboard/walletsProgress/walletsProgress.render.js
@@ -1,20 +1,95 @@
import React from 'react';
import { translate } from '../../../translate/translate';
-const WalletsProgressRender = function () {
+export const SyncErrorLongestChainRender = function() {
+ return (
+
+ { translate('INDEX.SYNC_ERR_LONGESTCHAIN') }
+
+ );
+};
+
+export const SyncErrorBlocksRender = function() {
+ return (
+
+ { translate('INDEX.SYNC_ERR_BLOCKS') }
+
+ );
+};
+
+export const SyncPercentageRender = function(syncPercentage) {
+ return (
+
+ { syncPercentage } | { this.props.Dashboard.progress.blocks } / { this.props.Dashboard.progress.longestchain } | { translate('INDEX.CONNECTIONS') }: { this.props.Dashboard.progress.connections }
+
+ );
+};
+
+export const LoadingBlocksRender = function() {
+ return (
+
+ Loading blocks...it can take up to 15 min to load blocks
+
+ );
+};
+
+export const TranslationComponentsRender = function(translationID) {
+ const translationComponents = translate(translationID).split('
');
+ return translationComponents.map((translation, idx) =>
+
+ { translation }
+
+
+ );
+};
+
+export const CoinIsBusyRender = function() {
+ return (
+
{ translate('INDEX.COIN_IS_BUSY') }
+ );
+};
+
+export const ChainActivationNotificationRender = function() {
+ return (
+
+
+
+ { translate('INDEX.ACTIVATING_CHAIN') }
+ { this.renderActivatingBestChainProgress() }
+
+
{ this.renderLB('INDEX.KMD_STARTED') }
+
+ );
+};
+
+export const WalletsProgressRender = function () {
return (