diff --git a/react/src/actions/actions/coinList.js b/react/src/actions/actions/coinList.js index 7a69e19..034ba0c 100644 --- a/react/src/actions/actions/coinList.js +++ b/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)) + }); } \ No newline at end of file diff --git a/react/src/actions/actions/nativeDashboardUpdate.js b/react/src/actions/actions/nativeDashboardUpdate.js index fae99b5..5463ef3 100644 --- a/react/src/actions/actions/nativeDashboardUpdate.js +++ b/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, diff --git a/react/src/components/dashboard/claimInterestModal/claimInterestModal.js b/react/src/components/dashboard/claimInterestModal/claimInterestModal.js index 8fe21d3..0023587 100755 --- a/react/src/components/dashboard/claimInterestModal/claimInterestModal.js +++ b/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 { diff --git a/react/src/components/dashboard/coinTile/coinTileItem.js b/react/src/components/dashboard/coinTile/coinTileItem.js index 8dc431e..c4adf7a 100644 --- a/react/src/components/dashboard/coinTile/coinTileItem.js +++ b/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) => { diff --git a/react/src/components/dashboard/settings/settings.coindClearDataDirPanel.js b/react/src/components/dashboard/settings/settings.coindClearDataDirPanel.js new file mode 100644 index 0000000..3ce9de2 --- /dev/null +++ b/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( + + ); + for (let i = 0; i < _nativeCoins.length; i++) { + if (_nativeCoins[i] !== 'CHIPS') { + _items.push( + + ); + } + } + + return _items; + } + + render() { + return ( +
+
+
+

+ Warning: the following form will wipe out all native coin data!
Don't touch anything if you're not sure what you're doing. +

+
+
+ + + + Keep wallet.dat + + { !this.state.displayYesNo && + + } + { this.state.displayYesNo && +
Are you sure you want to clear {this.state.coin} data folder?
+ } + { this.state.displayYesNo && + + } + { this.state.displayYesNo && + + } +
+
+
+
+
+ ); + }; +} + +export default CoindClearDataDirPanel; \ No newline at end of file diff --git a/react/src/components/dashboard/settings/settings.render.js b/react/src/components/dashboard/settings/settings.render.js index 49fa7c5..3f6176f 100644 --- a/react/src/components/dashboard/settings/settings.render.js +++ b/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"> + + + { this.props.Main.coins && this.props.Main.coins.spv && Object.keys(this.props.Main.coins.spv).length && diff --git a/react/src/components/overrides.scss b/react/src/components/overrides.scss index 765fd79..4d72e01 100644 --- a/react/src/components/overrides.scss +++ b/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; } \ No newline at end of file