Browse Source

on demand coind down modal; rpc con error icon

v0.25
pbca26 7 years ago
parent
commit
41e06bb744
  1. 38
      react/src/components/dashboard/coinTile/coinTileItem.js
  2. 8
      react/src/components/dashboard/coinTile/coinTileItem.render.js
  3. 2
      react/src/components/dashboard/coindDownModal/coindDownModal.js
  4. 10
      react/src/components/dashboard/navbar/navbar.js
  5. 12
      react/src/components/dashboard/navbar/navbar.render.js
  6. 11
      react/src/components/overrides.scss
  7. 5
      react/src/reducers/activeCoin.js

38
react/src/components/dashboard/coinTile/coinTileItem.js

@ -24,6 +24,7 @@ import {
activeHandle, activeHandle,
triggerToaster, triggerToaster,
shepherdRemoveCoin, shepherdRemoveCoin,
toggleCoindDownModal,
} from '../../../actions/actionCreators'; } from '../../../actions/actionCreators';
import Store from '../../../store'; import Store from '../../../store';
import Config from '../../../config'; import Config from '../../../config';
@ -32,17 +33,38 @@ import CoinTileItemRender from './coinTileItem.render';
const SPV_DASHBOARD_UPDATE_TIMEOUT = 60000; const SPV_DASHBOARD_UPDATE_TIMEOUT = 60000;
const ACTIVE_HANDLE_TIMEOUT_COIND_NATIVE = 15000; const ACTIVE_HANDLE_TIMEOUT_COIND_NATIVE = 15000;
const COIND_DOWN_MODAL_FETCH_FAILURES_THRESHOLD = window.require('electron').remote.getCurrentWindow().appConfig.failedRPCAttemptsThreshold || 10; const COIND_DOWN_MODAL_FETCH_FAILURES_THRESHOLD = 2; //window.require('electron').remote.getCurrentWindow().appConfig.failedRPCAttemptsThreshold || 10;
class CoinTileItem extends React.Component { class CoinTileItem extends React.Component {
constructor() { constructor() {
super(); super();
this.state = { this.state = {
appConfig: {}, appConfig: {},
activeCoin: null,
activeCoinMode: null,
propsUpdatedCounter: 0,
}; };
this.autoSetActiveCoin = this.autoSetActiveCoin.bind(this); this.autoSetActiveCoin = this.autoSetActiveCoin.bind(this);
} }
openCoindDownModal() {
Store.dispatch(toggleCoindDownModal(true));
}
renderCoinConError(item) {
if (this.props.ActiveCoin.getinfoFetchFailures >= COIND_DOWN_MODAL_FETCH_FAILURES_THRESHOLD &&
(this.props.ActiveCoin.mode === 'native' &&
this.props.ActiveCoin.coin === this.state.activeCoin &&
this.props.ActiveCoin.coin === item.coin &&
this.state.activeCoin === item.coin &&
this.state.activeCoinMode === 'native' &&
this.props.ActiveCoin.mode === this.state.activeCoinMode &&
this.state.propsUpdatedCounter > 1) ||
(this.props.ActiveCoin.coins && this.props.ActiveCoin.coins[item.coin]) && this.props.ActiveCoin.coins[item.coin].getinfoFetchFailures >= COIND_DOWN_MODAL_FETCH_FAILURES_THRESHOLD) {
return true;
}
}
renderStopCoinButton() { renderStopCoinButton() {
if (this.props.Main && if (this.props.Main &&
this.props.Main.coins && this.props.Main.coins &&
@ -87,11 +109,11 @@ class CoinTileItem extends React.Component {
_coinMode[coin] = mode; _coinMode[coin] = mode;
}); });
if (_coinMode['KMD'] && if (_coinMode.KMD &&
_coinMode['KMD'] === 'native') { _coinMode.KMD === 'native') {
_coin = 'KMD'; _coin = 'KMD';
_mode = 'native'; _mode = 'native';
} else if (_coinMode['KMD'] && _coinMode['KMD'] === 'spv') { } else if (_coinMode.KMD && _coinMode.KMD === 'spv') {
_coin = 'KMD'; _coin = 'KMD';
_mode = 'spv'; _mode = 'spv';
} }
@ -271,6 +293,13 @@ class CoinTileItem extends React.Component {
Store.dispatch(electrumServerChanged(false)); Store.dispatch(electrumServerChanged(false));
}, 100); }, 100);
} }
this.setState({
activeCoin: props.ActiveCoin.coin,
activeCoinMode: props.ActiveCoin.mode,
// prevent native con error icon flashing on coin switch
propsUpdatedCounter: this.state.activeCoin === props.ActiveCoin.coin && this.state.activeCoinMode === props.ActiveCoin.mode ? this.state.propsUpdatedCounter + 1 : 0,
});
} }
render() { render() {
@ -282,6 +311,7 @@ const mapStateToProps = (state) => {
return { return {
ActiveCoin: { ActiveCoin: {
coin: state.ActiveCoin.coin, coin: state.ActiveCoin.coin,
coins: state.ActiveCoin.coins,
mode: state.ActiveCoin.mode, mode: state.ActiveCoin.mode,
addresses: state.ActiveCoin.addresses, addresses: state.ActiveCoin.addresses,
mainBasiliskAddress: state.ActiveCoin.mainBasiliskAddress, mainBasiliskAddress: state.ActiveCoin.mainBasiliskAddress,

8
react/src/components/dashboard/coinTile/coinTileItem.render.js

@ -34,7 +34,7 @@ const CoinTileItemRender = function() {
<i <i
onClick={ () => this.removeCoin(item.coin, item.mode) } onClick={ () => this.removeCoin(item.coin, item.mode) }
title="Remove" title="Remove"
className={ 'icon fa-plus-circle ' + (item.mode === 'spv' ? 'coind-remove-icon coind-remove-icon-spv' : 'coind-remove-icon') }></i> className={ 'icon fa-plus-circle coind-remove-icon' + (item.mode === 'spv' ? ' coind-remove-icon-spv' : '') }></i>
} }
{ this.props.Dashboard && { this.props.Dashboard &&
this.props.Dashboard.electrumCoins && this.props.Dashboard.electrumCoins &&
@ -45,6 +45,12 @@ const CoinTileItemRender = function() {
title={ translate('SETTINGS.SPV_SINGLE_SERVER_NOTICE') } title={ translate('SETTINGS.SPV_SINGLE_SERVER_NOTICE') }
className="icon fa-info-circle icon-spv-connection-warning"></i> className="icon fa-info-circle icon-spv-connection-warning"></i>
} }
{ this.renderCoinConError(item) &&
<i
onClick={ this.openCoindDownModal }
title={ `Unable to establish RPC connection! Retries count: ${this.props.ActiveCoin.getinfoFetchFailures}.` }
className="icon fa-warning icon-native-connection-warning"></i>
}
</div> </div>
); );
}; };

2
react/src/components/dashboard/coindDownModal/coindDownModal.js

@ -5,7 +5,7 @@ import Store from '../../../store';
import CoindDownModalRender from './coindDownModal.render'; import CoindDownModalRender from './coindDownModal.render';
const COIND_DOWN_MODAL_FETCH_FAILURES_THRESHOLD = window.require('electron').remote.getCurrentWindow().appConfig.failedRPCAttemptsThreshold || 10; const COIND_DOWN_MODAL_FETCH_FAILURES_THRESHOLD = 2; //window.require('electron').remote.getCurrentWindow().appConfig.failedRPCAttemptsThreshold || 10;
class CoindDownModal extends React.Component { class CoindDownModal extends React.Component {
constructor() { constructor() {

10
react/src/components/dashboard/navbar/navbar.js

@ -31,6 +31,16 @@ class Navbar extends React.Component {
this.spvLogout = this.spvLogout.bind(this); this.spvLogout = this.spvLogout.bind(this);
} }
isRenderSpvLockLogout() {
if (this.props.Main &&
this.props.Main.isLoggedIn &&
this.props.Main.coins &&
this.props.Main.coins.spv &&
this.props.Main.coins.spv.length) {
return true;
}
}
spvLock() { spvLock() {
shepherdElectrumLock() shepherdElectrumLock()
.then((res) => { .then((res) => {

12
react/src/components/dashboard/navbar/navbar.render.js

@ -109,22 +109,14 @@ const NavbarRender = function() {
<i className="icon fa-users"></i> { translate('ABOUT.ABOUT_AGAMA') } <i className="icon fa-users"></i> { translate('ABOUT.ABOUT_AGAMA') }
</a> </a>
</li> </li>
{ this.props.Main && { this.isRenderSpvLockLogout() &&
this.props.Main.isLoggedIn &&
this.props.Main.coins &&
this.props.Main.coins.spv &&
this.props.Main.coins.spv.length &&
<li> <li>
<a onClick={ this.spvLock }> <a onClick={ this.spvLock }>
<i className="icon fa-lock"></i> Lock <i className="icon fa-lock"></i> Lock
</a> </a>
</li> </li>
} }
{ this.props.Main && { this.isRenderSpvLockLogout() &&
this.props.Main.isLoggedIn &&
this.props.Main.coins &&
this.props.Main.coins.spv &&
this.props.Main.coins.spv.length &&
<li> <li>
<a onClick={ this.spvLogout }> <a onClick={ this.spvLogout }>
<i className="icon fa-power-off"></i> Logout <i className="icon fa-power-off"></i> Logout

11
react/src/components/overrides.scss

@ -447,9 +447,10 @@ select{
padding-top: 5px; padding-top: 5px;
} }
.icon-spv-connection-warning { .icon-spv-connection-warning,
.icon-native-connection-warning {
position: absolute; position: absolute;
bottom: 15px; bottom: 20px;
right: 15px; right: 15px;
&:before { &:before {
@ -458,6 +459,12 @@ select{
} }
} }
.icon-native-connection-warning {
&:before {
color: #e9595b;
}
}
.color-warning { .color-warning {
color: #FF6600; color: #FF6600;
} }

5
react/src/reducers/activeCoin.js

@ -59,6 +59,7 @@ export function ActiveCoin(state = {
activeBasiliskAddress: state.activeBasiliskAddress, activeBasiliskAddress: state.activeBasiliskAddress,
progress: state.progress, progress: state.progress,
rescanInProgress: state.rescanInProgress, rescanInProgress: state.rescanInProgress,
getinfoFetchFailures: state.getinfoFetchFailures,
}; };
let _coins = state.coins; let _coins = state.coins;
_coins[state.coin] = _coinDataToStore; _coins[state.coin] = _coinDataToStore;
@ -81,6 +82,7 @@ export function ActiveCoin(state = {
activeBasiliskAddress: _coinData.activeBasiliskAddress, activeBasiliskAddress: _coinData.activeBasiliskAddress,
progress: _coinData.progress, progress: _coinData.progress,
rescanInProgress: _coinData.rescanInProgress, rescanInProgress: _coinData.rescanInProgress,
getinfoFetchFailures: _coinData.getinfoFetchFailures,
}; };
} else { } else {
if (state.coin) { if (state.coin) {
@ -100,6 +102,7 @@ export function ActiveCoin(state = {
activeBasiliskAddress: state.activeBasiliskAddress, activeBasiliskAddress: state.activeBasiliskAddress,
progress: state.progress, progress: state.progress,
rescanInProgress: state.rescanInProgress, rescanInProgress: state.rescanInProgress,
getinfoFetchFailures: state.getinfoFetchFailures,
}; };
let _coins = state.coins; let _coins = state.coins;
_coins[state.coin] = _coinData; _coins[state.coin] = _coinData;
@ -214,7 +217,7 @@ export function ActiveCoin(state = {
return { return {
...state, ...state,
progress: action.progress, progress: action.progress,
getinfoFetchFailures: !action.progress ? state.getinfoFetchFailures + 1 : 0, getinfoFetchFailures: typeof action.progress === 'string' && action.progress.indexOf('"code":-777') ? state.getinfoFetchFailures + 1 : 0,
}; };
case DASHBOARD_ACTIVE_COIN_GETINFO_FAILURE: case DASHBOARD_ACTIVE_COIN_GETINFO_FAILURE:
return { return {

Loading…
Cancel
Save