Browse Source

refresh notaries con modal

all-modes
pbca26 8 years ago
parent
commit
e5197dcaa3
  1. 96
      react/src/actions/actionCreators.js
  2. 25
      react/src/components/dashboard/walletsBasiliskConnection.js
  3. 4
      react/src/components/dashboard/walletsData.js
  4. 18
      react/src/reducers/dashboard.js
  5. 6
      react/src/styles/index.scss

96
react/src/actions/actionCreators.js

@ -45,6 +45,7 @@ export const DASHBOARD_ACTIVE_COIN_GET_CACHE = 'DASHBOARD_ACTIVE_COIN_GET_CACHE'
export const DASHBOARD_ACTIVE_COIN_MAIN_BASILISK_ADDR = 'DASHBOARD_ACTIVE_COIN_MAIN_BASILISK_ADDR';
export const DASHBOARD_GET_NOTARIES_LIST = 'DASHBOARD_GET_NOTARIES_LIST';
export const DASHBOARD_DISPLAY_NOTARIES_MODAL = 'DASHBOARD_DISPLAY_NOTARIES_MODAL';
export const DASHBOARD_CONNECT_NOTARIES = 'DASHBOARD_CONNECT_NOTARIES';
export function displayNotariesModal(display) {
return {
@ -1772,11 +1773,11 @@ export function deleteCacheFile(_payload) {
}
export function fetchNewCacheData(_payload) {
const _userpass = '?userpass=tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth');
const _pubkey = '&pubkey=' + _payload.pubkey;
const _route = _payload.allcoins ? 'cache-all' : 'cache-one';
const _coin = '&coin=' + _payload.coin;
const _calls = '&calls=' + _payload.calls;
const _userpass = '?userpass=tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
_pubkey = '&pubkey=' + _payload.pubkey,
_route = _payload.allcoins ? 'cache-all' : 'cache-one',
_coin = '&coin=' + _payload.coin,
_calls = '&calls=' + _payload.calls;
return dispatch => {
return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/' + _route + _userpass + _pubkey + _coin + _calls, {
@ -1794,6 +1795,91 @@ export function fetchNewCacheData(_payload) {
}
}
function initNotaryNodesConSequence(nodes) {
return dispatch => {
Promise.all(nodes.map((node, index) => {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': 'dex',
'method': 'getinfo',
'symbol': node
};
return new Promise((resolve, reject) => {
fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
method: 'POST',
body: JSON.stringify(payload),
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'getInfoDexNode+' + node, 'Error', 'error'));
})
.then(response => response.json())
.then(json => dispatch(updateNotaryNodeConState(json, nodes.length, index, node)))
});
}));
}
}
function updateNotaryNodeConState(json, totalNodes, currentNodeIndex, currentNodeName) {
if (currentNodeIndex === totalNodes - 1) {
return dispatch => {
dispatch(basiliskConnectionState(false));
};
} else {
if (json && json.error === 'less than required responses') {
return {
type: DASHBOARD_CONNECT_NOTARIES,
total: totalNodes - 1,
current: currentNodeIndex,
name: currentNodeName,
failedNode: currentNodeName,
}
} else {
return {
type: DASHBOARD_CONNECT_NOTARIES,
total: totalNodes - 1,
current: currentNodeIndex,
name: currentNodeName,
}
}
}
}
function connectAllNotaryNodes(json, dispatch) {
if (json && json.length) {
dispatch(initNotaryNodesConSequence(json));
return {
type: DASHBOARD_CONNECT_NOTARIES,
total: json.length - 1,
current: 0,
name: json[0],
}
}
}
export function connectNotaries() {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': 'dpow',
'method': 'notarychains'
};
return dispatch => {
return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
method: 'POST',
body: JSON.stringify(payload),
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'connectNotaries', 'Error', 'error'));
})
.then(response => response.json())
.then(json => dispatch(connectAllNotaryNodes(json, dispatch)))
}
}
/*function Shepherd_SendPendValue() {
Shepherd_SysInfo().then(function(result){
var ram_data = formatBytes(result.totalmem_bytes)

25
react/src/components/dashboard/walletsBasiliskConnection.js

@ -1,7 +1,18 @@
import React from 'react';
import { translate } from '../../translate/translate';
import { basiliskConnection } from '../../actions/actionCreators';
import Store from '../../store';
class WalletsBasiliskConnection extends React.Component {
constructor(props) {
super(props);
this.basiliskConnectionAction = this.basiliskConnectionAction.bind(this);
}
basiliskConnectionAction() {
Store.dispatch(basiliskConnection(false));
}
render() {
if (this.props && this.props.Dashboard.basiliskConnection) {
return (
@ -11,8 +22,12 @@ class WalletsBasiliskConnection extends React.Component {
<div className="modal-content">
<div className="modal-header bg-orange-a400 wallet-send-header" style={{borderRadius: '3px 3px 0 0'}}>
<h4 className="modal-title white">
<span className="icon fa-refresh" style={{margin: '0'}}></span> {translate('INDEX.REFRESHING_BASILISK_NET')}... <span id="mdl_receive_coin_name"></span>
<span className="icon fa-refresh" style={{margin: '0'}}></span> {translate('INDEX.REFRESHING_BASILISK_NET')}...
</h4>
<button type="button" className="close btn-close" data-dismiss="alert" aria-label="Close" onClick={this.basiliskConnectionAction}>
<span aria-hidden="true">&times;</span>
<span className="sr-only">{translate('INDEX.CLOSE')}</span>
</button>
</div>
<div className="modal-body" style={{textAlign: 'center'}}>
<div className="loader-wrapper active">
@ -54,12 +69,14 @@ class WalletsBasiliskConnection extends React.Component {
</div>
</div>
<h5 className="text-left">
<span id="basilisk-connections-refresh-title">-</span> <span className="pull-right" id="basilisk-connections-refresh-percent">-</span>
{translate('IAPI.CON_STATUS') + '... ' + this.props.Dashboard.connectedNotaries.current + '/' + this.props.Dashboard.connectedNotaries.total + ': ' + this.props.Dashboard.connectedNotaries.currentNodeName} <span className="pull-right" id="basilisk-connections-refresh-percent">{Math.floor(this.props.Dashboard.connectedNotaries.current * 100 / this.props.Dashboard.connectedNotaries.total)}%</span>
</h5>
<div className="progress progress-sm">
<div className="progress-bar progress-bar-info progress-bar-striped active" style={{width: '10%', fontSize: '80%'}} role="progressbar" data-edexcoin="COIN" id="basilisk-connections-refresh-progress-bar"></div>
<div className="progress-bar progress-bar-info progress-bar-striped active" style={{width: Math.floor(this.props.Dashboard.connectedNotaries.current * 100 / this.props.Dashboard.connectedNotaries.total) + '%', fontSize: '80%'}} role="progressbar" data-edexcoin="COIN" id="basilisk-connections-refresh-progress-bar"></div>
</div>
<pre data-edexcoin="COIN" id="basilisk-connections-refresh-status-output"></pre>
<pre data-edexcoin="COIN" id="basilisk-connections-refresh-status-output">
{this.props.Dashboard.connectedNotaries.failedToConnectNodes ? 'Failed: ' + this.props.Dashboard.connectedNotaries.failedToConnectNodes : null}
</pre>
</div>
</div>
</div>

4
react/src/components/dashboard/walletsData.js

@ -9,7 +9,8 @@ import {
getBasiliskTransactionsList,
changeMainBasiliskAddress,
displayNotariesModal,
deleteCacheFile
deleteCacheFile,
connectNotaries
} from '../../actions/actionCreators';
import Store from '../../store';
@ -90,6 +91,7 @@ class WalletsData extends React.Component {
basiliskConnectionAction() {
if (this.props.Dashboard) {
Store.dispatch(basiliskConnection(!this.props.Dashboard.basiliskConnection));
Store.dispatch(connectNotaries());
}
}

18
react/src/reducers/dashboard.js

@ -4,7 +4,8 @@ import {
BASILISK_REFRESH,
SYNCING_FULL_MODE,
SYNCING_NATIVE_MODE,
BASILISK_CONNECTION
BASILISK_CONNECTION,
DASHBOARD_CONNECT_NOTARIES
} from '../actions/actionCreators';
export function Dashboard(state = {
@ -12,6 +13,12 @@ export function Dashboard(state = {
activeHandle: null,
basiliskRefresh: false,
basiliskConnection: false,
connectedNotaries: {
total: 0,
current: 0,
currentNodeName: null,
failedToConnectNodes: null,
}
}, action) {
switch (action.type) {
case DASHBOARD_SECTION_CHANGE:
@ -42,6 +49,15 @@ export function Dashboard(state = {
syncingNativeMode: action.syncingNativeMode,
progress: action.progress,
});
case DASHBOARD_CONNECT_NOTARIES:
return Object.assign({}, state, {
connectedNotaries: {
total: action.total,
current: action.current,
currentNodeName: action.name,
failedToConnectNodes: action.failedNode,
}
});
default:
return state;
}

6
react/src/styles/index.scss

@ -143,6 +143,12 @@ body {
user-select: all;
}
#RefreshBasiliskConnectionsMdl .btn-close {
position: absolute;
top: 15px;
right: 15px;
}
/*.toaster .single-toast:nth-child(0) {
bottom: 12px;
}

Loading…
Cancel
Save