Browse Source

Merge the walletsNativeReceive component

all-modes
petitPapillon 8 years ago
parent
commit
11b24b1b0a
  1. 2
      react/src/components/dashboard/main/dashboard.render.js
  2. 83
      react/src/components/dashboard/receiveCoin/receiveCoin.js
  3. 98
      react/src/components/dashboard/receiveCoin/receiveCoin.render.js
  4. 2
      react/src/components/dashboard/walletsNative/walletsNative.render.js
  5. 76
      react/src/components/dashboard/walletsNativeReceive/walletsNativeReceive.js
  6. 82
      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' }>

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

@ -1,17 +1,17 @@
import React from 'react';
import React from "react";
import {
copyCoinAddress,
checkAddressBasilisk,
validateAddressBasilisk
} from '../../../actions/actionCreators';
import Store from '../../../store';
validateAddressBasilisk,
getNewKMDAddresses
} from "../../../actions/actionCreators";
import Store from "../../../store";
import {
AddressActionsBasiliskModeRender,
AddressActionsNonBasiliskModeRender,
AddressItemRender,
ReceiveCoinRender
} from './receiveCoin.render';
} from "./receiveCoin.render";
// TODO: implement sorting
// TODO: fallback to localstorage/stores data in case iguana is taking too long to respond
@ -19,6 +19,35 @@ 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) {
@ -37,12 +66,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) {
@ -53,26 +86,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)
);
}
@ -83,9 +124,11 @@ class ReceiveCoin extends React.Component {
}
render() {
console.log('RENDER11', this.props.receive, this.isNativeMode(), this.props.nativeActiveSection);
// 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);
}

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

@ -1,7 +1,7 @@
import React from 'react';
import { translate } from '../../../translate/translate';
import React from "react";
import {translate} from "../../../translate/translate";
export const AddressActionsBasiliskModeRender = function(address) {
export const AddressActionsBasiliskModeRender = function (address) {
return (
<td>
<span className="label label-default">
@ -10,7 +10,8 @@ export const AddressActionsBasiliskModeRender = function(address) {
<button
className="btn btn-default btn-xs clipboard-edexaddr margin-left-10"
title={ translate('INDEX.COPY_TO_CLIPBOARD') }
onClick={ () => this._copyCoinAddress(address) }><i className="icon wb-copy"></i> { translate('INDEX.COPY') }</button>
onClick={ () => this._copyCoinAddress(address) }><i className="icon wb-copy"></i> { translate('INDEX.COPY') }
</button>
<span
className="label label-default margin-left-10 action"
title={ translate('INDEX.CHECK') }
@ -27,31 +28,35 @@ 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"
onClick={ () => this._copyCoinAddress(address) }><i className="icon wb-copy"></i> { translate('INDEX.COPY') }</button>
onClick={ () => this._copyCoinAddress(address) }><i className="icon wb-copy"></i> { translate('INDEX.COPY') }
</button>
</td>
);
};
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>
{!this.isNativeMode() &&
<td>{ address.interest ? address.interest : 'N/A' }</td>
}
</tr>
);
};
export const ReceiveCoinRender = function() {
export const ReceiveCoinRender = function () {
return (
<div>
<div className="col-xs-12 margin-top-20">
@ -60,29 +65,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>
{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>
<tr>
<th>{ translate('INDEX.TYPE') }</th>
<th>{ translate('INDEX.ADDRESS') }</th>
<th>{ translate('INDEX.BALANCE') }</th>
<th>{ translate('INDEX.INTEREST') }</th>
</tr>
{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>
}
</thead>
<tbody>
{ this.renderAddressList() }
{this.renderAddressList('public')}
{this.isNativeMode() && this.renderAddressList('private')}
</tbody>
<tfoot>
<tr>
<th>{ translate('INDEX.TYPE') }</th>
<th>{ translate('INDEX.ADDRESS') }</th>
<th>{ translate('INDEX.BALANCE') }</th>
<th>{ translate('INDEX.INTEREST') }</th>
</tr>
{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';
@ -22,7 +21,6 @@ const WalletsNativeRender = function() {
<div className="row">
<WalletsNativeBalance {...this.props} />
<WalletsNativeTxHistory {...this.props} />
<WalletsNativeReceive {...this.props} />
<WalletsNativeSend {...this.props} />
<WalletsNativeInfo {...this.props} />
</div>

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

@ -1,76 +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;

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

@ -1,82 +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

@ -63,6 +63,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