Browse Source

daemon down modal threshold; stop/remove native coin

v0.25
pbca26 7 years ago
parent
commit
4550ba236f
  1. 48
      react/src/actions/actions/coinList.js
  2. 10
      react/src/actions/actions/electrum.js
  3. 5
      react/src/actions/actions/nativeDashboardUpdate.js
  4. 6
      react/src/components/dashboard/claimInterestModal/claimInterestModal.render.js
  5. 138
      react/src/components/dashboard/coinTile/coinTileItem.js
  6. 24
      react/src/components/dashboard/coinTile/coinTileItem.render.js
  7. 2
      react/src/components/dashboard/coindDownModal/coindDownModal.js
  8. 4
      react/src/components/dashboard/walletsData/walletsData.js
  9. 4
      react/src/components/login/login.js
  10. 2
      react/src/components/login/login.render.js
  11. 18
      react/src/components/overrides.scss
  12. 1
      react/src/translate/en.js

48
react/src/actions/actions/coinList.js

@ -1,6 +1,54 @@
import { triggerToaster } from '../actionCreators';
import Config from '../../config';
export function shepherdStopCoind(coin) {
return new Promise((resolve, reject) => {
fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/coind/stop`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: coin === 'KMD' ? '' : JSON.stringify({ chain: coin }),
})
.catch((error) => {
console.log(error);
dispatch(
triggerToaster(
'shepherdStopCoind',
'Error',
'error'
)
);
})
.then(response => response.json())
.then(json => resolve(json))
});
}
export function shepherdRemoveCoin(coin) {
return new Promise((resolve, reject) => {
fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/coins/remove`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: coin === 'KMD' ? '' : JSON.stringify({ chain: coin }),
})
.catch((error) => {
console.log(error);
dispatch(
triggerToaster(
'shepherdRemoveCoin',
'Error',
'error'
)
);
})
.then(response => response.json())
.then(json => resolve(json))
});
}
export function shepherdGetCoinList() {
return new Promise((resolve, reject) => {
fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/coinslist`, {

10
react/src/actions/actions/electrum.js

@ -114,7 +114,7 @@ export function shepherdElectrumBalance(coin, address) {
'Error',
'error'
)
)
);
})
.then(response => response.json())
.then(json => {
@ -146,7 +146,7 @@ export function shepherdElectrumTransactions(coin, address) {
'Error',
'error'
)
)
);
})
.then(response => response.json())
.then(json => {
@ -187,7 +187,7 @@ export function shepherdElectrumCoins() {
'Error',
'error'
)
)
);
})
.then(response => response.json())
.then(json => {
@ -220,7 +220,7 @@ export function shepherdElectrumSend(coin, value, sendToAddress, changeAddress)
'Error',
'error'
)
)
);
})
.then(response => response.json())
.then(json => {
@ -249,7 +249,7 @@ export function shepherdElectrumSendPreflight(coin, value, sendToAddress, change
'Error',
'error'
)
)
);
})
.then(response => response.json())
.then(json => {

5
react/src/actions/actions/nativeDashboardUpdate.js

@ -31,8 +31,9 @@ export function getDashboardUpdate(coin, activeCoinProps) {
dispatch(getDashboardUpdateState(json, coin));
// dirty hack to trigger dashboard render
if (!activeCoinProps.balance &&
!activeCoinProps.addresses) {
if (!activeCoinProps || (activeCoinProps &&
!activeCoinProps.balance &&
!activeCoinProps.addresses)) {
setTimeout(() => {
dispatch(getDashboardUpdateState(json, coin));
}, 100);

6
react/src/components/dashboard/claimInterestModal/claimInterestModal.render.js

@ -1,8 +1,6 @@
import React from 'react';
import { translate } from '../../../translate/translate';
const MIN_INTEREST_THRESHOLD = 0.001;
export const _ClaimInterestTableRender = function() {
const _transactionsList = this.state.transactionsList;
let _items = [];
@ -11,7 +9,7 @@ export const _ClaimInterestTableRender = function() {
if ((_transactionsList[i].interest === 0 && this.state.showZeroInterest) ||
(_transactionsList[i].amount > 0 && _transactionsList[i].interest > 0)) {
_items.push(
<tr key={ `${_transactionsList[i].txid}${_transactionsList[i].address}` }>
<tr key={ `${_transactionsList[i].txid}-${_transactionsList[i].address}-${i}` }>
<td>
<button
className="btn btn-default btn-xs clipboard-edexaddr copy-string-btn"
@ -59,7 +57,7 @@ export const _ClaimInterestTableRender = function() {
<div
className="toggle-label margin-right-15 pointer"
onClick={ this.toggleZeroInterest }>
Show zero interest
{ translate('CLAIM_INTEREST.SHOW_ZERO_INTEREST') }
</div>
<button
type="button"

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

@ -19,6 +19,11 @@ import {
shepherdElectrumTransactions,
shepherdElectrumCoins,
electrumServerChanged,
shepherdStopCoind,
getDexCoins,
activeHandle,
triggerToaster,
shepherdRemoveCoin,
} from '../../../actions/actionCreators';
import Store from '../../../store';
import Config from '../../../config';
@ -27,51 +32,116 @@ import CoinTileItemRender from './coinTileItem.render';
const SPV_DASHBOARD_UPDATE_TIMEOUT = 60000;
const ACTIVE_HANDLE_TIMEOUT_COIND_NATIVE = 15000;
const COIND_DOWN_MODAL_FETCH_FAILURES_THRESHOLD = 5;
const COIND_DOWN_MODAL_FETCH_FAILURES_THRESHOLD = window.require('electron').remote.getCurrentWindow().appConfig.failedRPCAttemptsThreshold || 10;
class CoinTileItem extends React.Component {
constructor() {
super();
this.state = {
appConfig: {},
};
this.autoSetActiveCoin = this.autoSetActiveCoin.bind(this);
}
componentWillMount() {
if (!this.props.ActiveCoin.coin) {
let _coinSelected = false;
let _mode;
let _coin;
let _coinMode = {};
const modes = [
'native',
'spv',
];
const allCoins = this.props.Main.coins;
if (allCoins) {
modes.map((mode) => {
allCoins[mode].map((coin) => {
if (!_coinSelected) {
_coinSelected = true;
_coin = coin;
_mode = mode;
}
_coinMode[coin] = mode;
});
if (_coinMode['KMD'] &&
_coinMode['KMD'] === 'native') {
_coin = 'KMD';
_mode = 'native';
} else if (_coinMode['KMD'] && _coinMode['KMD'] === 'spv') {
_coin = 'KMD';
_mode = 'spv';
autoSetActiveCoin() {
const modes = [
'native',
'spv',
];
const allCoins = this.props.Main.coins;
let _coinSelected = false;
let _mode;
let _coin;
let _coinMode = {};
if (allCoins) {
modes.map((mode) => {
allCoins[mode].map((coin) => {
if (!_coinSelected) {
_coinSelected = true;
_coin = coin;
_mode = mode;
}
_coinMode[coin] = mode;
});
if (_coinMode['KMD'] &&
_coinMode['KMD'] === 'native') {
_coin = 'KMD';
_mode = 'native';
} else if (_coinMode['KMD'] && _coinMode['KMD'] === 'spv') {
_coin = 'KMD';
_mode = 'spv';
}
});
setTimeout(() => {
this._dashboardChangeActiveCoin(_coin, _mode);
}, 100);
}
}
componentWillMount() {
if (!this.props.ActiveCoin.coin) {
this.autoSetActiveCoin();
}
let appConfig;
try {
appConfig = window.require('electron').remote.getCurrentWindow().appConfig;
} catch (e) {}
this.setState({
appConfig,
});
}
removeCoin(coin) {
shepherdRemoveCoin(coin)
.then((res) => {
Store.dispatch(
triggerToaster(
`${coin} is removed`,
'Coin notification',
'success'
)
);
Store.dispatch(getDexCoins());
Store.dispatch(activeHandle());
setTimeout(() => {
this.autoSetActiveCoin();
}, 500);
});
}
stopCoind(coin) {
shepherdStopCoind(coin)
.then((res) => {
if (res.msg === 'error') {
Store.dispatch(
triggerToaster(
`Unable to stop ${coin}. Try again.`,
'Error',
'error'
)
);
} else {
Store.dispatch(
triggerToaster(
`${coin} is stopped`,
'Coin notification',
'success'
)
);
Store.dispatch(getDexCoins());
Store.dispatch(activeHandle());
setTimeout(() => {
this._dashboardChangeActiveCoin(_coin, _mode);
}, 100);
this.autoSetActiveCoin();
}, 500);
}
}
});
}
dispatchCoinActions(coin, mode) {

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

@ -24,6 +24,30 @@ const CoinTileItemRender = function() {
</div>
</div>
</div>
{ item.mode === 'native' &&
this.props.Main &&
this.props.Main.coins &&
this.props.Main.coins.native &&
this.props.Main.coins.native.length &&
this.props.Main.coins.native.length > 1 &&
<i
onClick={ () => this.stopCoind(item.coin) }
title="Stop"
className="icon fa-stop-circle coind-stop-icon"></i>
}
{ item.mode === 'native' &&
this.props.Main &&
this.props.Main.coins &&
this.props.Main.coins.native &&
this.props.Main.coins.native.length &&
this.props.Main.coins.native.length > 1 &&
this.state.appConfig &&
!this.state.appConfig.stopNativeDaemonsOnQuit &&
<i
onClick={ () => this.removeCoin(item.coin) }
title="Remove"
className="icon fa-plus-circle coind-remove-icon"></i>
}
{ this.props.Dashboard &&
this.props.Dashboard.electrumCoins &&
this.props.Dashboard.electrumCoins[item.coin] &&

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

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

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

@ -356,8 +356,8 @@ class WalletsData extends React.Component {
className="table-cell-offset-16 color-warning">
{ translate('DASHBOARD.SPV_CONN_ERROR') }
<span className={ this.props.Dashboard.electrumCoins[this.props.ActiveCoin.coin].serverList !== 'none' ? '' : 'hide' }>
<br/>{ translate('DASHBOARD.SPV_CONN_ERROR_SPV1') }
<br/>{ translate('DASHBOARD.SPV_CONN_ERROR_SPV2') }
<br/>{ translate('DASHBOARD.SPV_CONN_ERROR_P1') }
<br/>{ translate('DASHBOARD.SPV_CONN_ERROR_P2') }
</span>
</td>
</tr>

4
react/src/components/login/login.js

@ -241,8 +241,8 @@ class Login extends React.Component {
// auto-size textarea
setTimeout(() => {
if (this.state.seedInputVisibility) {
document.querySelector('#loginPassphrase').style.height = '1px';
document.querySelector('#loginPassphrase').style.height = `${(15 + document.querySelector('#loginPassphrase').scrollHeight)}px`;
document.querySelector('#loginPassphrase').style.height = '1px';
document.querySelector('#loginPassphrase').style.height = `${(15 + document.querySelector('#loginPassphrase').scrollHeight)}px`;
}
}, 100);
}

2
react/src/components/login/login.render.js

@ -255,7 +255,7 @@ const LoginRender = function () {
<div className="form-group form-material floating">
<div
className="radio-custom radio-default radio-inline"
onClick={ () =>this.state.bitsOption !== 256 && this.generateNewSeed(256) }>
onClick={ () => this.state.bitsOption !== 256 && this.generateNewSeed(256) }>
<input
type="radio"
name="PassPhraseOptions"

18
react/src/components/overrides.scss

@ -493,4 +493,22 @@ select{
.bs-caret {
display: none;
}
}
.coind-stop-icon,
.coind-remove-icon {
font-size: 20px;
position: absolute;
top: 19px;
right: 12px;
color: #ccc !important;
&:hover {
color: #e9595b !important;
}
}
.coind-remove-icon {
transform: rotate(45deg);
top: 45px;
}

1
react/src/translate/en.js

@ -21,6 +21,7 @@ export const _lang = {
'IMPORT_AND_RESCAN': 'Import and rescan',
},
'CLAIM_INTEREST': {
'SHOW_ZERO_INTEREST': 'Show zero interest',
'REQ_P1': 'Requirements to accrue interest',
'REQ_P2': 'spend transaction was made at least 1 hour ago, locktime field is set and amount is greater than',
'CLAIM_INTEREST': 'Claim @template@ interest',

Loading…
Cancel
Save