Browse Source

native tx history, tx info modal

all-modes
pbca26 8 years ago
parent
commit
20031e5e6e
  1. 132
      react/src/components/dashboard/walletsNativeTxHistory.js
  2. 85
      react/src/components/dashboard/walletsNativeTxInfo.js

132
react/src/components/dashboard/walletsNativeTxHistory.js

@ -1,30 +1,43 @@
import React from 'react';
import { translate } from '../../translate/translate';
import { secondsToString } from '../../util/time';
import { toggleDashboardTxInfoModal } from '../../actions/actionCreators';
import Store from '../../store';
class WalletsNativeTxHistory extends React.Component {
constructor(props) {
super(props);
}
// TODO: implement sorting and pagination
toggleTxInfoModal(display, txIndex) {
Store.dispatch(toggleDashboardTxInfoModal(display, txIndex));
}
renderTxType(category) {
if ( category == 'send' ) {
if ( category === 'send' ) {
return (
<span>
<i className="icon fa-arrow-circle-left"></i> <span>{translate('DASHBOARD.OUT')}</span>
</span>
);
}
if ( category == 'receive' ) {
if ( category === 'receive' ) {
return (
<span>
<i className="icon fa-arrow-circle-right"></i> <span>{translate('DASHBOARD.IN')}</span>
</span>
);
}
if ( category == 'generate' ) {
if ( category === 'generate' ) {
return (
<span>
<i className="icon fa-cogs"></i> <span>{translate('DASHBOARD.MINED')}</span>
</span>
);
}
if ( category == 'immature' ) {
if ( category === 'immature' ) {
return (
<span>
<i className="icon fa-clock-o"></i> <span>{translate('DASHBOARD.IMMATURE')}</span>
@ -33,9 +46,21 @@ class WalletsNativeTxHistory extends React.Component {
}
}
renderAddress(tx) {
if (!tx.address) {
return (
<span>
<i className="icon fa-bullseye"></i> <span className="label label-dark">{translate('DASHBOARD.ZADDR_NOT_LISTED')}</span>
</span>
);
} else {
return (tx.address);
}
}
renderTxHistoryList() {
if (this.props.ActiveCoin.txhistory && this.props.ActiveCoin.txhistory.length) {
return this.props.ActiveCoin.txhistory.map((tx) =>
if (this.props.ActiveCoin.txhistory && this.props.ActiveCoin.txhistory.length && this.props.ActiveCoin.nativeActiveSection === 'default') {
return this.props.ActiveCoin.txhistory.map((tx, index) =>
<tr key={tx.txid}>
<td>
<span className="label label-default">
@ -43,8 +68,13 @@ class WalletsNativeTxHistory extends React.Component {
</span>
</td>
<td>{this.renderTxType(tx.category)}</td>
<td></td>
<td></td>
<td>{tx.confirmations}</td>
<td>{tx.amount}</td>
<td>{secondsToString(tx.time)}</td>
<td>{this.renderAddress(tx)}</td>
<td>
<button type="button" className="btn btn-xs white btn-info waves-effect waves-light btn-kmdtxid" onClick={() => this.toggleTxInfoModal(!this.props.ActiveCoin.showTransactionInfo, index)}><i className="icon fa-search"></i></button>
</td>
</tr>
);
} else {
@ -53,52 +83,58 @@ class WalletsNativeTxHistory extends React.Component {
}
render() {
return (
<div data-extcoin="COIN" id="kmd_wallet_dashboardinfo">
<div className="col-xs-12 margin-top-20">
<div className="panel nav-tabs-horizontal">
<div data-extcoin="COIN" id="kmd_wallet_dashoard_section">
<div className="col-xlg-12 col-lg-12 col-sm-12 col-xs-12">
<div className="panel">
<header className="panel-heading">
<h3 className="panel-title">{translate('INDEX.TRANSACTION_HISTORY')}</h3>
</header>
<div className="panel-body">
<table className="table table-hover dataTable table-striped" data-extcoin="COIN" id="kmd-tx-history-tbl" width="100%">
<thead>
<tr>
<th>{translate('INDEX.TYPE')}</th>
<th>{translate('INDEX.DIRECTION')}</th>
<th>{translate('INDEX.CONFIRMATIONS')}</th>
<th>{translate('INDEX.AMOUNT')}</th>
<th>{translate('INDEX.TIME')}</th>
<th>{translate('INDEX.DEST_ADDRESS')}</th>
<th>{translate('INDEX.TX_DETAIL')}</th>
</tr>
</thead>
<tbody>
{this.renderTxHistoryList()}
</tbody>
<tfoot>
<tr>
<th>{translate('INDEX.TYPE')}</th>
<th>{translate('INDEX.DIRECTION')}</th>
<th>{translate('INDEX.CONFIRMATIONS')}</th>
<th>{translate('INDEX.AMOUNT')}</th>
<th>{translate('INDEX.TIME')}</th>
<th>{translate('INDEX.DEST_ADDRESS')}</th>
<th>{translate('INDEX.TX_DETAIL')}</th>
</tr>
</tfoot>
</table>
if (this.props && this.props.ActiveCoin.nativeActiveSection === 'default') {
return (
<div className="native-transactions">
<div data-extcoin="COIN" id="kmd_wallet_dashboardinfo">
<div className="col-xs-12 margin-top-20">
<div className="panel nav-tabs-horizontal">
<div data-extcoin="COIN" id="kmd_wallet_dashoard_section">
<div className="col-xlg-12 col-lg-12 col-sm-12 col-xs-12">
<div className="panel">
<header className="panel-heading">
<h3 className="panel-title">{translate('INDEX.TRANSACTION_HISTORY')}</h3>
</header>
<div className="panel-body">
<table className="table table-hover dataTable table-striped" data-extcoin="COIN" id="kmd-tx-history-tbl" width="100%">
<thead>
<tr>
<th>{translate('INDEX.TYPE')}</th>
<th>{translate('INDEX.DIRECTION')}</th>
<th>{translate('INDEX.CONFIRMATIONS')}</th>
<th>{translate('INDEX.AMOUNT')}</th>
<th>{translate('INDEX.TIME')}</th>
<th>{translate('INDEX.DEST_ADDRESS')}</th>
<th>{translate('INDEX.TX_DETAIL')}</th>
</tr>
</thead>
<tbody>
{this.renderTxHistoryList()}
</tbody>
<tfoot>
<tr>
<th>{translate('INDEX.TYPE')}</th>
<th>{translate('INDEX.DIRECTION')}</th>
<th>{translate('INDEX.CONFIRMATIONS')}</th>
<th>{translate('INDEX.AMOUNT')}</th>
<th>{translate('INDEX.TIME')}</th>
<th>{translate('INDEX.DEST_ADDRESS')}</th>
<th>{translate('INDEX.TX_DETAIL')}</th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
);
);
} else {
return null;
}
}
}

85
react/src/components/dashboard/walletsNativeTxInfo.js

@ -1,128 +1,159 @@
import React from 'react';
import { translate } from '../../translate/translate';
import { secondsToString } from '../../util/time';
import { toggleDashboardTxInfoModal } from '../../actions/actionCreators';
import Store from '../../store';
class WalletsNativeTxInfo extends React.Component {
constructor(props) {
super(props);
this.state = {
activeTab: 0,
};
this.toggleTxInfoModal = this.toggleTxInfoModal.bind(this);
}
toggleTxInfoModal() {
Store.dispatch(toggleDashboardTxInfoModal(false));
}
openTab(tab) {
this.setState(Object.assign({}, this.state, {
activeTab: tab,
}));
}
render() {
if (this.props && this.props.ActiveCoin && this.props.ActiveCoin.showTransactionInfo) {
if (this.props && this.props.ActiveCoin.showTransactionInfo && this.props.ActiveCoin.nativeActiveSection === 'default') {
const txInfo = this.props.ActiveCoin.txhistory[this.props.ActiveCoin.showTransactionInfoTxIndex];
return (
<div>
<div className="modal show" data-extcoin="COIN" id="kmd_txid_info_mdl" aria-hidden="false" role="dialog">
<div className="modal-dialog modal-center modal-lg">
<div className="modal-content">
<div className="modal-body">
<div className="modal-body" style={{height: '590px'}}>
<div className="panel nav-tabs-horizontal">
<ul className="nav nav-tabs nav-tabs-line" data-plugin="nav-tabs" role="tablist">
<li className="active" role="presentation">
<a data-toggle="tab" href="#KmdTxIDInfotab1" data-extcoin="COIN" aria-controls="KmdTxIDInfotab1" role="tab">
<li className={this.state.activeTab === 0 ? 'active' : ''} role="presentation">
<a data-toggle="tab" data-extcoin="COIN" aria-controls="KmdTxIDInfotab1" role="tab" onClick={() => this.openTab(0)}>
<i className="icon md-balance-wallet" aria-hidden="true"></i>TxID Info
</a>
</li>
<li role="presentation">
<a data-toggle="tab" href="#KmdTxIDInfotab2" data-extcoin="COIN" aria-controls="KmdTxIDInfotab2" role="tab">
<i className="icon md-plus-square" aria-hidden="true"></i>vjointsplits, details
<li className={this.state.activeTab === 1 ? 'active' : ''} role="presentation">
<a data-toggle="tab" data-extcoin="COIN" aria-controls="KmdTxIDInfotab2" role="tab" onClick={() => this.openTab(1)}>
<i className="icon md-plus-square" aria-hidden="true"></i>Vjointsplits, Details
</a>
</li>
<li role="presentation">
<a data-toggle="tab" href="#KmdTxIDInfotab3" data-extcoin="COIN" aria-controls="KmdTxIDInfotab3" role="tab">
<i className="icon wb-briefcase" aria-hidden="true"></i>hex
<li className={this.state.activeTab === 2 ? 'active' : ''} role="presentation">
<a data-toggle="tab" data-extcoin="COIN" aria-controls="KmdTxIDInfotab3" role="tab" onClick={() => this.openTab(2)}>
<i className="icon wb-briefcase" aria-hidden="true"></i>Hex
</a>
</li>
<li className={this.state.activeTab === 3 ? 'active' : ''} role="presentation">
<a data-toggle="tab" data-extcoin="COIN" aria-controls="KmdTxIDInfotab4" role="tab" onClick={() => this.openTab(3)}>
<i className="icon wb-file" aria-hidden="true"></i>Raw info
</a>
</li>
</ul>
<div className="panel-body">
<div className="tab-content">
<div className="tab-pane active" id="KmdTxIDInfotab1" data-extcoin="COIN" role="tabpanel">
<div className={this.state.activeTab === 0 ? 'tab-pane active' : 'tab-pane'} id="KmdTxIDInfotab1" data-extcoin="COIN" role="tabpanel">
<table className="table table-striped">
<tbody>
<tr>
<td>amount</td>
<td>
<span data-extcoin="COIN" id="kmd_txid_info_amount"></span>
{txInfo.amount}
</td>
</tr>
<tr>
<td>fee</td>
<td>
<span data-extcoin="COIN" id="kmd_txid_info_fee"></span>
{txInfo.fee}
</td>
</tr>
<tr>
<td>confirmations</td>
<td>
<span data-extcoin="COIN" id="kmd_txid_info_confirmations"></span>
{txInfo.confirmations}
</td>
</tr>
<tr>
<td>blockhash</td>
<td>
<span data-extcoin="COIN" id="kmd_txid_info_blockhash"></span>
{txInfo.blockhash}
</td>
</tr>
<tr>
<td>blockindex</td>
<td>
<span data-extcoin="COIN" id="kmd_txid_info_blockindex"></span>
{txInfo.blockindex}
</td>
</tr>
<tr>
<td>blocktime</td>
<td>
<span data-extcoin="COIN" id="kmd_txid_info_blocktime"></span>
{secondsToString(txInfo.blocktime)}
</td>
</tr>
<tr>
<td>txid</td>
<td>
<span data-extcoin="COIN" id="kmd_txid_info_txid"></span>
{txInfo.txid}
</td>
</tr>
<tr>
<td>walletconflicts</td>
<td>
<span data-extcoin="COIN" id="kmd_txid_info_walletconflicts"></span>
{txInfo.walletconflicts.length}
</td>
</tr>
<tr>
<td>time</td>
<td>
<span data-extcoin="COIN" id="kmd_txid_info_time"></span>
{secondsToString(txInfo.time)}
</td>
</tr>
<tr>
<td>timereceived</td>
<td>
<span data-extcoin="COIN" id="kmd_txid_info_timereceived"></span>
{secondsToString(txInfo.timereceived)}
</td>
</tr>
</tbody>
</table>
</div>
<div className="tab-pane" id="KmdTxIDInfotab2" data-extcoin="COIN" role="tabpanel">
<div className={this.state.activeTab === 1 ? 'tab-pane active' : 'tab-pane'} id="KmdTxIDInfotab2" data-extcoin="COIN" role="tabpanel">
<table className="table table-striped">
<tbody>
<tr>
<td>vjoinsplit</td>
<td>
<span data-extcoin="COIN" id="kmd_txid_info_vjoinsplit"></span>
{txInfo.vjoinsplit}
</td>
</tr>
<tr>
<td>details</td>
<td>
<span data-extcoin="COIN" id="kmd_txid_info_details"></span>
{txInfo.details}
</td>
</tr>
</tbody>
</table>
</div>
<div className="tab-pane" id="KmdTxIDInfotab3" data-extcoin="COIN" role="tabpanel">
<textarea id="kmd_txid_info_hex" data-extcoin="COIN" style={{width: '100%', height: '170px'}} rows="10" cols="80" disabled></textarea>
<div className={this.state.activeTab === 2 ? 'tab-pane active' : 'tab-pane'} id="KmdTxIDInfotab3" data-extcoin="COIN" role="tabpanel">
<textarea id="kmd_txid_info_hex" data-extcoin="COIN" style={{width: '100%', height: '170px'}} rows="10" cols="80" disabled>{txInfo.hex}</textarea>
</div>
<div className={this.state.activeTab === 3 ? 'tab-pane active' : 'tab-pane'} id="KmdTxIDInfotab4" data-extcoin="COIN" role="tabpanel">
<textarea id="kmd_txid_info_hex" data-extcoin="COIN" style={{width: '100%', height: '400px'}} rows="40" cols="80" disabled>{JSON.stringify(txInfo, null, '\t')}</textarea>
</div>
</div>
</div>
</div>
</div>
<div className="modal-footer">
<button type="button" className="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" className="btn btn-default" data-dismiss="modal" onClick={this.toggleTxInfoModal}>Close</button>
</div>
</div>
</div>

Loading…
Cancel
Save