-
- { this.state.error }
+export const QRModalReaderRender = function() {
+ if (!this.state.errorShown) {
+ return (
+
+
+
+
+
+
+
+
{ translate('INDEX.SCAN_QRCODE_WEBCAM') }
+
+
+
+
+
+ { this.state.error }
+
-
-
-
- );
+
+
+ );
+ } else {
+ return null;
+ }
};
\ No newline at end of file
diff --git a/react/src/components/dashboard/qrModal/qrModal.scss b/react/src/components/dashboard/qrModal/qrModal.scss
new file mode 100644
index 0000000..7eef696
--- /dev/null
+++ b/react/src/components/dashboard/qrModal/qrModal.scss
@@ -0,0 +1,11 @@
+.qr-modal-send-block {
+ position: absolute;
+ top: 15px;
+ right: 30px;
+}
+
+.webcam-frame {
+ width: 100%;
+ text-align: center;
+ font-size: 16px;
+}
\ No newline at end of file
diff --git a/react/src/components/dashboard/receiveCoin/receiveCoin.js b/react/src/components/dashboard/receiveCoin/receiveCoin.js
index c9f0097..668a9d3 100644
--- a/react/src/components/dashboard/receiveCoin/receiveCoin.js
+++ b/react/src/components/dashboard/receiveCoin/receiveCoin.js
@@ -217,8 +217,9 @@ class ReceiveCoin extends React.Component {
return null;
}
}
-const mapStateToProps = (state) => {
- return {
+
+const mapStateToProps = (state, props) => {
+ let _mappedProps = {
coin: state.ActiveCoin.coin,
mode: state.ActiveCoin.mode,
receive: state.ActiveCoin.receive,
@@ -226,9 +227,17 @@ const mapStateToProps = (state) => {
cache: state.ActiveCoin.cache,
activeSection: state.ActiveCoin.activeSection,
activeAddress: state.ActiveCoin.activeAddress,
- addresses: state.ActiveCoin.addresses
+ addresses: state.ActiveCoin.addresses,
};
-
+
+ if (props &&
+ props.activeSection &&
+ props.renderTableOnly) {
+ _mappedProps.activeSection = props.activeSection;
+ _mappedProps.renderTableOnly = props.renderTableOnly;
+ }
+
+ return _mappedProps;
};
export default connect(mapStateToProps)(ReceiveCoin);
\ No newline at end of file
diff --git a/react/src/components/dashboard/sendCoin/sendCoin.js b/react/src/components/dashboard/sendCoin/sendCoin.js
index 8d14e94..4d3ce8b 100644
--- a/react/src/components/dashboard/sendCoin/sendCoin.js
+++ b/react/src/components/dashboard/sendCoin/sendCoin.js
@@ -10,7 +10,6 @@ import {
import {
resolveOpenAliasAddress,
triggerToaster,
- basiliskRefresh,
shepherdGroomPostPromise,
edexGetTransaction,
getCacheFile,
@@ -128,13 +127,6 @@ class SendCoin extends React.Component {
currentStackLength: data.message.shepherd.iguanaAPI.currentStackLength,
}));
}
- if (data &&
- data.message &&
- data.message.shepherd.method &&
- data.message.shepherd.method === 'cache-one' &&
- data.message.shepherd.status === 'done') {
- Store.dispatch(basiliskRefresh(false));
- }
}
_fetchNewUTXOData() {
@@ -765,7 +757,7 @@ class SendCoin extends React.Component {
}
// TODO same as in walletsNav and receiveCoin, find a way to reuse it?
- checkTotalBalance() {
+ checkBalance() {
let _balance = '0';
const _mode = this.props.ActiveCoin.mode;
@@ -785,21 +777,16 @@ class SendCoin extends React.Component {
(_cache[_coin][_address].getbalance.data.balance ||
_cache[_coin][_address].getbalance.data.interest)) {
const _regBalance = _cache[_coin][_address].getbalance.data.balance ? _cache[_coin][_address].getbalance.data.balance : 0;
- const _regInterest = _cache[_coin][_address].getbalance.data.interest ? _cache[_coin][_address].getbalance.data.interest : 0;
- _balance = _regBalance + _regInterest;
+ _balance = _regBalance;
}
}
- } else if (_mode === 'native') {
- if (this.props.ActiveCoin.balance &&
- this.props.ActiveCoin.balance.total) {
- _balance = this.props.ActiveCoin.balance.total;
- }
}
- return +_balance;
+ return _balance;
}
+ // TODO: reduce to a single toast
validateSendFormData() {
let valid = true;
if (!this.state.sendTo || this.state.sendTo.length < 34) {
@@ -846,7 +833,8 @@ class SendCoin extends React.Component {
valid = false;
}
- if (this.state.amount > this.checkTotalBalance()) {
+ /*if ((this.props.ActiveCoin.mode === 'basilisk' && Number(this.state.amount) > Number(this.state.sendFromAmount)) ||
+ (this.props.ActiveCoin.mode === 'full' && Number(this.state.amount) > Number(this.checkBalance()))) {
Store.dispatch(
triggerToaster(
translate('SEND.INSUFFICIENT_FUNDS'),
@@ -855,7 +843,7 @@ class SendCoin extends React.Component {
)
);
valid = false;
- }
+ }*/
return valid;
}
@@ -890,10 +878,8 @@ const mapStateToProps = (state) => {
},
Dashboard: {
activeHandle: state.Dashboard.activeHandle,
- }
-
+ },
};
-
};
export default connect(mapStateToProps)(SendCoin);
\ No newline at end of file
diff --git a/react/src/components/dashboard/settings/settings.addNodePanel.js b/react/src/components/dashboard/settings/settings.addNodePanel.js
new file mode 100644
index 0000000..67ac130
--- /dev/null
+++ b/react/src/components/dashboard/settings/settings.addNodePanel.js
@@ -0,0 +1,180 @@
+import React from 'react';
+import { translate } from '../../../translate/translate';
+import { connect } from 'react-redux';
+
+import {
+ addPeerNode,
+ getPeersList,
+ getPeersListState,
+} from '../../../actions/actionCreators';
+import Store from '../../../store';
+
+import AddCoinOptionsCrypto from '../../addcoin/addcoinOptionsCrypto';
+import AddCoinOptionsAC from '../../addcoin/addcoinOptionsAC';
+import AddCoinOptionsACFiat from '../../addcoin/addcoinOptionsACFiat';
+
+class AddNodePanel extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ addNodeCoin: null,
+ addPeerIP: null,
+ getPeersCoin: null,
+ trimPassphraseTimer: null,
+ wifkeysPassphrase:'',
+ };
+ this.renderSNPeersList = this.renderSNPeersList.bind(this);
+ this.renderPeersList = this.renderPeersList.bind(this);
+ this.checkNodes = this.checkNodes.bind(this);
+ this.addNode = this.addNode.bind(this);
+ this.updateInput = this.updateInput.bind(this);
+ }
+
+ renderSNPeersList() {
+ if (this.state.getPeersCoin) {
+ const _getPeersCoin = this.state.getPeersCoin;
+ const _supernetPeers = this.props.Settings.supernetPeers;
+ const coin = _getPeersCoin.split('|')[0];
+
+ if (_supernetPeers &&
+ _getPeersCoin &&
+ _supernetPeers[coin]) {
+ return _supernetPeers[coin].map((ip) =>
+
{ ip }
+ );
+ } else {
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ renderPeersList() {
+ if (this.state.getPeersCoin) {
+ const _getPeersCoin = this.state.getPeersCoin;
+ const _rawPeers = this.props.Settings.rawPeers;
+ const coin = _getPeersCoin.split('|')[0];
+
+ if (_rawPeers &&
+ _getPeersCoin &&
+ _rawPeers[coin]) {
+ return _rawPeers[coin].map((ip) =>
+
{ ip }
+ );
+ } else {
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ checkNodes() {
+ if (this.state.getPeersCoin) {
+ console.warn(this.state.getPeersCoin.split('|')[0]);
+ Store.dispatch(getPeersList(this.state.getPeersCoin.split('|')[0]));
+ }
+ }
+
+ addNode() {
+ if (this.state.addNodeCoin && this.state.addPeerIP) {
+ Store.dispatch(
+ addPeerNode(
+ this.state.addNodeCoin.split('|')[0],
+ this.state.addPeerIP
+ )
+ );
+ }
+ }
+
+ updateInput(e) {
+ this.setState({
+ [e.target.name]: e.target.value,
+ });
+ }
+
+ render() {
+ return (
+
+
+
+
+
{ translate('INDEX.USE_THIS_SECTION') }
+
+
+
+
+
+
+
+
+
+
+
+ SuperNET Peers:
+
+
{ this.renderSNPeersList() }
+
+ Raw Peers:
+
+
{ this.renderPeersList() }
+
+
+
+
+
+
{ translate('INDEX.USE_THIS_SECTION_PEER') }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+ };
+}
+
+const mapStateToProps = (state) => {
+ return {
+ Settings: state.Settings,
+ };
+};
+
+export default connect(mapStateToProps)(AddNodePanel);
\ No newline at end of file
diff --git a/react/src/components/dashboard/settings/settings.appInfoPanel.js b/react/src/components/dashboard/settings/settings.appInfoPanel.js
new file mode 100644
index 0000000..030caf4
--- /dev/null
+++ b/react/src/components/dashboard/settings/settings.appInfoPanel.js
@@ -0,0 +1,90 @@
+import React from 'react';
+import { translate } from '../../../translate/translate';
+import { connect } from 'react-redux';
+
+class AppInfoPanel extends React.Component {
+ constructor() {
+ super();
+ }
+
+ render() {
+ return (
+
+
+
+
{ translate('SETTINGS.APP_RELEASE') }
+
+ { translate('SETTINGS.NAME') }: { this.props.Settings.appInfo.releaseInfo.name }
+
+
+ { translate('SETTINGS.VERSION') }: { `${this.props.Settings.appInfo.releaseInfo.version.replace('version=', '')}-beta` }
+
+
+ { translate('SETTINGS.APP_SESSION') }: { this.props.Settings.appInfo.appSession }
+
+
+
+
+
+
{ translate('SETTINGS.SYS_INFO') }
+
+ { translate('SETTINGS.ARCH') }: { this.props.Settings.appInfo.sysInfo.arch }
+
+
+ { translate('SETTINGS.OS_TYPE') }: { this.props.Settings.appInfo.sysInfo.os_type }
+
+
+ { translate('SETTINGS.OS_PLATFORM') }: { this.props.Settings.appInfo.sysInfo.platform }
+
+
+ { translate('SETTINGS.OS_RELEASE') }: { this.props.Settings.appInfo.sysInfo.os_release }
+
+
+ { translate('SETTINGS.CPU') }: { this.props.Settings.appInfo.sysInfo.cpu }
+
+
+ { translate('SETTINGS.CPU_CORES') }: { this.props.Settings.appInfo.sysInfo.cpu_cores }
+
+
+ { translate('SETTINGS.MEM') }: { this.props.Settings.appInfo.sysInfo.totalmem_readable }
+
+
+
+
+
+
{ translate('SETTINGS.LOCATIONS') }
+
+ { translate('SETTINGS.CACHE') }: { this.props.Settings.appInfo.dirs.cacheLocation }
+
+
+ { translate('SETTINGS.CONFIG') }: { this.props.Settings.appInfo.dirs.configLocation }
+
+
+ Iguana { translate('SETTINGS.BIN') }: { this.props.Settings.appInfo.dirs.iguanaBin }
+
+
+ Iguana { translate('SETTINGS.DIR') }: { this.props.Settings.appInfo.dirs.iguanaDir }
+
+
+ Komodo { translate('SETTINGS.BIN') }: { this.props.Settings.appInfo.dirs.komododBin }
+
+
+ Komodo { translate('SETTINGS.DIR') }: { this.props.Settings.appInfo.dirs.komodoDir }
+
+
+ Komodo wallet.dat: { this.props.Settings.appInfo.dirs.komodoDir }
+
+
+
+
+ );
+ };
+}
+
+const mapStateToProps = (state) => {
+ return {
+ Settings: state.Settings,
+ };
+};
+
+export default connect(mapStateToProps)(AppInfoPanel);
\ No newline at end of file
diff --git a/react/src/components/dashboard/settings/settings.appSettingsPanel.js b/react/src/components/dashboard/settings/settings.appSettingsPanel.js
new file mode 100644
index 0000000..77b982f
--- /dev/null
+++ b/react/src/components/dashboard/settings/settings.appSettingsPanel.js
@@ -0,0 +1,321 @@
+import React from 'react';
+import { connect } from 'react-redux';
+import { translate } from '../../../translate/translate';
+import Config from '../../../config';
+import {
+ iguanaActiveHandle,
+ getAppConfig,
+ getAppInfo,
+ resetAppConfig,
+ saveAppConfig,
+ skipFullDashboardUpdate,
+ triggerToaster,
+} from '../../../actions/actionCreators';
+import Store from '../../../store';
+
+class AppSettingsPanel extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ appSettings: {},
+ appConfigSchema: {},
+ };
+ this._saveAppConfig = this._saveAppConfig.bind(this);
+ this._resetAppConfig = this._resetAppConfig.bind(this);
+ this._skipFullDashboardUpdate = this._skipFullDashboardUpdate.bind(this);
+ this.updateInput = this.updateInput.bind(this);
+ }
+
+ componentWillMount() {
+ try {
+ const _appConfigSchema = window.require('electron').remote.getCurrentWindow().appConfigSchema;
+ const _appSettings = this.props.Settings.appSettings ? this.props.Settings.appSettings : Object.assign({}, window.require('electron').remote.getCurrentWindow().appConfig);
+
+ this.setState(Object.assign({}, this.state, {
+ appConfigSchema: _appConfigSchema,
+ appSettings: _appSettings,
+ }));
+ } catch(e) {}
+ }
+
+ componentDidMount(props) {
+ if (!this.props.disableWalletSpecificUI) {
+ Store.dispatch(iguanaActiveHandle());
+ }
+
+ Store.dispatch(getAppConfig());
+ Store.dispatch(getAppInfo());
+ }
+
+ _skipFullDashboardUpdate() {
+ Store.dispatch(skipFullDashboardUpdate(!this.props.Dashboard.skipFullDashboardUpdate));
+ }
+
+ _resetAppConfig() {
+ Store.dispatch(resetAppConfig());
+ }
+
+ _saveAppConfig() {
+ const _appSettings = this.state.appSettings;
+ let _appSettingsPristine = Object.assign({}, this.props.Settings.appSettings);
+ let isError = false;
+ let saveAfterPathCheck = false;
+
+ for (let key in _appSettings) {
+ if (key.indexOf('__') === -1) {
+ _appSettingsPristine[key] = this.state.appConfigSchema[key] && this.state.appConfigSchema[key].type === 'number' ? Number(_appSettings[key]) : _appSettings[key];
+
+ if (this.state.appConfigSchema[key] && this.state.appConfigSchema[key].type === 'folder' &&
+ _appSettings[key] &&
+ _appSettings[key].length) {
+ const _testLocation = window.require('electron').remote.getCurrentWindow().testLocation;
+ saveAfterPathCheck = true;
+
+ _testLocation(_appSettings[key])
+ .then((res) => {
+ if (res === -1) {
+ isError = true;
+ Store.dispatch(
+ triggerToaster(
+ translate('TOASTR.KOMODO_DATADIR_INVALID'),
+ translate('INDEX.SETTINGS'),
+ 'error'
+ )
+ );
+ } else if (res === false) {
+ isError = true;
+ Store.dispatch(
+ triggerToaster(
+ translate('TOASTR.KOMODO_DATADIR_NOT_DIR'),
+ translate('INDEX.SETTINGS'),
+ 'error'
+ )
+ );
+ } else {
+ Store.dispatch(saveAppConfig(_appSettingsPristine));
+ }
+ });
+ }
+ } else {
+ const _nestedKey = key.split('__');
+ _appSettingsPristine[_nestedKey[0]][_nestedKey[1]] = this.state.appConfigSchema[_nestedKey[0]][_nestedKey[1]].type === 'number' ? Number(_appSettings[key]) : _appSettings[key];
+ }
+ }
+
+ if (!saveAfterPathCheck) {
+ Store.dispatch(saveAppConfig(_appSettingsPristine));
+ }
+ }
+
+ renderConfigEditForm() {
+ let items = [];
+ const _appConfig = this.state.appSettings;
+ for (let key in _appConfig) {
+ if (this.state.appConfigSchema[key] && typeof _appConfig[key] === 'object') {
+ if (this.state.appConfigSchema[key].display) {
+ items.push(
+
+
+ { this.state.appConfigSchema[key].displayName ? this.state.appConfigSchema[key].displayName : key }
+ { this.state.appConfigSchema[key].info &&
+
+ }
+ |
+ |
+
+ );
+
+ for (let _key in _appConfig[key]) {
+ items.push(
+
+
+ { this.state.appConfigSchema[key][_key].displayName ? this.state.appConfigSchema[key][_key].displayName : _key }
+ { this.state.appConfigSchema[key][_key].info &&
+
+ }
+ |
+
+ { this.state.appConfigSchema[key][_key].type === 'number' &&
+ this.updateInputSettings(event, key, _key) } />
+ }
+ { (this.state.appConfigSchema[key][_key].type === 'string' || this.state.appConfigSchema[key][_key].type === 'folder') &&
+ this.updateInputSettings(event, key, _key) } />
+ }
+ { this.state.appConfigSchema[key][_key].type === 'boolean' &&
+
+
+
+ }
+ |
+
+ );
+ }
+ }
+ } else {
+ if (this.state.appConfigSchema[key] && this.state.appConfigSchema[key].display) {
+ items.push(
+
+
+ { this.state.appConfigSchema[key].displayName ? this.state.appConfigSchema[key].displayName : key }
+ { this.state.appConfigSchema[key].info &&
+
+ }
+ |
+
+ { this.state.appConfigSchema[key].type === 'number' &&
+ this.updateInputSettings(event, key) } />
+ }
+ { (this.state.appConfigSchema[key].type === 'string' || this.state.appConfigSchema[key].type === 'folder') &&
+ this.updateInputSettings(event, key) } />
+ }
+ { this.state.appConfigSchema[key].type === 'boolean' &&
+
+
+
+ }
+ |
+
+ );
+ }
+ }
+ }
+
+ items.push(
+
+
+ KMD main sync only
+
+ |
+
+
+
+
+ |
+
+ );
+
+ return items;
+ }
+
+ updateInput(e) {
+ this.setState({
+ [e.target.name]: e.target.value,
+ });
+ }
+
+ updateInputSettings(e, parentKey, childKey) {
+ let _appSettings = this.state.appSettings;
+ let _appSettingsPrev = Object.assign({}, _appSettings);
+
+ if (!childKey && this.state.appConfigSchema[parentKey].type === 'boolean') {
+ _appSettings[parentKey] = typeof _appSettings[parentKey] !== undefined ? !_appSettings[parentKey] : !this.state.appSettings[parentKey];
+ } else if (childKey && this.state.appConfigSchema[parentKey][childKey].type === 'boolean') {
+ _appSettings[parentKey][childKey] = typeof _appSettings[parentKey][childKey] !== undefined ? !_appSettings[parentKey][childKey] : !this.state.appSettings[parentKey][childKey];
+ } else if ((!childKey && this.state.appConfigSchema[parentKey].type === 'number') || (childKey && this.state.appConfigSchema[parentKey][childKey].type === 'number')) {
+ if (e.target.value === '') {
+ _appSettings[e.target.name] = _appSettingsPrev[e.target.name];
+ } else {
+ _appSettings[e.target.name] = e.target.value.replace(/[^0-9]+/g, '');
+ }
+ } else {
+ _appSettings[e.target.name] = e.target.value;
+ }
+
+ this.setState({
+ appSettings: _appSettings,
+ });
+ }
+
+ render() {
+ return (
+
+
+ { translate('SETTINGS.CONFIG_RESTART_REQUIRED') }
+
+
+
+
+ { this.renderConfigEditForm() }
+
+
+
+
+
+
+
+
+ );
+ };
+}
+
+const mapStateToProps = (state) => {
+ return {
+ Settings: state.Settings,
+ Dashboard: {
+ skipFullDashboardUpdate: state.Dashboard.skipFullDashboardUpdate,
+ },
+ };
+};
+
+export default connect(mapStateToProps)(AppSettingsPanel);
diff --git a/react/src/components/dashboard/settings/settings.appUpdatePanel.js b/react/src/components/dashboard/settings/settings.appUpdatePanel.js
new file mode 100644
index 0000000..b7230b0
--- /dev/null
+++ b/react/src/components/dashboard/settings/settings.appUpdatePanel.js
@@ -0,0 +1,151 @@
+import React from 'react';
+import { translate } from '../../../translate/translate';
+import { connect } from 'react-redux';
+import Config from '../../../config';
+import {
+ getPeersList,
+ checkForUpdateUIPromise,
+ updateUIPromise,
+} from '../../../actions/actionCreators';
+
+import { SocketProvider } from 'socket.io-react';
+import io from 'socket.io-client';
+
+const socket = io.connect(`http://127.0.0.1:${Config.agamaPort}`);
+
+let updateProgressBar = {
+ patch: -1,
+};
+
+class AppUpdatePanel extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ updatePatch: null,
+ updateLog: [],
+ updateProgressPatch: null,
+ updatePatch: null,
+ updateBins: null,
+ };
+ this._checkForUpdateUIPromise = this._checkForUpdateUIPromise.bind(this);
+ this._updateUIPromise = this._updateUIPromise.bind(this);
+ this.checkNodes = this.checkNodes.bind(this);
+ }
+
+ componentWillMount() {
+ socket.on('patch', msg => this.updateSocketsData = (msg) => {});
+ }
+
+ componentWillUnmount() {
+ socket.removeAllListeners('patch', msg => this.updateSocketsData(msg));
+ }
+
+ checkNodes() {
+ if (this.state.getPeersCoin) {
+ Store.dispatch(getPeersList(this.state.getPeersCoin.split('|')[0]));
+ }
+ }
+
+ _updateUIPromise() {
+ updateProgressBar.patch = 0;
+ let _updateLog = [];
+ _updateLog.push(`${translate('INDEX.DOWNLOADING_UI_UPDATE')}...`);
+ this.setState(Object.assign({}, this.state, {
+ updateLog: _updateLog,
+ }));
+
+ updateUIPromise();
+ }
+
+ _checkForUpdateUIPromise() {
+ let _updateLog = [];
+ _updateLog.push(translate('INDEX.CHECKING_UI_UPDATE'));
+ this.setState(Object.assign({}, this.state, {
+ updateLog: _updateLog,
+ }));
+
+ checkForUpdateUIPromise()
+ .then((res) => {
+ let _updateLog = this.state.updateLog;
+ _updateLog.push(res.result === 'update' ? (`${translate('INDEX.NEW_UI_UPDATE')} ${res.version.remote}`) : translate('INDEX.YOU_HAVE_LATEST_UI'));
+ this.setState(Object.assign({}, this.state, {
+ updatePatch: res.result === 'update' ? true : false,
+ updateLog: _updateLog,
+ }));
+ });
+ }
+
+ renderUpdateStatus() {
+ let items = [];
+ let patchProgressBar = null;
+ const _updateLogLength = this.state.updateLog.length;
+
+ for (let i = 0; i < _updateLogLength; i++) {
+ items.push(
+
{ this.state.updateLog[i] }
+ );
+ }
+
+ if (_updateLogLength) {
+ return (
+
+
+
{ translate('SETTINGS.PROGRESS') }:
+
{ items }
+
-1 ? 'progress progress-sm' : 'hide' }>
+
+
+
+
+ );
+ } else {
+ return null;
+ }
+ }
+
+ render() {
+ return (
+
+
+
{ translate('INDEX.UI_UPDATE') }
+
+
+
+
+
+
+
{ translate('INDEX.BINS_UPDATE') }
+
+
+
+
+
+
+ { this.renderUpdateStatus() }
+
+
+ );
+ };
+}
+const mapStateToProps = (state) => {
+ return {
+ Settings: state.Settings,
+ };
+};
+
+export default connect(mapStateToProps)(AppUpdatePanel);
diff --git a/react/src/components/dashboard/settings/settings.cliPanel.js b/react/src/components/dashboard/settings/settings.cliPanel.js
new file mode 100644
index 0000000..312dcb2
--- /dev/null
+++ b/react/src/components/dashboard/settings/settings.cliPanel.js
@@ -0,0 +1,206 @@
+import React from 'react';
+import { connect } from 'react-redux';
+import { translate } from '../../../translate/translate';
+import {
+ shepherdCli,
+} from '../../../actions/actionCreators';
+import Store from '../../../store';
+
+class CliPanel extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ cliCmdString: '',
+ cliCoin: null,
+ cliResponse: null,
+ };
+ }
+
+ renderActiveCoinsList(mode) {
+ const modes = [
+ 'native',
+ 'basilisk',
+ 'full'
+ ];
+
+ const allCoins = this.props.Main.coins;
+ let items = [];
+
+ if (allCoins) {
+ if (mode === 'all') {
+ modes.map(function(mode) {
+ allCoins[mode].map(function(coin) {
+ items.push(
+
+ );
+ });
+ });
+ } else {
+ allCoins[mode].map(function(coin) {
+ items.push(
+
+ );
+ });
+ }
+
+ return items;
+ } else {
+ return null;
+ }
+ }
+
+ // TODO: rerender only if prop is changed
+ renderCliResponse() {
+ const _cliResponse = this.props.Settings.cli;
+ let _items = [];
+
+ if (_cliResponse) {
+ let _cliResponseParsed;
+ let responseType;
+
+ try {
+ _cliResponseParsed = JSON.parse(_cliResponse.result);
+ } catch(e) {
+ _cliResponseParsed = _cliResponse.result;
+ }
+
+ if (Object.prototype.toString.call(_cliResponseParsed) === '[object Array]') {
+ responseType = 'array';
+
+ for (let i = 0; i < _cliResponseParsed.length; i++) {
+ _items.push(
+
{ JSON.stringify(_cliResponseParsed[i], null, '\t') }
+ );
+ }
+ }
+ if (Object.prototype.toString.call(_cliResponseParsed) === '[object]' ||
+ typeof _cliResponseParsed === 'object') {
+ responseType = 'object';
+
+ _items.push(
+
{ JSON.stringify(_cliResponseParsed, null, '\t') }
+ );
+ }
+ if (Object.prototype.toString.call(_cliResponseParsed) === 'number' ||
+ typeof _cliResponseParsed === 'boolean' ||
+ _cliResponseParsed === 'wrong cli string format') {
+ responseType = 'number';
+
+ _items.push(
+
{ _cliResponseParsed.toString() }
+ );
+ }
+
+ if (responseType !== 'number' &&
+ responseType !== 'array' &&
+ responseType !== 'object' &&
+ _cliResponseParsed.indexOf('\n') > -1) {
+ _cliResponseParsed = _cliResponseParsed.split('\n');
+
+ for (let i = 0; i < _cliResponseParsed.length; i++) {
+ _items.push(
+
{ _cliResponseParsed[i] }
+ );
+ }
+ }
+
+ return (
+
+
+ { translate('SETTINGS.CLI_RESPONSE') }:
+
+ { _items }
+
+ );
+ } else {
+ return null;
+ }
+ }
+
+ execCliCmd() {
+ Store.dispatch(
+ shepherdCli(
+ 'passthru',
+ this.state.cliCoin,
+ this.state.cliCmdString
+ )
+ );
+ }
+
+ updateInput = (e) => {
+ this.setState({
+ [e.target.name]: e.target.value,
+ });
+ }
+
+ render() {
+ return (
+
+
{ translate('INDEX.CLI_SELECT_A_COIN') }
+
+
+
+ );
+ };
+}
+
+const mapStateToProps = (state) => {
+ return {
+ Main: {
+ coins: state.Main.coins,
+ },
+ Settings: state.Settings,
+ };
+};
+
+export default connect(mapStateToProps)(CliPanel);
diff --git a/react/src/components/dashboard/settings/settings.debugLogPanel.js b/react/src/components/dashboard/settings/settings.debugLogPanel.js
new file mode 100644
index 0000000..e0b89c5
--- /dev/null
+++ b/react/src/components/dashboard/settings/settings.debugLogPanel.js
@@ -0,0 +1,180 @@
+import React from 'react';
+import { connect } from 'react-redux';
+import { translate } from '../../../translate/translate';
+import Config from '../../../config';
+import { secondsToString } from '../../../util/time';
+import {
+ getDebugLog,
+} from '../../../actions/actionCreators';
+import Store from '../../../store';
+
+class DebugLogPanel extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ appRuntimeLog: [],
+ debugLinesCount: 10,
+ debugTarget: 'iguana',
+ nativeOnly: Config.iguanaLessMode,
+ toggleAppRuntimeLog: false,
+ };
+ this.readDebugLog = this.readDebugLog.bind(this);
+ this.updateInput = this.updateInput.bind(this);
+ this.getAppRuntimeLog = this.getAppRuntimeLog.bind(this);
+ this.toggleAppRuntimeLog = this.toggleAppRuntimeLog.bind(this);
+ this.renderAppRuntimeLog = this.renderAppRuntimeLog.bind(this);
+ }
+
+ readDebugLog() {
+ Store.dispatch(
+ getDebugLog(
+ this.state.debugTarget,
+ this.state.debugLinesCount
+ )
+ );
+ }
+
+ renderAppRuntimeLog() {
+ let _items = [];
+ const _appRuntimeLog = this.state.appRuntimeLog;
+
+ for (let i = 0; i < _appRuntimeLog.length; i++) {
+ _items.push(
+
+ { secondsToString(_appRuntimeLog[i].time, true) }
+ { JSON.stringify(_appRuntimeLog[i].msg, null, '') }
+
+ );
+ }
+
+ return _items;
+ }
+
+ toggleAppRuntimeLog() {
+ this.setState(Object.assign({}, this.state, {
+ toggleAppRuntimeLog: !this.state.toggleAppRuntimeLog,
+ }));
+
+ this.getAppRuntimeLog();
+ }
+
+ getAppRuntimeLog() {
+ let _appRuntimeLog;
+
+ try {
+ _appRuntimeLog = window.require('electron').remote.getCurrentWindow().getAppRuntimeLog;
+ } catch (e) {}
+
+ _appRuntimeLog()
+ .then((json) => {
+ this.setState(Object.assign({}, this.state, {
+ appRuntimeLog: json,
+ }));
+ });
+ }
+
+ renderDebugLogData() {
+ if (this.props.Settings.debugLog) {
+ const _debugLogDataRows = this.props.Settings.debugLog.split('\n');
+
+ if (_debugLogDataRows &&
+ _debugLogDataRows.length) {
+ return _debugLogDataRows.map((_row) =>
+
{ _row }
+ );
+ } else {
+ return (
+
{ translate('INDEX.EMPTY_DEBUG_LOG') }
+ );
+ }
+ } else {
+ return null;
+ }
+ }
+
+ updateInput(e) {
+ this.setState({
+ [e.target.name]: e.target.value,
+ });
+ }
+
+ render() {
+ return (
+
+
{ translate('INDEX.DEBUG_LOG_DESC') }
+
+
+
+ Show app runtime log
+
+
+ { !this.state.toggleAppRuntimeLog &&
+
+ }
+ { this.state.toggleAppRuntimeLog &&
+
{ this.renderAppRuntimeLog() }
+ }
+
+ );
+ };
+}
+
+const mapStateToProps = (state) => {
+ return {
+ Settings: state.Settings,
+ };
+};
+
+export default connect(mapStateToProps)(DebugLogPanel);
diff --git a/react/src/components/dashboard/settings/settings.exportKeysPanel.js b/react/src/components/dashboard/settings/settings.exportKeysPanel.js
new file mode 100644
index 0000000..7c59ea5
--- /dev/null
+++ b/react/src/components/dashboard/settings/settings.exportKeysPanel.js
@@ -0,0 +1,235 @@
+import React from 'react';
+import { translate } from '../../../translate/translate';
+import { connect } from 'react-redux';
+import {
+ encryptWallet,
+ settingsWifkeyState,
+ copyCoinAddress,
+} from '../../../actions/actionCreators';
+import Store from '../../../store';
+
+class ExportKeysPanel extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ exportWifKeysRaw: false,
+ seedInputVisibility: false,
+ trimPassphraseTimer: null,
+ wifkeysPassphrase: '',
+ };
+ this.exportWifKeys = this.exportWifKeys.bind(this);
+ this.exportWifKeysRaw = this.exportWifKeysRaw.bind(this);
+ this.toggleSeedInputVisibility = this.toggleSeedInputVisibility.bind(this);
+ this._copyCoinAddress = this._copyCoinAddress.bind(this);
+ this.updateInput = this.updateInput.bind(this);
+ }
+
+ exportWifKeys() {
+ Store.dispatch(
+ encryptWallet(
+ this.state.wifkeysPassphrase,
+ settingsWifkeyState,
+ this.props.ActiveCoin.coin
+ )
+ );
+ }
+
+ exportWifKeysRaw() {
+ this.setState(Object.assign({}, this.state, {
+ exportWifKeysRaw: !this.state.exportWifKeysRaw,
+ }));
+ }
+
+ toggleSeedInputVisibility() {
+ this.setState({
+ seedInputVisibility: !this.state.seedInputVisibility,
+ });
+ }
+
+ renderExportWifKeysRaw() {
+ const _wifKeysResponse = this.props.Settings.wifkey;
+
+ if (_wifKeysResponse &&
+ this.state.exportWifKeysRaw) {
+ return (
+
+ { JSON.stringify(_wifKeysResponse, null, '\t') }
+
+ );
+ } else {
+ return null;
+ }
+ }
+
+ _copyCoinAddress(address) {
+ Store.dispatch(copyCoinAddress(address));
+ }
+
+ renderWifKeys() {
+ let items = [];
+
+ if (this.props.Settings.wifkey) {
+ const _wifKeys = this.props.Settings.wifkey;
+
+ for (let i = 0; i < 2; i++) {
+ items.push(
+
+
+ { i === 0 ? translate('SETTINGS.ADDRESS_LIST') : translate('SETTINGS.WIF_KEY_LIST') }
+ |
+ |
+
+ );
+
+ for (let _key in _wifKeys) {
+ if ((i === 0 && _key.length === 3 && _key !== 'tag') ||
+ (i === 1 && _key.indexOf('wif') > -1)) {
+ items.push(
+
+ { _key.replace('wif', ' WIF') } |
+
+ { _wifKeys[_key] }
+
+ |
+
+ );
+ }
+ }
+ }
+
+ return items;
+ } else {
+ return null;
+ }
+ }
+
+ updateInput(e) {
+ if (e.target.name === 'wifkeysPassphrase') {
+ // remove any empty chars from the start/end of the string
+ const newValue = e.target.value;
+
+ clearTimeout(this.state.trimPassphraseTimer);
+
+ const _trimPassphraseTimer = setTimeout(() => {
+ this.setState({
+ wifkeysPassphrase: newValue ? newValue.trim() : '', // hardcoded field name
+ });
+ }, 2000);
+
+ this.resizeLoginTextarea();
+
+ this.setState({
+ trimPassphraseTimer: _trimPassphraseTimer,
+ [e.target.name]: newValue,
+ });
+ } else {
+ this.setState({
+ [e.target.name]: e.target.value,
+ });
+ }
+ }
+
+ resizeLoginTextarea() {
+ // auto-size textarea
+ setTimeout(() => {
+ if (this.state.seedInputVisibility) {
+ document.querySelector('#wifkeysPassphraseTextarea').style.height = '1px';
+ document.querySelector('#wifkeysPassphraseTextarea').style.height = `${(15 + document.querySelector('#wifkeysPassphraseTextarea').scrollHeight)}px`;
+ }
+ }, 100);
+ }
+
+ renderLB(_translationID) {
+ const _translationComponents = translate(_translationID).split('
');
+
+ return _translationComponents.map((_translation) =>
+
+ { _translation }
+
+
+ );
+ }
+
+ render() {
+ return (
+
+
+
{ this.renderLB('INDEX.ONLY_ACTIVE_WIF_KEYS') }
+
+ { this.renderLB('SETTINGS.EXPORT_KEYS_NOTE') }
+
+
+ { translate('INDEX.PLEASE_KEEP_KEYS_SAFE') }
+
+
+
+
+
+
+
+
+ { this.renderWifKeys() }
+
+
+
+
+
+ { this.renderExportWifKeysRaw() }
+
+
+
+
+ );
+ };
+}
+
+const mapStateToProps = (state) => {
+ return {
+ ActiveCoin: {
+ coin: state.ActiveCoin.coin,
+ },
+ Settings: state.Settings,
+ };
+};
+
+export default connect(mapStateToProps)(ExportKeysPanel);
\ No newline at end of file
diff --git a/react/src/components/dashboard/settings/settings.fiatCurrencyPanel.js b/react/src/components/dashboard/settings/settings.fiatCurrencyPanel.js
new file mode 100644
index 0000000..ad61436
--- /dev/null
+++ b/react/src/components/dashboard/settings/settings.fiatCurrencyPanel.js
@@ -0,0 +1,23 @@
+import React from 'react';
+import { translate } from '../../../translate/translate';
+import { connect } from 'react-redux';
+
+class FiatCurrencyPanel extends React.Component {
+ constructor() {
+ super();
+ }
+
+ render() {
+ return (
+
Fiat currency settings section to be updated soon.
+ );
+ };
+}
+
+const mapStateToProps = (state) => {
+ return {
+ Settings: state.Settings,
+ };
+};
+
+export default connect(mapStateToProps)(FiatCurrencyPanel);
\ No newline at end of file
diff --git a/react/src/components/dashboard/settings/settings.importKeysPanel.js b/react/src/components/dashboard/settings/settings.importKeysPanel.js
new file mode 100644
index 0000000..e395871
--- /dev/null
+++ b/react/src/components/dashboard/settings/settings.importKeysPanel.js
@@ -0,0 +1,67 @@
+import React from 'react';
+import { translate } from '../../../translate/translate';
+import {
+ importPrivKey,
+} from '../../../actions/actionCreators';
+import Store from '../../../store';
+
+class ImportKeysPanel extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ importWifKey: '',
+ };
+ this.importWifKey = this.importWifKey.bind(this);
+ }
+
+ importWifKey() {
+ Store.dispatch(importPrivKey(this.state.importWifKey));
+ }
+
+ updateInput = (e) => {
+ this.setState({
+ [e.target.name]: e.target.value,
+ });
+ }
+
+ render() {
+ return (
+
+
{ translate('INDEX.IMPORT_KEYS_DESC_P1') }
+
{ translate('INDEX.IMPORT_KEYS_DESC_P2') }
+
{ translate('INDEX.IMPORT_KEYS_DESC_P3') }
+
+
+ { translate('INDEX.PLEASE_KEEP_KEYS_SAFE') }
+
+
+
+
+
+ );
+ }
+}
+
+export default ImportKeysPanel;
\ No newline at end of file
diff --git a/react/src/components/dashboard/settings/settings.js b/react/src/components/dashboard/settings/settings.js
index 101565e..32c276d 100644
--- a/react/src/components/dashboard/settings/settings.js
+++ b/react/src/components/dashboard/settings/settings.js
@@ -4,36 +4,31 @@ import { translate } from '../../../translate/translate';
import Config from '../../../config';
import {
iguanaActiveHandle,
- encryptWallet,
- settingsWifkeyState,
- importPrivKey,
- getDebugLog,
+ getAppConfig,
getPeersList,
addPeerNode,
- getAppConfig,
- saveAppConfig,
- resetAppConfig,
getAppInfo,
shepherdCli,
- checkForUpdateUIPromise,
- updateUIPromise,
triggerToaster,
} from '../../../actions/actionCreators';
import Store from '../../../store';
import {
- AppInfoTabRender,
SettingsRender,
- AppUpdateTabRender,
} from './settings.render';
-import { SocketProvider } from 'socket.io-react';
-import io from 'socket.io-client';
-
-const socket = io.connect(`http://127.0.0.1:${Config.agamaPort}`);
-let updateProgressBar = {
- patch: -1,
-};
+import AppUpdatePanel from './settings.appUpdatePanel';
+import AppInfoPanel from './settings.appInfoPanel';
+import AddNodePanel from './settings.addNodePanel';
+import AppSettingsPanel from './settings.appSettingsPanel';
+import CliPanel from './settings.cliPanel';
+import DebugLogPanel from './settings.debugLogPanel';
+import FiatCurrencyPanel from './settings.fiatCurrencyPanel';
+import ExportKeysPanel from './settings.exportKeysPanel';
+import ImportKeysPanel from './settings.importKeysPanel';
+import SupportPanel from './settings.supportPanel';
+import WalletInfoPanel from './settings.walletInfoPanel';
+import WalletBackupPanel from './settings.walletBackupPanel';
/*
TODO:
@@ -47,77 +42,12 @@ class Settings extends React.Component {
super();
this.state = {
activeTab: 0,
- debugLinesCount: 10,
- debugTarget: 'iguana',
- activeTabHeight: '0',
- appSettings: {},
- appConfigSchema: {},
tabElId: null,
- cliCmdString: '',
- cliCoin: null,
- cliResponse: null,
- exportWifKeysRaw: false,
seedInputVisibility: false,
nativeOnly: Config.iguanaLessMode,
- updatePatch: null,
- updateBins: null,
- updateLog: [],
- updateProgressPatch: null,
- wifkeysPassphrase: '',
- trimPassphraseTimer: null,
- disableWalletSpecificUI: null,
+ disableWalletSpecificUI: false,
};
- this.exportWifKeys = this.exportWifKeys.bind(this);
this.updateInput = this.updateInput.bind(this);
- // this.updateInputSettings = this.updateInputSettings.bind(this);
- this.importWifKey = this.importWifKey.bind(this);
- this.readDebugLog = this.readDebugLog.bind(this);
- this.checkNodes = this.checkNodes.bind(this);
- this.addNode = this.addNode.bind(this);
- this.renderPeersList = this.renderPeersList.bind(this);
- this.renderSNPeersList = this.renderSNPeersList.bind(this);
- this._saveAppConfig = this._saveAppConfig.bind(this);
- this._resetAppConfig = this._resetAppConfig.bind(this);
- this.exportWifKeysRaw = this.exportWifKeysRaw.bind(this);
- this.toggleSeedInputVisibility = this.toggleSeedInputVisibility.bind(this);
- this._checkForUpdateUIPromise = this._checkForUpdateUIPromise.bind(this);
- this._updateUIPromise = this._updateUIPromise.bind(this);
- this.updateTabDimensions = this.updateTabDimensions.bind(this);
- }
-
- updateTabDimensions() {
- setTimeout(() => {
- const _height = document.querySelector(`#${this.state.tabElId} .panel-collapse .panel-body`).offsetHeight;
-
- this.setState(Object.assign({}, this.state, {
- activeTabHeight: _height,
- }));
- }, 100);
- }
-
- componentWillMount() {
- socket.on('patch', msg => this.updateSocketsData(msg));
- window.addEventListener('resize', this.updateTabDimensions);
-
- try {
- const _appConfigSchema = window.require('electron').remote.getCurrentWindow().appConfigSchema;
- const _appSettings = this.props.Settings.appSettings ? this.props.Settings.appSettings : Object.assign({}, window.require('electron').remote.getCurrentWindow().appConfig);
-
- this.setState(Object.assign({}, this.state, {
- appConfigSchema: _appConfigSchema,
- appSettings: _appSettings,
- }));
- } catch(e) {}
- }
-
- componentWillUnmount() {
- socket.removeAllListeners('patch', msg => this.updateSocketsData(msg));
- window.removeEventListener('resize', this.updateTabDimensions);
-
- if (!this.state.disableWalletSpecificUI) {
- document.documentElement.style.height = '100%';
- document.body.style.height = '100%';
- }
}
componentDidMount(props) {
@@ -127,719 +57,84 @@ class Settings extends React.Component {
Store.dispatch(getAppConfig());
Store.dispatch(getAppInfo());
+
+ document.getElementById('section-iguana-wallet-settings').setAttribute('style', 'height:auto; min-height: 100%');
}
componentWillReceiveProps(props) {
if (this.state.tabElId) {
- const _height = document.querySelector(`#${this.state.tabElId} .panel-collapse .panel-body`).offsetHeight;
-
this.setState(Object.assign({}, this.state, {
activeTab: this.state.activeTab,
- activeTabHeight: _height,
tabElId: this.state.tabElId,
- disableWalletSpecificUI: props.disableWalletSpecificUI,
+ disableWalletSpecificUI: this.props.disableWalletSpecificUI,
}));
}
}
- openExternalWindow(url) {
- const remote = window.require('electron').remote;
- const BrowserWindow = remote.BrowserWindow;
-
- const externalWindow = new BrowserWindow({
- width: 1280,
- height: 800,
- title: `${translate('INDEX.LOADING')}...`,
- icon: remote.getCurrentWindow().iguanaIcon,
- });
-
- externalWindow.loadURL(url);
- externalWindow.webContents.on('did-finish-load', function() {
- setTimeout(function() {
- externalWindow.show();
- }, 40);
- });
- }
-
- _resetAppConfig() {
- Store.dispatch(resetAppConfig());
- }
-
- resizeLoginTextarea() {
- // auto-size textarea
- setTimeout(() => {
- if (this.state.seedInputVisibility) {
- document.querySelector('#wifkeysPassphraseTextarea').style.height = '1px';
- document.querySelector('#wifkeysPassphraseTextarea').style.height = `${(15 + document.querySelector('#wifkeysPassphraseTextarea').scrollHeight)}px`;
- }
- }, 100);
- }
-
- updateSocketsData(data) {
- if (data &&
- data.msg &&
- data.msg.type === 'ui') {
-
- if (data.msg.status === 'progress' &&
- data.msg.progress &&
- data.msg.progress < 100) {
- this.setState(Object.assign({}, this.state, {
- updateProgressPatch: data.msg.progress,
- }));
- updateProgressBar.patch = data.msg.progress;
- } else {
- if (data.msg.status === 'progress' &&
- data.msg.progress &&
- data.msg.progress === 100) {
- let _updateLog = [];
- _updateLog.push(`${translate('INDEX.UI_UPDATE_DOWNLOADED')}...`);
- this.setState(Object.assign({}, this.state, {
- updateLog: _updateLog,
- }));
- updateProgressBar.patch = 100;
- }
-
- if (data.msg.status === 'done') {
- let _updateLog = [];
- _updateLog.push(translate('INDEX.UI_UPDATED'));
- this.setState(Object.assign({}, this.state, {
- updateLog: _updateLog,
- updatePatch: null,
- }));
- updateProgressBar.patch = -1;
- }
-
- if (data.msg.status === 'error') {
- let _updateLog = [];
- _updateLog.push(translate('INDEX.UI_UPDATE_ERROR'));
- this.setState(Object.assign({}, this.state, {
- updateLog: _updateLog,
- }));
- updateProgressBar.patch = -1;
- }
- }
- } else {
- if (data &&
- data.msg) {
- let _updateLog = this.state.updateLog;
- _updateLog.push(data.msg);
- this.setState(Object.assign({}, this.state, {
- updateLog: _updateLog,
- }));
- }
- }
- }
-
- _checkForUpdateUIPromise() {
- let _updateLog = [];
- _updateLog.push(translate('INDEX.CHECKING_UI_UPDATE'));
- this.setState(Object.assign({}, this.state, {
- updateLog: _updateLog,
- }));
-
- checkForUpdateUIPromise()
- .then((res) => {
- let _updateLog = this.state.updateLog;
- _updateLog.push(res.result === 'update' ? (`${translate('INDEX.NEW_UI_UPDATE')} ${res.version.remote}`) : translate('INDEX.YOU_HAVE_LATEST_UI'));
- this.setState(Object.assign({}, this.state, {
- updatePatch: res.result === 'update' ? true : false,
- updateLog: _updateLog,
- }));
- });
- }
-
- _updateUIPromise() {
- updateProgressBar.patch = 0;
- let _updateLog = [];
- _updateLog.push(`${translate('INDEX.DOWNLOADING_UI_UPDATE')}...`);
- this.setState(Object.assign({}, this.state, {
- updateLog: _updateLog,
+ openTab(elemId, tab) {
+ this.setState(Object.assign({}, this.state, {
+ activeTab: tab,
+ tabElId: elemId,
}));
-
- updateUIPromise();
}
- renderUpdateStatus() {
- let items = [];
- let patchProgressBar = null;
- const _updateLogLength = this.state.updateLog.length;
-
- for (let i = 0; i < _updateLogLength; i++) {
- items.push(
-
{ this.state.updateLog[i] }
- );
- }
-
- if (_updateLogLength) {
- return (
-
-
-
{ translate('SETTINGS.PROGRESS') }:
-
{ items }
-
-1 ? 'progress progress-sm' : 'hide' }>
-
-
-
-
- );
- } else {
- return null;
- }
- }
-
- toggleSeedInputVisibility() {
+ updateInput(e) {
this.setState({
- seedInputVisibility: !this.state.seedInputVisibility,
+ [e.target.name]: e.target.value,
});
}
- execCliCmd() {
- Store.dispatch(
- shepherdCli(
- 'passthru',
- this.state.cliCoin,
- this.state.cliCmdString
- )
- );
- }
-
- openTab(elemId, tab) {
- setTimeout(() => {
- const _height = document.querySelector(`#${elemId} .panel-collapse .panel-body`).offsetHeight;
-
- this.setState(Object.assign({}, this.state, {
- activeTab: tab,
- activeTabHeight: _height,
- tabElId: elemId,
- }));
-
- // body size hack
- if (!this.state.disableWalletSpecificUI) {
- document.documentElement.style.height = '100%';
- document.body.style.height = '100%';
-
- setTimeout(() => {
- document.documentElement.style.height = _height <= 200 ? '100%' : 'inherit';
- document.body.style.height = _height <= 200 ? '100%' : 'inherit';
- }, 100);
- }
- }, 100);
- }
-
- exportWifKeys() {
- Store.dispatch(
- encryptWallet(
- this.state.wifkeysPassphrase,
- settingsWifkeyState,
- this.props.ActiveCoin.coin
- )
- );
- }
-
- importWifKey() {
- Store.dispatch(importPrivKey(this.state.importWifKey));
- }
-
- readDebugLog() {
- Store.dispatch(
- getDebugLog(
- this.state.debugTarget,
- this.state.debugLinesCount
- )
- );
- }
-
- checkNodes() {
- if (this.state.getPeersCoin) {
- Store.dispatch(getPeersList(this.state.getPeersCoin.split('|')[0]));
- }
- }
-
- addNode() {
- if (this.state.addNodeCoin) {
- Store.dispatch(
- addPeerNode(
- this.state.addNodeCoin.split('|')[0],
- this.state.addPeerIP
- )
- );
- }
- }
-
- renderPeersList() {
- if (this.state.getPeersCoin) {
- const _getPeersCoin = this.state.getPeersCoin;
- const _rawPeers = this.props.Settings.rawPeers;
- const coin = _getPeersCoin.split('|')[0];
-
- if (_rawPeers &&
- _getPeersCoin &&
- _rawPeers[coin]) {
- return _rawPeers[coin].map((ip) =>
-
{ ip }
- );
- } else {
- return null;
- }
- } else {
- return null;
- }
- }
-
renderAppInfoTab() {
const releaseInfo = this.props.Settings.appInfo && this.props.Settings.appInfo.releaseInfo;
if (releaseInfo) {
- return AppInfoTabRender.call(this);
+ return
}
return null;
}
renderAppUpdateTab() {
- return AppUpdateTabRender.call(this);
+ return
}
- renderSNPeersList() {
- if (this.state.getPeersCoin) {
- const _getPeersCoin = this.state.getPeersCoin;
- const _supernetPeers = this.props.Settings.supernetPeers;
- const coin = _getPeersCoin.split('|')[0];
-
- if (_supernetPeers &&
- _getPeersCoin &&
- _supernetPeers[coin]) {
- return _supernetPeers[coin].map((ip) =>
-
{ ip }
- );
- } else {
- return null;
- }
- } else {
- return null;
- }
+ renderWalletInfo() {
+ return
}
-
- updateInputSettings(e, parentKey, childKey) {
- let _appSettings = this.state.appSettings;
- let _appSettingsPrev = Object.assign({}, _appSettings);
-
- if (!childKey && this.state.appConfigSchema[parentKey].type === 'boolean') {
- _appSettings[parentKey] = typeof _appSettings[parentKey] !== undefined ? !_appSettings[parentKey] : !this.state.appSettings[parentKey];
- } else if (childKey && this.state.appConfigSchema[parentKey][childKey].type === 'boolean') {
- _appSettings[parentKey][childKey] = typeof _appSettings[parentKey][childKey] !== undefined ? !_appSettings[parentKey][childKey] : !this.state.appSettings[parentKey][childKey];
- } else if ((!childKey && this.state.appConfigSchema[parentKey].type === 'number') || (childKey && this.state.appConfigSchema[parentKey][childKey].type === 'number')) {
- if (e.target.value === '') {
- _appSettings[e.target.name] = _appSettingsPrev[e.target.name];
- } else {
- _appSettings[e.target.name] = e.target.value.replace(/[^0-9]+/g, '');
- }
- } else {
- _appSettings[e.target.name] = e.target.value;
- }
-
- this.setState({
- appSettings: _appSettings,
- });
- }
-
- _saveAppConfig() {
- const _appSettings = this.state.appSettings;
- let _appSettingsPristine = Object.assign({}, this.props.Settings.appSettings);
- let isError = false;
- let saveAfterPathCheck = false;
-
- for (let key in _appSettings) {
- if (key.indexOf('__') === -1) {
- _appSettingsPristine[key] = this.state.appConfigSchema[key].type === 'number' ? Number(_appSettings[key]) : _appSettings[key];
-
- if (this.state.appConfigSchema[key].type === 'folder' &&
- _appSettings[key] &&
- _appSettings[key].length) {
- const _testLocation = window.require('electron').remote.getCurrentWindow().testLocation;
- saveAfterPathCheck = true;
-
- _testLocation(_appSettings[key])
- .then((res) => {
- if (res === -1) {
- isError = true;
- Store.dispatch(
- triggerToaster(
- translate('TOASTR.KOMODO_DATADIR_INVALID'),
- translate('INDEX.SETTINGS'),
- 'error'
- )
- );
- } else if (res === false) {
- isError = true;
- Store.dispatch(
- triggerToaster(
- translate('TOASTR.KOMODO_DATADIR_NOT_DIR'),
- translate('INDEX.SETTINGS'),
- 'error'
- )
- );
- } else {
- Store.dispatch(saveAppConfig(_appSettingsPristine));
- }
- });
- }
- } else {
- const _nestedKey = key.split('__');
- _appSettingsPristine[_nestedKey[0]][_nestedKey[1]] = this.state.appConfigSchema[_nestedKey[0]][_nestedKey[1]].type === 'number' ? Number(_appSettings[key]) : _appSettings[key];
- }
- }
-
- if (!saveAfterPathCheck) {
- Store.dispatch(saveAppConfig(_appSettingsPristine));
- }
- }
-
- renderConfigEditForm() {
- let items = [];
- const _appConfig = this.state.appSettings;
-
- for (let key in _appConfig) {
- if (typeof _appConfig[key] === 'object') {
- if (this.state.appConfigSchema[key].display) {
- items.push(
-
-
- { this.state.appConfigSchema[key].displayName ? this.state.appConfigSchema[key].displayName : key }
- { this.state.appConfigSchema[key].info &&
-
- }
- |
- |
-
- );
-
- for (let _key in _appConfig[key]) {
- items.push(
-
-
- { this.state.appConfigSchema[key][_key].displayName ? this.state.appConfigSchema[key][_key].displayName : _key }
- { this.state.appConfigSchema[key][_key].info &&
-
- }
- |
-
- { this.state.appConfigSchema[key][_key].type === 'number' &&
- this.updateInputSettings(event, key, _key) } />
- }
- { (this.state.appConfigSchema[key][_key].type === 'string' || this.state.appConfigSchema[key][_key].type === 'folder') &&
- this.updateInputSettings(event, key, _key) } />
- }
- { this.state.appConfigSchema[key][_key].type === 'boolean' &&
-
-
-
- }
- |
-
- );
- }
- }
- } else {
- if (this.state.appConfigSchema[key].display) {
- items.push(
-
-
- { this.state.appConfigSchema[key].displayName ? this.state.appConfigSchema[key].displayName : key }
- { this.state.appConfigSchema[key].info &&
-
- }
- |
-
- { this.state.appConfigSchema[key].type === 'number' &&
- this.updateInputSettings(event, key) } />
- }
- { (this.state.appConfigSchema[key].type === 'string' || this.state.appConfigSchema[key].type === 'folder') &&
- this.updateInputSettings(event, key) } />
- }
- { this.state.appConfigSchema[key].type === 'boolean' &&
-
-
-
- }
- |
-
- );
- }
- }
- }
-
- return items;
+ renderAddNode() {
+ return
}
- updateInput(e) {
- if (e.target.name === 'wifkeysPassphrase') {
- // remove any empty chars from the start/end of the string
- const newValue = e.target.value;
-
- clearTimeout(this.state.trimPassphraseTimer);
-
- const _trimPassphraseTimer = setTimeout(() => {
- this.setState({
- wifkeysPassphrase: newValue ? newValue.trim() : '', // hardcoded field name
- });
- }, 2000);
-
- this.resizeLoginTextarea();
-
- this.setState({
- trimPassphraseTimer: _trimPassphraseTimer,
- [e.target.name]: newValue,
- });
- } else {
- this.setState({
- [e.target.name]: e.target.value,
- });
- }
+ renderWalletBackup() {
+ return
}
- renderDebugLogData() {
- if (this.props.Settings.debugLog) {
- const _debugLogDataRows = this.props.Settings.debugLog.split('\n');
-
- if (_debugLogDataRows &&
- _debugLogDataRows.length) {
- return _debugLogDataRows.map((_row) =>
-
{ _row }
- );
- } else {
- return (
-
{ translate('INDEX.EMPTY_DEBUG_LOG') }
- );
- }
- } else {
- return null;
- }
+ renderFiatCurrency() {
+ return
}
- renderLB(_translationID) {
- const _translationComponents = translate(_translationID).split('
');
-
- return _translationComponents.map((_translation) =>
-
- { _translation }
-
-
- );
+ renderExportKeys() {
+ return
}
- // TODO: rerender only if prop is changed
- renderCliResponse() {
- const _cliResponse = this.props.Settings.cli;
- let _items = [];
-
- if (_cliResponse) {
- let _cliResponseParsed;
- let responseType;
-
- try {
- _cliResponseParsed = JSON.parse(_cliResponse.result);
- } catch(e) {
- _cliResponseParsed = _cliResponse.result;
- }
-
- if (Object.prototype.toString.call(_cliResponseParsed) === '[object Array]') {
- responseType = 'array';
-
- for (let i = 0; i < _cliResponseParsed.length; i++) {
- _items.push(
-
{ JSON.stringify(_cliResponseParsed[i], null, '\t') }
- );
- }
- }
- if (Object.prototype.toString.call(_cliResponseParsed) === '[object]' ||
- typeof _cliResponseParsed === 'object') {
- responseType = 'object';
-
- _items.push(
-
{ JSON.stringify(_cliResponseParsed, null, '\t') }
- );
- }
- if (Object.prototype.toString.call(_cliResponseParsed) === 'number' ||
- typeof _cliResponseParsed === 'boolean' ||
- _cliResponseParsed === 'wrong cli string format') {
- responseType = 'number';
-
- _items.push(
-
{ _cliResponseParsed.toString() }
- );
- }
-
- if (responseType !== 'number' &&
- responseType !== 'array' &&
- responseType !== 'object' &&
- _cliResponseParsed.indexOf('\n') > -1) {
- _cliResponseParsed = _cliResponseParsed.split('\n');
-
- for (let i = 0; i < _cliResponseParsed.length; i++) {
- _items.push(
-
{ _cliResponseParsed[i] }
- );
- }
- }
-
- return (
-
-
- { translate('SETTINGS.CLI_RESPONSE') }:
-
- { _items }
-
- );
- } else {
- return null;
- }
+ renderImportKeys() {
+ return
}
- renderActiveCoinsList(mode) {
- const modes = [
- 'native',
- 'basilisk',
- 'full'
- ];
-
- const allCoins = this.props.Main.coins;
- let items = [];
-
- if (allCoins) {
- if (mode === 'all') {
- modes.map(function(mode) {
- allCoins[mode].map(function(coin) {
- items.push(
-
- );
- });
- });
- } else {
- allCoins[mode].map(function(coin) {
- items.push(
-
- );
- });
- }
-
- return items;
- } else {
- return null;
- }
+ renderDebugLog() {
+ return
}
- renderExportWifKeysRaw() {
- const _wifKeysResponse = this.props.Settings.wifkey;
-
- if (_wifKeysResponse &&
- this.state.exportWifKeysRaw) {
- return (
-
- { JSON.stringify(_wifKeysResponse, null, '\t') }
-
- );
- } else {
- return null;
- }
+ renderAppSettings() {
+ return
}
- renderWifKeys() {
- let items = [];
-
- if (this.props.Settings.wifkey) {
- const _wifKeys = this.props.Settings.wifkey;
-
- for (let i = 0; i < 2; i++) {
- items.push(
-
-
- { i === 0 ? translate('SETTINGS.ADDRESS_LIST') : translate('SETTINGS.WIF_KEY_LIST') }
- |
- |
-
- );
-
- for (let _key in _wifKeys) {
- if ((i === 0 && _key.length === 3 && _key !== 'tag') ||
- (i === 1 && _key.indexOf('wif') > -1)) {
- items.push(
-
- { _key } |
- { _wifKeys[_key] } |
-
- );
- }
- }
- }
-
- return items;
- } else {
- return null;
- }
+ renderCliPanel() {
+ return
}
- exportWifKeysRaw() {
- this.setState(Object.assign({}, this.state, {
- exportWifKeysRaw: !this.state.exportWifKeysRaw,
- }));
+ renderSupportPanel() {
+ return
}
render() {
@@ -856,9 +151,9 @@ const mapStateToProps = (state) => {
ActiveCoin: {
coin: state.ActiveCoin.coin,
},
- Settings: state.Settings,
+ Settings: state.Settings,
+ Dashboard: state.Dashboard,
};
-
};
export default connect(mapStateToProps)(Settings);
diff --git a/react/src/components/dashboard/settings/settings.render.js b/react/src/components/dashboard/settings/settings.render.js
index 227a581..5a999d1 100644
--- a/react/src/components/dashboard/settings/settings.render.js
+++ b/react/src/components/dashboard/settings/settings.render.js
@@ -1,146 +1,5 @@
import React from 'react';
import { translate } from '../../../translate/translate';
-import AddCoinOptionsCrypto from '../../addcoin/addcoinOptionsCrypto';
-import AddCoinOptionsAC from '../../addcoin/addcoinOptionsAC';
-import AddCoinOptionsACFiat from '../../addcoin/addcoinOptionsACFiat';
-
-export const AppUpdateTabRender = function() {
- return (
-
this.openTab('AppUpdate', 10) }>
-
-
-
-
-
{ translate('INDEX.UI_UPDATE') }
-
-
-
-
-
-
-
{ translate('INDEX.BINS_UPDATE') }
-
-
-
-
-
-
- { this.renderUpdateStatus() }
-
-
-
-
- );
-};
-
-export const AppInfoTabRender = function() {
- return (
-
this.openTab('AppInfo', 8) }>
-
-
-
-
-
-
{ translate('SETTINGS.APP_RELEASE') }
-
- { translate('SETTINGS.NAME') }: { this.props.Settings.appInfo.releaseInfo.name }
-
-
- { translate('SETTINGS.VERSION') }: { `${this.props.Settings.appInfo.releaseInfo.version.replace('version=', '')}-beta` }
-
-
- { translate('SETTINGS.APP_SESSION') }: { this.props.Settings.appInfo.appSession }
-
-
-
-
-
-
{ translate('SETTINGS.SYS_INFO') }
-
- { translate('SETTINGS.ARCH') }: { this.props.Settings.appInfo.sysInfo.arch }
-
-
- { translate('SETTINGS.OS_TYPE') }: { this.props.Settings.appInfo.sysInfo.os_type }
-
-
- { translate('SETTINGS.OS_PLATFORM') }: { this.props.Settings.appInfo.sysInfo.platform }
-
-
- { translate('SETTINGS.OS_RELEASE') }: { this.props.Settings.appInfo.sysInfo.os_release }
-
-
- { translate('SETTINGS.CPU') }: { this.props.Settings.appInfo.sysInfo.cpu }
-
-
- { translate('SETTINGS.CPU_CORES') }: { this.props.Settings.appInfo.sysInfo.cpu_cores }
-
-
- { translate('SETTINGS.MEM') }: { this.props.Settings.appInfo.sysInfo.totalmem_readable }
-
-
-
-
-
-
{ translate('SETTINGS.LOCATIONS') }
-
- { translate('SETTINGS.CACHE') }: { this.props.Settings.appInfo.dirs.cacheLocation }
-
-
- { translate('SETTINGS.CONFIG') }: { this.props.Settings.appInfo.dirs.configLocation }
-
-
- Iguana { translate('SETTINGS.BIN') }: { this.props.Settings.appInfo.dirs.iguanaBin }
-
-
- Iguana { translate('SETTINGS.DIR') }: { this.props.Settings.appInfo.dirs.iguanaDir }
-
-
- Komodo { translate('SETTINGS.BIN') }: { this.props.Settings.appInfo.dirs.komododBin }
-
-
- Komodo { translate('SETTINGS.DIR') }: { this.props.Settings.appInfo.dirs.komodoDir }
-
-
- Komodo wallet.dat: { this.props.Settings.appInfo.dirs.komodoDir }
-
-
-
-
-
-
- );
-};
export const SettingsRender = function() {
return (
@@ -156,6 +15,7 @@ export const SettingsRender = function() {
+
{ !this.props.disableWalletSpecificUI &&
-
-
-
-
- { translate('INDEX.KEY') } |
- { translate('INDEX.VALUE') } |
-
-
-
-
- pubkey |
- { this.props.Main.activeHandle.pubkey } |
-
-
- btcpubkey |
- { this.props.Main.activeHandle.btcpubkey } |
-
-
- rmd160 |
- { this.props.Main.activeHandle.rmd160 } |
-
-
- NXT |
- { this.props.Main.activeHandle.NXT } |
-
-
- notary |
- { this.props.Main.activeHandle.notary } |
-
-
- status |
- { this.props.Main.activeHandle.status } |
-
-
-
-
+ style={{ height: this.state.activeTab === 0 ? `auto` : '0' }}>
+ { this.renderWalletInfo() }
}
@@ -220,78 +45,8 @@ export const SettingsRender = function() {
-
-
-
-
-
{ translate('INDEX.USE_THIS_SECTION') }
-
-
-
-
-
-
-
-
-
-
-
- SuperNET Peers:
-
-
{ this.renderSNPeersList() }
-
- Raw Peers:
-
-
{ this.renderPeersList() }
-
-
-
-
-
-
{ translate('INDEX.USE_THIS_SECTION_PEER') }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ style={{ height: this.state.activeTab === 1 ? `auto` : '0' }}>
+ { this.renderAddNode() }
}
@@ -299,7 +54,7 @@ export const SettingsRender = function() {
}
@@ -316,7 +71,7 @@ export const SettingsRender = function() {
}
@@ -341,69 +96,8 @@ export const SettingsRender = function() {