diff --git a/react/src/actions/actionCreators.js b/react/src/actions/actionCreators.js index b2562e3..8aead6d 100644 --- a/react/src/actions/actionCreators.js +++ b/react/src/actions/actionCreators.js @@ -194,7 +194,7 @@ export function triggerToaster(message, title, _type, autoClose = true) { message, title, _type, - autoClose + autoClose, } } @@ -202,7 +202,7 @@ export function triggerToaster(message, title, _type, autoClose = true) { export function dismissToaster(toastId) { return { type: REMOVE_TOASTER_MESSAGE, - toastId: toastId + toastId: toastId, } } @@ -218,7 +218,7 @@ export function dashboardCoinsState(json) { return { type: GET_ACTIVE_COINS, coins: json, - activeCoins: Object.keys(json.native).length || Object.keys(json.basilisk).length || Object.keys(json.full).length ? true : false + activeCoins: Object.keys(json.native).length || Object.keys(json.basilisk).length || Object.keys(json.full).length ? true : false, } } @@ -292,7 +292,13 @@ export function rpcErrorHandler(json, dispatch) { if (json && json.error) { if (json.error === 'bitcoinrpc needs coin that is active') { - dispatch(triggerToaster(translate('API.NO_ACTIVE_COIN'), translate('TOASTR.SERVICE_NOTIFICATION'), 'error')); + dispatch( + triggerToaster( + translate('API.NO_ACTIVE_COIN'), + translate('TOASTR.SERVICE_NOTIFICATION'), + 'error' + ) + ); } } } @@ -303,8 +309,8 @@ export function setBasiliskMainAddress(json, coin, mode) { for (let i = 0; i < json.result.length; i++) { publicAddressArray.push({ - 'address': json.result[i], - 'amount': 'N/A' + address: json.result[i], + amount: 'N/A', }); } @@ -321,7 +327,7 @@ export function setBasiliskMainAddress(json, coin, mode) { return { type: ACTIVE_COIN_GET_ADDRESSES, - addresses: { 'public': [] }, + addresses: { public: [] }, } } @@ -331,7 +337,7 @@ export function getNativeTxHistoryState(json) { json = null; } else if (json && json.result && json.result.length) { json = json.result; - } else if (!json || !json.result.length) { + } else if (!json || (!json.result || !json.result.length)) { json = 'no data'; } diff --git a/react/src/components/dashboard/settings/settings.js b/react/src/components/dashboard/settings/settings.js index 988f567..cad8864 100644 --- a/react/src/components/dashboard/settings/settings.js +++ b/react/src/components/dashboard/settings/settings.js @@ -106,8 +106,6 @@ class Settings extends React.Component { appConfigSchema: _appConfigSchema, appSettings: _appSettings, })); - - console.warn(_appSettings); } catch(e) {} } @@ -263,14 +261,15 @@ class Settings extends React.Component { renderUpdateStatus() { let items = []; let patchProgressBar = null; + const _updateLogLength = this.state.updateLog.length; - for (let i = 0; i < this.state.updateLog.length; i++) { + for (let i = 0; i < _updateLogLength; i++) { items.push(
{ this.state.updateLog[i] }
); } - if (this.state.updateLog.length) { + if (_updateLogLength) { return (

@@ -279,7 +278,7 @@ class Settings extends React.Component {
-1 ? 'progress progress-sm' : 'hide' }>
+ style={{ width: `${updateProgressBar.patch}%` }}>
@@ -300,7 +299,7 @@ class Settings extends React.Component { shepherdCli( 'passthru', this.state.cliCoin, - this.state.cliCmd + this.state.cliCmdString ) ); } @@ -467,7 +466,7 @@ class Settings extends React.Component { isError = true; Store.dispatch( triggerToaster( - 'Komodo datadir path is invalid', + translate('TOASTR.KOMODO_DATADIR_INVALID'), translate('INDEX.SETTINGS'), 'error' ) @@ -476,7 +475,7 @@ class Settings extends React.Component { isError = true; Store.dispatch( triggerToaster( - 'Komodo datadir path is not a directory', + translate('TOASTR.KOMODO_DATADIR_NOT_DIR'), translate('INDEX.SETTINGS'), 'error' ) diff --git a/react/src/components/dashboard/settings/settings.render.js b/react/src/components/dashboard/settings/settings.render.js index 976a8e4..227a581 100644 --- a/react/src/components/dashboard/settings/settings.render.js +++ b/react/src/components/dashboard/settings/settings.render.js @@ -605,7 +605,7 @@ export const SettingsRender = function() {
diff --git a/react/src/components/dashboard/walletsBalance/walletsBalance.render.js b/react/src/components/dashboard/walletsBalance/walletsBalance.render.js index b375faf..39b9f63 100644 --- a/react/src/components/dashboard/walletsBalance/walletsBalance.render.js +++ b/react/src/components/dashboard/walletsBalance/walletsBalance.render.js @@ -38,7 +38,7 @@ const WalletsBalanceRender = function() { - { Config.roundValues ? formatValue('round', this.renderBalance('transparent'), -6) : this.renderBalance('transparent') } + { Config.roundValues ? formatValue(this.renderBalance('transparent')) : this.renderBalance('transparent') }
@@ -58,7 +58,7 @@ const WalletsBalanceRender = function() { - { Config.roundValues ? formatValue('round', this.renderBalance('private'), -6) : this.renderBalance('private') } + { Config.roundValues ? formatValue(this.renderBalance('private')) : this.renderBalance('private') } @@ -79,7 +79,7 @@ const WalletsBalanceRender = function() { - { Config.roundValues ? formatValue('round', this.renderBalance('interest'), -6) : this.renderBalance('interest') } + { Config.roundValues ? formatValue(this.renderBalance('interest')) : this.renderBalance('interest') } @@ -100,7 +100,7 @@ const WalletsBalanceRender = function() { - { Config.roundValues ? formatValue('round', this.renderBalance('total'), -6) : this.renderBalance('total') } + { Config.roundValues ? formatValue(this.renderBalance('total')) : this.renderBalance('total') } diff --git a/react/src/components/dashboard/walletsData/walletsData.js b/react/src/components/dashboard/walletsData/walletsData.js index 1a17144..91b0e93 100644 --- a/react/src/components/dashboard/walletsData/walletsData.js +++ b/react/src/components/dashboard/walletsData/walletsData.js @@ -102,6 +102,31 @@ class WalletsData extends React.Component { socket.removeAllListeners('messages'); } + // https://react-table.js.org/#/custom-sorting + tableSorting(a, b) { // ugly workaround, override default sort + if (Date.parse(a)) { // convert date to timestamp + a = Date.parse(a); + } + if (Date.parse(b)) { + b = Date.parse(b); + } + // force null and undefined to the bottom + a = (a === null || a === undefined) ? -Infinity : a; + b = (b === null || b === undefined) ? -Infinity : b; + // force any string values to lowercase + a = typeof a === 'string' ? a.toLowerCase() : a; + b = typeof b === 'string' ? b.toLowerCase() : b; + // Return either 1 or -1 to indicate a sort priority + if (a > b) { + return 1; + } + if (a < b) { + return -1; + } + // returning 0 or undefined will use any subsequent column sorting methods or the row index as a tiebreaker + return 0; + } + generateItemsListColumns() { let columns = []; @@ -356,13 +381,11 @@ class WalletsData extends React.Component { if (!this.state.itemsList || (this.state.coin && this.state.coin !== this.props.ActiveCoin.coin) || (JSON.stringify(this.props.ActiveCoin.txhistory) !== JSON.stringify(this.state.txhistory))) { - const sortedItemsList = this.indexTxHistory(sortByDate(this.props.ActiveCoin.txhistory, this.props.ActiveCoin.mode === 'basilisk' ? 'index' : 'confirmations')); - this.setState(Object.assign({}, this.state, { - itemsList: sortedItemsList, - filteredItemsList: this.filterTransactions(sortedItemsList, this.state.searchTerm), + itemsList: this.props.ActiveCoin.txhistory, + filteredItemsList: this.filterTransactions(this.props.ActiveCoin.txhistory, this.state.searchTerm), txhistory: this.props.ActiveCoin.txhistory, - showPagination: this.props.ActiveCoin.txhistory && this.props.ActiveCoin.txhistory.length >= this.state.defaultPageSize + showPagination: this.props.ActiveCoin.txhistory && this.props.ActiveCoin.txhistory.length >= this.state.defaultPageSize, })); } } @@ -379,7 +402,7 @@ class WalletsData extends React.Component { } this.setState({ - itemsListColumns: this.generateItemsListColumns() + itemsListColumns: this.generateItemsListColumns(), }); } @@ -428,7 +451,7 @@ class WalletsData extends React.Component { onPageSizeChange(pageSize, pageIndex) { this.setState(Object.assign({}, this.state, { pageSize: pageSize, - showPagination: this.state.itemsList && this.state.itemsList.length >= defaultPageSize, + showPagination: this.state.itemsList && this.state.itemsList.length >= this.state.defaultPageSize, })) } @@ -486,7 +509,7 @@ class WalletsData extends React.Component { } if (_amount !== 'N/A') { - _amount = formatValue('round', _amount, -6); + _amount = formatValue(_amount); } items.push( @@ -523,7 +546,7 @@ class WalletsData extends React.Component { let _amount = _addresses.public[i].amount; if (_amount !== 'N/A') { - _amount = formatValue('round', _amount, -6); + _amount = formatValue(_amount); } return _amount; @@ -538,7 +561,7 @@ class WalletsData extends React.Component { } if (_amount !== 'N/A') { - _amount = formatValue('round', _amount, -6); + _amount = formatValue(_amount); } return _amount; @@ -551,13 +574,15 @@ class WalletsData extends React.Component { } renderSelectorCurrentLabel() { - if (this.state.currentAddress) { + const _currentAddress = this.state.currentAddress; + + if (_currentAddress) { return (    [ { this.renderAddressAmount() } { this.props.ActiveCoin.coin } ]   - { this.state.currentAddress } + { _currentAddress } ); diff --git a/react/src/components/dashboard/walletsData/walletsData.render.js b/react/src/components/dashboard/walletsData/walletsData.render.js index 41c6b31..a8ac35a 100644 --- a/react/src/components/dashboard/walletsData/walletsData.render.js +++ b/react/src/components/dashboard/walletsData/walletsData.render.js @@ -155,7 +155,7 @@ export const TxAmountRender = function(tx) { if (Config.roundValues) { return ( - { formatValue('round', tx.amount, -6) * _amountNegative || translate('DASHBOARD.UNKNOWN') } + { formatValue(tx.amount) * _amountNegative || translate('DASHBOARD.UNKNOWN') } ); } @@ -177,6 +177,11 @@ export const TxHistoryListRender = function() { previousText={ translate('INDEX.PREVIOUS_PAGE') } showPaginationBottom={ this.state.showPagination } pageSize={ this.pageSize } + defaultSortMethod={ this.tableSorting } + defaultSorted={[{ // default sort + id: 'timestamp', + desc: true, + }]} onPageSizeChange={ (pageSize, pageIndex) => this.onPageSizeChange(pageSize, pageIndex) } /> ); }; diff --git a/react/src/components/main/main.js b/react/src/components/main/main.js index 74039aa..fe4b634 100644 --- a/react/src/components/main/main.js +++ b/react/src/components/main/main.js @@ -27,14 +27,17 @@ class Main extends React.Component { componentDidMount() { let appVersion; let zcashParamsExist; + let appConfig; try { appVersion = window.require('electron').remote.getCurrentWindow().appBasicInfo; + appConfig = window.require('electron').remote.getCurrentWindow().appConfig; zcashParamsExist = window.require('electron').remote.getCurrentWindow().zcashParamsExist; } catch (e) {} if (appVersion) { - document.title = `${appVersion.name} (v${appVersion.version.replace('version=', '')}-beta)`; + const _appMode = `${appConfig.iguanaLessMode ? ' - ' + translate('INDEX.NATIVE_ONLY_MODE') : ' - ' + translate('INDEX.NORMAL_MODE')}`; + document.title = `${appVersion.name} (v${appVersion.version.replace('version=', '')}-beta)${_appMode}`; } if (!zcashParamsExist) { diff --git a/react/src/translate/en.js b/react/src/translate/en.js index 26ae261..eded9b0 100644 --- a/react/src/translate/en.js +++ b/react/src/translate/en.js @@ -35,7 +35,7 @@ export const _lang = { 'ADDRESS_ALREADY_REG': 'Address already registered', 'COULDNT_COPY_ADDRESS': 'Couldn\'t copy address to clipboard', 'COULDNT_CREATE_SEED': 'Couldn\'t create new wallet seed', - 'WALLETDAT_MISMATCH': 'Your wallet.dat is not matching the blockchain. Please resync from the scratch.', + 'WALLETDAT_MISMATCH': 'Your wallet.dat is not matching the blockchain. Please restart the wallet with -reindex param.', 'PEER_ADDED': 'Peer is added', 'ADDNODE_ALREADY_PENDING': 'Addnode connection was already pending', 'PEER_ALREADY_CONN': 'Peer was already connected', @@ -46,6 +46,8 @@ export const _lang = { 'NO_ACTIVE_COIN': 'No active coin', }, 'INDEX': { + 'NATIVE_ONLY_MODE': 'Native only mode', + 'NORMAL_MODE': 'Normal mode', 'T_FUNDS': 'Transparent funds', 'HASH': 'Hash', 'SYNC_IN_PROGRESS': 'Synchronization is in progress', @@ -443,6 +445,8 @@ export const _lang = { 'QR_ERR_UNKNOWN': 'Error: unknown error!', }, 'TOASTR': { + 'KOMODO_DATADIR_INVALID': 'Komodo datadir path is invalid', + 'KOMODO_DATADIR_NOT_DIR': 'Komodo datadir path is not a directory', 'INVALID_ADDRESS': 'Invalid @template@ address', 'RESTART_AGAMA_WITH_REINDEX_PARAM': 'Restart Agama and run Komodo with -reindex param', 'JUMBLR_DEPOSIT_ADDRESS_SET': 'Jumblr deposit address is set', diff --git a/react/src/util/formatValue.js b/react/src/util/formatValue.js index c355e8f..a80f085 100644 --- a/react/src/util/formatValue.js +++ b/react/src/util/formatValue.js @@ -1,52 +1,24 @@ -// ref: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Math/round#Decimal_rounding -export function formatValue(formatType, formatValue, formatExp) { - let _formatExp; - /** - * Decimal adjustment of a number. - * - * @param {String} type The type of adjustment. - * @param {Number} value The number. - * @param {Integer} exp The exponent (the 10 logarithm of the adjustment base). - * @returns {Number} The adjusted value. - */ - function decimalAdjust(type, value, exp) { - // If the exp is undefined or zero... - if (typeof exp === 'undefined' || +exp === 0) { - return Math[type](value); - } - value = +value; - exp = +exp; - // If the value is not a number or the exp is not an integer... - if (isNaN(value) || !(typeof exp === 'number' && exp % 1 === 0)) { - return NaN; - } - // If the value is negative... - if (value < 0) { - return -decimalAdjust(type, -value, exp); - } - // Shift - value = value.toString().split('e'); - value = Math[type](+(value[0] + 'e' + (value[1] ? (+value[1] - exp) : -exp))); - // Shift back - value = value.toString().split('e'); - return +(value[0] + 'e' + (value[1] ? (+value[1] + exp) : exp)); - } +// display rounding +export function formatValue(formatValue) { + const _valueToStr = formatValue.toString(); - if (Math.abs(Number(formatValue)) >= 1) { - _formatExp = -3; + if (_valueToStr.indexOf('.') === -1) { + return formatValue; } else { - _formatExp = formatExp; - } + if (_valueToStr) { + const _decimal = _valueToStr.substr(_valueToStr.indexOf('.') + 1, _valueToStr.length); + let newVal = _valueToStr.substr(0, _valueToStr.indexOf('.') + 1); + + for (let i = 0; i < _decimal.length; i++) { + if (_decimal[i] === '0') { + newVal = newVal + _decimal[i]; + } else { + newVal = newVal + _decimal[i]; + break; + } + } - switch (formatType) { - case 'round': - return decimalAdjust('round', formatValue, _formatExp); - break; - case 'floor': - return decimalAdjust('floor', formatValue, _formatExp); - break; - case 'ceil': - return decimalAdjust('ceil', formatValue, _formatExp); - break; + return newVal; + } } } \ No newline at end of file