Browse Source

Merge pull request #137 from SuperNETorg/merge-wallets-native-receive

Merge wallets native receive
all-modes
pbca26 8 years ago
committed by GitHub
parent
commit
0d2cf2e023
  1. 2
      react/src/components/dashboard/main/dashboard.render.js
  2. 82
      react/src/components/dashboard/receiveCoin/receiveCoin.js
  3. 68
      react/src/components/dashboard/receiveCoin/receiveCoin.render.js
  4. 2
      react/src/components/dashboard/walletsNative/walletsNative.render.js
  5. 94
      react/src/components/dashboard/walletsNativeReceive/walletsNativeReceive.js
  6. 90
      react/src/components/dashboard/walletsNativeReceive/walletsNativeReceive.render.js
  7. 1
      react/src/components/dashboard/walletsNativeSyncProgress/walletsNativeSyncProgress.js

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

@ -30,10 +30,10 @@ const DashboardRender = function() {
<WalletsProgress {...this.props} />
<WalletsBalance {...this.props} />
<SendCoin {...this.props} />
<ReceiveCoin {...this.props.ActiveCoin} />
<WalletsData {...this.props} />
<WalletsTxInfo {...this.props} />
<WalletsNative {...this.props} />
<ReceiveCoin {...this.props.ActiveCoin} />
<WalletsNativeTxInfo {...this.props} />
</div>
<div className={ this.isSectionActive('edex') ? 'show' : 'hide' }>

82
react/src/components/dashboard/receiveCoin/receiveCoin.js

@ -2,10 +2,10 @@ import React from 'react';
import {
copyCoinAddress,
checkAddressBasilisk,
validateAddressBasilisk
validateAddressBasilisk,
getNewKMDAddresses
} from '../../../actions/actionCreators';
import Store from '../../../store';
import {
AddressActionsBasiliskModeRender,
AddressActionsNonBasiliskModeRender,
@ -19,6 +19,43 @@ import {
class ReceiveCoin extends React.Component {
constructor(props) {
super(props);
this.state = {
openDropMenu: false,
};
this.openDropMenu = this.openDropMenu.bind(this);
this.handleClickOutside = this.handleClickOutside.bind(this);
}
componentWillMount() {
document.addEventListener(
'click',
this.handleClickOutside,
false
);
}
componentWillUnmount() {
document.removeEventListener(
'click',
this.handleClickOutside,
false
);
}
handleClickOutside(e) {
if (e.srcElement.className.indexOf('dropdown') === -1 &&
(e.srcElement.offsetParent && e.srcElement.offsetParent.className.indexOf('dropdown') === -1)) {
this.setState({
openDropMenu: false,
});
}
}
openDropMenu() {
this.setState(Object.assign({}, this.state, {
openDropMenu: !this.state.openDropMenu,
}));
}
_checkAddressBasilisk(address) {
@ -47,12 +84,16 @@ class ReceiveCoin extends React.Component {
return this.props.mode === 'basilisk';
}
renderAddressActions(address) {
isNativeMode() {
return this.props.mode == 'native';
}
renderAddressActions(address, type) {
if (this.isBasiliskMode()) {
return AddressActionsBasiliskModeRender.call(this, address);
}
return AddressActionsNonBasiliskModeRender.call(this, address);
return AddressActionsNonBasiliskModeRender.call(this, address, type);
}
hasNoAmount(address) {
@ -63,26 +104,34 @@ class ReceiveCoin extends React.Component {
return address.interest === 'N/A' || address.interest === 0 || !address.interest;
}
renderAddressList() {
getNewAddress(type) {
Store.dispatch(getNewKMDAddresses(this.props.coin, type));
}
renderAddressList(type) {
if (this.props.addresses &&
this.props.addresses.public &&
this.props.addresses.public.length) {
this.props.addresses[type] &&
this.props.addresses[type].length) {
let items = [];
for (let i = 0; i < this.props.addresses.public.length; i++) {
let address = this.props.addresses.public[i];
for (let i = 0; i < this.props.addresses[type].length; i++) {
let address = this.props.addresses[type][i];
if (this.isBasiliskMode() &&
this.hasNoAmount(address)) {
address.amount = this.props.cache && this.props.cache[this.props.coin][address.address] && this.props.cache[this.props.coin][address.address].getbalance.data && this.props.cache[this.props.coin][address.address].getbalance.data.balance ? this.props.cache[this.props.coin][address.address].getbalance.data.balance : 'N/A';
this.hasNoAmount(address)) {
address.amount = this.props.cache && this.props.cache[this.props.coin][address.address]
&& this.props.cache[this.props.coin][address.address].getbalance.data
&& this.props.cache[this.props.coin][address.address].getbalance.data.balance ? this.props.cache[this.props.coin][address.address].getbalance.data.balance : 'N/A';
}
if (this.isBasiliskMode() &&
this.hasNoInterest(address)) {
address.interest = this.props.cache && this.props.cache[this.props.coin][address.address] && this.props.cache[this.props.coin][address.address].getbalance.data && this.props.cache[this.props.coin][address.address].getbalance.data.interest ? this.props.cache[this.props.coin][address.address].getbalance.data.interest : 'N/A';
this.hasNoInterest(address)) {
address.interest = this.props.cache && this.props.cache[this.props.coin][address.address]
&& this.props.cache[this.props.coin][address.address].getbalance.data
&& this.props.cache[this.props.coin][address.address].getbalance.data.interest ? this.props.cache[this.props.coin][address.address].getbalance.data.interest : 'N/A';
}
items.push(
AddressItemRender.call(this, address)
AddressItemRender.call(this, address, type)
);
}
@ -93,9 +142,10 @@ class ReceiveCoin extends React.Component {
}
render() {
// TODO nativeActiveSection === 'receive' should be removed when native mode is fully merged
// into the rest of the components
if (this.props &&
this.props.receive &&
this.props.mode !== 'native') {
(this.props.receive || (this.isNativeMode() && this.props.nativeActiveSection === 'receive'))) {
return ReceiveCoinRender.call(this);
}

68
react/src/components/dashboard/receiveCoin/receiveCoin.render.js

@ -29,11 +29,12 @@ export const AddressActionsBasiliskModeRender = function(address) {
);
};
export const AddressActionsNonBasiliskModeRender = function(address) {
export const AddressActionsNonBasiliskModeRender = function(address, type) {
return (
<td>
<span className="label label-default">
<i className="icon fa-eye"></i> { translate('IAPI.PUBLIC_SM') }
<span className={ type === 'public' ? 'label label-default' : 'label label-dark' }>
<i className={ type === 'public' ? 'icon fa-eye' : 'icon fa-eye-slash' }></i>
{ type === 'public' ? translate('IAPI.PUBLIC_SM') : translate('KMD_NATIVE.PRIVATE') }
</span>
<button
className="btn btn-default btn-xs clipboard-edexaddr margin-left-10"
@ -44,13 +45,15 @@ export const AddressActionsNonBasiliskModeRender = function(address) {
);
};
export const AddressItemRender = function(address) {
export const AddressItemRender = function(address, type) {
return (
<tr key={ address.address }>
{ this.renderAddressActions(address.address) }
<td>{ address.address }</td>
{ this.renderAddressActions(address.address, type) }
<td>{ type === 'public' ? address.address : address.address.substring(0, 34) + '...' }</td>
<td>{ address.amount }</td>
<td>{ address.interest ? address.interest : 'N/A' }</td>
{!this.isNativeMode() &&
<td>{ address.interest ? address.interest : 'N/A' }</td>
}
</tr>
);
};
@ -64,31 +67,70 @@ export const ReceiveCoinRender = function() {
<div className="col-xlg-12 col-lg-12 col-sm-12 col-xs-12">
<div className="panel">
<header className="panel-heading">
<div className="panel-actions"></div>
<h4 className="panel-title">
{ translate('INDEX.RECEIVING_ADDRESS') }
</h4>
{this.isNativeMode() &&
<div className="panel-actions">
<div className={ 'dropdown' + (this.state.openDropMenu ? ' open' : '') }
onClick={ this.openDropMenu }>
<a className="dropdown-toggle white btn btn-warning">
<i className="icon md-arrows margin-right-10"></i> { translate('INDEX.GET_NEW_ADDRESS') }
<span
className="caret"></span>
</a>
<ul
className="dropdown-menu dropdown-menu-right">
<li>
<a onClick={ () => this.getNewAddress('public') }>
<i className="icon fa-eye"></i> { translate('INDEX.TRANSPARENT_ADDRESS') }
</a>
</li>
<li>
<a onClick={ () => this.getNewAddress('private') }>
<i className="icon fa-eye-slash"></i> { translate('INDEX.PRIVATE_Z_ADDRESS') }
</a>
</li>
</ul>
</div>
</div>
}
<h4 className="panel-title">{ translate('INDEX.RECEIVING_ADDRESS') }</h4>
</header>
<div className="panel-body">
<table className="table table-hover dataTable table-striped">
<thead>
{this.isNativeMode() ?
<tr>
<th>{ translate('INDEX.TYPE') }</th>
<th>{ translate('INDEX.ADDRESS') }</th>
<th>{ translate('INDEX.AMOUNT') }</th>
</tr>
:
<tr>
<th>{ translate('INDEX.TYPE') }</th>
<th>{ translate('INDEX.ADDRESS') }</th>
<th>{ translate('INDEX.BALANCE') }</th>
<th>{ translate('INDEX.INTEREST') }</th>
<th> {translate('INDEX.INTEREST') }</th>
</tr>
}
</thead>
<tbody>
{ this.renderAddressList() }
{this.renderAddressList('public')}
{this.isNativeMode() && this.renderAddressList('private')}
</tbody>
<tfoot>
{this.isNativeMode() ?
<tr>
<th>{ translate('INDEX.TYPE') }</th>
<th>{ translate('INDEX.ADDRESS') }</th>
<th>{ translate('INDEX.AMOUNT') }</th>
</tr>
:
<tr>
<th>{ translate('INDEX.TYPE') }</th>
<th>{ translate('INDEX.ADDRESS') }</th>
<th>{ translate('INDEX.BALANCE') }</th>
<th>{ translate('INDEX.INTEREST') }</th>
</tr>
}
</tfoot>
</table>
</div>

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

@ -1,7 +1,6 @@
import React from 'react';
import WalletsNativeBalance from '../walletsNativeBalance/walletsNativeBalance';
import WalletsNativeInfo from '../walletsNativeInfo/walletsNativeInfo';
import WalletsNativeReceive from '../walletsNativeReceive/walletsNativeReceive';
import WalletsNativeSend from '../walletsNativeSend/walletsNativeSend';
import WalletsNativeSyncProgress from '../walletsNativeSyncProgress/walletsNativeSyncProgress';
import WalletsNativeTxHistory from '../walletsNativeTxHistory/walletsNativeTxHistory';
@ -28,7 +27,6 @@ const WalletsNativeRender = function() {
<div className="row">
<WalletsNativeBalance {...this.props} />
<WalletsNativeTxHistory {...this.props} />
<WalletsNativeReceive {...this.props} />
<WalletsNativeSend {...this.props} />
<WalletsNativeInfo {...this.props} />
</div>

94
react/src/components/dashboard/walletsNativeReceive/walletsNativeReceive.js

@ -1,94 +0,0 @@
import React from 'react';
import {
copyCoinAddress,
getNewKMDAddresses
} from '../../../actions/actionCreators';
import Store from '../../../store';
import {
AddressListRender,
WalletsNativeReceiveRender
} from './walletsNativeReceive.render';
class WalletsNativeReceive extends React.Component {
constructor(props) {
super(props);
this.state = {
openDropMenu: false,
};
this.openDropMenu = this.openDropMenu.bind(this);
this.handleClickOutside = this.handleClickOutside.bind(this);
}
componentWillMount() {
document.addEventListener(
'click',
this.handleClickOutside,
false
);
}
componentWillUnmount() {
document.removeEventListener(
'click',
this.handleClickOutside,
false
);
}
handleClickOutside(e) {
if (e.srcElement.className.indexOf('dropdown') === -1 &&
(e.srcElement.offsetParent && e.srcElement.offsetParent.className.indexOf('dropdown') === -1)) {
this.setState({
openDropMenu: false,
});
}
}
openDropMenu() {
this.setState(Object.assign({}, this.state, {
openDropMenu: !this.state.openDropMenu,
}));
}
copyZAddress(address) {
Store.dispatch(copyCoinAddress(address));
}
renderAddressList(type) {
if (this.props.ActiveCoin.addresses &&
this.props.ActiveCoin.addresses[type] &&
this.props.ActiveCoin.addresses[type].length) {
return this.props.ActiveCoin.addresses[type].map(
(address) =>
AddressListRender.call(
this,
address,
type
)
);
}
return null;
}
getNewAddress(type) {
Store.dispatch(
getNewKMDAddresses(
this.props.ActiveCoin.coin,
type
)
);
}
render() {
if (this.props &&
this.props.ActiveCoin &&
this.props.ActiveCoin.nativeActiveSection === 'receive') {
return WalletsNativeReceiveRender.call(this);
}
return null;
}
}
export default WalletsNativeReceive;

90
react/src/components/dashboard/walletsNativeReceive/walletsNativeReceive.render.js

@ -1,90 +0,0 @@
import React from 'react';
import { translate } from '../../../translate/translate';
export const AddressListRender = function(address, type) {
return (
<tr key={ address.address }>
<td>
<span className={ type === 'public' ? 'label label-default' : 'label label-dark' }>
<i className={ type === 'public' ? 'icon fa-eye' : 'icon fa-eye-slash' }></i>
{ type === 'public' ? translate('IAPI.PUBLIC_SM') : translate('KMD_NATIVE.PRIVATE') }
</span>
<button
className="btn btn-default btn-xs clipboard-edexaddr margin-left-10"
onClick={ () => this.copyZAddress(address.address) }>
<i className="icon wb-copy"></i> { translate('INDEX.COPY') }
</button>
</td>
<td>{ type === 'public' ? address.address : address.address.substring(0, 34) + '...' }</td>
<td>{ address.amount }</td>
<td></td>
</tr>
);
};
export const WalletsNativeReceiveRender = function() {
return (
<div>
<div className="col-xs-12 margin-top-20">
<div className="panel nav-tabs-horizontal">
<div>
<div className="col-xlg-12 col-lg-12 col-sm-12 col-xs-12">
<div className="panel">
<header className="panel-heading">
<div className="panel-actions">
<div
className={ 'dropdown' + (this.state.openDropMenu ? ' open' : '') }
onClick={ this.openDropMenu }>
<a className="dropdown-toggle white btn btn-warning">
<i className="icon md-arrows margin-right-10"></i>
{ translate('INDEX.GET_NEW_ADDRESS') }
<span className="caret"></span>
</a>
<ul className="dropdown-menu dropdown-menu-right">
<li>
<a onClick={ () => this.getNewAddress('public') }>
<i className="icon fa-eye"></i>
{ translate('INDEX.TRANSPARENT_ADDRESS') }
</a>
</li>
<li>
<a onClick={ () => this.getNewAddress('private') }>
<i className="icon fa-eye-slash"></i>
{ translate('INDEX.PRIVATE_Z_ADDRESS') }
</a>
</li>
</ul>
</div>
</div>
<h3 className="panel-title">{ translate('INDEX.RECEIVING_ADDRESS') }</h3>
</header>
<div className="panel-body">
<table className="table table-hover dataTable table-striped">
<thead>
<tr>
<th>{ translate('INDEX.TYPE') }</th>
<th>{ translate('INDEX.ADDRESS') }</th>
<th>{ translate('INDEX.AMOUNT') }</th>
</tr>
</thead>
<tbody>
{ this.renderAddressList('public') }
{ this.renderAddressList('private') }
</tbody>
<tfoot>
<tr>
<th>{ translate('INDEX.TYPE') }</th>
<th>{ translate('INDEX.ADDRESS') }</th>
<th>{ translate('INDEX.AMOUNT') }</th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
);
};

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

@ -77,6 +77,7 @@ class WalletsNativeSyncProgress extends React.Component {
}
} else if (this.props.Settings.debugLog.indexOf('Still rescanning') > -1) {
const temp = this.props.Settings.debugLog.split(' ');
let currentProgress;
for (let i = 0; i < temp.length; i++) {
if (temp[i].indexOf('Progress=') > -1) {

Loading…
Cancel
Save