diff --git a/assets/mainWindow/css/loading.css b/assets/mainWindow/css/loading.css index 8782de6..5fbddc8 100644 --- a/assets/mainWindow/css/loading.css +++ b/assets/mainWindow/css/loading.css @@ -1,7 +1,7 @@ body { - overflow: hidden !important; border: solid 1px #ccc; - height: 300px; + user-select: none; + cursor: default; } .text-center { @@ -19,30 +19,41 @@ body { margin: auto; } -.pulse-loader { - position: absolute; - top: 10px; - left: -100px; - margin: 80px 50px; - width: 400px !important; -} - body.agamaMode { background-color: rgba(33, 33, 33, 0.85); padding-top: 40px; color: #fff; } +body.loading-window, +body.agama-default-window-height { + height: 355px; +} + +body.agama-app-settings-window { + height: 700px; +} + .agama-logo { padding-bottom: 20px; } #agamaModeStatus { - padding-bottom: 25px; + padding-bottom: 35px; font-weight: bold; font-size: 16px; } +.btn-info { + color: #fff; + background-color: #25b4c5 !important; + border-color: #25b4c5 !important; +} +.btn-info:hover { + background-color: #6cd2de !important; + border-color: #6cd2de !important; +} + .btn-primary.focus, .btn-primary:focus, .btn-primary:hover, @@ -67,8 +78,8 @@ body.agamaMode { font-size: 14px; line-height: 1.57142857; border-radius: 3px; - -webkit-box-shadow: 0 1px 4px 0 rgba(0,0,0,.1); - box-shadow: 0 1px 4px 0 rgba(0,0,0,.1); + -webkit-box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.1); + box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.1); -webkit-transition: border .2s linear,color .2s linear,width .2s linear,background-color .2s linear; -o-transition: border .2s linear,color .2s linear,width .2s linear,background-color .2s linear; transition: border .2s linear,color .2s linear,width .2s linear,background-color .2s linear; @@ -114,4 +125,326 @@ body.agamaMode { .app-closing { position: relative; top: 50px; +} + +.height--auto { + height: auto; +} + +.settings-title { + font-weight: bold; + margin-bottom: 30px; +} + +.margin-right-5 { + margin-right: 5px; +} +.margin-right-10 { + margin-right: 10px; +} +.margin-right-20 { + margin-right: 20px; +} +.margin-top-15 { + margin-top: 15px; +} +.margin-top-20 { + margin-top: 20px; +} + +.pull-left { + float: left; + margin-left: 50px; +} + +.btn-close { + border-bottom-left-radius: 50%; + background: #fff; + color: rgba(33, 33, 33, 0.85); + padding: 8px 10px; + font-weight: bold; + font-size: 20px; + position: absolute; + top: 0; + right: 0; + cursor: pointer; +} + +.btn-close img { + height: 12px; + position: relative; + top: -1px; + right: -1px; +} + +.btn-mode img { + height: 20px; + position: relative; + top: -1px; + left: -4px; + padding-right: 5px; +} + +/* settings */ +.settings-help { + position: relative; + top: -2px; + left: 10px; + color: #fff; + border-radius: 50%; + background: #5683ad; + display: inline-block; + padding: 4px 4px; + line-height: 30px; + cursor: default; +} + +.settings-help img { + height: 13px; +} + +.settings-buttons-block { + margin-top: 50px; + margin-right: 50px; + text-align: right; +} + +.settings-table { + margin: 0 auto; + width: 650px; + text-align: left; +} + +.settings-table input[type="number"] { + width: 100px; + padding: 0 4px; +} + +.settings-table input[type="text"] { + width: 100%; + padding: 0 4px; +} + +.settings-table td { + padding-bottom: 35px; +} + +.settings-table tr:last-child td { + padding: 0; +} + +.settings-table .left { + width: 50%; +} + +.settings-table .right { + width: 50%; + text-align: left; +} + +.agama-app-settings-window #agamaModeStatus { + padding-bottom: 50px; +} + +/* toggle */ +.slider { + border-radius: 20px; + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: #fff; + transition: .4s; +} +.switch input { + display: none; +} +input[type=checkbox], +input[type=radio] { + margin: 4px 0 0; + margin-top: 1px\9; + line-height: normal; +} +input[type=checkbox], +input[type=radio] { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + padding: 0; +} +.switch { + position: relative; + display: inline-block; + width: 40px; + height: 24px; +} +label { + font-weight: 300; +} +label { + display: inline-block; + max-width: 100%; + margin-bottom: 5px; + font-weight: 700; +} +input:checked + .slider { + background: #36ab7a; +} +input:checked + .slider:before { + background: #fff; +} +input:checked + .slider:before { + -ms-transform: translateX(16px); + transform: translateX(16px); +} +.slider:before { + content: ''; + display: inline-block; + border-radius: 50%; + position: absolute; + height: 20px; + width: 20px; + left: 2px; + bottom: 2px; + background-color: #ccc; + transition: .4s; +} +input[type="text"], +input[type="number"] { + color: rgb(33, 33, 33); +} + +/* toastr */ +#toast-container { + position: fixed; + z-index: 999999; +} +.toast-bottom-right { + right: 12px; + bottom: 12px; +} +#toast-container > .toast-success { + background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADsSURBVEhLY2AYBfQMgf///3P8+/evAIgvA/FsIF+BavYDDWMBGroaSMMBiE8VC7AZDrIFaMFnii3AZTjUgsUUWUDA8OdAH6iQbQEhw4HyGsPEcKBXBIC4ARhex4G4BsjmweU1soIFaGg/WtoFZRIZdEvIMhxkCCjXIVsATV6gFGACs4Rsw0EGgIIH3QJYJgHSARQZDrWAB+jawzgs+Q2UO49D7jnRSRGoEFRILcdmEMWGI0cm0JJ2QpYA1RDvcmzJEWhABhD/pqrL0S0CWuABKgnRki9lLseS7g2AlqwHWQSKH4oKLrILpRGhEQCw2LiRUIa4lwAAAABJRU5ErkJggg==) !important; +} +#toast-container > .toast-error { + background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHOSURBVEhLrZa/SgNBEMZzh0WKCClSCKaIYOED+AAKeQQLG8HWztLCImBrYadgIdY+gIKNYkBFSwu7CAoqCgkkoGBI/E28PdbLZmeDLgzZzcx83/zZ2SSXC1j9fr+I1Hq93g2yxH4iwM1vkoBWAdxCmpzTxfkN2RcyZNaHFIkSo10+8kgxkXIURV5HGxTmFuc75B2RfQkpxHG8aAgaAFa0tAHqYFfQ7Iwe2yhODk8+J4C7yAoRTWI3w/4klGRgR4lO7Rpn9+gvMyWp+uxFh8+H+ARlgN1nJuJuQAYvNkEnwGFck18Er4q3egEc/oO+mhLdKgRyhdNFiacC0rlOCbhNVz4H9FnAYgDBvU3QIioZlJFLJtsoHYRDfiZoUyIxqCtRpVlANq0EU4dApjrtgezPFad5S19Wgjkc0hNVnuF4HjVA6C7QrSIbylB+oZe3aHgBsqlNqKYH48jXyJKMuAbiyVJ8KzaB3eRc0pg9VwQ4niFryI68qiOi3AbjwdsfnAtk0bCjTLJKr6mrD9g8iq/S/B81hguOMlQTnVyG40wAcjnmgsCNESDrjme7wfftP4P7SP4N3CJZdvzoNyGq2c/HWOXJGsvVg+RA/k2MC/wN6I2YA2Pt8GkAAAAASUVORK5CYII=) !important; +} +#toast-container > div { + margin: 0 0 6px; + padding: 15px 15px 15px 50px; + width: 300px; + -moz-border-radius: 3px 3px 3px 3px; + -webkit-border-radius: 3px 3px 3px 3px; + border-radius: 3px 3px 3px 3px; + background-position: 15px center; + background-repeat: no-repeat; + color: #fff; +} +.toast-success { + background-color: #51a351; +} +.toast-error { + background-color: #bd362f; +} +.toast-title { + font-weight: bold; + text-align: left; + margin-left: 10px; +} +button.toast-close-button { + padding: 0; + cursor: pointer; + background: transparent; + border: 0; + -webkit-appearance: none; +} +.toast-close-button { + position: relative; + right: -0.3em; + top: -0.3em; + float: right; + font-size: 20px; + font-weight: bold; + color: #fff; + -webkit-text-shadow: 0 1px 0 #fff; + text-shadow: 0 1px 0 #fff; + opacity: .8; + -ms-filter: alpha(opacity=80); + filter: alpha(opacity=80); +} +.toast-message { + text-align: left; + margin-left: 10px; + -ms-word-wrap: break-word; + word-wrap: break-word; +} + +.test-bins { + text-align: left; + margin-top: 10px; + margin-left: 30px; +} + +.btn-caret { + display: inline-block; + position: relative; + left: -4px; + height: 36px; + border-bottom-left-radius: 0; + border-top-left-radius: 0; + box-shadow: none; + width: 38px; +} + +.btn-caret:before { + content: ''; + display: inline-block; + position: absolute; + height: 25px; + background: #fff; + width: 1px; + left: -2px; + top: 4px; +} + +.btn-caret img { + height: 14px; + position: absolute; + top: 10px; + left: 10px; +} + +.btn-native { + border-bottom-right-radius: 0; + border-top-right-radius: 0; +} + +.btn-native:hover + .btn-caret:before { + display: none; +} +.btn-caret:hover:before { + display: none; +} + +.dropdown-menu { + display: inherit; + top: inherit; + left: inherit; + right: 48%; + padding: 2px 0; +} + +.dropdown-menu li { + cursor: pointer; + margin: 5px 0; +} + +body.iguana-less { + height: 570px; +} +.iguana-less #iguanaCorePort, +.iguana-less #useBasiliskInstance { + display: none; } \ No newline at end of file diff --git a/assets/mainWindow/img/fa-caret-down.png b/assets/mainWindow/img/fa-caret-down.png new file mode 100644 index 0000000..437f0d1 Binary files /dev/null and b/assets/mainWindow/img/fa-caret-down.png differ diff --git a/assets/mainWindow/img/fa-caret-up.png b/assets/mainWindow/img/fa-caret-up.png new file mode 100644 index 0000000..a1c4f35 Binary files /dev/null and b/assets/mainWindow/img/fa-caret-up.png differ diff --git a/assets/mainWindow/img/fa-close.png b/assets/mainWindow/img/fa-close.png new file mode 100644 index 0000000..541cde8 Binary files /dev/null and b/assets/mainWindow/img/fa-close.png differ diff --git a/assets/mainWindow/img/fa-cogs.png b/assets/mainWindow/img/fa-cogs.png new file mode 100644 index 0000000..3faf854 Binary files /dev/null and b/assets/mainWindow/img/fa-cogs.png differ diff --git a/assets/mainWindow/img/fa-cube.png b/assets/mainWindow/img/fa-cube.png new file mode 100644 index 0000000..6d89cfa Binary files /dev/null and b/assets/mainWindow/img/fa-cube.png differ diff --git a/assets/mainWindow/img/fa-cubes.png b/assets/mainWindow/img/fa-cubes.png new file mode 100644 index 0000000..df37e21 Binary files /dev/null and b/assets/mainWindow/img/fa-cubes.png differ diff --git a/assets/mainWindow/img/fa-question.png b/assets/mainWindow/img/fa-question.png new file mode 100644 index 0000000..429d671 Binary files /dev/null and b/assets/mainWindow/img/fa-question.png differ diff --git a/assets/mainWindow/js/init.js b/assets/mainWindow/js/init.js index b7f1414..224f074 100644 --- a/assets/mainWindow/js/init.js +++ b/assets/mainWindow/js/init.js @@ -3,6 +3,12 @@ $(document).ready(function() { var window = remote.getCurrentWindow(); var appConf = remote.getCurrentWindow().appConfig; + if (!appConf.experimentalFeatures) { + $('#normalStartBtn').hide(); + $('.dropdown-menu').css('right', '34.8%'); + $('#nativeOnlyBtnCarret').css('margin-right', '0'); + } + $('#pulse').jRoll({ radius: 100, animation: 'pulse' diff --git a/assets/mainWindow/js/loading.js b/assets/mainWindow/js/loading.js index 0620761..51d01c8 100644 --- a/assets/mainWindow/js/loading.js +++ b/assets/mainWindow/js/loading.js @@ -1,59 +1,284 @@ - function closeMainWindow() { - const remote = require('electron').remote; - const window = remote.getCurrentWindow(); +let _configCopy; - window.createWindow('open'); - window.hide(); +function toggleDropdown() { + const _dropdown = $('.dropdown-menu'); + + if (_dropdown.hasClass('hide')) { + _dropdown.removeClass('hide'); + } else { + _dropdown.addClass('hide'); } +} - function quitApp() { - const remote = require('electron').remote; - const window = remote.getCurrentWindow(); +function initSettingsForm() { + const remote = require('electron').remote; + let appConf = remote.getCurrentWindow().appConfig; + let appConfSchema = remote.getCurrentWindow().appConfigSchema; + _configCopy = Object.assign({}, appConf); + + if (!appConf.experimentalFeatures) { + $('.agama-app-settings-window').addClass('iguana-less'); + } + + let _htmlOut = ''; + for (let key in appConf) { + if (appConfSchema[key] && + appConfSchema[key].initDisplay) { + _htmlOut = ` + ${_htmlOut} + + + + `; + } else if (appConfSchema[key].type === 'string' || appConfSchema[key].type === 'folder') { + _htmlOut = ` + ${_htmlOut} + + + `; + } else if (appConfSchema[key].type === 'boolean') { + _htmlOut = `${_htmlOut} + + + `; + } + } } - function normalStart() { + _htmlOut = ` + ${_htmlOut} +
+ ${appConfSchema[key].displayName}`; - window.forseCloseApp(); + if (appConfSchema[key].info) { + _htmlOut = ` + ${_htmlOut} +
+ +
`; + } + + if (appConfSchema[key].type === 'number') { + _htmlOut = ` + ${_htmlOut} +
+ +
+ +
+ +
`; + + $('#agamaConfigBlock').html(_htmlOut); +} + +function hideToastImmediate() { + $('#toast-container').addClass('hide'); +} + +function hideToast() { + setTimeout(function() { + $('#toast-container').addClass('hide'); + }, 5000); +} + +function showToast(type, message) { + $('#toast-container .toast').removeClass('toast-success').removeClass('toast-error'); + $('#toast-container .toast').addClass(`toast-${type}`); + $('#toast-container .toast-message').html(message); + $('#toast-container').removeClass('hide'); + hideToast(); +} + +function setDefaultAppSettings() { + const remote = require('electron').remote; + + remote.getCurrentWindow().setDefaultAppSettings(); + remote.getCurrentWindow().appConfig = remote.getCurrentWindow().defaultAppSettings; + initSettingsForm(); + showToast('success', 'App settings are reset to default'); +} + +function testBins(binName) { + const remote = require('electron').remote; + remote.getCurrentWindow().testBins(binName). + then(function(res) { + $('#debugOut').html(JSON.stringify(res, null, '\t')); + }); +} + +function handleSaveSettings() { + if (_configCopy.dataDir && + _configCopy.dataDir.length) { const remote = require('electron').remote; - let appConf = remote.getCurrentWindow().appConfig; - appConf.iguanaLessMode = false; - - // run iguana-less mode with no daemons startup - if (appConf && appConf.iguanaLessMode) { - // do something - } else { // run normal mode with 2 iguana instances started prior loading GUI - if (appConf && !appConf.manualIguanaStart) { - StartIguana(); + + remote.getCurrentWindow().testLocation(_configCopy.dataDir) + .then(function(res) { + $('#debugOut').html(res + ' | ' + _configCopy.dataDir); + if (res === -1) { + showToast('error', 'Komodo datadir path is invalid'); + } else if (res === false) { + showToast('error', 'Komodo datadir path is not a directory'); + } else { + // save settings + remote.getCurrentWindow().updateAppSettings(_configCopy); + remote.getCurrentWindow().appConfig = _configCopy; + showToast('success', 'Settings saved'); } + }); + } else { + // save settings + const remote = require('electron').remote; - var portcheck; + remote.getCurrentWindow().updateAppSettings(_configCopy); + remote.getCurrentWindow().appConfig = _configCopy; + showToast('success', 'Settings saved'); + } +} - function startcheck() { - portcheck = setInterval(function() { - Iguana_activehandle(appConf).then(function(result){ - console.log(result); +function handleInput(key) { + const _value = $(`#${key}`).val(); + _configCopy[key] = _value; +} - if (result !== 'error') { - stopcheck(); +function settingsToggle(key) { + const _value = $(`#${key} .cb`).prop('checked'); + _configCopy[key] = _value; +} - if (appConf && appConf.useBasiliskInstance) { - StartIguana_Cache(); - } +function closeSettingsWindow() { + const remote = require('electron').remote; + const window = remote.getCurrentWindow(); + + toggleDropdown(); + window.destroyAppSettingsWindow(); +} + +function reloadSettingsWindow() { + const remote = require('electron').remote; + const window = remote.getCurrentWindow(); - $('#loading_status_text').text('Connecting to Basilisk Network...'); - EDEX_DEXgetinfoAll(appConf.skipBasiliskNetworkCheck, appConf.minNotaries, appConf); + window.reloadSettingsWindow(); +} + +function openSettingsWindow() { + const remote = require('electron').remote; + const window = remote.getCurrentWindow(); + + $('.dropdown-menu').addClass('hide'); + window.createAppSettingsWindow(); +} + +function startKMDPassive() { + const remote = require('electron').remote; + const window = remote.getCurrentWindow(); + + $('.dropdown-menu').addClass('hide'); + disableModeButtons(); + + window.startKMDNative('KMD', true); + + window.createWindow('open'); + window.hide(); +} + +function closeMainWindow(isKmdOnly, isCustom) { + const remote = require('electron').remote; + const window = remote.getCurrentWindow(); + + $('.dropdown-menu').addClass('hide'); + disableModeButtons(); + + if (!isCustom) { + window.startKMDNative(isKmdOnly ? 'KMD' : null); + + setTimeout(function() { + window.createWindow('open'); + window.hide(); + }, 3000); + } else { + window.createWindow('open'); + window.hide(); + } +} + +function quitApp() { + const remote = require('electron').remote; + const window = remote.getCurrentWindow(); + + window.forseCloseApp(); +} + +function disableModeButtons() { + $('#nativeOnlyBtn').attr('disabled', true); + $('#normalStartBtn').attr('disabled', true); + $('#settingsBtn').attr('disabled', true); + $('#nativeOnlyBtnCarret').attr('disabled', true); +} + +function normalStart() { + const remote = require('electron').remote; + let appConf = remote.getCurrentWindow().appConfig; + appConf.iguanaLessMode = false; + + $('.dropdown-menu').addClass('hide'); + disableModeButtons(); + + // run iguana-less mode with no daemons startup + if (appConf && + appConf.iguanaLessMode) { + // do something + } else { // run normal mode with 2 iguana instances started prior loading GUI + if (appConf && + !appConf.manualIguanaStart) { + StartIguana(); + } + + var portcheck; + + function startcheck() { + portcheck = setInterval(function() { + Iguana_activehandle(appConf).then(function(result){ + console.log(result); + + if (result !== 'error') { + stopcheck(); + + if (appConf && appConf.useBasiliskInstance) { + StartIguana_Cache(); } - }) - }, 2000); - } - function stopcheck() { - clearInterval(portcheck); - } + $('#loading_status_text').text('Connecting to Basilisk Network...'); + EDEX_DEXgetinfoAll(appConf.skipBasiliskNetworkCheck, appConf.minNotaries, appConf); + } + }) + }, 2000); + } - startcheck(); + function stopcheck() { + clearInterval(portcheck); } + + startcheck(); } +} function IguanaAJAX(url, ajax_data, timeout) { return $.ajax({ diff --git a/react/change.log b/react/change.log index d856f0b..ff11909 100644 --- a/react/change.log +++ b/react/change.log @@ -8,7 +8,7 @@ UI: - minor placeholders fixes - hide address dropdown if wallet has only one address - komodod crash report modal -- values rounding (up to 6 decimals) +- values clipping - add coin multi ui reflow fix - reset app setting to default - manual balance / transactions list refresh @@ -26,6 +26,7 @@ UI: - coin daemon port check on addcoin - updated application settings - komodo datadir +- windows bins path fix v0.2.0.21a-beta -------------- diff --git a/react/src/actions/actionCreators.js b/react/src/actions/actionCreators.js index fd910e4..2086541 100644 --- a/react/src/actions/actionCreators.js +++ b/react/src/actions/actionCreators.js @@ -6,7 +6,6 @@ import { GET_ACTIVE_COINS, DASHBOARD_ACTIVE_ADDRESS, VIEW_CACHE_DATA, - DASHBOARD_DISPLAY_NOTARIES_MODAL, DASHBOARD_ACTIVE_COIN_MAIN_BASILISK_ADDR, DASHBOARD_ACTIVE_SECTION, DASHBOARD_ACTIVE_TXINFO_MODAL, @@ -29,13 +28,10 @@ import { DISPLAY_COIND_DOWN_MODAL, DISPLAY_CLAIM_INTEREST_MODAL, START_INTERVAL, - STOP_INTERVAL + STOP_INTERVAL, + DASHBOARD_SYNC_ONLY_UPDATE, + DISPLAY_IMPORT_KEY_MODAL, } from './storeType'; -import { - logGuiHttp, - getAgamaLog, - guiLogState -} from './actions/log'; export * from './actions/nativeSyncInfo'; export * from './actions/basiliskCache'; @@ -52,7 +48,6 @@ export * from './actions/sendFullBasilisk'; export * from './actions/settings'; export * from './actions/syncOnly'; export * from './actions/iguanaInstance'; -export * from './actions/notary'; export * from './actions/edexBalance'; export * from './actions/addCoin'; export * from './actions/addressBalance'; @@ -71,6 +66,7 @@ export * from './actions/cli'; export * from './actions/update'; export * from './actions/jumblr'; export * from './actions/interest'; +export * from './actions/nativeDashboardUpdate'; export function changeActiveAddress(address) { return { @@ -92,13 +88,6 @@ export function toggleViewCacheModal(display) { } } -export function displayNotariesModal(display) { - return { - type: DASHBOARD_DISPLAY_NOTARIES_MODAL, - display, - } -} - export function changeMainBasiliskAddress(address) { return { type: DASHBOARD_ACTIVE_COIN_MAIN_BASILISK_ADDR, @@ -121,34 +110,6 @@ export function toggleDashboardTxInfoModal(display, txIndex) { } } -export function basiliskConnectionState(display, json) { - return { - type: BASILISK_CONNECTION, - basiliskConnection: display, - progress: json, - } -} - -export function basiliskRefreshState(display, json) { - return { - type: BASILISK_REFRESH, - basiliskRefresh: display, - progress: json, - } -} - -export function basiliskRefresh(display) { - return dispatch => { - dispatch(basiliskRefreshState(display)); - } -} - -export function basiliskConnection(display) { - return dispatch => { - dispatch(basiliskConnectionState(display)); - } -} - export function syncingNativeModeState(display, json) { return { type: SYNCING_NATIVE_MODE, @@ -382,4 +343,18 @@ export function toggleClaimInterestModal(display) { type: DISPLAY_CLAIM_INTEREST_MODAL, displayClaimInterestModal: display, } +} + +export function skipFullDashboardUpdate(skip) { + return { + type: DASHBOARD_SYNC_ONLY_UPDATE, + skipFullDashboardUpdate: skip, + } +} + +export function displayImportKeyModal(display) { + return { + type: DISPLAY_IMPORT_KEY_MODAL, + displayImportKeyModal: display, + } } \ No newline at end of file diff --git a/react/src/actions/actions/addCoin.js b/react/src/actions/actions/addCoin.js index 0ebe38d..612a99d 100644 --- a/react/src/actions/actions/addCoin.js +++ b/react/src/actions/actions/addCoin.js @@ -7,10 +7,6 @@ import { startIguanaInstance, iguanaWalletPassphraseState, } from '../actionCreators'; -import { - logGuiHttp, - guiLogState -} from './log'; import { startCurrencyAssetChain, startAssetChain, @@ -96,31 +92,12 @@ export function addCoin(coin, mode, syncOnly, port, startupParams) { export function iguanaAddCoin(coin, mode, acData, port) { function _iguanaAddCoin(dispatch) { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'iguanaAddCoin', - type: 'post', - url: `http://127.0.0.1:${(port ? port : Config.iguanaCorePort)}`, - payload: acData, - status: 'pending', - })); - } - return fetch(`http://127.0.0.1:${(port ? port : Config.iguanaCorePort)}`, { method: 'POST', body: JSON.stringify(acData), }) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( translate('TOASTR.FAILED_TO_ADDCOIN'), @@ -131,13 +108,6 @@ export function iguanaAddCoin(coin, mode, acData, port) { }) .then(response => response.json()) .then(json => { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } dispatch( addCoinResult( coin, @@ -287,7 +257,7 @@ export function shepherdHerd(coin, mode, path, startupParams) { console.warn(acData); dispatch( triggerToaster( - `Error starting ${coin} daemon. Port ${acData.rpc} is already taken!`, + `Error starting ${coin} daemon. Port ${acData.rpc} is already taken!`, // translate translate('TOASTR.SERVICE_NOTIFICATION'), 'error', false @@ -372,7 +342,7 @@ export function iguanaActiveHandleBypass() { .then(response => response.json()) .then( json => dispatch( - iguanaWalletPassphraseState(json, dispatch) + iguanaWalletPassphraseState(json, dispatch, true) ) ) } diff --git a/react/src/actions/actions/addressBalance.js b/react/src/actions/actions/addressBalance.js index 1072b21..c286ca5 100644 --- a/react/src/actions/actions/addressBalance.js +++ b/react/src/actions/actions/addressBalance.js @@ -5,10 +5,6 @@ import { getPassthruAgent, iguanaHashHex } from '../actionCreators'; -import { - logGuiHttp, - guiLogState -} from './log'; import Config from '../../config'; function getKMDAddressesNativeState(json) { @@ -105,18 +101,6 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { }; } - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'getKMDAddressesNative', - type: 'post', - url: Config.cli.default ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - let _fetchConfig = { method: 'POST', body: JSON.stringify(payload), @@ -139,13 +123,6 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { ) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'getKMDAddressesNative', @@ -156,13 +133,6 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { }) .then(response => response.json()) .then(json => { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } resolve(Config.cli.default && mode === 'native' ? json.result : json); }) } @@ -307,16 +277,6 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { hex: hashHexJson, }; } - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'getKMDAddressesNative+ZBalance', - type: 'post', - url: Config.cli.default ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } let _fetchConfig = { method: 'POST', @@ -349,13 +309,6 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { ) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'getKMDAddressesNative+ZBalance', @@ -369,13 +322,6 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { if (json && json.error) { resolve(0); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: json, - })); - } dispatch( triggerToaster( 'getKMDAddressesNative+ZBalance', @@ -394,13 +340,6 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { amount: json, type: 'private', }; - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } } }); }); @@ -448,31 +387,12 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { if (json[coin][currentAddress].refresh) { calcBalance(result, json[coin][currentAddress].refresh.data, dispatch, mode); } else { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'getKMDAddressesNative+Balance', - type: 'post', - url: `http://127.0.0.1:${(Config.useBasiliskInstance && mode === 'basilisk' ? Config.iguanaCorePort + 1 : Config.iguanaCorePort)}`, - payload: payload, - status: 'pending', - })); - } - fetch(`http://127.0.0.1:${(Config.useBasiliskInstance && mode === 'basilisk' ? Config.iguanaCorePort + 1 : Config.iguanaCorePort)}`, { method: 'POST', body: JSON.stringify(payload), }) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'getKMDAddressesNative+Balance', @@ -483,13 +403,6 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { }) .then(response => response.json()) .then(function(json) { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } updatedCache.basilisk[coin][currentAddress].refresh = { data: json, status: 'done', @@ -506,18 +419,6 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { } }) } else { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'getKMDAddressesNative+Balance', - type: 'post', - url: `http://127.0.0.1:${(Config.useBasiliskInstance && mode === 'basilisk' ? Config.iguanaCorePort + 1 : Config.iguanaCorePort)}`, - payload: payload, - status: 'pending', - })); - } - let _fetchConfig = { method: 'POST', body: JSON.stringify(payload), @@ -547,13 +448,6 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { ) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'getKMDAddressesNative+Balance', @@ -568,13 +462,6 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { mode === 'native') { json = json.result; } - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } calcBalance( result, json, diff --git a/react/src/actions/actions/atomic.js b/react/src/actions/actions/atomic.js index 378942b..d28e724 100644 --- a/react/src/actions/actions/atomic.js +++ b/react/src/actions/actions/atomic.js @@ -1,38 +1,15 @@ import { ATOMIC } from '../storeType'; import { triggerToaster } from '../actionCreators'; -import { - logGuiHttp, - guiLogState -} from './log'; import Config from '../../config'; export function atomic(payload) { return dispatch => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'atomic', - type: 'post', - url: `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( payload.method, @@ -43,13 +20,6 @@ export function atomic(payload) { }) .then(response => response.json()) .then(json => { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } dispatch(atomicState(json)); }); } diff --git a/react/src/actions/actions/basiliskCache.js b/react/src/actions/actions/basiliskCache.js index f3c743c..8b9506d 100644 --- a/react/src/actions/actions/basiliskCache.js +++ b/react/src/actions/actions/basiliskCache.js @@ -1,9 +1,5 @@ import { DASHBOARD_ACTIVE_COIN_GET_CACHE } from '../storeType'; import { triggerToaster } from '../actionCreators'; -import { - logGuiHttp, - guiLogState -} from './log'; import Config from '../../config'; // TODO: rewrite cache API to use POST diff --git a/react/src/actions/actions/basiliskProcessAddress.js b/react/src/actions/actions/basiliskProcessAddress.js index fd91018..83e63e1 100644 --- a/react/src/actions/actions/basiliskProcessAddress.js +++ b/react/src/actions/actions/basiliskProcessAddress.js @@ -1,9 +1,5 @@ import { translate } from '../../translate/translate'; import { triggerToaster } from '../actionCreators'; -import { - logGuiHttp, - guiLogState -} from './log'; import Config from '../../config'; export function checkAddressBasilisk(coin, address) { @@ -16,31 +12,12 @@ export function checkAddressBasilisk(coin, address) { }; return dispatch => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'checkAddressBasilisk', - type: 'post', - url: `http://127.0.0.1:${Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - return fetch(`http://127.0.0.1:${Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'checkAddressBasilisk', @@ -51,13 +28,6 @@ export function checkAddressBasilisk(coin, address) { }) .then(response => response.json()) .then(json => { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } dispatch(checkAddressBasiliskHandle(json)); }) } @@ -102,31 +72,12 @@ export function validateAddressBasilisk(coin, address) { }; return dispatch => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'validateAddressBasilisk', - type: 'post', - url: `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - return fetch(`http://127.0.0.1:${Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'validateAddressBasilisk', @@ -137,13 +88,6 @@ export function validateAddressBasilisk(coin, address) { }) .then(response => response.json()) .then(json => { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } dispatch(validateAddressBasiliskHandle(json)); }) } diff --git a/react/src/actions/actions/basiliskTxHistory.js b/react/src/actions/actions/basiliskTxHistory.js index 06485a3..259a607 100644 --- a/react/src/actions/actions/basiliskTxHistory.js +++ b/react/src/actions/actions/basiliskTxHistory.js @@ -2,10 +2,6 @@ import { triggerToaster, getNativeTxHistoryState } from '../actionCreators'; -import { - logGuiHttp, - guiLogState -} from './log'; import Config from '../../config'; export function getBasiliskTransactionsList(coin, address) { diff --git a/react/src/actions/actions/cli.js b/react/src/actions/actions/cli.js index 11e223f..ca98443 100644 --- a/react/src/actions/actions/cli.js +++ b/react/src/actions/actions/cli.js @@ -1,9 +1,5 @@ import { triggerToaster } from '../actionCreators'; import { CLI } from '../storeType'; -import { - logGuiHttp, - guiLogState -} from './log'; import Config from '../../config'; export function shepherdCliPromise(mode, chain, cmd) { diff --git a/react/src/actions/actions/coinList.js b/react/src/actions/actions/coinList.js index f83ab43..3fa06dc 100644 --- a/react/src/actions/actions/coinList.js +++ b/react/src/actions/actions/coinList.js @@ -1,8 +1,4 @@ import { triggerToaster } from '../actionCreators'; -import { - logGuiHttp, - guiLogState -} from './log'; import Config from '../../config'; export function shepherdGetCoinList() { diff --git a/react/src/actions/actions/createWallet.js b/react/src/actions/actions/createWallet.js index 671c807..cc94cba 100644 --- a/react/src/actions/actions/createWallet.js +++ b/react/src/actions/actions/createWallet.js @@ -1,9 +1,5 @@ import { translate } from '../../translate/translate'; import { triggerToaster } from '../actionCreators'; -import { - logGuiHttp, - guiLogState -} from './log'; import Config from '../../config'; function createNewWalletState(json) { @@ -41,31 +37,12 @@ export function createNewWallet(_passphrase) { }; return dispatch => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'createNewWallet', - type: 'post', - url: `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'createNewWallet', @@ -76,13 +53,6 @@ export function createNewWallet(_passphrase) { }) .then(response => response.json()) .then(json => { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } dispatch(createNewWalletState(json)); }) } diff --git a/react/src/actions/actions/dexCoins.js b/react/src/actions/actions/dexCoins.js index 12697e5..a5bd20b 100644 --- a/react/src/actions/actions/dexCoins.js +++ b/react/src/actions/actions/dexCoins.js @@ -2,10 +2,6 @@ import { triggerToaster, dashboardCoinsState } from '../actionCreators'; -import { - logGuiHttp, - guiLogState -} from './log'; import Config from '../../config'; // TODO: find out why it errors on slow systems @@ -17,18 +13,6 @@ export function getDexCoins() { }; return dispatch => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'getDexCoins', - type: 'post', - url: Config.iguanaLessMode ? `http://127.0.0.1:${Config.agamaPort}/shepherd/InstantDEX/allcoins` : `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: _payload, - status: 'pending', - })); - } - let _fetchConfig = { method: 'POST', body: JSON.stringify(_payload), @@ -49,13 +33,6 @@ export function getDexCoins() { ) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'Error getDexCoins', @@ -66,13 +43,6 @@ export function getDexCoins() { }) .then(response => response.json()) .then(json => { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } dispatch(dashboardCoinsState(json)); }); } diff --git a/react/src/actions/actions/edexBalance.js b/react/src/actions/actions/edexBalance.js index 29a1b14..39be212 100644 --- a/react/src/actions/actions/edexBalance.js +++ b/react/src/actions/actions/edexBalance.js @@ -1,9 +1,5 @@ import { DASHBOARD_ACTIVE_COIN_BALANCE } from '../storeType'; import { triggerToaster } from '../actionCreators'; -import { - logGuiHttp, - guiLogState -} from './log'; import Config from '../../config'; export function iguanaEdexBalance(coin) { @@ -16,31 +12,12 @@ export function iguanaEdexBalance(coin) { return dispatch => { if (coin) { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'iguanaEdexBalance', - type: 'post', - url: `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: _payload, - status: 'pending', - })); - } - return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(_payload), }) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'Error iguanaEdexBalance', @@ -73,31 +50,12 @@ export function getDexBalance(coin, mode, addr) { }; return new Promise((resolve, reject) => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'getDexBalance', - type: 'post', - url: `http://127.0.0.1:${Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - fetch(`http://127.0.0.1:${Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'getDexBalance', @@ -109,13 +67,6 @@ export function getDexBalance(coin, mode, addr) { .then(response => response.json()) .then(json => { console.log(json); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } }) resolve(index); diff --git a/react/src/actions/actions/edexGetTx.js b/react/src/actions/actions/edexGetTx.js index 77b09d2..f95e64c 100644 --- a/react/src/actions/actions/edexGetTx.js +++ b/react/src/actions/actions/edexGetTx.js @@ -1,8 +1,4 @@ import { triggerToaster } from '../actionCreators'; -import { - logGuiHttp, - guiLogState -} from './log'; import Config from '../../config'; export function edexGetTransaction(data, dispatch) { @@ -16,31 +12,12 @@ export function edexGetTransaction(data, dispatch) { }; return new Promise((resolve, reject) => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'edexGetTransaction', - type: 'post', - url: `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'edexGetTransaction', @@ -51,13 +28,6 @@ export function edexGetTransaction(data, dispatch) { }) .then(response => response.json()) .then(json => { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } resolve(json); }) }); diff --git a/react/src/actions/actions/fullTxHistory.js b/react/src/actions/actions/fullTxHistory.js index cbc92a8..c3ffe3a 100644 --- a/react/src/actions/actions/fullTxHistory.js +++ b/react/src/actions/actions/fullTxHistory.js @@ -2,10 +2,6 @@ import { triggerToaster, getNativeTxHistoryState } from '../actionCreators'; -import { - logGuiHttp, - guiLogState -} from './log'; import Config from '../../config'; export function getFullTransactionsList(coin) { @@ -21,31 +17,12 @@ export function getFullTransactionsList(coin) { }; return dispatch => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'getFullTransactionsList', - type: 'post', - url: `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'getFullTransactionsList', @@ -56,13 +33,6 @@ export function getFullTransactionsList(coin) { }) .then(response => response.json()) .then(json => { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } dispatch(getNativeTxHistoryState(json)); }) } diff --git a/react/src/actions/actions/getAddrByAccount.js b/react/src/actions/actions/getAddrByAccount.js index 1797c4a..d77a46e 100644 --- a/react/src/actions/actions/getAddrByAccount.js +++ b/react/src/actions/actions/getAddrByAccount.js @@ -1,8 +1,4 @@ import { ACTIVE_COIN_GET_ADDRESSES } from '../storeType'; -import { - logGuiHttp, - guiLogState -} from './log'; import Config from '../../config'; export function getAddressesByAccountState(json, coin, mode) { @@ -36,31 +32,12 @@ export function getAddressesByAccount(coin, mode) { }; return dispatch => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'getAddressesByAccount', - type: 'post', - url: `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch(updateErrosStack('activeHandle')); dispatch( triggerToaster( @@ -72,13 +49,6 @@ export function getAddressesByAccount(coin, mode) { }) .then(response => response.json()) .then(json => { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } dispatch( getAddressesByAccountState( json, diff --git a/react/src/actions/actions/iguanaHelpers.js b/react/src/actions/actions/iguanaHelpers.js index 76a0f88..2b2560c 100644 --- a/react/src/actions/actions/iguanaHelpers.js +++ b/react/src/actions/actions/iguanaHelpers.js @@ -1,7 +1,3 @@ -import { - logGuiHttp, - guiLogState -} from './log'; import Config from '../../config'; import { checkAC } from '../../components/addcoin/payload'; @@ -29,31 +25,12 @@ export function iguanaHashHex(data, dispatch) { if (Config.cli.default) { resolve(true); } else { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'iguanaHashHex', - type: 'post', - url: `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'iguanaHashHex', @@ -64,13 +41,6 @@ export function iguanaHashHex(data, dispatch) { }) .then(response => response.json()) .then(json => { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } resolve(json.hex); }) } diff --git a/react/src/actions/actions/iguanaInstance.js b/react/src/actions/actions/iguanaInstance.js index 28b5870..42856da 100644 --- a/react/src/actions/actions/iguanaInstance.js +++ b/react/src/actions/actions/iguanaInstance.js @@ -1,8 +1,4 @@ import { triggerToaster } from '../actionCreators'; -import { - logGuiHttp, - guiLogState -} from './log'; import Config from '../../config'; export function restartIguanaInstance(pmid) { @@ -28,22 +24,6 @@ export function restartIguanaInstance(pmid) { }); } -export function restartBasiliskInstance() { - return dispatch => { - getIguanaInstancesList() - .then(function(json) { - for (let port in json.result) { - if (json.result[port].mode === 'basilisk') { - restartIguanaInstance(json.result[port].pmid) - .then(function(json) { - console.log('restartBasiliskInstance', json); - }); - } - } - }); - } -} - export function startIguanaInstance(mode, coin) { return new Promise((resolve, reject) => { fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/forks`, { diff --git a/react/src/actions/actions/interest.js b/react/src/actions/actions/interest.js index 1dd95c6..1db5941 100644 --- a/react/src/actions/actions/interest.js +++ b/react/src/actions/actions/interest.js @@ -1,10 +1,6 @@ import { triggerToaster } from '../actionCreators'; -import { - logGuiHttp, - guiLogState -} from './log'; import Config from '../../config'; export function getListUnspent(coin) { diff --git a/react/src/actions/actions/jumblr.js b/react/src/actions/actions/jumblr.js index 1b4a359..8dc7a61 100644 --- a/react/src/actions/actions/jumblr.js +++ b/react/src/actions/actions/jumblr.js @@ -2,10 +2,6 @@ import { triggerToaster, getNewKMDAddresses } from '../actionCreators'; -import { - logGuiHttp, - guiLogState -} from './log'; import Config from '../../config'; function getNewAddress(coin) { // TODO: remove(?) @@ -121,7 +117,7 @@ function dumpPrivkey(coin, key) { }); } -export function importPrivkey(coin, key) { +export function importPrivkey(coin, key, rescan = false) { return new Promise((resolve, reject) => { const payload = { mode: null, @@ -130,7 +126,7 @@ export function importPrivkey(coin, key) { params: [ key, '', - false + rescan ], }; diff --git a/react/src/actions/actions/log.js b/react/src/actions/actions/log.js deleted file mode 100644 index c53f402..0000000 --- a/react/src/actions/actions/log.js +++ /dev/null @@ -1,61 +0,0 @@ -import { LOG_GUI_HTTP } from '../storeType'; -import { triggerToaster } from '../actionCreators'; -import Config from '../../config'; - -export function logGuiHttp(payload) { - return dispatch => { - dispatch(guiLogState(payload)); - - // disabled for now - /*return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/guilog`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify(payload), - }) - .catch(function(error) { - console.log(error); - dispatch(triggerToaster('logGuiHttp', 'Error', 'error')); - }) - .then(response => response.json())*/ - } -} - -export function getAgamaLog(type) { - return dispatch => { - return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/getlog?type=${type}`, { - method: 'GET', - headers: { - 'Content-Type': 'application/json', - }, - }) - .catch(function(error) { - console.log(error); - dispatch( - triggerToaster( - 'getAgamaLog', - 'Error', - 'error' - ) - ); - }) - .then(response => response.json()) - } -} - -export function guiLogState(logData) { - return { - type: LOG_GUI_HTTP, - timestamp: logData.timestamp, - log: { - timestamp: logData.timestamp, - function: logData.function, - httpMethod: logData.type, - url: logData.url, - payload: logData.payload, - status: logData.status, - response: logData.response, - } - } -} \ No newline at end of file diff --git a/react/src/actions/actions/logout.js b/react/src/actions/actions/logout.js index f12fdef..3449245 100644 --- a/react/src/actions/actions/logout.js +++ b/react/src/actions/actions/logout.js @@ -4,10 +4,6 @@ import { } from '../storeType'; import { triggerToaster } from '../actionCreators'; import Config from '../../config'; -import { - logGuiHttp, - guiLogState -} from './log'; function logoutState(json) { sessionStorage.removeItem('IguanaActiveAccount'); @@ -38,31 +34,12 @@ function walletLock() { }; return dispatch => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'walletLock', - type: 'post', - url: `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'walletLock', @@ -73,13 +50,6 @@ function walletLock() { }) .then(response => response.json()) .then(json => { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } dispatch(logoutState(json)); dispatch(logoutResetAppState()); }) diff --git a/react/src/actions/actions/nativeBalance.js b/react/src/actions/actions/nativeBalance.js index 93a9e14..1f545ec 100644 --- a/react/src/actions/actions/nativeBalance.js +++ b/react/src/actions/actions/nativeBalance.js @@ -4,10 +4,6 @@ import { getPassthruAgent } from '../actionCreators'; import Config from '../../config'; -import { - logGuiHttp, - guiLogState -} from './log'; export function getKMDBalanceTotal(coin) { let payload; @@ -41,18 +37,6 @@ export function getKMDBalanceTotal(coin) { } return dispatch => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'getKMDBalanceTotal', - type: 'post', - url: Config.cli.default ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - let _fetchConfig = { method: 'POST', body: JSON.stringify(payload), @@ -74,13 +58,6 @@ export function getKMDBalanceTotal(coin) { ) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'getKMDBalanceTotal', @@ -91,13 +68,6 @@ export function getKMDBalanceTotal(coin) { }) .then(response => response.json()) .then(function(json) { // TODO: figure out why komodod spits out "parse error" - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } if (json && !json.error) { dispatch(getNativeBalancesState(json)); diff --git a/react/src/actions/actions/nativeDashboardUpdate.js b/react/src/actions/actions/nativeDashboardUpdate.js new file mode 100644 index 0000000..319c85d --- /dev/null +++ b/react/src/actions/actions/nativeDashboardUpdate.js @@ -0,0 +1,86 @@ +import { + triggerToaster, +} from '../actionCreators'; +import Config from '../../config'; +import { DASHBOARD_UPDATE } from '../storeType'; + +export function getDashboardUpdate(coin, activeCoinProps) { + return dispatch => { + const _fetchConfig = { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ coin: coin }), + }; + + return fetch( + `http://127.0.0.1:${Config.agamaPort}/shepherd/native/dashboard/update`, + _fetchConfig + ) + .catch(function(error) { + console.log(error); + dispatch( + triggerToaster( + 'getDashboardUpdate', + 'Error', + 'error' + ) + ); + }) + .then(response => response.json()) + .then(json => { + dispatch(getDashboardUpdateState(json, coin)); + + // dirty hack to trigger dashboard render + if (!activeCoinProps.balance && + !activeCoinProps.addresses) { + setTimeout(() => { + dispatch(getDashboardUpdateState(json, coin)); + }, 100); + } + }) + } +} + +export function getDashboardUpdateState(json, coin, fakeResponse) { + // rescan or similar resource heavy process + if (fakeResponse || + ((json.result['getinfo'].error && json.result['getinfo'].error === 'daemon is busy') && + (json.result['z_getoperationstatus'].error && json.result['z_getoperationstatus'].error === 'daemon is busy') && + (json.result['listtransactions'].error && json.result['listtransactions'].error === 'daemon is busy') && + (json.result['listtransactions'].error && json.result['listtransactions'].error === 'daemon is busy'))) { + return { + type: DASHBOARD_UPDATE, + progress: null, + opids: null, + txhistory: null, + balance: null, + addresses: null, + coin: coin, + rescanInProgress: true, + }; + } else { + let _listtransactions = json.result['listtransactions']; + + if (_listtransactions && + _listtransactions.error) { + _listtransactions = null; + } else if (_listtransactions && _listtransactions.result && _listtransactions.result.length) { + _listtransactions = _listtransactions.result; + } else if (!_listtransactions || (!_listtransactions.result || !_listtransactions.result.length)) { + _listtransactions = 'no data'; + } + + return { + type: DASHBOARD_UPDATE, + progress: json.result['getinfo'].result, + opids: json.result['z_getoperationstatus'].result, + txhistory: _listtransactions, + balance: json.result['z_gettotalbalance'].result, + addresses: json.result['addresses'], + coin: coin, + rescanInProgress: false, + }; + } +} \ No newline at end of file diff --git a/react/src/actions/actions/nativeNewAddress.js b/react/src/actions/actions/nativeNewAddress.js index de3c376..96e163b 100644 --- a/react/src/actions/actions/nativeNewAddress.js +++ b/react/src/actions/actions/nativeNewAddress.js @@ -5,10 +5,6 @@ import { getKMDAddressesNative } from '../actionCreators'; import Config from '../../config'; -import { - logGuiHttp, - guiLogState -} from './log'; export function getNewKMDAddresses(coin, pubpriv, mode) { let payload; @@ -34,18 +30,6 @@ export function getNewKMDAddresses(coin, pubpriv, mode) { } return dispatch => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'getNewKMDAddresses', - type: 'post', - url: Config.cli.default ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - let _fetchConfig = { method: 'POST', body: JSON.stringify(payload), @@ -73,13 +57,6 @@ export function getNewKMDAddresses(coin, pubpriv, mode) { ) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'getNewKMDAddresses', @@ -93,13 +70,6 @@ export function getNewKMDAddresses(coin, pubpriv, mode) { if (Config.cli.default) { json = json.result; } - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } dispatch( triggerToaster( json.result ? json.result : json, diff --git a/react/src/actions/actions/nativeSend.js b/react/src/actions/actions/nativeSend.js index 17032ed..ca28f88 100644 --- a/react/src/actions/actions/nativeSend.js +++ b/react/src/actions/actions/nativeSend.js @@ -5,10 +5,6 @@ import { getPassthruAgent, iguanaHashHex } from '../actionCreators'; -import { - logGuiHttp, - guiLogState -} from './log'; import Config from '../../config'; export function sendNativeTx(coin, _payload) { @@ -47,18 +43,6 @@ export function sendNativeTx(coin, _payload) { }; } - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'sendNativeTx', - type: 'post', - url: Config.cli.default ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - let _fetchConfig = { method: 'POST', body: JSON.stringify(payload), @@ -110,13 +94,6 @@ export function sendNativeTx(coin, _payload) { ) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'sendNativeTx', @@ -130,14 +107,6 @@ export function sendNativeTx(coin, _payload) { return _response; }) .then(function(json) { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } - if (json.indexOf('"code":') > -1) { const _message = json.substring( `${json.indexOf('"message":"')}11`, @@ -230,18 +199,6 @@ export function getKMDOPID(opid, coin) { }; } - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'getKMDOPID', - type: 'post', - url: Config.cli.default ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - let _fetchConfig = { method: 'POST', body: JSON.stringify(payload), @@ -251,7 +208,7 @@ export function getKMDOPID(opid, coin) { payload = { mode: null, chain: coin, - cmd: 'z_getoperationstatus' + cmd: 'z_getoperationstatus', }; _fetchConfig = { @@ -269,13 +226,6 @@ export function getKMDOPID(opid, coin) { ) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'getKMDOPID', @@ -289,13 +239,6 @@ export function getKMDOPID(opid, coin) { if (Config.cli.default) { json = json.result; } - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } dispatch(getKMDOPIDState(json)); }) }) @@ -342,6 +285,6 @@ export function sendToAddressPromise(coin, address, amount) { .then(response => response.json()) .then(json => { resolve(json); - }) + }); }); } \ No newline at end of file diff --git a/react/src/actions/actions/nativeSyncInfo.js b/react/src/actions/actions/nativeSyncInfo.js index 60cabc4..783fbe5 100644 --- a/react/src/actions/actions/nativeSyncInfo.js +++ b/react/src/actions/actions/nativeSyncInfo.js @@ -1,98 +1,105 @@ -import { SYNCING_NATIVE_MODE } from '../storeType'; +import { + SYNCING_NATIVE_MODE, + DASHBOARD_ACTIVE_COIN_GETINFO_FAILURE +} from '../storeType'; import { triggerToaster, getPassthruAgent, getDebugLog, toggleCoindDownModal } from '../actionCreators'; -import { - logGuiHttp, - guiLogState -} from './log'; import Config from '../../config'; -export function getSyncInfoNativeKMD(skipDebug, json) { - const coin = 'KMD'; - // https://www.kmd.host/ - return dispatch => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'getSyncInfoNativeKMD', - type: 'post', - url: Config.iguanaLessMode ? 'http://kmd.explorer.supernet.org/api/status?q=getInfo' : `http://127.0.0.1:${Config.iguanaCorePort}/api/dex/getinfo?userpass=tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}&symbol=${coin}`, - payload: '', - status: 'pending', - })); - } +export function nativeGetinfoFailureState() { + return { + type: DASHBOARD_ACTIVE_COIN_GETINFO_FAILURE, + } +} + +// TODO: use debug.log instead +export function getSyncInfoNativeKMD(skipDebug, json, skipRemote) { + let _json = json; + + if (skipRemote) { + return dispatch => { + dispatch(getSyncInfoNativeState(Config.iguanaLessMode ? json.info : json )); - return fetch( - Config.iguanaLessMode ? 'http://kmd.explorer.supernet.org/api/status?q=getInfo' : `http://127.0.0.1:${Config.iguanaCorePort}/api/dex/getinfo?userpass=tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}&symbol=${coin}`, { - method: 'GET', - }) - .catch(function(error) { - console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } - /*dispatch( - triggerToaster( - 'getSyncInfoNativeKMD', - 'Error', - 'error' - ) - );*/ - console.warn('remote kmd node fetch failed', true); - dispatch(getSyncInfoNativeState({ remoteKMDNode: null })); - }) - .then(response => response.json()) - .then(json => { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: Config.iguanaLessMode ? json.info : json, - })); - } - dispatch(getSyncInfoNativeState({ remoteKMDNode: Config.iguanaLessMode ? json.info : json })); - }) - .then(function() { if (!skipDebug) { dispatch(getDebugLog('komodo', 1)); } - }) + } + } else { + const coin = 'KMD'; + // https://www.kmd.host/ + return dispatch => { + return fetch( + Config.iguanaLessMode ? 'https://kmd.explorer.supernet.org/api/status?q=getInfo' : `http://127.0.0.1:${Config.iguanaCorePort}/api/dex/getinfo?userpass=tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}&symbol=${coin}`, { + method: 'GET', + }) + .catch(function(error) { + console.log(error); + /*dispatch( + triggerToaster( + 'getSyncInfoNativeKMD', + 'Error', + 'error' + ) + );*/ + console.warn('remote kmd node fetch failed', true); + _json = _json.error; + _json['remoteKMDNode'] = null; + dispatch(getSyncInfoNativeState(_json)); + }) + .then(response => response.json()) + .then(json => { + _json = _json.error; + _json['remoteKMDNode'] = json.info; + dispatch(getSyncInfoNativeState(_json)); + }) + .then(function() { + if (!skipDebug) { + dispatch(getDebugLog('komodo', 1)); + } + }) + } } } -function getSyncInfoNativeState(json, coin, skipDebug) { - if (coin === 'KMD' && - json && - json.error && - json.error.message.indexOf('Activating best') === -1) { - return getSyncInfoNativeKMD(skipDebug, json); +function getSyncInfoNativeState(json, coin, skipDebug, skipRemote) { + /*if (!json.remoteKMDNode) { + json = { error: { code: -28, message: 'Activating best chain...' } }; + }*/ + + if (json.remoteKMDNode) { + return { + type: SYNCING_NATIVE_MODE, + progress: json, + } } else { - if (json && + if (coin === 'KMD' && + json && json.error && - Config.cli.default) { - return { - type: SYNCING_NATIVE_MODE, - progress: json.error, - } + json.error.message.indexOf('Activating best') > -1) { + return getSyncInfoNativeKMD(skipDebug, json, skipRemote); } else { - return { - type: SYNCING_NATIVE_MODE, - progress: json.result ? json.result : json, + if (json && + json.error && + Config.cli.default) { + return { + type: SYNCING_NATIVE_MODE, + progress: json.error, + } + } else { + return { + type: SYNCING_NATIVE_MODE, + progress: json.result ? json.result : json, + } } } } } -export function getSyncInfoNative(coin, skipDebug) { +export function getSyncInfoNative(coin, skipDebug, skipRemote, suppressErrors) { let payload = { userpass: `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, agent: getPassthruAgent(coin), @@ -111,17 +118,6 @@ export function getSyncInfoNative(coin, skipDebug) { } return dispatch => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'getSyncInfo', - type: 'post', - url: Config.cli.default ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } let _fetchConfig = { method: 'POST', body: JSON.stringify(payload), @@ -143,20 +139,15 @@ export function getSyncInfoNative(coin, skipDebug) { ) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); + if (!suppressErrors) { // rescan case + dispatch( + triggerToaster( + 'getSyncInfo', + 'Error', + 'error' + ) + ); } - dispatch( - triggerToaster( - 'getSyncInfo', - 'Error', - 'error' - ) - ); }) .then(function(response) { const _response = response.text().then(function(text) { return text; }); @@ -164,6 +155,11 @@ export function getSyncInfoNative(coin, skipDebug) { }) .then(json => { if (json === 'Work queue depth exceeded') { + if (coin === 'KMD') { + dispatch(getDebugLog('komodo', 100)); + } else { + dispatch(getDebugLog('komodo', 100, coin)); + } dispatch( getSyncInfoNativeState( { @@ -172,20 +168,39 @@ export function getSyncInfoNative(coin, skipDebug) { id: null }, coin, - skipDebug + true, + skipRemote ) ); } else { if (!json && Config.cli.default) { - dispatch( - triggerToaster( - 'Komodod is down', - 'Critical Error', - 'error', - true - ) - ); + let _kmdMainPassiveMode; + + try { + _kmdMainPassiveMode = window.require('electron').remote.getCurrentWindow().kmdMainPassiveMode; + } catch (e) {} + + if (!_kmdMainPassiveMode) { + dispatch(nativeGetinfoFailureState()); + /* dispatch( + triggerToaster( + 'Komodod is down', + 'Critical Error', + 'error', + true + ) + ); */ + } else { + dispatch( + triggerToaster( + 'Please make sure to run komodod manually', + 'Connection error', + 'warning', + true + ) + ); + } if (coin === 'KMD') { dispatch(getDebugLog('komodo', 50)); @@ -206,18 +221,12 @@ export function getSyncInfoNative(coin, skipDebug) { } } - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } dispatch( getSyncInfoNativeState( json, coin, - skipDebug + skipDebug, + skipRemote ) ); } diff --git a/react/src/actions/actions/nativeTxHistory.js b/react/src/actions/actions/nativeTxHistory.js index 5cba39c..2a0c19f 100644 --- a/react/src/actions/actions/nativeTxHistory.js +++ b/react/src/actions/actions/nativeTxHistory.js @@ -4,10 +4,6 @@ import { getNativeTxHistoryState } from '../actionCreators'; import Config from '../../config'; -import { - logGuiHttp, - guiLogState -} from './log'; export function getNativeTxHistory(coin) { let payload; @@ -32,18 +28,6 @@ export function getNativeTxHistory(coin) { } return dispatch => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'getNativeTxHistory', - type: 'post', - url: Config.cli.default ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - let _fetchConfig = { method: 'POST', body: JSON.stringify(payload), @@ -71,13 +55,6 @@ export function getNativeTxHistory(coin) { ) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'getNativeTxHistory', @@ -88,13 +65,6 @@ export function getNativeTxHistory(coin) { }) .then(response => response.json()) .then(json => { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } dispatch(getNativeTxHistoryState(json)); }) } diff --git a/react/src/actions/actions/notary.js b/react/src/actions/actions/notary.js deleted file mode 100644 index 23c7479..0000000 --- a/react/src/actions/actions/notary.js +++ /dev/null @@ -1,223 +0,0 @@ -import { - DASHBOARD_CONNECT_NOTARIES, - DASHBOARD_GET_NOTARIES_LIST -} from '../storeType'; -import { translate } from '../../translate/translate'; -import { triggerToaster } from '../actionCreators'; -import Config from '../../config'; -import { - logGuiHttp, - guiLogState -} from './log'; - -function initNotaryNodesConSequence(nodes) { - return dispatch => { - Promise.all(nodes.map((node, index) => { - const payload = { - userpass: `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, - agent: 'dex', - method: 'getinfo', - symbol: node, - timeout: 10000, - }; - - return new Promise((resolve, reject) => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: `initNotaryNodesConSequence+${node}`, - type: 'post', - url: `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - - fetch(`http://127.0.0.1:${(Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort)}/api/dex/getinfo?userpass=${('tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'))}&symbol=${node}`, { - method: 'GET', - }) - .catch(function(error) { - console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } - dispatch( - triggerToaster( - `getInfoDexNode+${node}`, - 'Error', - 'error' - ) - ); - }) - .then(response => response.json()) - .then(json => { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } - dispatch( - updateNotaryNodeConState( - json, - nodes.length, - index, - node - ) - ); - }) - }); - })); - } -} - -function updateNotaryNodeConState(json, totalNodes, currentNodeIndex, currentNodeName) { - if (currentNodeIndex === totalNodes - 1) { - return dispatch => { - dispatch(basiliskConnectionState(false)); - }; - } else { - if (json && - json.error === 'less than required responses') { - return { - type: DASHBOARD_CONNECT_NOTARIES, - total: totalNodes - 1, - current: currentNodeIndex, - name: currentNodeName, - failedNode: currentNodeName, - } - } else { - return { - type: DASHBOARD_CONNECT_NOTARIES, - total: totalNodes - 1, - current: currentNodeIndex, - name: currentNodeName, - } - } - } -} - -function connectAllNotaryNodes(json, dispatch) { - if (json && - json.length) { - dispatch(initNotaryNodesConSequence(json)); - - return { - type: DASHBOARD_CONNECT_NOTARIES, - total: json.length - 1, - current: 0, - name: json[0], - } - } -} - -export function connectNotaries() { - const payload = { - userpass: `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, - agent: 'dpow', - method: 'notarychains', - }; - - return dispatch => { - return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { - method: 'POST', - body: JSON.stringify(payload), - }) - .catch(function(error) { - console.log(error); - dispatch( - triggerToaster( - 'connectNotaries', - 'Error', - 'error' - ) - ); - }) - .then(response => response.json()) - .then( - json => dispatch( - connectAllNotaryNodes(json, dispatch) - ) - ) - } -} - -function getDexNotariesState(json) { - if (json.error === 'less than required responses') { - return dispatch => { - dispatch( - triggerToaster( - translate('TOASTR.LESS_RESPONSES_REQ'), - translate('TOASTR.BASILISK_NOTIFICATION'), - 'error' - ) - ); - } - } else { - return { - type: DASHBOARD_GET_NOTARIES_LIST, - notaries: json, - } - } -} - -export function getDexNotaries(coin) { - const payload = { - userpass: `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, - agent: 'dex', - method: 'getnotaries', - symbol: coin, - }; - - return dispatch => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'getDexNotaries', - type: 'post', - url: `http://127.0.0.1:${Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - return fetch(`http://127.0.0.1:${Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort}`, { - method: 'POST', - body: JSON.stringify(payload), - }) - .catch(function(error) { - console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } - dispatch( - triggerToaster( - 'getDexNotaries', - 'Error', - 'error' - ) - ); - }) - .then(response => response.json()) - .then(json => { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } - dispatch(getDexNotariesState(json)); - }) - } -} \ No newline at end of file diff --git a/react/src/actions/actions/openAlias.js b/react/src/actions/actions/openAlias.js index f7edec3..14b0801 100644 --- a/react/src/actions/actions/openAlias.js +++ b/react/src/actions/actions/openAlias.js @@ -1,8 +1,4 @@ import { triggerToaster } from '../actionCreators'; -import { - logGuiHttp, - guiLogState -} from './log'; export function resolveOpenAliasAddress(email) { const url = email.replace('@', '.'); diff --git a/react/src/actions/actions/sendFullBasilisk.js b/react/src/actions/actions/sendFullBasilisk.js index 9b78aa6..a3bdd51 100644 --- a/react/src/actions/actions/sendFullBasilisk.js +++ b/react/src/actions/actions/sendFullBasilisk.js @@ -5,10 +5,6 @@ import { getDispatch } from '../actionCreators'; import Config from '../../config'; -import { - logGuiHttp, - guiLogState -} from './log'; export function sendToAddress(coin, _payload) { const payload = { @@ -24,31 +20,12 @@ export function sendToAddress(coin, _payload) { }; return dispatch => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'sendToAddress', - type: 'post', - url: `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'sendToAddress', @@ -59,13 +36,6 @@ export function sendToAddress(coin, _payload) { }) .then(response => response.json()) .then(json => { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } dispatch(sendToAddressState(json, dispatch)); }) } @@ -86,31 +56,12 @@ export function sendFromAddress(coin, _payload) { }; return dispatch => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'sendFromAddress', - type: 'post', - url: `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'sendFromAddress', @@ -121,13 +72,6 @@ export function sendFromAddress(coin, _payload) { }) .then(response => response.json()) .then(json => { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } dispatch(sendToAddressState(json, dispatch)); }) } @@ -151,31 +95,12 @@ export function iguanaUTXORawTX(data, dispatch) { }; return new Promise((resolve, reject) => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'iguanaUTXORawTX', - type: 'post', - url: `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch => dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'iguanaUTXORawTX', @@ -186,13 +111,6 @@ export function iguanaUTXORawTX(data, dispatch) { }) .then(response => response.json()) .then(json => { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } resolve(json); }) }); @@ -208,31 +126,12 @@ export function dexSendRawTX(data, dispatch) { }; return new Promise((resolve, reject) => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'dexSendRawTX', - type: 'post', - url: `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - - fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'dexSendRawTX', @@ -247,13 +146,6 @@ export function dexSendRawTX(data, dispatch) { return _response; }) .then(function(json) { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } resolve(json); }) }); diff --git a/react/src/actions/actions/settings.js b/react/src/actions/actions/settings.js index f4cdab3..aa5afdb 100644 --- a/react/src/actions/actions/settings.js +++ b/react/src/actions/actions/settings.js @@ -8,10 +8,6 @@ import { import { translate } from '../../translate/translate'; import { triggerToaster } from '../actionCreators'; import Config from '../../config'; -import { - logGuiHttp, - guiLogState -} from './log'; function getAppInfoState(json) { return { @@ -56,7 +52,7 @@ function parseImportPrivKeyResponse(json, dispatch) { return dispatch => { dispatch( triggerToaster( - transalte('API.ILLEGAL_PRIVKEY'), + translate('API.ILLEGAL_PRIVKEY'), translate('TOASTR.SETTINGS_NOTIFICATION'), 'error' ) @@ -67,7 +63,7 @@ function parseImportPrivKeyResponse(json, dispatch) { return dispatch => { dispatch( triggerToaster( - transalte('API.PRIVKEY_IN_WALLET'), + translate('API.PRIVKEY_IN_WALLET'), translate('TOASTR.SETTINGS_NOTIFICATION'), 'warning' ) @@ -100,31 +96,12 @@ export function importPrivKey(wifKey) { }; return dispatch => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'importPrivKey', - type: 'post', - url: `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'importPrivKey', @@ -135,13 +112,6 @@ export function importPrivKey(wifKey) { }) .then(response => response.json()) .then(json => { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } dispatch( parseImportPrivKeyResponse( json, @@ -209,31 +179,12 @@ export function getPeersList(coin) { }; return dispatch => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'getPeersList', - type: 'post', - url: `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'getPeersList', @@ -244,13 +195,6 @@ export function getPeersList(coin) { }) .then(response => response.json()) .then(json => { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } dispatch(getPeersListState(json, dispatch)); }) } @@ -331,31 +275,12 @@ export function addPeerNode(coin, ip) { }; return dispatch => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'addPeerNode', - type: 'post', - url: `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'addPeerNode', @@ -366,13 +291,6 @@ export function addPeerNode(coin, ip) { }) .then(response => response.json()) .then(json => { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } dispatch(addPeerNodeState(json, dispatch)); }) } diff --git a/react/src/actions/actions/syncInfo.js b/react/src/actions/actions/syncInfo.js index 157911a..56ce526 100644 --- a/react/src/actions/actions/syncInfo.js +++ b/react/src/actions/actions/syncInfo.js @@ -1,10 +1,6 @@ import { SYNCING_FULL_MODE } from '../storeType'; import { triggerToaster } from '../actionCreators'; import Config from '../../config'; -import { - logGuiHttp, - guiLogState -} from './log'; // TODO: add custom json parser function getSyncInfoState(json) { @@ -30,31 +26,12 @@ export function getSyncInfo(coin) { }; return dispatch => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'getSyncInfo', - type: 'post', - url: `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'getSyncInfo', @@ -69,13 +46,6 @@ export function getSyncInfo(coin) { return _response; }) .then(function(json) { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } if (json.indexOf('coin is busy processing') === -1) { dispatch(getSyncInfoState(json, dispatch)); } diff --git a/react/src/actions/actions/syncOnly.js b/react/src/actions/actions/syncOnly.js index d98aef4..44d32e3 100644 --- a/react/src/actions/actions/syncOnly.js +++ b/react/src/actions/actions/syncOnly.js @@ -5,10 +5,6 @@ import { import { translate } from '../../translate/translate'; import Config from '../../config'; import { triggerToaster } from '../actionCreators'; -import { - logGuiHttp, - guiLogState -} from './log'; export function toggleSyncOnlyModal(display) { return { diff --git a/react/src/actions/actions/sysInfo.js b/react/src/actions/actions/sysInfo.js index 597e53f..9a4b15b 100644 --- a/react/src/actions/actions/sysInfo.js +++ b/react/src/actions/actions/sysInfo.js @@ -1,9 +1,5 @@ import { triggerToaster } from '../actionCreators'; import Config from '../../config'; -import { - logGuiHttp, - guiLogState -} from './log'; export function shepherdGetSysInfo() { return dispatch => { diff --git a/react/src/actions/actions/update.js b/react/src/actions/actions/update.js index 7ddd761..4210fdc 100644 --- a/react/src/actions/actions/update.js +++ b/react/src/actions/actions/update.js @@ -1,9 +1,5 @@ import { triggerToaster } from '../actionCreators'; import Config from '../../config'; -import { - logGuiHttp, - guiLogState -} from './log'; export function checkForUpdateUIPromise() { return new Promise((resolve, reject) => { diff --git a/react/src/actions/actions/walletAuth.js b/react/src/actions/actions/walletAuth.js index c73d920..5959420 100644 --- a/react/src/actions/actions/walletAuth.js +++ b/react/src/actions/actions/walletAuth.js @@ -9,10 +9,6 @@ import { getMainAddressState, updateErrosStack } from '../actionCreators'; -import { - logGuiHttp, - guiLogState -} from './log'; export function encryptWallet(_passphrase, cb, coin) { const payload = { @@ -23,31 +19,12 @@ export function encryptWallet(_passphrase, cb, coin) { }; return dispatch => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'encryptWallet', - type: 'post', - url: `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'encryptWallet', @@ -59,13 +36,6 @@ export function encryptWallet(_passphrase, cb, coin) { .then(dispatch(walletPassphrase(_passphrase))) .then(response => response.json()) .then(json => { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } dispatch( cb.call( this, @@ -87,31 +57,12 @@ export function walletPassphrase(_passphrase) { }; return dispatch => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'walletpassphrase', - type: 'post', - url: `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: payload, - status: 'pending', - })); - } - return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'walletPassphrase', @@ -121,13 +72,6 @@ export function walletPassphrase(_passphrase) { ); }) .then(json => { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } }) } } @@ -143,31 +87,12 @@ export function iguanaWalletPassphrase(_passphrase) { }; return dispatch => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'iguanaWalletPassphrase', - type: 'post', - url: `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: _payload, - status: 'pending', - })); - } - return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(_payload), }) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch( triggerToaster( 'Error iguanaWalletPassphrase', @@ -178,13 +103,6 @@ export function iguanaWalletPassphrase(_passphrase) { }) .then(response => response.json()) .then(json => { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } dispatch(iguanaWalletPassphraseState(json, dispatch)); }); } @@ -198,18 +116,6 @@ export function iguanaActiveHandle(getMainAddress) { }; return dispatch => { - const _timestamp = Date.now(); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - function: 'iguanaActiveHandle', - type: 'post', - url: Config.iguanaLessMode ? `http://127.0.0.1:${Config.agamaPort}/shepherd/SuperNET/activehandle` : `http://127.0.0.1:${Config.iguanaCorePort}`, - payload: _payload, - status: 'pending', - })); - } - let _fetchConfig = { method: 'POST', body: JSON.stringify(_payload), @@ -230,13 +136,6 @@ export function iguanaActiveHandle(getMainAddress) { ) .catch(function(error) { console.log(error); - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'error', - response: error, - })); - } dispatch(updateErrosStack('activeHandle')); dispatch( triggerToaster( @@ -248,13 +147,6 @@ export function iguanaActiveHandle(getMainAddress) { }) .then(response => response.json()) .then(json => { - if (Config.debug) { - dispatch(logGuiHttp({ - timestamp: _timestamp, - status: 'success', - response: json, - })); - } if (!Config.iguanaLessMode && sessionStorage.getItem('IguanaActiveAccount') && JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey === json.pubkey && @@ -266,15 +158,18 @@ export function iguanaActiveHandle(getMainAddress) { } } -export function iguanaWalletPassphraseState(json, dispatch) { +export function iguanaWalletPassphraseState(json, dispatch, skipToastr) { sessionStorage.setItem('IguanaActiveAccount', JSON.stringify(json)); - dispatch( - triggerToaster( - translate('TOASTR.LOGIN_SUCCESSFULL'), - translate('TOASTR.ACCOUNT_NOTIFICATION'), - 'success' - ) - ); + + if (!skipToastr) { + dispatch( + triggerToaster( + translate('TOASTR.LOGIN_SUCCESSFULL'), + translate('TOASTR.ACCOUNT_NOTIFICATION'), + 'success' + ) + ); + } dispatch(getMainAddressState(json)); dispatch(iguanaActiveHandleState(json)); diff --git a/react/src/actions/storeType.js b/react/src/actions/storeType.js index 1e4c8af..7a7bdfb 100644 --- a/react/src/actions/storeType.js +++ b/react/src/actions/storeType.js @@ -20,8 +20,8 @@ export const BASILISK_CONNECTION = 'BASILISK_CONNECTION'; export const SYNCING_FULL_MODE = 'SYNCING_FULL_MODE'; export const SYNCING_NATIVE_MODE = 'SYNCING_NATIVE_MODE'; export const ACTIVE_COIN_GET_ADDRESSES = 'ACTIVE_COIN_GET_ADDRESSES'; -export const START_INTERVAL= 'START_INTERVAL'; -export const STOP_INTERVAL= 'STOP_INTERVAL'; +export const START_INTERVAL = 'START_INTERVAL'; +export const STOP_INTERVAL = 'STOP_INTERVAL'; export const DASHBOARD_ACTIVE_SECTION = 'DASHBOARD_ACTIVE_SECTION'; export const DASHBOARD_ACTIVE_TXINFO_MODAL = 'DASHBOARD_ACTIVE_TXINFO_MODAL'; export const DASHBOARD_ACTIVE_COIN_NATIVE_BALANCE = 'DASHBOARD_ACTIVE_COIN_NATIVE_BALANCE'; @@ -30,9 +30,9 @@ export const DASHBOARD_ACTIVE_COIN_NATIVE_OPIDS = 'DASHBOARD_ACTIVE_COIN_NATIVE_ export const DASHBOARD_ACTIVE_COIN_SENDTO = 'DASHBOARD_ACTIVE_COIN_SENDTO'; export const DASHBOARD_ACTIVE_COIN_GET_CACHE = 'DASHBOARD_ACTIVE_COIN_GET_CACHE'; export const DASHBOARD_ACTIVE_COIN_MAIN_BASILISK_ADDR = 'DASHBOARD_ACTIVE_COIN_MAIN_BASILISK_ADDR'; -export const DASHBOARD_GET_NOTARIES_LIST = 'DASHBOARD_GET_NOTARIES_LIST'; -export const DASHBOARD_DISPLAY_NOTARIES_MODAL = 'DASHBOARD_DISPLAY_NOTARIES_MODAL'; -export const DASHBOARD_CONNECT_NOTARIES = 'DASHBOARD_CONNECT_NOTARIES'; +export const DASHBOARD_ACTIVE_COIN_GETINFO_FAILURE = 'DASHBOARD_ACTIVE_COIN_GETINFO_FAILURE'; +export const DASHBOARD_UPDATE = 'DASHBOARD_UPDATE'; +export const DASHBOARD_SYNC_ONLY_UPDATE = 'DASHBOARD_SYNC_ONLY_UPDATE'; export const VIEW_CACHE_DATA = 'VIEW_CACHE_DATA'; export const SYNC_ONLY_MODAL_TOGGLE = 'SYNC_ONLY_MODAL_TOGGLE'; export const SYNC_ONLY_DATA = 'SYNC_ONLY_DATA'; @@ -41,9 +41,9 @@ export const SAVE_APP_CONFIG = 'SAVE_APP_CONFIG'; export const SERVICE_ERROR = 'SERVICE_ERROR'; export const DASHBOARD_ACTIVE_ADDRESS = 'DASHBOARD_ACTIVE_ADDRESS'; export const LOAD_APP_INFO = 'LOAD_APP_INFO'; -export const LOG_GUI_HTTP = 'LOG_GUI_HTTP'; export const CLI = 'CLI'; export const LOGOUT = 'LOGOUT'; export const DISPLAY_COIND_DOWN_MODAL = 'DISPLAY_COIND_DOWN_MODAL'; export const DISPLAY_LOGIN_SETTINGS_MODAL = 'DISPLAY_LOGIN_SETTINGS_MODAL'; -export const DISPLAY_CLAIM_INTEREST_MODAL = 'DISPLAY_CLAIM_INTEREST_MODAL'; \ No newline at end of file +export const DISPLAY_CLAIM_INTEREST_MODAL = 'DISPLAY_CLAIM_INTEREST_MODAL'; +export const DISPLAY_IMPORT_KEY_MODAL = 'DISPLAY_IMPORT_KEY_MODAL'; \ No newline at end of file diff --git a/react/src/components/addcoin/addcoin.js b/react/src/components/addcoin/addcoin.js index 50ddc9c..221ae38 100644 --- a/react/src/components/addcoin/addcoin.js +++ b/react/src/components/addcoin/addcoin.js @@ -43,6 +43,7 @@ class AddCoin extends React.Component { display: false, actionsMenu: false, modalClassName: 'hide', + isExperimentalOn: false, }; this.existingCoins = null; this.activateCoin = this.activateCoin.bind(this); @@ -113,6 +114,16 @@ class AddCoin extends React.Component { componentWillMount() { this.addNewItem(); + + let appConfig; + + try { + appConfig = window.require('electron').remote.getCurrentWindow().appConfig; + } catch (e) {} + + this.setState({ + isExperimentalOn: appConfig.experimentalFeatures, + }); } componentWillReceiveProps(props) { @@ -363,9 +374,8 @@ const mapStateToProps = (state) => { ActiveCoin: { coin: state.ActiveCoin.coin, }, - AddCoin: state.AddCoin, + AddCoin: state.AddCoin, }; - }; export default connect(mapStateToProps)(AddCoin); diff --git a/react/src/components/addcoin/addcoin.scss b/react/src/components/addcoin/addcoin.scss index ca0772b..284e025 100644 --- a/react/src/components/addcoin/addcoin.scss +++ b/react/src/components/addcoin/addcoin.scss @@ -1,5 +1,43 @@ .add-coin-modal { color: #757575; + + .modal-body { + max-height: 590px; + overflow-y: auto; + } + + .multi { + .col-sm-8 { + width: 30%; + } + .col-sm-12 { + &.text-center { + width: 60%; + padding: 0; + + .col-lg-4 { + width: 25%; + margin-right: 8%; + padding: 0; + + .input{ + &.to-labelauty+label { + max-width: 136px; + } + } + } + .col-lg-4 { + &:last-child { + margin-right: 0; + } + } + .col-sm-1 { + width: 44px; + padding: 0; + } + } + } + } } .vertical-margin-20 { @@ -24,4 +62,25 @@ margin: 0; } } +} + +.btn-add-coin-item, +.btn-add-coin-item-options, +.btn-save-coin-selection, +.btn-load-coin-selection { + position: absolute; + right: 32px; + z-index: 50; +} +.btn-add-coin-item { + right: 60px; +} +.btn-add-coin-item-options { + padding: 6px; +} +.btn-save-coin-selection { + top: 60px; +} +.btn-load-coin-selection { + top: 95px; } \ No newline at end of file diff --git a/react/src/components/addcoin/addcoinOptionsAC.js b/react/src/components/addcoin/addcoinOptionsAC.js index 811f186..5847800 100644 --- a/react/src/components/addcoin/addcoinOptionsAC.js +++ b/react/src/components/addcoin/addcoinOptionsAC.js @@ -3,25 +3,37 @@ import { translate } from '../../translate/translate'; class AddCoinOptionsAC extends React.Component { render() { + const _assetChains = [ + 'bet', + 'bots', + 'ceal', + 'coqui', + 'crypto', + 'hodl', + 'dex', + 'jumblr', + 'kv', + 'mgw', + //'mvp', + 'pangea', + 'revs', + 'shark', + 'supernet', + 'wlc', + ]; + let _items = []; + + for (let i = 0; i < _assetChains.length; i++) { + _items.push( + + ); + } + return ( - - - - - - - - - - - - - - - - - + { _items } ); } diff --git a/react/src/components/addcoin/addcoinOptionsACFiat.js b/react/src/components/addcoin/addcoinOptionsACFiat.js index c5b8ace..3506c43 100644 --- a/react/src/components/addcoin/addcoinOptionsACFiat.js +++ b/react/src/components/addcoin/addcoinOptionsACFiat.js @@ -3,40 +3,53 @@ import { translate } from '../../translate/translate'; class AddCoinOptionsACFiat extends React.Component { render() { + const _fiat = [ + 'aud', + 'brl', + 'gbp', + 'bgn', + 'cad', + 'hrk', + 'czk', + 'cny', + 'dkk', + 'eur', + 'hkd', + 'huf', + 'inr', + 'idr', + 'ils', + 'jpy', + 'krw', + 'myr', + 'mxn', + 'nzd', + 'nok', + 'php', + 'pln', + 'ron', + 'rub', + 'sgd', + 'zar', + 'sek', + 'chf', + 'thb', + 'try', + 'usd' + ]; + let _items = []; + + for (let i = 0; i < _fiat.length; i++) { + _items.push( + + ); + } + return ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + { _items } ); } diff --git a/react/src/components/addcoin/addcoinOptionsCrypto.js b/react/src/components/addcoin/addcoinOptionsCrypto.js index c192407..c72aa68 100644 --- a/react/src/components/addcoin/addcoinOptionsCrypto.js +++ b/react/src/components/addcoin/addcoinOptionsCrypto.js @@ -12,50 +12,61 @@ class AddCoinOptionsCrypto extends React.Component { } render() { - const isWindows = this.props.appSettings && this.props.appSettings.appInfo && this.props.appSettings.appInfo.sysInfo && this.props.appSettings.appInfo.sysInfo.platform === 'win32'; + // const isWindows = this.props.appSettings && this.props.appSettings.appInfo && this.props.appSettings.appInfo.sysInfo && this.props.appSettings.appInfo.sysInfo.platform === 'win32'; + let appConfig; + + try { + appConfig = window.require('electron').remote.getCurrentWindow().appConfig; + } catch (e) {} - // - // - // return ( + + className={ this.state.nativeOnly || !appConfig.experimentalFeatures ? 'hide' : '' }>BitcoinDark (BTCD) + className={ this.state.nativeOnly || !appConfig.experimentalFeatures ? 'hide' : '' }>Bitcoin (BTC) + className={ this.state.nativeOnly || !appConfig.experimentalFeatures ? 'hide' : '' }>Bitmark (BTM) + className={ this.state.nativeOnly || !appConfig.experimentalFeatures ? 'hide' : '' }>Carboncoin (CARB) + className={ this.state.nativeOnly || !appConfig.experimentalFeatures ? 'hide' : '' }>Digibyte (DGB) + className={ this.state.nativeOnly || !appConfig.experimentalFeatures ? 'hide' : '' }>Dogecoin (DOGE) + className={ this.state.nativeOnly || !appConfig.experimentalFeatures ? 'hide' : '' }>Franko (FRK) + className={ this.state.nativeOnly || !appConfig.experimentalFeatures ? 'hide' : '' }>Gamecredits (GAME) + + className={ this.state.nativeOnly || !appConfig.experimentalFeatures ? 'hide' : '' }>Litecoin (LTC) + + className={ this.state.nativeOnly || !appConfig.experimentalFeatures ? 'hide' : '' }>Unobtanium (UNO) + className={ this.state.nativeOnly || !appConfig.experimentalFeatures ? 'hide' : '' }>Zcash (ZEC) + className={ this.state.nativeOnly || !appConfig.experimentalFeatures ? 'hide' : '' }>Zetacoin (ZET) ); } @@ -65,7 +76,6 @@ const mapStateToProps = (state) => { return { appSettings: state.appSettings, }; - }; export default connect(mapStateToProps)(AddCoinOptionsCrypto); diff --git a/react/src/components/addcoin/coin-selectors.render.js b/react/src/components/addcoin/coin-selectors.render.js index 7f164f8..ed33140 100644 --- a/react/src/components/addcoin/coin-selectors.render.js +++ b/react/src/components/addcoin/coin-selectors.render.js @@ -5,7 +5,8 @@ import AddCoinOptionsAC from '../addcoin/addcoinOptionsAC'; import AddCoinOptionsACFiat from '../addcoin/addcoinOptionsACFiat'; const CoinSelectorsRender = function(item, coin, i) { - const isWindows = this.props.Settings && this.props.Settings.appInfo && this.props.Settings.appInfo.sysInfo && this.props.Settings.appInfo.sysInfo.platform === 'win32'; + // const isWindows = this.props.Settings && this.props.Settings.appInfo && this.props.Settings.appInfo.sysInfo && this.props.Settings.appInfo.sysInfo.platform === 'win32'; + const hideFullModeBtn = item && item.selectedCoin && item.selectedCoin.indexOf('|full') === -1 || !this.state.isExperimentalOn ? true : false; return (
-
+
-
+
) }; + export default CoinSelectorsRender; \ No newline at end of file diff --git a/react/src/components/addcoin/payload.js b/react/src/components/addcoin/payload.js index 13f172a..3703e82 100644 --- a/react/src/components/addcoin/payload.js +++ b/react/src/components/addcoin/payload.js @@ -688,6 +688,7 @@ export function startAssetChain(confpath, coin, mode, getSuppyOnly) { 'seedipaddr': '78.47.196.146' }; + // TODO: move netmagic to node const acConfig = { 'SUPERNET': { 'name': 'SUPERNET', @@ -790,7 +791,7 @@ export function startAssetChain(confpath, coin, mode, getSuppyOnly) { 'supply': 72000000, 'AddCoinData': confpath ? Object.assign({}, _acPayloadOrigin, {'coin':'COQUI','conf':'COQUI.conf','path':confpath,'RELAY':-1,'VALIDATE':1,'startpend':4,'endpend':4,'maxpeers':8,'newcoin':'COQUI','name':'COQUI','netmagic':'4cbd5ef4','p2p':assetChainPorts.COQUI - 1,'rpc':assetChainPorts.COQUI}) : {}, 'AddCoinDataVar': Object.assign({}, _acPayloadOrigin, {'userpass':tmpIguanaRPCAuth,'RELAY':mode,'VALIDATE':mode,'startpend':tmpPendValue,'endpend':tmpPendValue,'maxpeers':8,'newcoin':'COQUI','name':'COQUI','netmagic':'4cbd5ef4','p2p':assetChainPorts.COQUI - 1,'rpc':assetChainPorts.COQUI}) - } + }, }; if (mode === '-1') { diff --git a/react/src/components/app/app.js b/react/src/components/app/app.js index 81ab7f4..75b3992 100644 --- a/react/src/components/app/app.js +++ b/react/src/components/app/app.js @@ -14,7 +14,6 @@ function mapStateToProps(state) { Settings: state.Settings, Interval: state.Interval, SyncOnly: state.SyncOnly, - Errors: state.Errors, }; } diff --git a/react/src/components/dashboard/atomic/atomic.js b/react/src/components/dashboard/atomic/atomic.js index 562502a..75c7bf3 100755 --- a/react/src/components/dashboard/atomic/atomic.js +++ b/react/src/components/dashboard/atomic/atomic.js @@ -502,9 +502,8 @@ const mapStateToProps = (state) => { return { Atomic: { response: state.Atomic.response, - } + }, }; - }; export default connect(mapStateToProps)(Atomic); diff --git a/react/src/components/dashboard/claimInterestModal/claimInterestModal.js b/react/src/components/dashboard/claimInterestModal/claimInterestModal.js index c1cbb3b..5bfba87 100755 --- a/react/src/components/dashboard/claimInterestModal/claimInterestModal.js +++ b/react/src/components/dashboard/claimInterestModal/claimInterestModal.js @@ -24,6 +24,7 @@ class ClaimInterestModal extends React.Component { isLoading: true, transactionsList: [], showZeroInterest: true, + totalInterest: 0, }; this.claimInterestTableRender = this.claimInterestTableRender.bind(this); this.toggleZeroInterest = this.toggleZeroInterest.bind(this); @@ -37,6 +38,7 @@ class ClaimInterestModal extends React.Component { loadListUnspent() { let _transactionsList = []; + let _totalInterest = 0; getListUnspent(this.props.ActiveCoin.coin) .then((json) => { @@ -52,11 +54,13 @@ class ClaimInterestModal extends React.Component { interest: json[i].interest, txid: json[i].txid, }); + _totalInterest += Number(json[i].interest); if (i === json.length - 1) { this.setState({ transactionsList: _transactionsList, isLoading: false, + totalInterest: _totalInterest, }); } }); @@ -80,7 +84,7 @@ class ClaimInterestModal extends React.Component { } else if (json.result && json.result.length && json.result.length === 64) { Store.dispatch( triggerToaster( - `translate('TOASTR.CLAIM_INTEREST_BALANCE_SENT_P1') ${this.state.transactionsList[0].address}. translate('TOASTR.CLAIM_INTEREST_BALANCE_SENT_P2')`, + `${translate('TOASTR.CLAIM_INTEREST_BALANCE_SENT_P1')} ${this.state.transactionsList[0].address}. ${translate('TOASTR.CLAIM_INTEREST_BALANCE_SENT_P2')}`, translate('TOASTR.WALLET_NOTIFICATION'), 'success', false @@ -134,6 +138,7 @@ class ClaimInterestModal extends React.Component { return ClaimInterestModalRender.call(this); } } + const mapStateToProps = (state) => { return { ActiveCoin: { @@ -142,10 +147,9 @@ const mapStateToProps = (state) => { activeSection: state.ActiveCoin.activeSection, }, Dashboard: { - displayClaimInterestModal: state.Dashboard.displayClaimInterestModal - } + displayClaimInterestModal: state.Dashboard.displayClaimInterestModal, + }, }; - }; export default connect(mapStateToProps)(ClaimInterestModal); diff --git a/react/src/components/dashboard/claimInterestModal/claimInterestModal.render.js b/react/src/components/dashboard/claimInterestModal/claimInterestModal.render.js index 84dc66c..419d603 100644 --- a/react/src/components/dashboard/claimInterestModal/claimInterestModal.render.js +++ b/react/src/components/dashboard/claimInterestModal/claimInterestModal.render.js @@ -39,29 +39,36 @@ export const _ClaimInterestTableRender = function() { return (
- { translate('CLAIM_INTEREST.REQ_P1') }: { translate('CLAIM_INTEREST.REQ_P2') } 10 KMD +

+ { translate('CLAIM_INTEREST.REQ_P1') }: { translate('CLAIM_INTEREST.REQ_P2') } 10 KMD +

+

+ { translate('CLAIM_INTEREST.TIP') }: { translate('CLAIM_INTEREST.TIP_DESC') } +

-
-
- + }
@@ -69,7 +76,7 @@ export const _ClaimInterestTableRender = function() { - + @@ -81,7 +88,7 @@ export const _ClaimInterestTableRender = function() { - + @@ -104,7 +111,7 @@ export const ClaimInterestModalRender = function() { onClick={ this.closeModal }> × -

{ translate('INDEX.CLAIM_INTEREST') }

+

{ translate('CLAIM_INTEREST.CLAIM_INTEREST', ' ') }

tbody > tr > td, + .table > tbody > tr > th, + .table > tfoot > tr > td, + .table > tfoot > tr > th, + .table > thead > tr > td, + .table > thead > tr > th { + padding: 8px 30px 8px 0; + } + + .claim-btn { + float: right; + margin-bottom: 30px; + } + .table-scroll { + height: 366px; + overflow-y: auto; + overflow-x: hidden; + width: 100%; + } + .bold { + font-weight: bold; + } + .green { + color: #66bb6a; + } + .red { + color: #f96868; + } + .locktime { + i { + font-size: 20px; + line-height: 1.1; + } + } + + .refresh-icon { + position: absolute; + right: 20px; + font-size: 20px; + z-index: 100; + } + } +} \ No newline at end of file diff --git a/react/src/components/dashboard/coinTile/coinTile.js b/react/src/components/dashboard/coinTile/coinTile.js index 40deefa..07ff029 100755 --- a/react/src/components/dashboard/coinTile/coinTile.js +++ b/react/src/components/dashboard/coinTile/coinTile.js @@ -53,8 +53,7 @@ class CoinTile extends React.Component { ) + item={ item } />) ); } @@ -66,7 +65,6 @@ const mapStateToProps = (state) => { return { allCoins: state.Main.coins, }; - }; export default connect(mapStateToProps)(CoinTile); diff --git a/react/src/components/dashboard/coinTile/coinTileItem.js b/react/src/components/dashboard/coinTile/coinTileItem.js index 08c0fab..ca009d0 100644 --- a/react/src/components/dashboard/coinTile/coinTileItem.js +++ b/react/src/components/dashboard/coinTile/coinTileItem.js @@ -18,7 +18,8 @@ import { getNativeTxHistory, getKMDBalanceTotal, getSyncInfoNative, - getDebugLog + getDebugLog, + getDashboardUpdate } from '../../../actions/actionCreators'; import Store from '../../../store'; import Config from '../../../config'; @@ -39,72 +40,133 @@ class CoinTileItem extends React.Component { // 2) limit amount of req per update e.g. list of addresses don't change too often // 3) limit req in basilisk as much as possible incl. activehandle - dispatchCoinActions(coin, mode) { - if (mode === 'native') { - Store.dispatch(iguanaActiveHandle(true)); - const _propsDashboard = this.props.Dashboard; - const syncPercentage = _propsDashboard && _propsDashboard.progress && (parseFloat(parseInt(_propsDashboard.progress.blocks, 10) * 100 / parseInt(this.props.Dashboard.progress.longestchain, 10)).toFixed(2)).replace('NaN', 0); - - if (syncPercentage < 100 && - !this.props.Dashboard.displayCoindDownModal) { - Store.dispatch(getDebugLog('komodo', 10)); - } - if (!this.props.Dashboard.displayCoindDownModal && - _propsDashboard.progress && - _propsDashboard.progress.blocks && - _propsDashboard.progress.longestchain && - syncPercentage && - (Config.iguanaLessMode || syncPercentage >= NATIVE_MIN_SYNC_PERCENTAGE_THRESHOLD)) { - Store.dispatch(getSyncInfoNative(coin, true)); - Store.dispatch(getKMDBalanceTotal(coin)); - Store.dispatch(getNativeTxHistory(coin)); - Store.dispatch(getKMDAddressesNative(coin, mode)); - Store.dispatch(getKMDOPID(null, coin)); - } else { - Store.dispatch(getSyncInfoNative(coin)); + componentWillMount() { + if (!this.props.ActiveCoin.coin) { + let _coinSelected = false; + let _mode; + let _coin; + let _coinMode = {}; + const modes = [ + 'native', + 'basilisk', + 'full' + ]; + const allCoins = this.props.Main.coins; + + if (allCoins) { + modes.map((mode) => { + allCoins[mode].map((coin) => { + if (!_coinSelected) { + _coinSelected = true; + _coin = coin; + _mode = mode; + } + _coinMode[coin] = mode; + }); + + if (_coinMode['KMD'] && + _coinMode['KMD'] === 'native') { + _coin = 'KMD'; + _mode = 'native'; + } + }); + + setTimeout(() => { + this._dashboardChangeActiveCoin(_coin, _mode); + }, 100); } } - if (mode === 'full') { - Store.dispatch(iguanaActiveHandle(true)); - Store.dispatch(getSyncInfo(coin)); - Store.dispatch(iguanaEdexBalance(coin, mode)); - Store.dispatch(getAddressesByAccount(coin, mode)); - Store.dispatch(getFullTransactionsList(coin)); - } - if (mode === 'basilisk') { - const useAddress = this.props.ActiveCoin.mainBasiliskAddress ? this.props.ActiveCoin.mainBasiliskAddress : this.props.Dashboard.activeHandle[coin]; + } - Store.dispatch(iguanaActiveHandle(true)); + dispatchCoinActions(coin, mode) { + if (this.props.Dashboard && + this.props.Dashboard.activeSection === 'wallets') { + if (mode === 'native') { + Store.dispatch(iguanaActiveHandle(true)); + const _propsDashboard = this.props.ActiveCoin; + const syncPercentage = _propsDashboard && _propsDashboard.progress && (parseFloat(parseInt(_propsDashboard.progress.blocks, 10) * 100 / parseInt(_propsDashboard.progress.longestchain, 10)).toFixed(2)).replace('NaN', 0); - Store.dispatch( - getKMDAddressesNative( - coin, - mode, - useAddress - ) - ); + if ((syncPercentage < 100 && + !this.props.Dashboard.displayCoindDownModal) || + this.props.ActiveCoin.rescanInProgress) { + if (coin === 'KMD') { + Store.dispatch(getDebugLog('komodo', 50)); + } else { + Store.dispatch(getDebugLog('komodo', 50, coin)); + } + } - Store.dispatch( - getShepherdCache( - JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey, - coin - ) - ); + if (!this.props.Dashboard.displayCoindDownModal && + _propsDashboard.progress && + _propsDashboard.progress.blocks && + _propsDashboard.progress.longestchain && + syncPercentage && + (Config.iguanaLessMode || syncPercentage >= NATIVE_MIN_SYNC_PERCENTAGE_THRESHOLD)) { + Store.dispatch( + getSyncInfoNative( + coin, + true, + this.props.Dashboard.skipFullDashboardUpdate, + this.props.ActiveCoin.rescanInProgress + ) + ); - if (this.props && - this.props.Dashboard && - this.props.Dashboard.activeHandle && - this.props.Dashboard.activeHandle[coin]) { - if (!this.props.ActiveCoin.addresses) { - Store.dispatch(getAddressesByAccount(coin, mode)); + if (!this.props.Dashboard.skipFullDashboardUpdate) { + Store.dispatch(getDashboardUpdate(coin, _propsDashboard)); + } + } else { + Store.dispatch( + getSyncInfoNative( + coin, + null, + this.props.Dashboard.skipFullDashboardUpdate, + this.props.ActiveCoin.rescanInProgress + ) + ); } + } + if (mode === 'full') { + Store.dispatch(iguanaActiveHandle(true)); + Store.dispatch(getSyncInfo(coin)); + Store.dispatch(iguanaEdexBalance(coin, mode)); + Store.dispatch(getAddressesByAccount(coin, mode)); + Store.dispatch(getFullTransactionsList(coin)); + } + if (mode === 'basilisk') { + const useAddress = this.props.ActiveCoin.mainBasiliskAddress ? this.props.ActiveCoin.mainBasiliskAddress : this.props.Dashboard.activeHandle[coin]; + + Store.dispatch(iguanaActiveHandle(true)); + + Store.dispatch( + getKMDAddressesNative( + coin, + mode, + useAddress + ) + ); + + Store.dispatch( + getShepherdCache( + JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey, + coin + ) + ); + + if (this.props && + this.props.Dashboard && + this.props.Dashboard.activeHandle && + this.props.Dashboard.activeHandle[coin]) { + if (!this.props.ActiveCoin.addresses) { + Store.dispatch(getAddressesByAccount(coin, mode)); + } - Store.dispatch(getBasiliskTransactionsList(coin, useAddress)); + Store.dispatch(getBasiliskTransactionsList(coin, useAddress)); + } } } } - dashboardChangeActiveCoin(coin, mode) { + _dashboardChangeActiveCoin(coin, mode) { if (coin !== this.props.ActiveCoin.coin) { Store.dispatch(dashboardChangeActiveCoin(coin, mode)); setTimeout(() => { @@ -205,14 +267,16 @@ const mapStateToProps = (state) => { ActiveCoin: { coin: state.ActiveCoin.coin, addresses: state.ActiveCoin.addresses, - mainBasiliskAddress: state.ActiveCoin.mainBasiliskAddress + mainBasiliskAddress: state.ActiveCoin.mainBasiliskAddress, + progress: state.ActiveCoin.progress, + rescanInProgress: state.ActiveCoin.rescanInProgress, }, Dashboard: state.Dashboard, Interval: { - interval: state.Interval.interval - } + interval: state.Interval.interval, + }, + Main: state.Main, }; - }; export default connect(mapStateToProps)(CoinTileItem); \ No newline at end of file diff --git a/react/src/components/dashboard/coinTile/coinTileItem.render.js b/react/src/components/dashboard/coinTile/coinTileItem.render.js index b669c6c..3ad7886 100644 --- a/react/src/components/dashboard/coinTile/coinTileItem.render.js +++ b/react/src/components/dashboard/coinTile/coinTileItem.render.js @@ -8,7 +8,7 @@ const CoinTileItemRender = function() {
this.dashboardChangeActiveCoin(item.coin, item.mode) }> + onClick={ () => this._dashboardChangeActiveCoin(item.coin, item.mode) }> = COIND_DOWN_MODAL_FETCH_FAILURES_THRESHOLD) { return CoindDownModalRender.call(this); } return null; } } + const mapStateToProps = (state) => { return { + ActiveCoin: { + mode: state.ActiveCoin.mode, + coin: state.ActiveCoin.coin, + getinfoFetchFailures: state.ActiveCoin.getinfoFetchFailures, + }, displayCoindDownModal: state.Dashboard.displayCoindDownModal, - debugLog: state.Settings.debugLog + debugLog: state.Settings.debugLog, }; - }; export default connect(mapStateToProps)(CoindDownModal); diff --git a/react/src/components/dashboard/coindDownModal/coindDownModal.render.js b/react/src/components/dashboard/coindDownModal/coindDownModal.render.js index 7aad606..4b22596 100644 --- a/react/src/components/dashboard/coindDownModal/coindDownModal.render.js +++ b/react/src/components/dashboard/coindDownModal/coindDownModal.render.js @@ -1,7 +1,7 @@ import React from 'react'; import { translate } from '../../../translate/translate'; -const CoindDownModalRender = function () { +const CoindDownModalRender = function() { return (
div { + height: 100%; + } + .form-group { + &.form-material { + &.floating { + height: 80%; + } + } + } + .page-content { + width: 90%; + height: 100%; + + textarea { + height: 100%; + } + } + } +} \ No newline at end of file diff --git a/react/src/components/dashboard/importKeyModal/importKeyModal.js b/react/src/components/dashboard/importKeyModal/importKeyModal.js new file mode 100755 index 0000000..7244ca4 --- /dev/null +++ b/react/src/components/dashboard/importKeyModal/importKeyModal.js @@ -0,0 +1,243 @@ +import React from 'react'; +import { connect } from 'react-redux'; +import ReactDOM from 'react-dom'; +import Store from '../../../store'; +import { + displayImportKeyModal, + importPrivkey, + triggerToaster, + copyCoinAddress, + getDebugLog, + getDashboardUpdateState +} from '../../../actions/actionCreators'; +import { translate } from '../../../translate/translate'; +import { + ImportKeyModalRender, +} from './importKeyModal.render'; + +// import gen komodo keys utils +import '../../../util/crypto/gen/array.map.js'; +import '../../../util/crypto/gen/cryptojs.js'; +import '../../../util/crypto/gen/cryptojs.sha256.js'; +import '../../../util/crypto/gen/cryptojs.pbkdf2.js'; +import '../../../util/crypto/gen/cryptojs.hmac.js'; +import '../../../util/crypto/gen/cryptojs.aes.js'; +import '../../../util/crypto/gen/cryptojs.blockmodes.js'; +import '../../../util/crypto/gen/cryptojs.ripemd160.js'; +import '../../../util/crypto/gen/securerandom.js'; +import '../../../util/crypto/gen/ellipticcurve.js'; +import '../../../util/crypto/gen/biginteger.js'; +import '../../../util/crypto/gen/crypto-scrypt.js'; +import { Bitcoin } from '../../../util/crypto/gen/bitcoin.js'; + +class ImportKeyModal extends React.Component { + constructor() { + super(); + this.state = { + open: false, + wif: '', + wifkeysPassphrase: '', + passphraseWif: null, + passphraseAddress: null, + keyImportResult: null, + importWithRescan: false, + seedInputVisibility: false, + toggleSeedInputVisibility: false, + trimPassphraseTimer: null, + }; + this.generateKeysFromPassphrase = this.generateKeysFromPassphrase.bind(this); + this.toggleImportWithRescan = this.toggleImportWithRescan.bind(this); + this.toggleSeedInputVisibility = this.toggleSeedInputVisibility.bind(this); + this._copyCoinAddress = this._copyCoinAddress.bind(this); + this.showPassphraseAddress = this.showPassphraseAddress.bind(this); + this.importWifAddress = this.importWifAddress.bind(this); + this.updateInput = this.updateInput.bind(this); + this.importFromPassphrase = this.importFromPassphrase.bind(this); + this.importFromWif = this.importFromWif.bind(this); + } + + _copyCoinAddress(address) { + Store.dispatch(copyCoinAddress(address)); + } + + 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); + } + + toggleSeedInputVisibility() { + this.setState({ + seedInputVisibility: !this.state.seedInputVisibility, + }); + } + + showPassphraseAddress() { + const _address = this.generateKeysFromPassphrase(); + + if (_address) { + this.setState({ + passphraseAddress: _address.address, + passphraseWif: _address.wif, + }); + } + } + + importFromPassphrase() { + const _address = this.generateKeysFromPassphrase(); + + if (_address) { + this.importWifAddress(_address.wif, true); + } + } + + importFromWif() { + this.importWifAddress(this.state.wif, this.state.importWithRescan); + } + + importWifAddress(wif, rescan) { + let _rescanInProgress = true; + + if (rescan) { + setTimeout(() => { + if (_rescanInProgress) { + setTimeout(() => { + if (this.props.ActiveCoin.coin === 'KMD') { + Store.dispatch(getDebugLog('komodo', 100)); + } else { + Store.dispatch(getDebugLog('komodo', 100, this.props.ActiveCoin.coin)); + } + }, 2000); + + Store.dispatch(getDashboardUpdateState(null, this.props.ActiveCoin.coin, true)); + Store.dispatch( + triggerToaster( + 'Address imported. Wallet rescan is in progress. Please wait until it is finished.', + translate('TOASTR.WALLET_NOTIFICATION'), + 'info', + false + ) + ); + this.closeModal(); + } + }, 2000); + } + + importPrivkey( + this.props.ActiveCoin.coin, + wif, + rescan + ).then((json) => { + _rescanInProgress = false; + + if (!json.id && + !json.result && + !json.error) { + // console.warn('importPrivkey', json); + Store.dispatch( + triggerToaster( + rescan ? 'Wallet rescan finished' : 'Address imported', + translate('TOASTR.WALLET_NOTIFICATION'), + 'success', + false + ) + ); + } else { + Store.dispatch( + triggerToaster( + json.error.message, + 'Error', + 'error' + ) + ); + } + }); + } + + generateKeysFromPassphrase() { + if (this.state.wifkeysPassphrase && + this.state.wifkeysPassphrase.length) { + const bytes = Crypto.SHA256(this.state.wifkeysPassphrase, { asBytes: true }); + // byte flipping to make it compat with iguana core + bytes[0] &= 248; + bytes[31] &= 127; + bytes[31] |= 64; + const btcKey = new Bitcoin.ECKey(bytes).setCompressed(true); + const kmdAddress = btcKey.getBitcoinAddress(); + const wifAddress = btcKey.getBitcoinWalletImportFormat(); + + return { + address: kmdAddress, + wif: wifAddress, + }; + } else { + Store.dispatch( + triggerToaster( + 'Empty passphrase field', + 'Error', + 'error' + ) + ); + + return null; + } + } + + toggleImportWithRescan() { + this.setState({ + importWithRescan: !this.state.importWithRescan, + }); + } + + closeModal() { + Store.dispatch(displayImportKeyModal(false)); + } + + render() { + return ImportKeyModalRender.call(this); + } +} + +const mapStateToProps = (state) => { + return { + ActiveCoin: { + coin: state.ActiveCoin.coin, + balance: state.ActiveCoin.balance, + }, + Dashboard: { + displayImportKeyModal: state.Dashboard.displayImportKeyModal, + }, + }; +}; + +export default connect(mapStateToProps)(ImportKeyModal); diff --git a/react/src/components/dashboard/importKeyModal/importKeyModal.render.js b/react/src/components/dashboard/importKeyModal/importKeyModal.render.js new file mode 100644 index 0000000..9a69d0c --- /dev/null +++ b/react/src/components/dashboard/importKeyModal/importKeyModal.render.js @@ -0,0 +1,136 @@ +import React from 'react'; +import { translate } from '../../../translate/translate'; + +/*export const _ClaimInterestTableRender = function() { +};*/ + +export const ImportKeyModalRender = function() { + return ( + +
+
+
+
+ +

Import key

+
+
+
+ Two forms below allow you to import either Iguana Core / ICO passphrase (seed) or WIF (Wallet Import Format) key. +
+
+ Passphrase / seed +

+ Notice: importing a passphrase will trigger a full wallet rescan.  + This process can take hours to rescan the whole blockchain. +

+
+
+ + + + +
+
+ + +
+ + { this.state.passphraseAddress && this.state.passphraseWif && +
+

+ Address: { this.state.passphraseAddress } + +

+

+ WIF: { this.state.passphraseWif } + +

+
+ } +
+
or
+
+ WIF (Wallet Import Format) +
+ + +
+ Trigger rescan + +
+
+
+
+ + +
+ +
+
+
+
+
+
+
+ ); +}; \ No newline at end of file diff --git a/react/src/components/dashboard/importKeyModal/importKeyModal.scss b/react/src/components/dashboard/importKeyModal/importKeyModal.scss new file mode 100644 index 0000000..2d9f692 --- /dev/null +++ b/react/src/components/dashboard/importKeyModal/importKeyModal.scss @@ -0,0 +1,33 @@ +.modal-import-key { + .modal-dialog { + width: 70%; + max-height: 90vh; + overflow-y: auto; + overflow-x: hidden; + } + .line { + padding: 50px 0 40px 0; + text-transform: uppercase; + font-weight: bold; + } + .line:before { + content: ''; + display: inline-block; + height: 1px; + width: 47%; + background: #ccc; + margin-right: 10px; + position: relative; + top: -4px; + } + .line:after { + content: ''; + display: inline-block; + height: 1px; + width: 47%; + background: #ccc; + margin-left: 10px; + position: relative; + top: -4px; + } +} \ No newline at end of file diff --git a/react/src/components/dashboard/jumblr/jumblr.js b/react/src/components/dashboard/jumblr/jumblr.js index 85eb056..75d93a9 100755 --- a/react/src/components/dashboard/jumblr/jumblr.js +++ b/react/src/components/dashboard/jumblr/jumblr.js @@ -128,12 +128,6 @@ class Jumblr extends React.Component { }); } - /*toggleAddressGenMod() { - this.setState({ - jumblrDepositAddressPBased: !this.state.jumblrDepositAddressPBased, - }); - }*/ - generateJumblrSecretAddress() { let _jumblrSecretAddress = []; let _apiSuccessCount = 0; @@ -285,7 +279,9 @@ class Jumblr extends React.Component { importPrivkey(this.props.ActiveCoin.coin, _genKeys.wif) .then((json) => { - if (!json.id && !json.result && !json.error) { + if (!json.id && + !json.result && + !json.error) { _jumblrSecretAddress.push(_genKeys); this.setState(Object.assign({}, this.state, { jumblrSecretAddressImport: _jumblrSecretAddress, @@ -344,7 +340,9 @@ class Jumblr extends React.Component { importPrivkey(this.props.ActiveCoin.coin, _genKeys.wif) .then((json) => { - if (!json.id && !json.result && !json.error) { + if (!json.id && + !json.result && + !json.error) { // console.warn('importPrivkey', json); setJumblrAddress( this.props.ActiveCoin.coin, @@ -429,9 +427,8 @@ const mapStateToProps = (state) => { return { ActiveCoin: { coin: state.ActiveCoin.coin, - } + }, }; - }; export default connect(mapStateToProps)(Jumblr); diff --git a/react/src/components/dashboard/jumblr/jumblr.scss b/react/src/components/dashboard/jumblr/jumblr.scss new file mode 100644 index 0000000..80861e6 --- /dev/null +++ b/react/src/components/dashboard/jumblr/jumblr.scss @@ -0,0 +1,92 @@ +.jumblr { + .alert-info { + width: 100%; + } + p { + width: calc(100% - 100px); + } + .breadcrumb { + padding: 8px 30px; + position: relative; + top: 0; + } + .img-responsive { + position: absolute; + top: -28px; + right: 18px; + + .coin { + font-size: 30px; + position: relative; + left: -18px; + top: 4px; + } + .image { + width: 60px; + } + } + .header-easydex-section { + img { + max-width: inherit; + } + } + .copy-string-btn { + position: absolute; + right: 36px; + margin-top: -68px; + } + .btn-next { + position: absolute; + top: 60px; + right: 32px; + } + input.labelauty+label, + input.labelauty+label { + background: #d6d5d5; + color: #504e4e; + } + input.labelauty:checked+label { + color: #fff; + background-color: #3949ab; + } + input.labelauty + label:hover .labelauty-unchecked, + input.labelauty + label .labelauty-unchecked { + color: #504e4e; + } + .nofloat { + float: none; + display: inline-block; + padding-left: 0; + } +} + +.jumblr-mode-selector { + .nav-tabs { + li { + cursor: pointer; + + &.active { + > a { + cursor: pointer; + color: #fff; + background-color: #62a8ea; + border-color: transparent; + border-bottom-color: #62a8ea; + } + } + } + } + + .panel-heading { + background: #f3f3f3; + cursor: pointer; + } + .panel-title { + color: #676767; + } + .jumblr-addresses-list { + .col-xs-3 { + padding: 0; + } + } +} \ No newline at end of file diff --git a/react/src/components/dashboard/loginModal/loginModal.render.js b/react/src/components/dashboard/loginModal/loginModal.render.js index 6933a95..653c61a 100644 --- a/react/src/components/dashboard/loginModal/loginModal.render.js +++ b/react/src/components/dashboard/loginModal/loginModal.render.js @@ -1,7 +1,7 @@ import React from 'react'; import { translate } from '../../../translate/translate'; -const LoginModalRender = function () { +const LoginModalRender = function() { return (
{ return { - Main: state.Main + Main: state.Main, }; - }; export default connect(mapStateToProps)(LoginSettingsModal); diff --git a/react/src/components/dashboard/loginSettingsModal/loginSettingsModal.scss b/react/src/components/dashboard/loginSettingsModal/loginSettingsModal.scss new file mode 100644 index 0000000..42636c4 --- /dev/null +++ b/react/src/components/dashboard/loginSettingsModal/loginSettingsModal.scss @@ -0,0 +1,7 @@ +.login-settings-modal { + form { + width: 100%; + margin: 0; + margin-top: 25px; + } +} \ No newline at end of file diff --git a/react/src/components/dashboard/main/dashboard.js b/react/src/components/dashboard/main/dashboard.js index 470fbd3..00f56a6 100755 --- a/react/src/components/dashboard/main/dashboard.js +++ b/react/src/components/dashboard/main/dashboard.js @@ -45,11 +45,8 @@ const mapStateToProps = (state) => { ActiveCoin: { mode: state.ActiveCoin.mode, }, - Dashboard: { - activeSection: state.Dashboard.activeSection, - } + Dashboard: state.Dashboard, }; - }; export default connect(mapStateToProps)(Dashboard); diff --git a/react/src/components/dashboard/main/dashboard.render.js b/react/src/components/dashboard/main/dashboard.render.js index cb734fd..2427e4c 100644 --- a/react/src/components/dashboard/main/dashboard.render.js +++ b/react/src/components/dashboard/main/dashboard.render.js @@ -16,6 +16,7 @@ import About from '../about/about'; import WalletsNative from '../walletsNative/walletsNative'; import WalletsTxInfo from '../walletsTxInfo/walletsTxInfo'; import CoindDownModal from '../coindDownModal/coindDownModal'; +import ImportKeyModal from '../importKeyModal/importKeyModal'; const DashboardRender = function() { return ( @@ -25,6 +26,9 @@ const DashboardRender = function() { id="section-dashboard"> + { this.props.Dashboard.displayImportKeyModal && + + }
@@ -46,7 +50,7 @@ const DashboardRender = function() { } { this.isSectionActive('settings') && - + } { this.isSectionActive('about') && diff --git a/react/src/components/dashboard/navbar/navbar.js b/react/src/components/dashboard/navbar/navbar.js index c4adac0..0f414ce 100755 --- a/react/src/components/dashboard/navbar/navbar.js +++ b/react/src/components/dashboard/navbar/navbar.js @@ -7,6 +7,7 @@ import { startInterval, toggleSyncOnlyModal, getSyncOnlyForks, + displayImportKeyModal, logout, } from '../../../actions/actionCreators'; import Store from '../../../store'; @@ -21,6 +22,7 @@ class Navbar extends React.Component { this.state = { openDropMenu: false, nativeOnly: Config.iguanaLessMode, + isExperimentalOn: false, }; this.openDropMenu = this.openDropMenu.bind(this); this.logout = this.logout.bind(this); @@ -34,6 +36,16 @@ class Navbar extends React.Component { this.handleClickOutside, false ); + + let appConfig; + + try { + appConfig = window.require('electron').remote.getCurrentWindow().appConfig; + } catch (e) {} + + this.setState({ + isExperimentalOn: appConfig.experimentalFeatures, + }); } componentWillUnmount() { @@ -56,6 +68,10 @@ class Navbar extends React.Component { } } + openImportKeyModal() { + Store.dispatch(displayImportKeyModal(true)); + } + openDropMenu() { this.setState(Object.assign({}, this.state, { openDropMenu: !this.state.openDropMenu, @@ -115,6 +131,7 @@ class Navbar extends React.Component { return NavbarRender.call(this); } } + const mapStateToProps = (state) => { return { ActiveCoin: { @@ -127,9 +144,8 @@ const mapStateToProps = (state) => { Interval: { interval: state.Interval.interval, }, - nativeOnly: Config.iguanaLessMode + nativeOnly: Config.iguanaLessMode, }; - }; export default connect(mapStateToProps)(Navbar); diff --git a/react/src/components/dashboard/navbar/navbar.render.js b/react/src/components/dashboard/navbar/navbar.render.js index 4449f5f..073bc8f 100644 --- a/react/src/components/dashboard/navbar/navbar.render.js +++ b/react/src/components/dashboard/navbar/navbar.render.js @@ -57,13 +57,20 @@ const NavbarRender = function() { BarterDEX - { this.props.ActiveCoin && this.props.ActiveCoin.mode === 'native' && (this._checkAC() || this.props.ActiveCoin.coin === 'KMD') && + { this.props.ActiveCoin && this.props.ActiveCoin.mode === 'native' && (/*this._checkAC() || */this.props.ActiveCoin.coin === 'KMD') &&
  • this.dashboardChangeSection('jumblr') }> Jumblr
  • } + { this.state.nativeOnly && +
  • + + Import key + +
  • + }
  • this.dashboardChangeSection('atomic') }> Atomic Explorer @@ -99,14 +106,14 @@ const NavbarRender = function() { { translate('INDEX.SETTINGS') }
  • -
  • +
  • this.openSyncOnlyModal() }> { translate('ADD_COIN.SYNC_ONLY') }
  • this.dashboardChangeSection('about') }> - { translate('INDEX.ABOUT_IGUANA') } + { translate('ABOUT.ABOUT_AGAMA') }
  • diff --git a/react/src/components/dashboard/notifications/notifications.js b/react/src/components/dashboard/notifications/notifications.js deleted file mode 100755 index 1504121..0000000 --- a/react/src/components/dashboard/notifications/notifications.js +++ /dev/null @@ -1,122 +0,0 @@ -import React from 'react'; -import { connect } from 'react-redux'; -import { sortByDate } from '../../../util/sort'; -import Config from '../../../config'; -import { - NotificationsByTypeRender, - NotificationsModalRender, - NotificationsRender -} from './notifications.render'; - -class Notifications extends React.Component { - constructor() { - super(); - this.state = { - displayModal: false, - calls: { - total: 0, - error: 0, - success: 0, - pending: 0, - }, - activeTab: 2, - guiLog: null, - debug: Config.debug, - }; - this.toggleNotificationsModal = this.toggleNotificationsModal.bind(this); - } - - openTab(tab) { - this.setState(Object.assign({}, this.state, { - activeTab: tab, - })); - } - - componentWillReceiveProps(props) { - // get total number of calls per type - if (this.props.Dashboard && - this.props.Dashboard.guiLog) { - const _guiLog = this.props.Dashboard.guiLog; - let _callsLength = { - total: Object.keys(_guiLog).length, - error: 0, - success: 0, - pending: 0, - } - let guiLogToArray = []; - - for (let timestamp in _guiLog) { - guiLogToArray.push(_guiLog[timestamp]); - _callsLength[_guiLog[timestamp].status]++; - } - - this.setState(Object.assign({}, this.state, { - calls: { - total: _callsLength.total, - error: _callsLength.error, - success: _callsLength.success, - pending: _callsLength.pending, - }, - guiLog: guiLogToArray, - })); - } - } - - renderNotificationsByType(type) { - // get total number of calls per type - if (this.state.guiLog && - this.state.guiLog.length) { - let _guiLog = this.state.guiLog; - let items = []; - _guiLog = sortByDate(_guiLog); - - for (let i = 0; i < _guiLog.length; i++) { - if (_guiLog[i].status === type) { - const _logItem = _guiLog[i]; - - items.push( - NotificationsByTypeRender.call( - this, - _logItem, - type, - i - ) - ); - } - } - - return items; - } - } - - renderNotificationsModal() { - if (this.state.displayModal) { - return NotificationsModalRender.call(this); - } - - return null; - } - - toggleNotificationsModal() { - this.setState(Object.assign({}, this.state, { - displayModal: !this.state.displayModal, - })); - } - - render() { - return NotificationsRender.call(this); - } -} - -const mapStateToProps = (state) => { - return { - Dashboard: { - guiLog: state.Dashboard.guiLog, - activeHandle: state.Dashboard.activeHandle, - } - }; - -}; - -export default connect(mapStateToProps)(Notifications); - diff --git a/react/src/components/dashboard/notifications/notifications.render.js b/react/src/components/dashboard/notifications/notifications.render.js deleted file mode 100644 index 8a894c9..0000000 --- a/react/src/components/dashboard/notifications/notifications.render.js +++ /dev/null @@ -1,116 +0,0 @@ -import React from 'react'; -import { - secondsToString -} from '../../../util/time'; -import { translate } from '../../../translate/translate'; - -export const NotificationsByTypeRender = function(logItem, type, index) { - return ( -
    -
    { index + 1 }.
    -
    - Time: { secondsToString(logItem.timestamp, true, true) } -
    -
    - GUI Function: { logItem.function } -
    -
    - HTTP: { logItem.httpMethod.toUpperCase() } -
    -
    - URL: { logItem.url } -
    -
    - Payload: { JSON.stringify(logItem.payload, null, '\t') } -
    -
    - Response: { JSON.stringify(logItem.response, null, '\t') } -
    -
    -
    - ); -} - -export const NotificationsModalRender = function() { - return ( -
    this.handleKeydown(event) }> -
    -
    -
    -
    -
    - -
    -
    -
    - { this.renderNotificationsByType('success') } -
    -
    - { this.renderNotificationsByType('error') } -
    -
    - { this.renderNotificationsByType('pending') } -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    - ); -}; - -export const NotificationsRender = function() { - return ( -
    -
    - - { this.state.calls.success } - - - { this.state.calls.error } - - - { this.state.calls.pending } - -
    -
    -
    -
    -
    -
    -
    -
    - { this.renderNotificationsModal() } -
    - ); -}; \ No newline at end of file diff --git a/react/src/components/dashboard/qrModal/qrModal.js b/react/src/components/dashboard/qrModal/qrModal.js index 973730e..c1a5757 100755 --- a/react/src/components/dashboard/qrModal/qrModal.js +++ b/react/src/components/dashboard/qrModal/qrModal.js @@ -14,6 +14,7 @@ class QRModal extends React.Component { this.state = { modalIsOpen: false, error: null, + errorShown: false, }; this.openModal = this.openModal.bind(this); this.closeModal = this.closeModal.bind(this); @@ -45,7 +46,7 @@ class QRModal extends React.Component { openModal() { this.setState({ - modalIsOpen: true + modalIsOpen: true, }); if (this.props.mode === 'scan') { @@ -65,6 +66,7 @@ class QRModal extends React.Component { closeModal() { this.setState({ modalIsOpen: false, + errorShown: this.state.error ? true : false, }); } diff --git a/react/src/components/dashboard/qrModal/qrModal.render.js b/react/src/components/dashboard/qrModal/qrModal.render.js index db7d0eb..b08bdbf 100644 --- a/react/src/components/dashboard/qrModal/qrModal.render.js +++ b/react/src/components/dashboard/qrModal/qrModal.render.js @@ -2,7 +2,7 @@ import React from 'react'; import { translate } from '../../../translate/translate'; import QRCode from 'qrcode.react'; -export const QRModalRender = function () { +export const QRModalRender = function() { return ( - -
    -
    -
    -
    - -

    { translate('INDEX.SCAN_QRCODE_WEBCAM') }

    -
    -
    -
    -
    -
    - { 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( +
    + + + + ); + + for (let _key in _appConfig[key]) { + items.push( + + + + + ); + } + } + } else { + if (this.state.appConfigSchema[key] && this.state.appConfigSchema[key].display) { + items.push( + + + + + ); + } + } + } + + items.push( + + + + + ); + + 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') } +

    +
    +
    { translate('INDEX.ADDRESS') } { translate('INDEX.AMOUNT') }{ translate('INDEX.Address') }{ translate('INDEX.INTEREST') } Locktime
    { translate('INDEX.ADDRESS') } { translate('INDEX.AMOUNT') }{ translate('INDEX.Address') }{ translate('INDEX.INTEREST') } Locktime
    + { this.state.appConfigSchema[key].displayName ? this.state.appConfigSchema[key].displayName : key } + { this.state.appConfigSchema[key].info && + + } +
    + { 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' && + + + + } +
    + { 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' && + + + + } +
    + KMD main sync only + + + + + +
    + + { 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') }

    +
    +
    +
    + + +
    +
    + + +
    +
    + +
    +
    +
    + { this.renderCliResponse() } +
    +
    +
    +
    + ); + }; +} + +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.renderDebugLogData() }
    +
    +
    + } + { 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() {
    this.openTab('DumpWallet', 2) } - className={ 'panel' + (this.state.nativeOnly ? ' hide' : '') }> + className={ 'hide panel' + (this.state.nativeOnly ? ' hide' : '') }>
    { translate('INDEX.WALLET_BACKUP') } @@ -307,8 +62,8 @@ export const SettingsRender = function() {
    -
    Wallet Backup section to be updated soon.
    + style={{ height: this.state.activeTab === 2 ? `auto` : '0' }}> + { this.renderWalletBackup() }
    } @@ -316,7 +71,7 @@ export const SettingsRender = function() { } @@ -341,69 +96,8 @@ export const SettingsRender = function() {
    -
    -
    -
    { this.renderLB('INDEX.ONLY_ACTIVE_WIF_KEYS') }
    -
    - { this.renderLB('SETTINGS.EXPORT_KEYS_NOTE') } -
    - - { translate('INDEX.PLEASE_KEEP_KEYS_SAFE') } - -
    -
    -
    -
    - - - - -
    -
    - -
    -
    - -
    -
    - - { this.renderWifKeys() } -
    -
    - -
    -
    - { this.renderExportWifKeysRaw() } -
    -
    -
    -
    + style={{ height: this.state.activeTab === 4 ? `auto` : '0' }}> + { this.renderExportKeys() }
    } @@ -419,41 +113,8 @@ export const SettingsRender = function() {
    -
    -
    { translate('INDEX.IMPORT_KEYS_DESC_P1') }

    -
    { translate('INDEX.IMPORT_KEYS_DESC_P2') }

    -
    { translate('INDEX.IMPORT_KEYS_DESC_P3') }

    -
    - - { translate('INDEX.PLEASE_KEEP_KEYS_SAFE') } - -
    -
    -
    -
    - - -
    -
    - -
    -
    -
    + style={{ height: this.state.activeTab === 5 ? `auto` : '0' }}> + { this.renderImportKeys() }
    } @@ -469,51 +130,8 @@ export const SettingsRender = function() {
    -
    -

    { translate('INDEX.DEBUG_LOG_DESC') }

    -
    -
    -
    - - -
    -
    - - -
    -
    - -
    -
    -
    { this.renderDebugLogData() }
    -
    -
    -
    + style={{ height: this.state.activeTab === 6 ? `auto` : '0' }}> + { this.renderDebugLog() }
    @@ -528,32 +146,26 @@ export const SettingsRender = function() {
    -
    -

    - { translate('SETTINGS.CONFIG_RESTART_REQUIRED') } -

    -
    - - - { this.renderConfigEditForm() } - -
    -
    -
    - - -
    -
    + style={{ height: this.state.activeTab === 7 ? `auto` : '0' }}> + { this.renderAppSettings() } +
    + + +
    this.openTab('AppInfo', 8) }> +
    + + { translate('SETTINGS.APP_INFO') } + +
    +
    + { this.renderAppInfoTab() }
    - { this.renderAppInfoTab() } { this.props.Main && this.props.Main.coins.native &&
    -
    -

    { translate('INDEX.CLI_SELECT_A_COIN') }

    -
    -
    -
    - - -
    -
    - - -
    -
    - -
    -
    -
    - { this.renderCliResponse() } -
    -
    -
    -
    + style={{ height: this.state.activeTab === 9 ? `auto` : '0' }}> + { this.renderCliPanel() }
    } - { this.renderAppUpdateTab() } +
    this.openTab('AppUpdate', 10) }> +
    + + { translate('INDEX.UPDATE') } + +
    +
    + { this.renderAppUpdateTab() } +
    +
    -
    -
    -
    -
    this.openExternalWindow('http://support.supernet.org') }> - Support tickets -
    { translate('SETTINGS.SUPPORT_TICKETS') }
    -
    support.supernet.org
    -
    -
    -
    -
    this.openExternalWindow('https://sprnt.slack.com') }> - Slack -
    Slack
    -
    sprnt.slack.com
    -
    -
    -
    -
    this.openExternalWindow('http://slackinvite.supernet.org') }> - Slack invite -
    { translate('SETTINGS.GET_SLACK_INVITE') }
    -
    slackinvite.supernet.org
    -
    -
    -
    -
    this.openExternalWindow('https://github.com/SuperNETorg/Agama') }> - Github -
    Github
    -
    github.com/SuperNETorg/Agama
    -
    -
    -
    -
    + style={{ height: this.state.activeTab === 11 ? `auto` : '0' }}> + { this.renderSupportPanel() }
    diff --git a/react/src/components/dashboard/settings/settings.scss b/react/src/components/dashboard/settings/settings.scss new file mode 100644 index 0000000..bc1a47c --- /dev/null +++ b/react/src/components/dashboard/settings/settings.scss @@ -0,0 +1,121 @@ +.support-box { + padding: 15px 20px; + width: 220px; + display: inline-block; + cursor: pointer; + + &-title { + font-weight: bold; + padding-top: 12px; + padding-bottom: 3px; + } + img { + height: 50px; + } +} + +.support-box-wrapper { + display: inline-block; + margin-right: 50px; + + &:last-child, { + margin-right: 0; + } +} + +.support-box:hover { + .support-box-link { + color: #5683ad; + font-weight: 500; + } +} + +.login-settings-modal { + #AppUpdate { + .col-sm-4 { + width: 100%; + } + } + .modal-dialog { + width: 80%; + } + .modal-body { + background: #f3f4f5; + border-radius: 4px; + } + .modal-footer { + margin-top: 15px; + } + .page-content { + padding-top: 0; + } + .support-box-wrapper { + .support-box { + margin: 0; + margin-bottom: 20px; + } + } +} + +.settings-help { + font-size: 20px; + position: relative; + top: 2px; + left: 10px; + color: #5683ad; +} + +#SettingsAccordion { + .toggle { + position: relative; + top: 4px; + + .title { + position: relative; + top: -12px; + left: 12px; + } + } + table { + width: 100%; + + td { + &:first-child { + width: 40%; + } + &:last-child { + width: 60%; + } + } + } +} + +#SettingsAccordion { + .panel { + .panel-collapse { + transition: all .3s; + + &.collapse { + height: 0; + } + } + } +} + +#section-iguana-wallet-settings { + background: #f3f4f5; + + .panel-title { + cursor: pointer; + cursor: hand; + + &:before { + content: '\F273'; + } + &.collapsed { + &:before { + content: '\F278'; + } + } + } +} \ No newline at end of file diff --git a/react/src/components/dashboard/settings/settings.supportPanel.js b/react/src/components/dashboard/settings/settings.supportPanel.js new file mode 100644 index 0000000..a13f89b --- /dev/null +++ b/react/src/components/dashboard/settings/settings.supportPanel.js @@ -0,0 +1,82 @@ +import React from 'react'; +import { translate } from '../../../translate/translate'; + +class SupportPanel extends React.Component { + constructor() { + super(); + } + + 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); + }); + } + + render() { + return ( +
    +
    +
    +
    this.openExternalWindow('http://support.supernet.org') }> + Support tickets +
    { translate('SETTINGS.SUPPORT_TICKETS') }
    +
    support.supernet.org
    +
    +
    +
    +
    this.openExternalWindow('https://sprnt.slack.com') }> + Slack +
    Slack
    +
    sprnt.slack.com
    +
    +
    +
    +
    this.openExternalWindow('http://slackinvite.supernet.org') }> + Slack invite +
    { translate('SETTINGS.GET_SLACK_INVITE') }
    +
    slackinvite.supernet.org
    +
    +
    +
    +
    this.openExternalWindow('https://github.com/SuperNETorg/Agama') }> + Github +
    Github
    +
    github.com/SuperNETorg/Agama
    +
    +
    +
    +
    + ); + }; +} + +export default SupportPanel; \ No newline at end of file diff --git a/react/src/components/dashboard/settings/settings.walletBackupPanel.js b/react/src/components/dashboard/settings/settings.walletBackupPanel.js new file mode 100644 index 0000000..e86ca8f --- /dev/null +++ b/react/src/components/dashboard/settings/settings.walletBackupPanel.js @@ -0,0 +1,23 @@ +import React from 'react'; +import { translate } from '../../../translate/translate'; +import { connect } from 'react-redux'; + +class WalletBackupPanel extends React.Component { + constructor() { + super(); + } + + render() { + return ( +
    Wallet Backup section to be updated soon.
    + ); + }; +} + +const mapStateToProps = (state) => { + return { + Settings: state.Settings, + }; +}; + +export default connect(mapStateToProps)(WalletBackupPanel); \ No newline at end of file diff --git a/react/src/components/dashboard/settings/settings.walletInfoPanel.js b/react/src/components/dashboard/settings/settings.walletInfoPanel.js new file mode 100644 index 0000000..29fda9d --- /dev/null +++ b/react/src/components/dashboard/settings/settings.walletInfoPanel.js @@ -0,0 +1,60 @@ +import React from 'react'; +import { translate } from '../../../translate/translate'; +import { connect } from 'react-redux'; + +class WalletInfoPanel extends React.Component { + constructor() { + super(); + } + + render() { + return ( +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    { 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 }
    +
    + ); + }; +} + +const mapStateToProps = (state) => { + return { + Main: { + activeHandle: state.Main.activeHandle, + }, + }; +}; + +export default connect(mapStateToProps)(WalletInfoPanel); \ No newline at end of file diff --git a/react/src/components/dashboard/syncOnly/syncOnly.js b/react/src/components/dashboard/syncOnly/syncOnly.js index 4aa1b63..12ddb1c 100644 --- a/react/src/components/dashboard/syncOnly/syncOnly.js +++ b/react/src/components/dashboard/syncOnly/syncOnly.js @@ -169,9 +169,8 @@ const mapStateToProps = (state) => { }, Interval: { interval: state.Interval.interval, - } + }, }; - }; export default connect(mapStateToProps)(SyncOnly); \ No newline at end of file diff --git a/react/src/components/dashboard/syncOnly/syncOnly.render.js b/react/src/components/dashboard/syncOnly/syncOnly.render.js index 12fc8be..f502b32 100644 --- a/react/src/components/dashboard/syncOnly/syncOnly.render.js +++ b/react/src/components/dashboard/syncOnly/syncOnly.render.js @@ -1,7 +1,7 @@ import React from 'react'; import { translate } from '../../../translate/translate'; -export const ProgressRender = function (fork) { +export const ProgressRender = function(fork) { return (
    @@ -46,7 +46,7 @@ export const ProgressRender = function (fork) { ); }; -export const ForkItemRender = function (forkInfo, port) { +export const ForkItemRender = function(forkInfo, port) { return (
    { return { ActiveCoin: { @@ -198,13 +222,13 @@ const mapStateToProps = (state) => { balance: state.ActiveCoin.balance, cache: state.ActiveCoin.cache, activeSection: state.ActiveCoin.activeSection, - activeAddress: state.ActiveCoin.activeAddress + activeAddress: state.ActiveCoin.activeAddress, + progress: state.ActiveCoin.progress, }, Dashboard: { - progress: state.Dashboard.progress, - } + activeHandle: state.Dashboard.activeHandle, + }, }; - }; export default connect(mapStateToProps)(WalletsBalance); \ No newline at end of file diff --git a/react/src/components/dashboard/walletsBalance/walletsBalance.render.js b/react/src/components/dashboard/walletsBalance/walletsBalance.render.js index 39b9f63..1513a6b 100644 --- a/react/src/components/dashboard/walletsBalance/walletsBalance.render.js +++ b/react/src/components/dashboard/walletsBalance/walletsBalance.render.js @@ -108,6 +108,8 @@ const WalletsBalanceRender = function() {
    + +
    Notice: balance is fetched from KMD explorer as a fallback measure!
    ); }; diff --git a/react/src/components/dashboard/walletsBasiliskConnection/walletsBasiliskConnection.js b/react/src/components/dashboard/walletsBasiliskConnection/walletsBasiliskConnection.js deleted file mode 100755 index eba514b..0000000 --- a/react/src/components/dashboard/walletsBasiliskConnection/walletsBasiliskConnection.js +++ /dev/null @@ -1,46 +0,0 @@ -import React from 'react'; -import { connect } from 'react-redux'; -import { basiliskConnection } from '../../../actions/actionCreators'; -import Store from '../../../store'; -import WalletsBasiliskConnectionRender from './walletsBasiliskConnection.render'; - -class WalletsBasiliskConnection extends React.Component { - constructor() { - super(); - this.basiliskConnectionAction = this.basiliskConnectionAction.bind(this); - } - - basiliskConnectionAction() { - Store.dispatch(basiliskConnection(false)); - } - - handleKeydown(e) { - if (e.key === 'Escape') { - this.basiliskConnectionAction(); - } - } - - isBasiliskConnection() { - return this.props && - this.props.Dashboard.basiliskConnection; - } - - render() { - if (this.isBasiliskConnection()) { - return WalletsBasiliskConnectionRender.call(this); - } else { - return null; - } - } -} - -const mapStateToProps = (state) => { - return { - Dashboard: { - basiliskConnection: state.Dashboard.basiliskConnection, - connectedNotaries: state.Dashboard.connectedNotaries, - } - }; -}; - -export default connect(mapStateToProps)(WalletsBasiliskConnection); diff --git a/react/src/components/dashboard/walletsBasiliskConnection/walletsBasiliskConnection.render.js b/react/src/components/dashboard/walletsBasiliskConnection/walletsBasiliskConnection.render.js deleted file mode 100644 index a9a8afd..0000000 --- a/react/src/components/dashboard/walletsBasiliskConnection/walletsBasiliskConnection.render.js +++ /dev/null @@ -1,83 +0,0 @@ -import React from 'react'; -import { translate } from '../../../translate/translate'; - -const WalletsBasiliskConnectionRender = function() { - return ( -
    this.handleKeydown(event) }> -
    -
    -
    -
    -

    - { translate('INDEX.REFRESHING_BASILISK_NET') }... -

    - -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - { `${translate('IAPI.CON_STATUS')}... ${this.props.Dashboard.connectedNotaries.current} / ${this.props.Dashboard.connectedNotaries.total}:${this.props.Dashboard.connectedNotaries.currentNodeName}` } { Math.floor(this.props.Dashboard.connectedNotaries.current * 100 / this.props.Dashboard.connectedNotaries.total) }% -
    -
    -
    -
    -
    -                { this.props.Dashboard.connectedNotaries.failedToConnectNodes ? `Failed: ${this.props.Dashboard.connectedNotaries.failedToConnectNodes}` : null }
    -                
    -
    -
    -
    -
    -
    -
    - ); -}; - -export default WalletsBasiliskConnectionRender; \ No newline at end of file diff --git a/react/src/components/dashboard/walletsBasiliskRefresh/walletsBasiliskRefresh.js b/react/src/components/dashboard/walletsBasiliskRefresh/walletsBasiliskRefresh.js deleted file mode 100644 index aa60dd7..0000000 --- a/react/src/components/dashboard/walletsBasiliskRefresh/walletsBasiliskRefresh.js +++ /dev/null @@ -1,26 +0,0 @@ -import React from 'react'; -import { connect } from 'react-redux'; -import WalletsBasiliskRefreshRender from './walletsBasiliskRefresh.render'; - -class WalletsBasiliskRefresh extends React.Component { - isBasiliskRefresh() { - return this.props && - this.props.Dashboard.basiliskRefresh; - } - - render() { - if (this.isBasiliskRefresh()) { - return WalletsBasiliskRefreshRender.call(this); - } - - return null; - } -} -const mapStateToProps = (state) => { - return { - Dashboard: { - basiliskRefresh: state.Dashboard.basiliskRefresh, - } - }; -}; -export default connect(mapStateToProps)(WalletsBasiliskRefresh); diff --git a/react/src/components/dashboard/walletsBasiliskRefresh/walletsBasiliskRefresh.render.js b/react/src/components/dashboard/walletsBasiliskRefresh/walletsBasiliskRefresh.render.js deleted file mode 100644 index 2ca1658..0000000 --- a/react/src/components/dashboard/walletsBasiliskRefresh/walletsBasiliskRefresh.render.js +++ /dev/null @@ -1,36 +0,0 @@ -import React from 'react'; -import { translate } from '../../../translate/translate'; - -const WalletsBasiliskRefreshRender = function() { - return ( -
    -
    -
    -
    -
    -

    { translate('INDEX.FETCHING_BASILISK_DATA') }

    -
    - -
    -
    -
    - - - - - - - - - - -
    { translate('INDEX.ADDRESS') }{ translate('INDEX.LIST_UNSPENT') }{ translate('INDEX.LIST_TRANSACTIONS') }{ translate('INDEX.GET_BALANCE') }{ translate('INDEX.REFRESH') }
    -
    -
    -
    -
    -
    - ); -}; - -export default WalletsBasiliskRefreshRender; \ No newline at end of file diff --git a/react/src/components/dashboard/walletsCacheData/walletsCacheData.js b/react/src/components/dashboard/walletsCacheData/walletsCacheData.js index 8296c43..ec30652 100644 --- a/react/src/components/dashboard/walletsCacheData/walletsCacheData.js +++ b/react/src/components/dashboard/walletsCacheData/walletsCacheData.js @@ -193,9 +193,8 @@ const mapStateToProps = (state) => { }, Dashboard: { displayViewCacheModal: state.Dashboard.displayViewCacheModal, - } + }, }; - }; export default connect(mapStateToProps)(WalletsCacheData); \ No newline at end of file diff --git a/react/src/components/dashboard/walletsData/pagination.js b/react/src/components/dashboard/walletsData/pagination.js index dba569d..e92d445 100644 --- a/react/src/components/dashboard/walletsData/pagination.js +++ b/react/src/components/dashboard/walletsData/pagination.js @@ -2,7 +2,7 @@ import React, { Component } from 'react'; import PaginationRender from './pagination.render'; export default class TablePaginationRenderer extends Component { - constructor (props) { + constructor(props) { super(); this.state = { page: props.page diff --git a/react/src/components/dashboard/walletsData/walletsData.js b/react/src/components/dashboard/walletsData/walletsData.js index 684718c..747ad58 100644 --- a/react/src/components/dashboard/walletsData/walletsData.js +++ b/react/src/components/dashboard/walletsData/walletsData.js @@ -5,17 +5,11 @@ import { sortByDate } from '../../../util/sort'; import { formatValue } from '../../../util/formatValue'; import Config from '../../../config'; import { - basiliskRefresh, - basiliskConnection, toggleDashboardTxInfoModal, getBasiliskTransactionsList, changeMainBasiliskAddress, - displayNotariesModal, toggleViewCacheModal, changeActiveAddress, - restartBasiliskInstance, - connectNotaries, - getDexNotaries, deleteCacheFile, fetchNewCacheData, fetchUtxoCache, @@ -60,18 +54,15 @@ class WalletsData extends React.Component { searchTerm: null, coin: null, txhistory: null, + isExplorerData: false, }; this.toggleBasiliskActionsMenu = this.toggleBasiliskActionsMenu.bind(this); this.basiliskRefreshAction = this.basiliskRefreshAction.bind(this); - this.basiliskConnectionAction = this.basiliskConnectionAction.bind(this); - this.getDexNotariesAction = this.getDexNotariesAction.bind(this); this.openDropMenu = this.openDropMenu.bind(this); this.removeAndFetchNewCache = this.removeAndFetchNewCache.bind(this); this._toggleViewCacheModal = this._toggleViewCacheModal.bind(this); - this.toggleCacheApi = this.toggleCacheApi.bind(this); this._fetchUtxoCache = this._fetchUtxoCache.bind(this); - this.restartBasiliskInstance = this.restartBasiliskInstance.bind(this); this.basiliskRefreshActionOne = this.basiliskRefreshActionOne.bind(this); this.handleClickOutside = this.handleClickOutside.bind(this); this.refreshTxHistory = this.refreshTxHistory.bind(this); @@ -219,20 +210,6 @@ class WalletsData extends React.Component { } } - // deprecated - toggleCacheApi() { - const _useCache = !this.state.useCache; - - sessionStorage.setItem('useCache', _useCache); - this.setState(Object.assign({}, this.state, { - useCache: _useCache, - })); - } - - restartBasiliskInstance() { - Store.dispatch(restartBasiliskInstance()); - } - _toggleViewCacheModal() { Store.dispatch(toggleViewCacheModal(!this.props.Dashboard.displayViewCacheModal)); } @@ -257,13 +234,6 @@ class WalletsData 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)); - } if (Object.keys(stateObj).length) { this.setState(Object.assign({}, this.state, stateObj)); @@ -340,18 +310,6 @@ class WalletsData extends React.Component { })); } - basiliskConnectionAction() { - if (this.props.Dashboard) { - Store.dispatch(basiliskConnection(!this.props.Dashboard.basiliskConnection)); - Store.dispatch(connectNotaries()); - } - } - - getDexNotariesAction() { - Store.dispatch(getDexNotaries(this.props.ActiveCoin.coin)); - Store.dispatch(displayNotariesModal(true)); - } - toggleTxInfoModal(display, txIndex) { Store.dispatch(toggleDashboardTxInfoModal(display, txIndex)); } @@ -367,52 +325,58 @@ class WalletsData extends React.Component { } componentWillReceiveProps(props) { + let _stateChange = {}; + if (!this.state.currentAddress && this.props.ActiveCoin.activeAddress && this.props.ActiveCoin.mode === 'basilisk') { - this.setState(Object.assign({}, this.state, { + _stateChange = Object.assign({}, _stateChange, { currentAddress: this.props.ActiveCoin.activeAddress, - })); + }); } + // TODO: clean + // TODO: figure out why changing ActiveCoin props doesn't trigger comp update if (this.props.ActiveCoin.txhistory && this.props.ActiveCoin.txhistory !== 'loading' && this.props.ActiveCoin.txhistory !== 'no data' && this.props.ActiveCoin.txhistory.length) { - if (!this.state.itemsList || + /*if (!this.state.itemsList || this.state.itemsList === 'no data' || (this.state.coin && this.state.coin !== this.props.ActiveCoin.coin) || - (JSON.stringify(this.props.ActiveCoin.txhistory) !== JSON.stringify(this.state.txhistory))) { - this.setState(Object.assign({}, this.state, { + (JSON.stringify(this.props.ActiveCoin.txhistory) !== JSON.stringify(this.state.txhistory))) {*/ + _stateChange = Object.assign({}, _stateChange, { + isExplorerData: this.props.ActiveCoin.txhistory[0].source ? true : false, 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, - })); - } + itemsListColumns: this.generateItemsListColumns(), + }); + //} } if (this.props.ActiveCoin.txhistory && this.props.ActiveCoin.txhistory === 'no data') { - this.setState(Object.assign({}, this.state, { - itemsList: 'no data', - })); + _stateChange = Object.assign({}, _stateChange, { + itemsList: 'no data', + }); } else if (this.props.ActiveCoin.txhistory && this.props.ActiveCoin.txhistory === 'loading') { - this.setState(Object.assign({}, this.state, { + _stateChange = Object.assign({}, _stateChange, { itemsList: 'loading', - })); + }); } - this.setState({ - itemsListColumns: this.generateItemsListColumns(), - }); + this.setState(Object.assign({}, _stateChange)); } isFullySynced() { - if (this.props.Dashboard.progress && - (Number(this.props.Dashboard.progress.balances) + - Number(this.props.Dashboard.progress.validated) + - Number(this.props.Dashboard.progress.bundles) + - Number(this.props.Dashboard.progress.utxo)) / 4 === 100) { + const _progress = this.props.ActiveCoin.progress; + + if (_progress && + (Number(_progress.balances) + + Number(_progress.validated) + + Number(_progress.bundles) + + Number(_progress.utxo)) / 4 === 100) { return true; } else { return false; @@ -421,28 +385,27 @@ class WalletsData extends React.Component { // TODO: add basilisk first run check, display no data if second run renderTxHistoryList() { - if (this.state.itemsList === 'loading' || - this.state.itemsList.length == 0) { + if (this.state.itemsList === 'loading') { if (this.isFullySynced()) { return ( - { translate('INDEX.LOADING_HISTORY') }... + { translate('INDEX.LOADING_HISTORY') }... ); } else { return ( - { translate('INDEX.SYNC_IN_PROGRESS') }... + { translate('INDEX.SYNC_IN_PROGRESS') }... ); } } else if (this.state.itemsList === 'no data') { return ( - { translate('INDEX.NO_DATA') } + { translate('INDEX.NO_DATA') } ); - } else if (this.state.itemsList) { + } else if (this.state.itemsList && this.state.itemsList.length) { return TxHistoryListRender.call(this); } @@ -687,19 +650,16 @@ const mapStateToProps = (state) => { addresses: state.ActiveCoin.addresses, txhistory: state.ActiveCoin.txhistory, showTransactionInfo: state.ActiveCoin.showTransactionInfo, + progress: state.ActiveCoin.progress, }, Dashboard: { activeHandle: state.Dashboard.activeHandle, displayViewCacheModal: state.Dashboard.displayViewCacheModal, - basiliskConnection: state.Dashboard.basiliskConnection, - progress: state.Dashboard.progress, }, Main: { coins: state.Main.coins, - } - + }, }; - }; export default connect(mapStateToProps)(WalletsData); \ No newline at end of file diff --git a/react/src/components/dashboard/walletsData/walletsData.render.js b/react/src/components/dashboard/walletsData/walletsData.render.js index f404a8f..5ef4129 100644 --- a/react/src/components/dashboard/walletsData/walletsData.render.js +++ b/react/src/components/dashboard/walletsData/walletsData.render.js @@ -1,8 +1,5 @@ import React from 'react'; import { translate } from '../../../translate/translate'; -import WalletsBasiliskRefresh from '../walletsBasiliskRefresh/walletsBasiliskRefresh'; -import WalletsBasiliskConnection from '../walletsBasiliskConnection/walletsBasiliskConnection'; -import WalletsNotariesList from '../walletsNotariesList/walletsNotariesList'; import WalletsCacheData from '../walletsCacheData/walletsCacheData'; import ReactTable from 'react-table'; import TablePaginationRenderer from './pagination'; @@ -192,9 +189,6 @@ export const WalletsDataRender = function() { return ( - - -

    { translate('INDEX.TRANSACTION_HISTORY') }

    +
    Notice: transactions list is fetched from KMD explorer as a fallback measure!
    { this.shouldDisplayAddressList() && @@ -277,7 +257,7 @@ export const WalletsDataRender = function() { { this.renderAddressList() }
    } - { this.props.ActiveCoin.txhistory !== 'loading' && + { (this.props.ActiveCoin.txhistory !== 'loading' && this.props.ActiveCoin.txhistory !== 'no data') &&
    { ActiveCoin: { coin: state.ActiveCoin.coin, activeSection: state.ActiveCoin.activeSection, + progress: state.ActiveCoin.progress, }, - Dashboard: { - progress: state.Dashboard.progress - } }; - }; export default connect(mapStateToProps)(WalletsInfo); diff --git a/react/src/components/dashboard/walletsInfo/walletsInfo.render.js b/react/src/components/dashboard/walletsInfo/walletsInfo.render.js index 972da9d..b4b6d29 100644 --- a/react/src/components/dashboard/walletsInfo/walletsInfo.render.js +++ b/react/src/components/dashboard/walletsInfo/walletsInfo.render.js @@ -3,6 +3,8 @@ import { translate } from '../../../translate/translate'; import ClaimInterestModal from '../claimInterestModal/claimInterestModal'; const WalletsInfoRender = function() { + const _progress = this.props.ActiveCoin.progress; + return (
    @@ -16,13 +18,13 @@ const WalletsInfoRender = function() { { translate('INDEX.WALLET_VERSION') } - { this.props.Dashboard.progress.walletversion } + { _progress.walletversion } { translate('INDEX.BALANCE') } - { this.props.Dashboard.progress.balance } + { _progress.balance } @@ -46,7 +48,7 @@ const WalletsInfoRender = function() { + onClick={ () => this.openClaimInterestModal() }>{ translate('CLAIM_INTEREST.CLAIM_INTEREST', ' ') }
    } @@ -65,19 +67,19 @@ const WalletsInfoRender = function() { { translate('INDEX.VERSION') } - { this.props.Dashboard.progress.KMDversion } + { _progress.KMDversion } { translate('INDEX.PROTOCOL_VERSION') } - { this.props.Dashboard.progress.protocolversion } + { _progress.protocolversion } { translate('INDEX.NOTARIZED') } - { this.props.Dashboard.progress.notarized } + { _progress.notarized } @@ -85,15 +87,15 @@ const WalletsInfoRender = function() { { translate('INDEX.NOTARIZED') } { translate('INDEX.HASH') } - { this.props.Dashboard.progress.notarizedhash ? - this.props.Dashboard.progress.notarizedhash.substring( + { _progress.notarizedhash ? + _progress.notarizedhash.substring( 0, - Math.floor(this.props.Dashboard.progress.notarizedhash.length / 2) + Math.floor(_progress.notarizedhash.length / 2) ) + '\t' + - this.props.Dashboard.progress.notarizedhash.substring( - Math.floor(this.props.Dashboard.progress.notarizedhash.length / 2), - this.props.Dashboard.progress.notarizedhash.length + _progress.notarizedhash.substring( + Math.floor(_progress.notarizedhash.length / 2), + _progress.notarizedhash.length ) : '' } @@ -108,43 +110,43 @@ const WalletsInfoRender = function() { { translate('INDEX.BLOCKS') } - { this.props.Dashboard.progress.blocks } + { _progress.blocks } { translate('INDEX.CONNECTIONS') } - { this.props.Dashboard.progress.connections } + { _progress.connections } { translate('INDEX.DIFFICULTY') } - { this.props.Dashboard.progress.difficulty } + { _progress.difficulty } Testnet - { this.props.Dashboard.progress.testnet } + { _progress.testnet } { translate('INDEX.PAY_TX_FEE') } - { this.props.Dashboard.progress.paytxfee } + { _progress.paytxfee } { translate('INDEX.RELAY_FEE') } - { this.props.Dashboard.progress.relayfee } + { _progress.relayfee } { translate('INDEX.ERRORS') } - { this.props.Dashboard.progress.errors } + { _progress.errors } diff --git a/react/src/components/dashboard/walletsNative/walletsNative.js b/react/src/components/dashboard/walletsNative/walletsNative.js index e220d6a..718b731 100644 --- a/react/src/components/dashboard/walletsNative/walletsNative.js +++ b/react/src/components/dashboard/walletsNative/walletsNative.js @@ -26,18 +26,18 @@ class WalletsNative extends React.Component { if (data && data.komodod && data.komodod.error) { - switch (data.komodod.error) { - case 'run -reindex': - Store.dispatch( - triggerToaster( - translate('TOASTR.RESTART_AGAMA_WITH_REINDEX_PARAM'), - translate('TOASTR.WALLET_NOTIFICATION'), - 'info', - false - ) - ); - break; - } + switch (data.komodod.error) { + case 'run -reindex': + Store.dispatch( + triggerToaster( + translate('TOASTR.RESTART_AGAMA_WITH_REINDEX_PARAM'), + translate('TOASTR.WALLET_NOTIFICATION'), + 'info', + false + ) + ); + break; + } } } @@ -79,9 +79,8 @@ const mapStateToProps = (state) => { ActiveCoin: { coin: state.ActiveCoin.coin, mode: state.ActiveCoin.mode, - } + }, }; - }; export default connect(mapStateToProps)(WalletsNative); diff --git a/react/src/components/dashboard/walletsNative/walletsNative.render.js b/react/src/components/dashboard/walletsNative/walletsNative.render.js index 580ae42..e5411f4 100644 --- a/react/src/components/dashboard/walletsNative/walletsNative.render.js +++ b/react/src/components/dashboard/walletsNative/walletsNative.render.js @@ -27,7 +27,7 @@ const WalletsNativeRender = function() {
    -
    +
    diff --git a/react/src/components/dashboard/walletsNativeAlert/walletsNativeAlert.js b/react/src/components/dashboard/walletsNativeAlert/walletsNativeAlert.js deleted file mode 100644 index 79b137c..0000000 --- a/react/src/components/dashboard/walletsNativeAlert/walletsNativeAlert.js +++ /dev/null @@ -1,20 +0,0 @@ -import React from 'react'; -import WalletsNativeAlertRender from './walletsNativeAlert.render'; - -class WalletsNativeAlert extends React.Component { - hasNoProgress() { - return this.props && - this.props.Dashboard && - !this.props.Dashboard.progress; - } - - render() { - if (this.hasNoProgress()) { - return WalletsNativeAlertRender.call(this); - } - - return null; - } -} - -export default WalletsNativeAlert; diff --git a/react/src/components/dashboard/walletsNativeAlert/walletsNativeAlert.render.js b/react/src/components/dashboard/walletsNativeAlert/walletsNativeAlert.render.js deleted file mode 100644 index ccf3a24..0000000 --- a/react/src/components/dashboard/walletsNativeAlert/walletsNativeAlert.render.js +++ /dev/null @@ -1,19 +0,0 @@ -import React from 'react'; -import { translate } from '../../../translate/translate'; - -const WalletsNativeAlertRender = function() { - return ( -
    -

    { translate('INDEX.OOPS_ERROR') }

    -

    - { translate('INDEX.OOPS_ERROR_DESC') } - server=1
    - rpcport=
    - rpcuser=
    - rpcpassword= -

    -
    - ); -}; - -export default WalletsNativeAlertRender; \ No newline at end of file diff --git a/react/src/components/dashboard/walletsNativeSend/walletsNativeSend.js b/react/src/components/dashboard/walletsNativeSend/walletsNativeSend.js index 0d9771c..7efbcf0 100644 --- a/react/src/components/dashboard/walletsNativeSend/walletsNativeSend.js +++ b/react/src/components/dashboard/walletsNativeSend/walletsNativeSend.js @@ -17,7 +17,7 @@ import { WalletsNativeSendFormRender, _WalletsNativeSendFormRender } from './walletsNativeSend.render'; -import { isPositiveNumber } from "../../../util/number"; +import { isPositiveNumber } from '../../../util/number'; class WalletsNativeSend extends React.Component { constructor(props) { @@ -47,6 +47,9 @@ class WalletsNativeSend extends React.Component { this.toggleSubstractFee = this.toggleSubstractFee.bind(this); } + // TODO: 1) t -> z amount validation + // 2) z -> z amount validation + WalletsNativeSendFormRender() { return _WalletsNativeSendFormRender.call(this); } @@ -364,18 +367,10 @@ class WalletsNativeSend extends React.Component { return null; } - checkTotalBalance() { - let _balance = 0; - if (this.props.ActiveCoin.balance && - this.props.ActiveCoin.balance.total) { - _balance = this.props.ActiveCoin.balance.total; - } - - return _balance; - } - + // TODO: reduce to a single toast validateSendFormData() { let valid = true; + if (!this.state.sendTo || this.state.sendTo.length < 34) { Store.dispatch( @@ -399,7 +394,20 @@ class WalletsNativeSend extends React.Component { valid = false; } - if (this.state.amount > this.checkTotalBalance()) { + if (((!this.state.sendFrom || this.state.addressType === 'public') && + this.state.sendTo && + this.state.sendTo.length === 34 && + this.props.ActiveCoin.balance && + this.props.ActiveCoin.balance.transparent && + Number(this.state.amount) > Number(this.props.ActiveCoin.balance.transparent)) || + (this.state.addressType === 'public' && + this.state.sendTo && + this.state.sendTo.length > 34 && + Number(this.state.amount) > Number(this.state.sendFromAmount)) || + (this.state.addressType === 'private' && + this.state.sendTo && + this.state.sendTo.length >= 34 && + Number(this.state.amount) > Number(this.state.sendFromAmount))) { Store.dispatch( triggerToaster( translate('SEND.INSUFFICIENT_FUNDS'), @@ -445,17 +453,26 @@ class WalletsNativeSend extends React.Component { } } -const mapStateToProps = (state) => { - return { +const mapStateToProps = (state, props) => { + let _mappedProps = { ActiveCoin: { addresses: state.ActiveCoin.addresses, coin: state.ActiveCoin.coin, mode: state.ActiveCoin.mode, opids: state.ActiveCoin.opids, + balance: state.ActiveCoin.balance, activeSection: state.ActiveCoin.activeSection, - } + }, }; - + + if (props && + props.activeSection && + props.renderFormOnly) { + _mappedProps.ActiveCoin.activeSection = props.activeSection; + _mappedProps.renderFormOnly = props.renderFormOnly; + } + + return _mappedProps; }; export default connect(mapStateToProps)(WalletsNativeSend); diff --git a/react/src/components/dashboard/walletsNativeSend/walletsNativeSend.render.js b/react/src/components/dashboard/walletsNativeSend/walletsNativeSend.render.js index da79af7..2804eeb 100644 --- a/react/src/components/dashboard/walletsNativeSend/walletsNativeSend.render.js +++ b/react/src/components/dashboard/walletsNativeSend/walletsNativeSend.render.js @@ -35,8 +35,6 @@ export const AddressListRender = function() { ); }; -// { this.renderAddressByType('public') } - export const OASendUIRender = function() { return (
    diff --git a/react/src/components/dashboard/walletsNav/walletsNav.js b/react/src/components/dashboard/walletsNav/walletsNav.js index 96b3732..fbcb274 100644 --- a/react/src/components/dashboard/walletsNav/walletsNav.js +++ b/react/src/components/dashboard/walletsNav/walletsNav.js @@ -115,7 +115,7 @@ class WalletsNav extends React.Component { if (this.props && this.props.ActiveCoin && !this.props.ActiveCoin.coin) { - return WalletsNavNoWalletRender.call(this); + return null; //WalletsNavNoWalletRender.call(this); } return WalletsNavWithWalletRender.call(this); @@ -132,12 +132,13 @@ const mapStateToProps = (state) => { balance: state.ActiveCoin.balance, cache: state.ActiveCoin.cache, activeSection: state.ActiveCoin.activeSection, - activeAddress: state.ActiveCoin.activeAddress + activeAddress: state.ActiveCoin.activeAddress, + }, + Dashboard: { + activeHandle: state.Dashboard.activeHandle, }, - ActiveHandle: state.Dashboard.activeHandle, nativeOnly: Config.iguanaLessMode, }; - }; export default connect(mapStateToProps)(WalletsNav); diff --git a/react/src/components/dashboard/walletsNav/walletsNav.render.js b/react/src/components/dashboard/walletsNav/walletsNav.render.js index 85892f6..7e71cfc 100644 --- a/react/src/components/dashboard/walletsNav/walletsNav.render.js +++ b/react/src/components/dashboard/walletsNav/walletsNav.render.js @@ -52,14 +52,13 @@ export const WalletsNavWithWalletRender = function() { onClick={ this.props.ActiveCoin.mode !== 'native' ? this.toggleSendReceiveCoinForms : this.toggleNativeWalletTransactions }> { translate('INDEX.TRANSACTIONS') } - { this.checkTotalBalance() > 0 && - - } +
    - ); - } else { - return ( -
    { translate('INDEX.TOTAL_NOTARIES') }: { this.props.ActiveCoin.notaries.numnotaries }
    - ); - } - } - - renderNotariesList() { - if (this.props.ActiveCoin.notaries && - this.props.ActiveCoin.notaries.notaries && - this.props.ActiveCoin.notaries.notaries.length) { - return this.props.ActiveCoin.notaries.notaries.map( - (node, index) => NotariesListRender.call(this, node, index) - ); - } else { - return null; - } - } - - render() { - if (this.props && - this.props.ActiveCoin.mode === 'basilisk' && - this.props.ActiveCoin.displayNotariesModal) { - return WalletsNotariesListRender.call(this); - } - - return null; - } -} -const mapStateToProps = (state) => { - return { - ActiveCoin: { - mode: state.ActiveCoin.mode, - displayNotariesModal: state.ActiveCoin.displayNotariesModal, - notaries: state.ActiveCoin.notaries, - } - }; - -}; - -export default connect(mapStateToProps)(WalletsNotariesList); diff --git a/react/src/components/dashboard/walletsNotariesList/walletsNotariesList.render.js b/react/src/components/dashboard/walletsNotariesList/walletsNotariesList.render.js deleted file mode 100644 index 4f45cc4..0000000 --- a/react/src/components/dashboard/walletsNotariesList/walletsNotariesList.render.js +++ /dev/null @@ -1,60 +0,0 @@ -import React from 'react'; -import { translate } from '../../../translate/translate'; -import Tree, { TreeNode } from 'rc-tree'; -import { animation } from '../../../util/rc-tree-animate'; - -export const NotariesListRender = function(node, index) { - return ( - - - - - - ); -}; - -export const WalletsNotariesListRender = function() { - return ( -
    this.handleKeydown(event) }> -
    -
    -
    -
    -
    -
    -
    -
    - { this.renderNotariesFetching() } - - { this.renderNotariesList() } - -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    - ); -}; \ No newline at end of file diff --git a/react/src/components/dashboard/walletsProgress/walletsProgress.js b/react/src/components/dashboard/walletsProgress/walletsProgress.js index 6e9e1aa..7daaf05 100644 --- a/react/src/components/dashboard/walletsProgress/walletsProgress.js +++ b/react/src/components/dashboard/walletsProgress/walletsProgress.js @@ -2,27 +2,53 @@ import React from 'react'; import { connect } from 'react-redux'; import { translate } from '../../../translate/translate'; import { - SyncErrorLongestChainRender, SyncErrorBlocksRender, SyncPercentageRender, LoadingBlocksRender, TranslationComponentsRender, CoinIsBusyRender, ChainActivationNotificationRender, + VerifyingBlocksRender, WalletsProgressRender } from './walletsProgress.render'; class WalletsProgress extends React.Component { constructor() { super(); + this.state = { + prevProgress: {}, + }; this.isFullySynced = this.isFullySynced.bind(this); } + componentWillReceiveProps(props) { + if (props.ActiveCoin && + props.ActiveCoin.progress && + Number(props.ActiveCoin.progress.longestchain) === 0) { + let _progress = props.ActiveCoin.progress; + + if (this.state.prevProgress && + this.state.prevProgress.longestchain && + Number(this.state.prevProgress.longestchain) > 0) { + _progress.longestchain = this.state.prevProgress.longestchain; + } + this.setState(Object.assign({}, this.state, { + prevProgress: _progress, + })); + } else { + this.setState(Object.assign({}, this.state, { + prevProgress: props.ActiveCoin.progress, + })); + } + } + isFullySynced() { - if ((Number(this.props.Dashboard.progress.balances) + - Number(this.props.Dashboard.progress.validated) + - Number(this.props.Dashboard.progress.bundles) + - Number(this.props.Dashboard.progress.utxo)) / 4 === 100) { + const _progress = this.props.ActiveCoin.progress; + + if ((Number(_progress.balances) + + Number(_progress.validated) + + Number(_progress.bundles) + + Number(_progress.utxo)) / 4 === 100) { return true; } else { return false; @@ -38,13 +64,20 @@ class WalletsProgress extends React.Component { } renderChainActivationNotification() { - if (this.props.Dashboard.progress) { - if ((!this.props.Dashboard.progress.blocks && !this.props.Dashboard.progress.longestchain) || - (this.props.Dashboard.progress.blocks < this.props.Dashboard.progress.longestchain)) { + const _progress = this.props.ActiveCoin.progress; + + if (_progress) { + if ((!_progress.blocks && !_progress.longestchain) || + (_progress.blocks < _progress.longestchain) || + this.props.ActiveCoin.rescanInProgress) { return ChainActivationNotificationRender.call(this); } } else { - return null; + if (this.props.ActiveCoin.rescanInProgress) { + return ChainActivationNotificationRender.call(this); + } else { + return null; + } } } @@ -74,47 +107,61 @@ class WalletsProgress extends React.Component { } if (temp[i].indexOf('progress=') > -1) { currentProgress = Number(temp[i].replace('progress=', '')) * 1000; - currentProgress = currentProgress >= 100 ? 100 : currentProgress; + if (currentProgress > 100) { + currentProgress = Number(temp[i].replace('progress=', '')) * 100; + } } } - return [ - currentBestChain, - currentProgress - ]; + if (this.props.ActiveCoin.progress.remoteKMDNode && + this.props.ActiveCoin.progress.remoteKMDNode.blocks) { + const longestHeight = this.props.ActiveCoin.progress.remoteKMDNode.blocks; + + return [ + currentBestChain, + currentProgress, + longestHeight + ]; + } else { + return [ + currentBestChain, + currentProgress + ]; + } } } renderSyncPercentagePlaceholder() { + const _progress = this.props.ActiveCoin.progress; + // activating best chain - if (this.props.Dashboard.progress && - this.props.Dashboard.progress.code && - this.props.Dashboard.progress.code === -28 && + if (_progress && + _progress.code && + _progress.code === -28 && this.props.Settings.debugLog) { - const _progress = this.parseActivatingBestChainProgress(); + if (_progress.message == 'Activating best chain...') { + const _parseProgress = this.parseActivatingBestChainProgress(); - if (_progress && - _progress[1]) { - return SyncPercentageRender.call(this, _progress[1] === 1000 ? 100 : _progress[1].toFixed(2)); - } else { - return LoadingBlocksRender.call(this); + if (_parseProgress && + _parseProgress[1]) { + return SyncPercentageRender.call(this, _parseProgress[1].toFixed(2) + '%', _parseProgress[0], _parseProgress[2] ? _parseProgress[2] : null); + } else { + return LoadingBlocksRender.call(this); + } + } else if (_progress.message === 'Verifying blocks...') { + return VerifyingBlocksRender.call(this); } } - if (this.props.Dashboard.progress && - this.props.Dashboard.progress.blocks > 0 && - this.props.Dashboard.progress.longestchain === 0) { - return SyncErrorLongestChainRender.call(this); - } - - if (this.props.Dashboard.progress && - this.props.Dashboard.progress.blocks === 0) { + if (_progress && + _progress.blocks === 0) { return SyncErrorBlocksRender.call(this); } - if (this.props.Dashboard.progress && - this.props.Dashboard.progress.blocks) { - const syncPercentage = (parseFloat(parseInt(this.props.Dashboard.progress.blocks, 10) * 100 / parseInt(this.props.Dashboard.progress.longestchain, 10)).toFixed(2) + '%').replace('NaN', 0); + if (_progress && + _progress.blocks && + _progress.blocks > 0) { + const syncPercentage = (parseFloat(parseInt(_progress.blocks, 10) * 100 / parseInt(Number(_progress.longestchain) || Number(this.state.prevProgress.longestchain), 10)).toFixed(2) + '%').replace('NaN', 0); return SyncPercentageRender.call(this, syncPercentage === 1000 ? 100 : syncPercentage); } @@ -125,12 +172,31 @@ class WalletsProgress extends React.Component { return TranslationComponentsRender.call(this, translationID); } + renderRescanProgress() { + if (this.props.Settings.debugLog.indexOf('Still rescanning') > -1 && + this.props.ActiveCoin.rescanInProgress) { + const temp = this.props.Settings.debugLog.split(' '); + let currentProgress; + + for (let i = 0; i < temp.length; i++) { + if (temp[i].indexOf('Progress=') > -1) { + currentProgress = Number(temp[i].replace('Progress=', '')) * 100; + } + } + + return currentProgress; + } else { + return null; + } + } + renderActivatingBestChainProgress() { if (this.props.Settings && - this.props.Settings.debugLog) { + this.props.Settings.debugLog && + !this.props.ActiveCoin.rescanInProgress) { if (this.props.Settings.debugLog.indexOf('UpdateTip') > -1 && - !this.props.Dashboard.progress && - !this.props.Dashboard.progress.blocks) { + !this.props.ActiveCoin.progress && + !this.props.ActiveCoin.progress.blocks) { const temp = this.props.Settings.debugLog.split(' '); let currentBestChain; let currentProgress; @@ -145,23 +211,23 @@ class WalletsProgress extends React.Component { } // fallback to local data if remote node is inaccessible - if (this.props.Dashboard.progress.remoteKMDNode && - !this.props.Dashboard.progress.remoteKMDNode.blocks) { + if (this.props.ActiveCoin.progress.remoteKMDNode && + !this.props.ActiveCoin.progress.remoteKMDNode.blocks) { return ( `: ${currentProgress}% (${ translate('INDEX.ACTIVATING_SM') })` ); } else { - if (this.props.Dashboard.progress.remoteKMDNode && - this.props.Dashboard.progress.remoteKMDNode.blocks) { + if (this.props.ActiveCoin.progress.remoteKMDNode && + this.props.ActiveCoin.progress.remoteKMDNode.blocks) { return( - `: ${Math.floor(currentBestChain * 100 / this.props.Dashboard.progress.remoteKMDNode.blocks)}% (${ translate('INDEX.BLOCKS_SM') } ${currentBestChain} / ${this.props.Dashboard.progress.remoteKMDNode.blocks})` + `: ${Math.floor(currentBestChain * 100 / this.props.ActiveCoin.progress.remoteKMDNode.blocks)}% (${ translate('INDEX.BLOCKS_SM') } ${currentBestChain} / ${this.props.ActiveCoin.progress.remoteKMDNode.blocks})` ); } } } else if ( this.props.Settings.debugLog.indexOf('Still rescanning') > -1 && - !this.props.Dashboard.progress || - !this.props.Dashboard.progress.blocks + !this.props.ActiveCoin.progress || + !this.props.ActiveCoin.progress.blocks ) { const temp = this.props.Settings.debugLog.split(' '); let currentProgress; @@ -173,9 +239,9 @@ class WalletsProgress extends React.Component { } // activating best chain - if (this.props.Dashboard.progress && - this.props.Dashboard.progress.code && - this.props.Dashboard.progress.code === -28 && + if (this.props.ActiveCoin.progress && + this.props.ActiveCoin.progress.code && + this.props.ActiveCoin.progress.code === -28 && this.props.Settings.debugLog) { const _blocks = this.parseActivatingBestChainProgress(); @@ -219,8 +285,8 @@ class WalletsProgress extends React.Component { if (this.props && this.props.ActiveCoin && (this.isFullMode() || this.isNativeMode())) { - if (this.props.Dashboard.progress && - this.props.Dashboard.progress.error) { + if (this.props.ActiveCoin.progress && + this.props.ActiveCoin.progress.error) { return CoinIsBusyRender.call(this); } @@ -238,10 +304,11 @@ const mapStateToProps = (state) => { }, ActiveCoin: { mode: state.ActiveCoin.mode, - coin: state.coin, - } + coin: state.ActiveCoin.coin, + progress: state.ActiveCoin.progress, + rescanInProgress: state.ActiveCoin.rescanInProgress, + }, }; - }; export default connect(mapStateToProps)(WalletsProgress); \ No newline at end of file diff --git a/react/src/components/dashboard/walletsProgress/walletsProgress.render.js b/react/src/components/dashboard/walletsProgress/walletsProgress.render.js index 0305aa1..96ae9e5 100644 --- a/react/src/components/dashboard/walletsProgress/walletsProgress.render.js +++ b/react/src/components/dashboard/walletsProgress/walletsProgress.render.js @@ -1,10 +1,10 @@ import React from 'react'; import { translate } from '../../../translate/translate'; -export const SyncErrorLongestChainRender = function() { +export const VerifyingBlocksRender = function() { return (
    - { translate('INDEX.SYNC_ERR_LONGESTCHAIN') } + Verifying blocks...
    ); }; @@ -17,24 +17,54 @@ export const SyncErrorBlocksRender = function() { ); }; -export const SyncPercentageRender = function(syncPercentage) { - return ( -
    - { syncPercentage } | { this.props.Dashboard.progress.blocks } / { this.props.Dashboard.progress.longestchain } | { translate('INDEX.CONNECTIONS') }: { this.props.Dashboard.progress.connections } -
    - ); +export const SyncPercentageRender = function(syncPercentage, currentBlock, maxHeight) { + if (this.props.ActiveCoin.rescanInProgress) { + return ( +
    + Please wait until rescan process is finished +
    + ); + } else { + if (syncPercentage === 'Infinity%') { + return ( +
    + Blocks: { this.props.ActiveCoin.progress.blocks } | { translate('INDEX.CONNECTIONS') }: { this.props.ActiveCoin.progress.connections } +
    + ); + } else { + return ( +
    + { syncPercentage === '100.00%' ? '100%' : syncPercentage } | { this.props.ActiveCoin.progress.blocks || currentBlock } / { this.props.ActiveCoin.progress.longestchain || maxHeight } | { translate('INDEX.CONNECTIONS') }: { this.props.ActiveCoin.progress.connections } +
    + ); + } + } }; export const LoadingBlocksRender = function() { - return ( -
    - { translate('INDEX.LOADING_BLOCKS') } -
    - ); + if (this.props.ActiveCoin.rescanInProgress) { + return ( +
    + Please wait until rescan process is finished +
    + ); + } else { + return ( +
    + { translate('INDEX.LOADING_BLOCKS') } +
    + ); + } }; export const TranslationComponentsRender = function(translationID) { @@ -56,15 +86,13 @@ export const CoinIsBusyRender = function() { export const ChainActivationNotificationRender = function() { return ( -
    +
    -

    - { translate('INDEX.ACTIVATING_CHAIN') } - { this.renderActivatingBestChainProgress() } +

    { translate('INDEX.ACTIVATING_CHAIN') } { this.props.ActiveCoin.rescanInProgress ? (this.renderRescanProgress() ? `: ${this.renderRescanProgress().toFixed(2)}% (rescanning blocks)` : '(rescanning blocks)') : this.renderActivatingBestChainProgress() }

    { this.renderLB('INDEX.KMD_STARTED') }

    @@ -75,24 +103,24 @@ export const WalletsProgressRender = function() { return (