From 16a634253b3ad411560ef5956cd1dbab94b9aefb Mon Sep 17 00:00:00 2001 From: pbca26 Date: Wed, 22 Nov 2017 19:44:48 +0300 Subject: [PATCH] jumblr pause/resume --- assets/mainWindow/css/loading.css | 2 +- assets/mainWindow/js/loading.js | 2 + react/src/actions/actions/jumblr.js | 76 +++++++++++++++++++ .../src/components/dashboard/jumblr/jumblr.js | 54 ++++++++++++- .../dashboard/jumblr/jumblr.render.js | 19 +++++ .../components/dashboard/jumblr/jumblr.scss | 12 +++ 6 files changed, 163 insertions(+), 2 deletions(-) diff --git a/assets/mainWindow/css/loading.css b/assets/mainWindow/css/loading.css index 3e58082..9b3dc0d 100644 --- a/assets/mainWindow/css/loading.css +++ b/assets/mainWindow/css/loading.css @@ -480,7 +480,7 @@ small { font-size: 14px; text-align: left; padding: 10px; - top: 60px; + top: 45px; left: 40px; z-index: 1000; } diff --git a/assets/mainWindow/js/loading.js b/assets/mainWindow/js/loading.js index 10fce43..b70eb48 100644 --- a/assets/mainWindow/js/loading.js +++ b/assets/mainWindow/js/loading.js @@ -295,5 +295,7 @@ function init() { $('.dropdown-menu.native').css('right', '165px'); $('#nativeOnlyBtnCarret').css('margin-right', '0'); $('#settingsBtn').css('margin', '0'); + $('.mode-desc.spv').hide(); + $('.mode-desc.native').css('left', '180px'); } } \ No newline at end of file diff --git a/react/src/actions/actions/jumblr.js b/react/src/actions/actions/jumblr.js index 46008b5..92bacc1 100644 --- a/react/src/actions/actions/jumblr.js +++ b/react/src/actions/actions/jumblr.js @@ -79,6 +79,82 @@ export function setJumblrAddress(coin, type, address) { }); } +export function pauseJumblr(coin) { + return new Promise((resolve, reject) => { + const payload = { + mode: null, + chain: coin, + cmd: 'jumblr_pause', + params: [], + }; + + const _fetchConfig = { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ payload: payload }), + }; + + fetch( + `http://127.0.0.1:${Config.agamaPort}/shepherd/cli`, + _fetchConfig + ) + .catch((error) => { + console.log(error); + dispatch( + triggerToaster( + 'pauseJumblr', + 'Error', + 'error' + ) + ); + }) + .then(response => response.json()) + .then(json => { + resolve(json); + }); + }); +} + +export function resumeJumblr(coin) { + return new Promise((resolve, reject) => { + const payload = { + mode: null, + chain: coin, + cmd: 'jumblr_resume', + params: [], + }; + + const _fetchConfig = { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ payload: payload }), + }; + + fetch( + `http://127.0.0.1:${Config.agamaPort}/shepherd/cli`, + _fetchConfig + ) + .catch((error) => { + console.log(error); + dispatch( + triggerToaster( + 'resumeJumblr', + 'Error', + 'error' + ) + ); + }) + .then(response => response.json()) + .then(json => { + resolve(json); + }); + }); +} + function dumpPrivkey(coin, key) { return new Promise((resolve, reject) => { const payload = { diff --git a/react/src/components/dashboard/jumblr/jumblr.js b/react/src/components/dashboard/jumblr/jumblr.js index 4bd5571..3034949 100755 --- a/react/src/components/dashboard/jumblr/jumblr.js +++ b/react/src/components/dashboard/jumblr/jumblr.js @@ -10,7 +10,9 @@ import { setJumblrAddress, importPrivkey, copyCoinAddress, - copyString + copyString, + resumeJumblr, + pauseJumblr, } from '../../../actions/actionCreators'; import Store from '../../../store'; import Config from '../../../config'; @@ -69,9 +71,59 @@ class Jumblr extends React.Component { this.copyPassphrase = this.copyPassphrase.bind(this); this.checkPassphraseValid = this.checkPassphraseValid.bind(this); this.importJumblrSecretAddress = this.importJumblrSecretAddress.bind(this); + this._pauseJumblr = this._pauseJumblr.bind(this); + this._resumeJumblr = this._resumeJumblr.bind(this); this.onChange = this.onChange.bind(this); } + _pauseJumblr() { + pauseJumblr(this.props.ActiveCoin.coin) + .then((json) => { + if (json.error && + json.error.code) { + Store.dispatch( + triggerToaster( + json.error.message, + 'Error', + 'error' + ) + ); + } else if (json.result && json.result.result && json.result.result === 'paused') { + Store.dispatch( + triggerToaster( + 'Jumblr paused', + 'Jumblr', + 'success' + ) + ); + } + }); + } + + _resumeJumblr() { + resumeJumblr(this.props.ActiveCoin.coin) + .then((json) => { + if (json.error && + json.error.code) { + Store.dispatch( + triggerToaster( + json.error.message, + 'Error', + 'error' + ) + ); + } else if (json.result && json.result.result && json.result.result === 'resumed') { + Store.dispatch( + triggerToaster( + 'Jumblr resumed', + 'Jumblr', + 'success' + ) + ); + } + }); + } + generateKeys(passphrase) { if (!passphrase) { const key = new Bitcoin.ECKey(false).setCompressed(true); diff --git a/react/src/components/dashboard/jumblr/jumblr.render.js b/react/src/components/dashboard/jumblr/jumblr.render.js index e25189d..805398d 100644 --- a/react/src/components/dashboard/jumblr/jumblr.render.js +++ b/react/src/components/dashboard/jumblr/jumblr.render.js @@ -128,6 +128,25 @@ export const JumblrRender = function() { + +
+ + +
diff --git a/react/src/components/dashboard/jumblr/jumblr.scss b/react/src/components/dashboard/jumblr/jumblr.scss index 80861e6..27dad77 100644 --- a/react/src/components/dashboard/jumblr/jumblr.scss +++ b/react/src/components/dashboard/jumblr/jumblr.scss @@ -89,4 +89,16 @@ padding: 0; } } +} + +.btn-jumblr-warning { + background: rgba(255, 152, 0, 0.8); + color: #fff; + + &:hover, + &:active, + &:focus { + color: #fff; + background: #ff9800; + } } \ No newline at end of file