Browse Source

Merge branch 'redux' into decouple-jsx-out-of-js

all-modes
petitPapillon 8 years ago
parent
commit
ddfe1125ec
  1. 104
      react/src/actions/actions/addressBalance.js
  2. 20
      react/src/components/dashboard/walletsData.js
  3. 2
      react/src/components/dashboard/walletsNativeBalance.js
  4. 2
      react/src/components/dashboard/walletsNativeSend.js
  5. 25
      react/src/components/dashboard/walletsNativeSyncProgress.js

104
react/src/actions/actions/addressBalance.js

@ -5,7 +5,8 @@ import {
triggerToaster, triggerToaster,
Config, Config,
shepherdGroomPost, shepherdGroomPost,
getPassthruAgent getPassthruAgent,
iguanaHashHex
} from '../actionCreators'; } from '../actionCreators';
import { import {
logGuiHttp, logGuiHttp,
@ -171,7 +172,6 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
}; };
} }
// if api cache option is off
if (mode === 'basilisk') { if (mode === 'basilisk') {
payload = { payload = {
'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`,
@ -235,17 +235,109 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
sum += filteredArray[i]; sum += filteredArray[i];
} }
if (sum === 0 &&
a === 1) {
}
newAddressArray[a][b] = { newAddressArray[a][b] = {
address: result[a][b], address: result[a][b],
amount: currentAddress === result[a][b] || mode === 'native' ? sum : 'N/A', amount: currentAddress === result[a][b] || mode === 'native' ? sum : 'N/A',
type: a === 0 ? 'public': 'private',
}; };
} }
} }
dispatch(getKMDAddressesNativeState({ // get zaddr balance
'public': newAddressArray[0], if (result[1] &&
'private': newAddressArray[1] result[1].length) {
})); Promise.all(result[1].map((_address, index) => {
return new Promise((resolve, reject) => {
const _timestamp = Date.now();
let ajaxDataToHex = `["${_address}"]`;
iguanaHashHex(ajaxDataToHex, dispatch).then((hashHexJson) => {
if (getPassthruAgent(coin) === 'iguana') {
payload = {
'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`,
'agent': getPassthruAgent(coin),
'method': 'passthru',
'asset': coin,
'function': 'z_getbalance',
'hex': hashHexJson,
};
} else {
payload = {
'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`,
'agent': getPassthruAgent(coin),
'method': 'passthru',
'function': 'z_getbalance',
'hex': hashHexJson,
};
}
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'getKMDAddressesNative+ZBalance',
'type': 'post',
'url': `http://127.0.0.1:${Config.iguanaCorePort}`,
'payload': payload,
'status': 'pending',
}));
fetch(`http://127.0.0.1:${Config.iguanaCorePort}`,
{
method: 'POST',
body: JSON.stringify(payload),
})
.catch(function(error) {
console.log(error);
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'error',
'response': error,
}));
dispatch(triggerToaster(true, 'getKMDAddressesNative+ZBalance', 'Error', 'error'));
})
.then(response => response.json())
.then(function(json) {
if (json &&
json.error) {
resolve(0);
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'error',
'response': json,
}));
dispatch(triggerToaster(true, 'getKMDAddressesNative+ZBalance', 'Error', 'error'));
} else {
resolve(json);
newAddressArray[1][index] = {
address: _address,
amount: json,
type: 'private',
};
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
}
});
});
});
}))
.then(zresult => {
dispatch(getKMDAddressesNativeState({
'public': newAddressArray[0],
'private': newAddressArray[1]
}));
});
} else {
dispatch(getKMDAddressesNativeState({
'public': newAddressArray[0],
'private': newAddressArray[1]
}));
}
} }
if (mode === 'basilisk') { if (mode === 'basilisk') {

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

@ -583,7 +583,7 @@ class WalletsData extends React.Component {
<div className="panel"> <div className="panel">
<header className="panel-heading z-index-10"> <header className="panel-heading z-index-10">
<div className={ this.props.ActiveCoin.mode === 'basilisk' ? 'panel-actions' : 'panel-actions hide' }> <div className={ this.props.ActiveCoin.mode === 'basilisk' ? 'panel-actions' : 'panel-actions hide' }>
<div className={'full-width margin-bottom-3 ' + (this.state.currentStackLength === 1 || (this.state.currentStackLength === 0 && this.state.totalStackLength === 0) ? 'hide' : 'progress progress-sm') }> <div className={ 'margin-bottom-3 ' + (this.state.currentStackLength === 1 || (this.state.currentStackLength === 0 && this.state.totalStackLength === 0) ? 'hide' : 'progress progress-sm') }>
<div <div
className="progress-bar progress-bar-striped active progress-bar-indicating progress-bar-success font-size-80-percent" className="progress-bar progress-bar-striped active progress-bar-indicating progress-bar-success font-size-80-percent"
style={{ width: 100 - (this.state.currentStackLength * 100 / this.state.totalStackLength) + '%'}}> style={{ width: 100 - (this.state.currentStackLength * 100 / this.state.totalStackLength) + '%'}}>
@ -598,23 +598,17 @@ class WalletsData extends React.Component {
</a> </a>
<ul className="dropdown-menu dropdown-menu-right"> <ul className="dropdown-menu dropdown-menu-right">
<li> <li>
<a <a onClick={ this.getDexNotariesAction }>
className="btn_edexcoin_dashboard_getnotaries"
onClick={ this.getDexNotariesAction }>
<i className="icon fa-sitemap"></i> { translate('INDEX.GET_NOTARY_NODES_LIST') } <i className="icon fa-sitemap"></i> { translate('INDEX.GET_NOTARY_NODES_LIST') }
</a> </a>
</li> </li>
<li> <li>
<a <a onClick={ this.basiliskConnectionAction }>
className="btn_edexcoin_dashboard_refresh_basilisk_conn"
onClick={ this.basiliskConnectionAction }>
<i className="icon wb-refresh"></i> { translate('INDEX.REFRESH_BASILISK_CONNECTIONS') } <i className="icon wb-refresh"></i> { translate('INDEX.REFRESH_BASILISK_CONNECTIONS') }
</a> </a>
</li> </li>
<li className={ !this.state.useCache ? 'hide' : '' }> <li className={ !this.state.useCache ? 'hide' : '' }>
<a <a onClick={ this.basiliskRefreshActionOne }>
className="btn_edexcoin_dashboard_fetchdata"
onClick={ this.basiliskRefreshActionOne }>
<i className="icon fa-cloud-download"></i> { translate('INDEX.FETCH_WALLET_DATA') } ({ translate('INDEX.ACTIVE_ADDRESS') }) <i className="icon fa-cloud-download"></i> { translate('INDEX.FETCH_WALLET_DATA') } ({ translate('INDEX.ACTIVE_ADDRESS') })
</a> </a>
</li> </li>
@ -624,9 +618,7 @@ class WalletsData extends React.Component {
</a> </a>
</li> </li>
<li className={ !this.state.useCache ? 'hide' : '' }> <li className={ !this.state.useCache ? 'hide' : '' }>
<a <a onClick={ this.removeAndFetchNewCache }>
className="btn_edexcoin_dashboard_refetchdata"
onClick={ this.removeAndFetchNewCache }>
<i className="icon fa-history"></i> { translate('INDEX.REFETCH_WALLET_DATA') } <i className="icon fa-history"></i> { translate('INDEX.REFETCH_WALLET_DATA') }
</a> </a>
</li> </li>
@ -636,7 +628,7 @@ class WalletsData extends React.Component {
</a> </a>
</li> </li>
<li className={ !this.state.useCache ? 'hide' : '' }> <li className={ !this.state.useCache ? 'hide' : '' }>
<a className="btn_edexcoin_dashboard_fetchdata" onClick={ this._toggleViewCacheModal }> <a onClick={ this._toggleViewCacheModal }>
<i className="icon fa-list-alt"></i> { translate('INDEX.VIEW_CACHE_DATA') } <i className="icon fa-list-alt"></i> { translate('INDEX.VIEW_CACHE_DATA') }
</a> </a>
</li> </li>

2
react/src/components/dashboard/walletsNativeBalance.js

@ -45,7 +45,7 @@ class WalletsNativeBalance extends React.Component {
<div className="pull-left padding-vertical-10"> <div className="pull-left padding-vertical-10">
<i className="icon fa-money font-size-24 vertical-align-bottom margin-right-5"></i>{ translate('INDEX.INTEREST_EARNED') } <i className="icon fa-money font-size-24 vertical-align-bottom margin-right-5"></i>{ translate('INDEX.INTEREST_EARNED') }
</div> </div>
<span className="pull-right padding-top-10 font-size-22">{ this.props.ActiveCoin.balance.interest ? this.props.ActiveCoin.balance.interest : '-' }</span> <span className="pull-right padding-top-10 font-size-22">{ this.props.Dashboard.progress && this.props.Dashboard.progress.interest ? this.props.Dashboard.progress.interest : '-' }</span>
</div> </div>
</div> </div>
</div> </div>

2
react/src/components/dashboard/walletsNativeSend.js

@ -54,7 +54,7 @@ class WalletsNativeSend extends React.Component {
this.props.ActiveCoin.addresses[type].length) { this.props.ActiveCoin.addresses[type].length) {
return this.props.ActiveCoin.addresses[type].map((address) => return this.props.ActiveCoin.addresses[type].map((address) =>
<li key={ address.address } className={ address.amount <= 0 ? 'hide' : '' }> <li key={ address.address } className={ address.amount <= 0 ? 'hide' : '' }>
<a onClick={ () => this.updateAddressSelection(address.address, type, address.amount) }><i className={ type === 'public' ? 'icon fa-eye' : 'icon fa-eye-slash' }></i> <span className="text">[ { address.amount } { this.props.ActiveCoin.coin } ] { address.address }</span><span className="glyphicon glyphicon-ok check-mark"></span></a> <a onClick={ () => this.updateAddressSelection(address.address, type, address.amount) }><i className={ type === 'public' ? 'icon fa-eye' : 'icon fa-eye-slash' }></i> <span className="text">[ { address.amount } { this.props.ActiveCoin.coin } ] { type === 'public' ? address.address : address.address.substring(0, 34) + '...' }</span><span className="glyphicon glyphicon-ok check-mark"></span></a>
</li> </li>
); );
} else { } else {

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

@ -31,19 +31,32 @@ class WalletsNativeSyncProgress extends React.Component {
renderActivatingBestChainProgress() { renderActivatingBestChainProgress() {
if (this.props.Settings && if (this.props.Settings &&
this.props.Settings.debugLog && this.props.Settings.debugLog) {
this.props.Dashboard.progress.remoteKMDNode) {
if (this.props.Settings.debugLog.indexOf('UpdateTip') > -1) { if (this.props.Settings.debugLog.indexOf('UpdateTip') > -1) {
let temp = this.props.Settings.debugLog.split(' '); let temp = this.props.Settings.debugLog.split(' ');
let currentBestChain; let currentBestChain;
let currentProgress;
for (let i = 0; i < temp.length; i++) { for (let i = 0; i < temp.length; i++) {
if (temp[i].indexOf('height=') > -1) { if (temp[i].indexOf('height=') > -1) {
currentBestChain = temp[i].replace('height=', ''); currentBestChain = temp[i].replace('height=', '');
} }
if (temp[i].indexOf('progress=') > -1) {
currentProgress = Number(temp[i].replace('progress=', '')) * 100;
}
} }
return(`: ${Math.floor(currentBestChain * 100 / this.props.Dashboard.progress.remoteKMDNode.blocks)}% (blocks ${currentBestChain} / ${this.props.Dashboard.progress.remoteKMDNode.blocks})`); // fallback to local data if remote node is inaccessible
if (this.props.Dashboard.progress.remoteKMDNode &&
!this.props.Dashboard.progress.remoteKMDNode.blocks) {
return (
`: ${currentProgress}%`
);
} else {
return(
`: ${Math.floor(currentBestChain * 100 / this.props.Dashboard.progress.remoteKMDNode.blocks)}% (blocks ${currentBestChain} / ${this.props.Dashboard.progress.remoteKMDNode.blocks})`
);
}
} else { } else {
return ( return (
<span>...</span> <span>...</span>
@ -57,15 +70,15 @@ class WalletsNativeSyncProgress extends React.Component {
return _translationComponents.map((_translation) => return _translationComponents.map((_translation) =>
<span> <span>
{_translation} { _translation }
<br /> <br />
</span> </span>
); );
} }
renderChainActivationNotification() { renderChainActivationNotification() {
if ((this.props.Dashboard.progress.blocks < this.props.Dashboard.progress.longestchain) || if ((!this.props.Dashboard.progress.blocks && !this.props.Dashboard.progress.longestchain) ||
this.props.Dashboard.progress.remoteKMDNode) { (this.props.Dashboard.progress.blocks < this.props.Dashboard.progress.longestchain)) {
return ( return (
<div className="alert alert-info alert-dismissible margin-bottom-40"> <div className="alert alert-info alert-dismissible margin-bottom-40">
<button className="close" type="button"> <button className="close" type="button">

Loading…
Cancel
Save