diff --git a/react/src/components/dashboard/walletsCacheData.js b/react/src/components/dashboard/walletsCacheData.js
new file mode 100644
index 0000000..887367f
--- /dev/null
+++ b/react/src/components/dashboard/walletsCacheData.js
@@ -0,0 +1,178 @@
+import React from 'react';
+import { translate } from '../../translate/translate';
+import { secondsToString } from '../../util/time';
+import { toggleViewCacheModal } from '../../actions/actionCreators';
+import Store from '../../store';
+import Tree, { TreeNode } from 'rc-tree';
+import { animation } from '../../util/rc-tree-animate';
+
+// TODO: refresh data render
+
+class WalletsCacheData extends React.Component {
+ constructor(props) {
+ super(props);
+ this.closeViewCacheModal = this.closeViewCacheModal.bind(this);
+ }
+
+ closeViewCacheModal() {
+ Store.dispatch(toggleViewCacheModal(false));
+ }
+
+ renderNotariesFetching() {
+ if (!this.props.ActiveCoin.cache) {
+ return (
+
Fetching cache data...
+ );
+ } else {
+ return (
+
+ {Object.keys(this.props.ActiveCoin.cache).length} coin(s) in cache file
+
+ );
+ }
+ }
+
+ renderKeyValueParent(pre, _sourceObj) {
+ if (_sourceObj.data[0] && Object.keys(_sourceObj.data[0]).length) {
+ return _sourceObj.data.map((key, value) =>
+
+ {this.renderArrayNode(`${pre}-array-${value}`, key)}
+ );
+ } else {
+ return Object.keys(_sourceObj.data).map((key, value) => this.renderKeyValue(pre, key, value));
+ }
+ }
+
+ renderArrayNode(pre, obj) {
+ return Object.keys(obj).map((key, value) => this.renderKeyValue(`${pre}-${key}`, key, obj[key]));
+ }
+
+ renderKeyValue(pre, key, value) {
+ return (
+
+ );
+ }
+
+ renderCallData(coin, address, call) {
+ const sourceObj = this.props.ActiveCoin.cache[coin][address];
+
+ if (sourceObj[call].data && (sourceObj[call].data.length || Object.keys(sourceObj[call].data).length)) {
+ return (
+
+
+
+
+ {this.renderKeyValueParent(`${coin}-${address}-${call}`, sourceObj[call])}
+
+
+ );
+ } else {
+ return (
+
+ );
+ }
+ }
+
+ renderAddressCallsList(coin, address) {
+ var allCalls = [];
+ const sourceObj = this.props.ActiveCoin.cache[coin][address];
+ const _allCalls = [
+ 'listtransactions',
+ 'listunspent',
+ 'getbalance',
+ 'refresh'
+ ];
+
+ for (let i = 0; i < _allCalls.length; i++) {
+ if (sourceObj[_allCalls[i]]) {
+ allCalls.push(_allCalls[i]);
+ }
+ }
+
+ if (sourceObj) {
+ return allCalls.map((call, index) => this.renderCallData(coin, address, call));
+ } else {
+ return null;
+ }
+ }
+
+ renderCoinAddressList(coin) {
+ const addrList = this.props.ActiveCoin.cache[coin].addresses;
+
+ if (addrList && addrList.length) {
+ return addrList.map((address, index) =>
+
+ {this.renderAddressCallsList(coin, address)}
+
+ );
+ } else {
+ return null;
+ }
+ }
+
+ renderCoinRootNodes() {
+ if (this.props.ActiveCoin.cache && Object.keys(this.props.ActiveCoin.cache).length) {
+ return Object.keys(this.props.ActiveCoin.cache).map((coinName, index) =>
+
+
+ {this.renderCoinAddressList(coinName)}
+
+
+ );
+ } else {
+ return null;
+ }
+ }
+
+ renderCoinData() {
+ if (this.props.ActiveCoin.notaries && this.props.ActiveCoin.notaries.notaries && this.props.ActiveCoin.notaries.notaries.length) {
+ return this.props.ActiveCoin.notaries.notaries.map((node, index) =>
+
+
+
+
+
+ );
+ } else {
+ return null;
+ }
+ }
+
+ render() {
+ if (this.props && this.props.ActiveCoin.mode === 'basilisk' && this.props.Dashboard.displayViewCacheModal) {
+
+ return (
+
+
+
+
+
+
+
+
+
+ {this.renderNotariesFetching()}
+
+ {this.renderCoinRootNodes()}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+ } else {
+ return null;
+ }
+ }
+}
+
+export default WalletsCacheData;
diff --git a/react/src/components/dashboard/walletsData.js b/react/src/components/dashboard/walletsData.js
index 24a576a..2c32ee9 100644
--- a/react/src/components/dashboard/walletsData.js
+++ b/react/src/components/dashboard/walletsData.js
@@ -1,4 +1,5 @@
import React from 'react';
+import Config from '../../config';
import { translate } from '../../translate/translate';
import { secondsToString } from '../../util/time';
import {
@@ -10,18 +11,20 @@ import {
changeMainBasiliskAddress,
displayNotariesModal,
deleteCacheFile,
- connectNotaries
+ connectNotaries,
+ toggleViewCacheModal
} from '../../actions/actionCreators';
import Store from '../../store';
import WalletsBasiliskRefresh from './walletsBasiliskRefresh';
import WalletsBasiliskConnection from './walletsBasiliskConnection';
import WalletsNotariesList from './walletsNotariesList';
+import WalletsCacheData from './walletsCacheData';
import { SocketProvider } from 'socket.io-react';
import io from 'socket.io-client';
-const socket = io.connect('http://localhost:17777');
+const socket = io.connect('http://127.0.0.1:' + Config.agamaPort);
class WalletsData extends React.Component {
constructor(props) {
@@ -43,10 +46,15 @@ class WalletsData extends React.Component {
this.getDexNotariesAction = this.getDexNotariesAction.bind(this);
this.openDropMenu = this.openDropMenu.bind(this);
this.refreshTxList = this.refreshTxList.bind(this);
- this.removeAndfetchNewCache = this.removeAndfetchNewCache.bind(this);
+ this.removeAndFetchNewCache = this.removeAndFetchNewCache.bind(this);
+ this._toggleViewCacheModal = this._toggleViewCacheModal.bind(this);
socket.on('messages', msg => this.updateSocketsData(msg));
}
+ _toggleViewCacheModal() {
+ Store.dispatch(toggleViewCacheModal(!this.props.Dashboard.displayViewCacheModal));
+ }
+
updateSocketsData(data) {
if (data && data.message && data.message.shepherd.iguanaAPI &&
data.message.shepherd.iguanaAPI.totalStackLength) {
@@ -67,7 +75,7 @@ class WalletsData extends React.Component {
}
}
- removeAndfetchNewCache() {
+ removeAndFetchNewCache() {
Store.dispatch(deleteCacheFile({
'pubkey': this.props.Dashboard.activeHandle.pubkey,
'allcoins': false,
@@ -348,6 +356,7 @@ class WalletsData extends React.Component {
+
diff --git a/react/src/components/dashboard/walletsNotariesList.js b/react/src/components/dashboard/walletsNotariesList.js
index 4eae35b..55f8546 100644
--- a/react/src/components/dashboard/walletsNotariesList.js
+++ b/react/src/components/dashboard/walletsNotariesList.js
@@ -1,7 +1,6 @@
import React from 'react';
import { translate } from '../../translate/translate';
-import { secondsToString } from '../../util/time';
-import { toggleDashboardTxInfoModal, displayNotariesModal } from '../../actions/actionCreators';
+import { displayNotariesModal } from '../../actions/actionCreators';
import Store from '../../store';
import Tree, { TreeNode } from 'rc-tree';
import { animation } from '../../util/rc-tree-animate';
@@ -9,9 +8,6 @@ import { animation } from '../../util/rc-tree-animate';
class WalletsNotariesList extends React.Component {
constructor(props) {
super(props);
- this.state = {
- display: false,
- };
this.closeNotariesModal = this.closeNotariesModal.bind(this);
}
diff --git a/react/src/reducers/dashboard.js b/react/src/reducers/dashboard.js
index 77480a1..13e8d72 100644
--- a/react/src/reducers/dashboard.js
+++ b/react/src/reducers/dashboard.js
@@ -5,7 +5,8 @@ import {
SYNCING_FULL_MODE,
SYNCING_NATIVE_MODE,
BASILISK_CONNECTION,
- DASHBOARD_CONNECT_NOTARIES
+ DASHBOARD_CONNECT_NOTARIES,
+ VIEW_CACHE_DATA
} from '../actions/actionCreators';
export function Dashboard(state = {
@@ -13,6 +14,7 @@ export function Dashboard(state = {
activeHandle: null,
basiliskRefresh: false,
basiliskConnection: false,
+ displayViewCacheModal: false,
connectedNotaries: {
total: 0,
current: 0,
@@ -58,6 +60,10 @@ export function Dashboard(state = {
failedToConnectNodes: action.failedNode,
}
});
+ case VIEW_CACHE_DATA:
+ return Object.assign({}, state, {
+ displayViewCacheModal: action.display,
+ });
default:
return state;
}
diff --git a/react/src/translate/en.js b/react/src/translate/en.js
index c644088..b2ee234 100644
--- a/react/src/translate/en.js
+++ b/react/src/translate/en.js
@@ -81,7 +81,8 @@ export const _lang = {
'GET_NOTARY_NODES_LIST': 'Get Notary Nodes List',
'REFRESH_BASILISK_CONNECTIONS': 'Refresh Basilisk Connections',
'FETCH_WALLET_DATA': 'Fetch Wallet Data',
- 'REFETCH_WALLET_DATA': 'Clear cache and fetch Wallet Data',
+ 'REFETCH_WALLET_DATA': 'Reset cache data',
+ 'VIEW_CACHE_DATA': 'View cache data',
'TRANSACTION_HISTORY': 'Transactions History',
'DIRECTION': 'Direction',
'CONFIRMATIONS': 'Confirmations',
diff --git a/react/src/util/time.js b/react/src/util/time.js
index 0ee7cb6..8cb8766 100644
--- a/react/src/util/time.js
+++ b/react/src/util/time.js
@@ -1,5 +1,5 @@
-export function secondsToString(seconds) {
- var a = new Date(seconds * 1000),
+export function secondsToString(seconds, skipMultiply) {
+ var a = new Date(seconds * (skipMultiply ? 1 : 1000)),
months = [
'Jan',
'Feb',