Browse Source

settings clear komodo/chain data folder

v0.25
pbca26 7 years ago
parent
commit
fda2392f83
  1. 23
      react/src/actions/actions/coinList.js
  2. 5
      react/src/actions/actions/nativeDashboardUpdate.js
  3. 2
      react/src/components/dashboard/claimInterestModal/claimInterestModal.js
  4. 2
      react/src/components/dashboard/coinTile/coinTileItem.js
  5. 166
      react/src/components/dashboard/settings/settings.coindClearDataDirPanel.js
  6. 6
      react/src/components/dashboard/settings/settings.render.js
  7. 18
      react/src/components/overrides.scss

23
react/src/actions/actions/coinList.js

@ -147,4 +147,27 @@ export function shepherdPostCoinList(data) {
.then(response => response.json())
.then(json => resolve(json))
});
}
export function shepherdClearCoindFolder(coin, keepWalletDat) {
return new Promise((resolve, reject) => {
fetch(keepWalletDat ? `http://127.0.0.1:${Config.agamaPort}/shepherd/kick?coin=${coin}&keepwallet=true` : `http://127.0.0.1:${Config.agamaPort}/shepherd/kick?coin=${coin}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.catch((error) => {
console.log(error);
dispatch(
triggerToaster(
'shepherdClearCoindFolder',
'Error',
'error'
)
);
})
.then(response => response.json())
.then(json => resolve(json))
});
}

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

@ -98,7 +98,10 @@ export function getDashboardUpdateState(json, coin, fakeResponse) {
}
json.result.z_gettotalbalance.result.transparent = _tbalance.toFixed(8);
json.result.z_gettotalbalance.result.total = json.result.z_gettotalbalance.result.transparent + Number(json.result.z_gettotalbalance.result.interest) + Number(json.result.z_gettotalbalance.result.private);
json.result.z_gettotalbalance.result.total = Number(json.result.z_gettotalbalance.result.transparent) + Number(json.result.z_gettotalbalance.result.interest) + Number(json.result.z_gettotalbalance.result.private);
json.result.z_gettotalbalance.result.total = json.result.z_gettotalbalance.result.total.toFixed(8);
json.result.z_gettotalbalance.result.total = 0;
json.result.z_gettotalbalance.result.interest = 0;
return {
type: DASHBOARD_UPDATE,

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

@ -8,7 +8,7 @@ import {
getRawTransaction,
copyString,
sendToAddressPromise,
triggerToaster
triggerToaster,
} from '../../../actions/actionCreators';
import { translate } from '../../../translate/translate';
import {

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

@ -95,9 +95,9 @@ class CoinTileItem extends React.Component {
];
const allCoins = this.props.Main.coins;
let _coinSelected = false;
let _coinMode = {};
let _mode;
let _coin;
let _coinMode = {};
if (allCoins) {
modes.map((mode) => {

166
react/src/components/dashboard/settings/settings.coindClearDataDirPanel.js

@ -0,0 +1,166 @@
import React from 'react';
import { translate } from '../../../translate/translate';
import {
shepherdClearCoindFolder,
triggerToaster
} from '../../../actions/actionCreators';
import { coindList } from '../../../util/coinHelper';
import Store from '../../../store';
class CoindClearDataDirPanel extends React.Component {
constructor() {
super();
this.state = {
coin: 'none',
keepWalletDat: true,
loading: false,
displayYesNo: false,
};
this.removeCoindData = this.removeCoindData.bind(this);
this.updateInput = this.updateInput.bind(this);
this.toggleKeepWalletDat = this.toggleKeepWalletDat.bind(this);
this.displayYesNo = this.displayYesNo.bind(this);
}
displayYesNo() {
this.setState({
displayYesNo: !this.state.displayYesNo,
});
}
removeCoindData() {
const _coin = this.state.coin;
this.setState({
loading: true,
displayYesNo: false,
});
setTimeout(() => {
shepherdClearCoindFolder(_coin, this.state.keepWalletDat ? this.state.keepWalletDat : null)
.then((res) => {
if (res.msg === 'success') {
this.setState({
keepWalletDat: true,
loading: false,
});
Store.dispatch(
triggerToaster(
`${_coin} data folder is cleared`,
translate('TOASTR.WALLET_NOTIFICATION'),
'success'
)
);
} else {
Store.dispatch(
triggerToaster(
`Unable to clear ${_coin}`,
translate('TOASTR.WALLET_NOTIFICATION'),
'error'
)
);
}
});
}, 100);
}
updateInput(e) {
this.setState({
[e.target.name]: e.target.value,
});
}
toggleKeepWalletDat() {
this.setState(Object.assign({}, this.state, {
keepWalletDat: !this.state.keepWalletDat,
}));
}
renderCoinListSelectorOptions() {
let _items = [];
let _nativeCoins = coindList();
_items.push(
<option
key={ `coind-clear-data-coins-none` }
value="none">Pick a coin</option>
);
for (let i = 0; i < _nativeCoins.length; i++) {
if (_nativeCoins[i] !== 'CHIPS') {
_items.push(
<option
key={ `coind-clear-data-coins-${ _nativeCoins[i] }` }
value={ `${_nativeCoins[i]}` }>{ `${_nativeCoins[i]}` }</option>
);
}
}
return _items;
}
render() {
return (
<div>
<div className="row">
<div className="col-sm-12 padding-bottom-10">
<h4 className="col-red">
<i className="fa fa-warning"></i> Warning: the following form will wipe out all native coin data!<br />Don't touch anything if you're not sure what you're doing.
</h4>
<div>
<div className="col-sm-4 no-padding-left text-center">
<select
className="form-control form-material margin-top-20 margin-bottom-10"
name="coin"
value={ this.state.coin }
onChange={ (event) => this.updateInput(event) }
autoFocus>
{ this.renderCoinListSelectorOptions() }
</select>
<span className="pointer toggle margin-top-20 block text-left">
<label className="switch">
<input
type="checkbox"
name="settings-app-debug-toggle"
value={ this.state.keepWalletDat }
checked={ this.state.keepWalletDat } />
<div
className="slider"
onClick={ this.toggleKeepWalletDat }></div>
</label>
<span
className="title"
onClick={ this.toggleKeepWalletDat }>Keep wallet.dat</span>
</span>
{ !this.state.displayYesNo &&
<button
type="button"
className="btn btn-primary waves-effect waves-light margin-top-20"
disabled={ this.state.loading || this.state.coin === 'none' }
onClick={ this.displayYesNo }>{ this.state.loading ? `Deleting ${this.state.coin} data...` : 'Delete' }</button>
}
{ this.state.displayYesNo &&
<div className="margin-top-20">Are you sure you want to clear {this.state.coin} data folder?</div>
}
{ this.state.displayYesNo &&
<button
type="button"
className="btn btn-primary waves-effect waves-light margin-top-20 margin-right-20"
onClick={ this.removeCoindData }>Yes</button>
}
{ this.state.displayYesNo &&
<button
type="button"
className="btn btn-primary waves-effect waves-light margin-top-20"
onClick={ this.displayYesNo }>No</button>
}
</div>
</div>
</div>
</div>
</div>
);
};
}
export default CoindClearDataDirPanel;

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

@ -16,6 +16,7 @@ import SupportPanel from './settings.supportPanel';
import SPVServersPanel from './settings.spvServersPanel';
import DaemonStdoutPanel from './settings.daemonStdoutPanel';
import NativeWalletDatKeysPanel from './settings.nativeWalletDatKeysPanel';
import CoindClearDataDirPanel from './settings.coindClearDataDirPanel';
// import WalletInfoPanel from './settings.walletInfoPanel';
// import WalletBackupPanel from './settings.walletBackupPanel';
@ -110,6 +111,11 @@ export const SettingsRender = function() {
icon="icon md-key">
<NativeWalletDatKeysPanel />
</PanelSection>
<PanelSection
title={ 'Clear native coin data dir' }
icon="icon fa-trash">
<CoindClearDataDirPanel />
</PanelSection>
{ this.props.Main.coins &&
this.props.Main.coins.spv &&
Object.keys(this.props.Main.coins.spv).length &&

18
react/src/components/overrides.scss

@ -598,4 +598,22 @@ select{
}
.push-left {
float: left;
}
.col-lg-12 {
&.col-xs-12 {
&.balance-placeholder--bold {
.icon {
&.fa-eye {
position: relative;
top: -2px;
padding-right: 5px;
}
}
}
}
}
.col-red {
color: #f96868;
}
Loading…
Cancel
Save