Browse Source

remove coin extended

v0.25
pbca26 7 years ago
parent
commit
c48bd079e9
  1. 2
      react/src/actions/actions/addCoin.js
  2. 57
      react/src/actions/actions/coinList.js
  3. 2
      react/src/components/addcoin/addcoin.js
  4. 4
      react/src/components/dashboard/claimInterestModal/claimInterestModal.js
  5. 32
      react/src/components/dashboard/coinTile/coinTileItem.js
  6. 22
      react/src/components/dashboard/coinTile/coinTileItem.render.js
  7. 4
      react/src/components/dashboard/importKeyModal/importKeyModal.js
  8. 2
      react/src/components/dashboard/importKeyModal/importKeyModal.render.js
  9. 6
      react/src/components/dashboard/settings/settings.exportKeysPanel.js
  10. 28
      react/src/components/login/login.js
  11. 6
      react/src/components/login/login.render.js
  12. 1
      react/src/components/overrides.scss

2
react/src/actions/actions/addCoin.js

@ -243,7 +243,7 @@ export function shepherdHerd(coin, mode, path, startupParams) {
console.warn(acData);
dispatch(
triggerToaster(
`Error starting ${coin} daemon. Port ${acData.rpc} is already taken!`, // translate
translate('TOASTR.ERROR_STARTING_DAEMON', coin) + ' ' + translate('TOASTR.PORT_IS_TAKEN', acData.rpc),
translate('TOASTR.SERVICE_NOTIFICATION'),
'error',
false

57
react/src/actions/actions/coinList.js

@ -1,6 +1,54 @@
import { triggerToaster } from '../actionCreators';
import Config from '../../config';
export function shepherdElectrumLock() {
return new Promise((resolve, reject) => {
fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/electrum/lock`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: '',
})
.catch((error) => {
console.log(error);
dispatch(
triggerToaster(
'shepherdElectrumLock',
'Error',
'error'
)
);
})
.then(response => response.json())
.then(json => resolve(json))
});
}
export function shepherdElectrumLogout() {
return new Promise((resolve, reject) => {
fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/electrum/logout`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: '',
})
.catch((error) => {
console.log(error);
dispatch(
triggerToaster(
'shepherdElectrumLogout',
'Error',
'error'
)
);
})
.then(response => response.json())
.then(json => resolve(json))
});
}
export function shepherdStopCoind(coin) {
return new Promise((resolve, reject) => {
fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/coind/stop`, {
@ -25,14 +73,19 @@ export function shepherdStopCoind(coin) {
});
}
export function shepherdRemoveCoin(coin) {
export function shepherdRemoveCoin(coin, mode) {
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 }),
body: JSON.stringify(coin === 'KMD' && mode === 'native' ? {
mode,
} : {
mode,
chain: coin,
}),
})
.catch((error) => {
console.log(error);

2
react/src/components/addcoin/addcoin.js

@ -128,7 +128,7 @@ class AddCoin extends React.Component {
addCoinProps.display !== this.state.display) {
this.setState(Object.assign({}, this.state, {
display: addCoinProps.display,
modalClassName: addCoinProps.display ? 'show fade' : 'show fade',
modalClassName: 'show fade',
}));
setTimeout(() => {

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

@ -35,7 +35,9 @@ class ClaimInterestModal extends React.Component {
}
componentWillMount() {
this.loadListUnspent();
if (this.props.ActiveCoin.mode === 'native') {
this.loadListUnspent();
}
}
loadListUnspent() {

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

@ -30,7 +30,7 @@ import Config from '../../../config';
import CoinTileItemRender from './coinTileItem.render';
const SPV_DASHBOARD_UPDATE_TIMEOUT = 60000;
const SPV_DASHBOARD_UPDATE_TIMEOUT = 10000;
const ACTIVE_HANDLE_TIMEOUT_COIND_NATIVE = 15000;
const COIND_DOWN_MODAL_FETCH_FAILURES_THRESHOLD = window.require('electron').remote.getCurrentWindow().appConfig.failedRPCAttemptsThreshold || 10;
@ -43,6 +43,28 @@ class CoinTileItem extends React.Component {
this.autoSetActiveCoin = this.autoSetActiveCoin.bind(this);
}
renderStopCoinButton() {
if (this.props.Main &&
this.props.Main.coins &&
this.props.Main.coins.native &&
this.props.Main.coins.native.length) {
return true;
}
}
renderRemoveCoinButton() {
if (this.props.Main &&
this.props.Main.coins &&
((this.props.Main.coins.native &&
this.props.Main.coins.native.length &&
this.state.appConfig &&
!this.state.appConfig.stopNativeDaemonsOnQuit) ||
(this.props.Main.coins.spv &&
this.props.Main.coins.spv.length))) {
return true;
}
}
autoSetActiveCoin() {
const modes = [
'native',
@ -97,8 +119,8 @@ class CoinTileItem extends React.Component {
});
}
removeCoin(coin) {
shepherdRemoveCoin(coin)
removeCoin(coin, mode) {
shepherdRemoveCoin(coin, mode)
.then((res) => {
Store.dispatch(
triggerToaster(
@ -189,9 +211,7 @@ class CoinTileItem extends React.Component {
)
);
}
}
if (mode === 'spv') {
} else if (mode === 'spv') {
Store.dispatch(shepherdElectrumBalance(coin, this.props.Dashboard.electrumCoins[coin].pub));
Store.dispatch(shepherdElectrumTransactions(coin, this.props.Dashboard.electrumCoins[coin].pub));
}

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

@ -24,29 +24,17 @@ 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 &&
{ this.renderStopCoinButton() &&
<i
onClick={ () => this.stopCoind(item.coin) }
onClick={ () => this.stopCoind(item.coin, item.mode) }
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 &&
{ this.renderRemoveCoinButton() &&
<i
onClick={ () => this.removeCoin(item.coin) }
onClick={ () => this.removeCoin(item.coin, item.mode) }
title="Remove"
className="icon fa-plus-circle coind-remove-icon"></i>
className={ 'icon fa-plus-circle ' + (item.mode === 'spv' ? 'coind-remove-icon coind-remove-icon-spv' : 'coind-remove-icon') }></i>
}
{ this.props.Dashboard &&
this.props.Dashboard.electrumCoins &&

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

@ -77,11 +77,11 @@ class ImportKeyModal extends React.Component {
this.setState({
trimPassphraseTimer: _trimPassphraseTimer,
[e.target.name]: newValue,
[e.target.name === 'wifkeysPassphraseTextarea' ? 'wifkeysPassphrase' : e.target.name]: newValue,
});
} else {
this.setState({
[e.target.name]: e.target.value,
[e.target.name === 'wifkeysPassphraseTextarea' ? 'wifkeysPassphrase' : e.target.name]: e.target.value,
});
}
}

2
react/src/components/dashboard/importKeyModal/importKeyModal.render.js

@ -43,7 +43,7 @@ export const ImportKeyModalRender = function() {
autoComplete="off"
className={ this.state.seedInputVisibility ? 'form-control' : 'hide' }
id="wifkeysPassphraseTextarea"
name="wifkeysPassphrase"
name="wifkeysPassphraseTextarea"
ref="wifkeysPassphraseTextarea"
onChange={ this.updateInput }
value={ this.state.wifkeysPassphrase }></textarea>

6
react/src/components/dashboard/settings/settings.exportKeysPanel.js

@ -125,11 +125,11 @@ class ExportKeysPanel extends React.Component {
this.setState({
trimPassphraseTimer: _trimPassphraseTimer,
[e.target.name]: newValue,
[e.target.name === 'wifkeysPassphraseTextarea' ? 'wifkeysPassphrase' : e.target.name]: newValue,
});
} else {
this.setState({
[e.target.name]: e.target.value,
[e.target.name === 'wifkeysPassphraseTextarea' ? 'wifkeysPassphrase' : e.target.name]: e.target.value,
});
}
}
@ -189,7 +189,7 @@ class ExportKeysPanel extends React.Component {
autoComplete="off"
id="wifkeysPassphraseTextarea"
ref="wifkeysPassphraseTextarea"
name="wifkeysPassphrase"
name="wifkeysPassphraseTextarea"
onChange={ this.updateInput }
value={ this.state.wifkeysPassphrase }></textarea>
<i

28
react/src/components/login/login.js

@ -10,6 +10,7 @@ import {
triggerToaster,
toggleLoginSettingsModal,
stopInterval,
dashboardChangeActiveCoin,
} from '../../actions/actionCreators';
import Config from '../../config';
import Store from '../../store';
@ -205,10 +206,12 @@ class Login extends React.Component {
if (props.Main.total === 0) {
this.setState({
activeLoginSection: 'activateCoin',
loginPassphrase: '',
display: true,
});
} else {
this.setState({
loginPassphrase: '',
display: false,
});
}
@ -222,6 +225,7 @@ class Login extends React.Component {
if (props.Interval &&
props.Interval.interval &&
props.Interval.interval.sync) {
Store.dispatch(dashboardChangeActiveCoin());
Store.dispatch(
stopInterval(
'sync',
@ -243,6 +247,7 @@ class Login extends React.Component {
if (props.Interval &&
props.Interval.interval &&
props.Interval.interval.sync) {
Store.dispatch(dashboardChangeActiveCoin());
Store.dispatch(
stopInterval(
'sync',
@ -257,6 +262,7 @@ class Login extends React.Component {
props.Main &&
props.Main.isLoggedIn) {
this.setState({
loginPassphrase: '',
activeLoginSection: 'activateCoin',
});
}
@ -293,7 +299,7 @@ class Login extends React.Component {
this.setState({
trimPassphraseTimer: _trimPassphraseTimer,
[e.target.name]: newValue,
[e.target.name === 'loginPassphraseTextarea' ? 'loginPassphrase' : e.target.name]: newValue,
loginPassPhraseSeedType: this.getLoginPassPhraseSeedType(newValue),
});
}
@ -315,6 +321,16 @@ class Login extends React.Component {
}
loginSeed() {
// reset the login pass phrase values so that when the user logs out, the values are clear
this.setState({
loginPassphrase: '',
loginPassPhraseSeedType: null,
});
// reset login input vals
this.refs.loginPassphrase.value = '';
this.refs.loginPassphraseTextarea.value = '';
if (this.state.shouldEncryptSeed) {
Store.dispatch(encryptPassphrase(this.state.loginPassphrase, this.state.encryptKey, this.state.pubKey));
}
@ -329,16 +345,6 @@ class Login extends React.Component {
shepherdElectrumCoins()
);
}
// reset the login pass phrase values so that when the user logs out, the values are clear
this.setState({
loginPassphrase: '',
loginPassPhraseSeedType: null,
});
// reset login input vals
this.refs.loginPassphrase.value = '';
this.refs.loginPassphraseEdit.value = '';
}
loadPinList() {

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

@ -55,7 +55,7 @@ const LoginRender = function () {
type="password"
className={ !this.state.seedInputVisibility ? 'form-control' : 'hide' }
name="loginPassphrase"
ref="loginPassphraseEdit"
ref="loginPassphrase"
onChange={ this.updateLoginPassPhraseInput }
onKeyDown={ (event) => this.handleKeydown(event) }
autoComplete="off"
@ -63,8 +63,8 @@ const LoginRender = function () {
<textarea
className={ this.state.seedInputVisibility ? 'form-control' : 'hide' }
id="loginPassphrase"
ref="loginPassphrase"
name="loginPassphrase"
ref="loginPassphraseTextarea"
name="loginPassphraseTextarea"
autoComplete="off"
onChange={ this.updateLoginPassPhraseInput }
onKeyDown={ (event) => this.handleKeydown(event) }

1
react/src/components/overrides.scss

@ -375,6 +375,7 @@ select{
.header-easydex-section {
img {
width: 60px;
max-height: 60px;
}
}
}

Loading…
Cancel
Save