diff --git a/react/src/components/dashboard/walletsNativeTxHistory.js b/react/src/components/dashboard/walletsNativeTxHistory.js
index 8c82162..d983285 100644
--- a/react/src/components/dashboard/walletsNativeTxHistory.js
+++ b/react/src/components/dashboard/walletsNativeTxHistory.js
@@ -7,9 +7,16 @@ import Store from '../../store';
class WalletsNativeTxHistory extends React.Component {
constructor(props) {
super(props);
+ this.state = {
+ itemsPerPage: 10,
+ activePage: 1,
+ itemsList: null,
+ };
+ this.updateInput = this.updateInput.bind(this);
}
- // TODO: implement sorting and pagination
+ // TODO: implement sorting
+ // implement pagination past X items should call listtransactions to get new chunk of data
// z transactions
// filter based on addr
@@ -17,6 +24,17 @@ class WalletsNativeTxHistory extends React.Component {
Store.dispatch(toggleDashboardTxInfoModal(display, txIndex));
}
+ updateInput(e) {
+ let historyToSplit = this.props.ActiveCoin.txhistory;
+ historyToSplit = historyToSplit.slice(0, e.target.value);
+
+ this.setState({
+ [e.target.name]: e.target.value,
+ activePage: 1,
+ itemsList: historyToSplit,
+ });
+ }
+
renderTxType(category) {
if ( category === 'send' ) {
return (
@@ -60,9 +78,92 @@ class WalletsNativeTxHistory extends React.Component {
}
}
+ componentWillReceiveProps(props) {
+ if (!this.state.itemsList || (this.state.itemsList && !this.state.itemsList.length)) {
+ let historyToSplit = this.props.ActiveCoin.txhistory;
+ historyToSplit = historyToSplit.slice((this.state.activePage - 1) * this.state.itemsPerPage, this.state.activePage * this.state.itemsPerPage);
+
+ this.setState(Object.assign({}, this.state, {
+ itemsList: historyToSplit,
+ }));
+ }
+ }
+
+ updateCurrentPage(page) {
+ let historyToSplit = this.props.ActiveCoin.txhistory;
+ historyToSplit = historyToSplit.slice((page - 1) * this.state.itemsPerPage, page * this.state.itemsPerPage);
+
+ this.setState(Object.assign({}, this.state, {
+ activePage: page,
+ itemsList: historyToSplit,
+ }));
+ }
+
+ renderPaginationItems() {
+ let items = [];
+
+ for (let i=0; i <= Math.floor(this.props.ActiveCoin.txhistory.length / this.state.itemsPerPage); i++) {
+ items.push(
+
+ this.updateCurrentPage(i + 1) : null}>{i + 1}
+
+ );
+ }
+
+ return items;
+ }
+
+ renderPaginationItemsPerPageSelector() {
+ if (this.props.ActiveCoin.txhistory.length > 10) {
+ return (
+
+
+
+ );
+ } else {
+ return null;
+ }
+ }
+
+ renderPagination() {
+ if (this.props.ActiveCoin.txhistory.length > 10) {
+ return (
+
+
+
Showing {((this.state.activePage - 1) * this.state.itemsPerPage) + 1} to {this.state.activePage * this.state.itemsPerPage} of {this.props.ActiveCoin.txhistory.length} entries
+
+
+
+ );
+ } else {
+ return null;
+ }
+ }
+
renderTxHistoryList() {
- if (this.props.ActiveCoin.txhistory && this.props.ActiveCoin.txhistory.length && this.props.ActiveCoin.nativeActiveSection === 'default') {
- return this.props.ActiveCoin.txhistory.map((tx, index) =>
+ if (this.state.itemsList && this.state.itemsList.length && this.props.ActiveCoin.nativeActiveSection === 'default') {
+ return this.state.itemsList.map((tx, index) =>
@@ -98,33 +199,48 @@ class WalletsNativeTxHistory extends React.Component {
{translate('INDEX.TRANSACTION_HISTORY')}
-
-
-
- {translate('INDEX.TYPE')} |
- {translate('INDEX.DIRECTION')} |
- {translate('INDEX.CONFIRMATIONS')} |
- {translate('INDEX.AMOUNT')} |
- {translate('INDEX.TIME')} |
- {translate('INDEX.DEST_ADDRESS')} |
- {translate('INDEX.TX_DETAIL')} |
-
-
-
- {this.renderTxHistoryList()}
-
-
-
- {translate('INDEX.TYPE')} |
- {translate('INDEX.DIRECTION')} |
- {translate('INDEX.CONFIRMATIONS')} |
- {translate('INDEX.AMOUNT')} |
- {translate('INDEX.TIME')} |
- {translate('INDEX.DEST_ADDRESS')} |
- {translate('INDEX.TX_DETAIL')} |
-
-
-
+
+
+ {this.renderPaginationItemsPerPageSelector()}
+
+
+
+
+
+
+
+ {translate('INDEX.TYPE')} |
+ {translate('INDEX.DIRECTION')} |
+ {translate('INDEX.CONFIRMATIONS')} |
+ {translate('INDEX.AMOUNT')} |
+ {translate('INDEX.TIME')} |
+ {translate('INDEX.DEST_ADDRESS')} |
+ {translate('INDEX.TX_DETAIL')} |
+
+
+
+ {this.renderTxHistoryList()}
+
+
+
+ {translate('INDEX.TYPE')} |
+ {translate('INDEX.DIRECTION')} |
+ {translate('INDEX.CONFIRMATIONS')} |
+ {translate('INDEX.AMOUNT')} |
+ {translate('INDEX.TIME')} |
+ {translate('INDEX.DEST_ADDRESS')} |
+ {translate('INDEX.TX_DETAIL')} |
+
+
+
+
+ {this.renderPagination()}
diff --git a/react/src/styles/index.scss b/react/src/styles/index.scss
index 5c6860f..b6753a1 100644
--- a/react/src/styles/index.scss
+++ b/react/src/styles/index.scss
@@ -78,7 +78,8 @@ body {
#edexcoin_dashboardinfo a,
.nav-top-menu,
-#kmd_txid_info_mdl .nav-tabs li {
+#kmd_txid_info_mdl .nav-tabs li,
+.pagination a {
cursor: pointer;
cursor: hand;
}
@@ -88,6 +89,10 @@ body {
background-size: 100%;
}
+.unselectable {
+ user-select: none;
+}
+
/*.toaster .single-toast:nth-child(0) {
bottom: 12px;
}
diff --git a/react/src/util/time.js b/react/src/util/time.js
index 80e7ec5..0ee7cb6 100644
--- a/react/src/util/time.js
+++ b/react/src/util/time.js
@@ -20,7 +20,7 @@ export function secondsToString(seconds) {
hour = a.getHours() < 10 ? '0' + a.getHours() : a.getHours(),
min = a.getMinutes() < 10 ? '0' + a.getMinutes() : a.getMinutes(),
sec = a.getSeconds(),
- time = date + ' ' + month + ' ' + year + ' ' + hour + ':' + min + ':' + sec;
+ time = date + ' ' + month + ' ' + year + ' ' + hour + ':' + min; // + ':' + sec;
return time;
}
\ No newline at end of file
|