From a9f7e807da7539781cdd5f24f5b7ba5d1d23d701 Mon Sep 17 00:00:00 2001 From: Aaron Imming Date: Thu, 21 Mar 2019 15:27:58 +0800 Subject: [PATCH 1/3] Emit bot.running event when entering position --- src/botPage/bot/TradeEngine/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/botPage/bot/TradeEngine/index.js b/src/botPage/bot/TradeEngine/index.js index 02ee2e475d..b018c85539 100644 --- a/src/botPage/bot/TradeEngine/index.js +++ b/src/botPage/bot/TradeEngine/index.js @@ -16,6 +16,7 @@ import Ticks from './Ticks'; import rootReducer from './state/reducers'; import * as constants from './state/constants'; import { start } from './state/actions'; +import { observer as globalObserver } from '../../../common/utils/observer'; const watchBefore = store => watchScope({ @@ -34,7 +35,7 @@ const watchDuring = store => }); /* The watchScope function is called randomly and resets the prevTick - * which leads to the same problem we try to solve. So prevTick is isolated + * which leads to the same problem we try to solve. So prevTick is isolated */ let prevTick; const watchScope = ({ store, stopScope, passScope, passFlag }) => { @@ -90,6 +91,8 @@ export default class TradeEngine extends Balance(Purchase(Sell(OpenContract(Prop throw createError('NotInitialized', translate('Bot.init is not called')); } + globalObserver.emit('bot.running'); + this.tradeOptions = expectTradeOptions(tradeOptions); this.store.dispatch(start()); From dd30bfe6e6da725c0e00895d9aa9a62529861606 Mon Sep 17 00:00:00 2001 From: Aaron Imming Date: Thu, 21 Mar 2019 15:29:47 +0800 Subject: [PATCH 2/3] Ensure correct status indicator is showing --- src/botPage/view/TradeInfoPanel/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/botPage/view/TradeInfoPanel/index.js b/src/botPage/view/TradeInfoPanel/index.js index 664abf034b..1cab39eaa8 100644 --- a/src/botPage/view/TradeInfoPanel/index.js +++ b/src/botPage/view/TradeInfoPanel/index.js @@ -30,6 +30,7 @@ class AnimateTrade extends Component { super(); this.indicatorMessages = { notRunning: translate('Bot is not running.'), + starting : translate('Bot is starting...'), running : translate('Bot is running...'), stopping : translate('Bot is stopping...'), stopped : translate('Bot has stopped.'), @@ -40,18 +41,24 @@ class AnimateTrade extends Component { }; } componentWillMount() { + globalObserver.register('bot.running', () => { + $('.stage-tooltip.top:eq(0)').addClass('running'); + this.setState({ indicatorMessage: this.indicatorMessages.running }); + }); globalObserver.register('bot.stop', () => { $('.stage-tooltip.top:eq(0)').removeClass('running'); this.setState({ indicatorMessage: this.indicatorMessages.stopped }); }); + $('#stopButton').click(() => { $('.stage-tooltip.top:eq(0)').removeClass('running'); this.setState({ indicatorMessage: this.state.stopMessage }); }); + $('#runButton').click(() => { resetAnimation(); $('.stage-tooltip.top:eq(0)').addClass('running'); - this.setState({ indicatorMessage: this.indicatorMessages.running }); + this.setState({ indicatorMessage: this.indicatorMessages.starting }); globalObserver.register('contract.status', contractStatus => { this.animateStage(contractStatus); }); From 742a5d63abc32147c1c5601cd14456be7411e9df Mon Sep 17 00:00:00 2001 From: Aaron Imming Date: Fri, 22 Mar 2019 14:32:03 +0800 Subject: [PATCH 3/3] Ensure correct (stop) status indicator is showing --- src/botPage/view/TradeInfoPanel/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/botPage/view/TradeInfoPanel/index.js b/src/botPage/view/TradeInfoPanel/index.js index 1cab39eaa8..20c70827a9 100644 --- a/src/botPage/view/TradeInfoPanel/index.js +++ b/src/botPage/view/TradeInfoPanel/index.js @@ -58,7 +58,10 @@ class AnimateTrade extends Component { $('#runButton').click(() => { resetAnimation(); $('.stage-tooltip.top:eq(0)').addClass('running'); - this.setState({ indicatorMessage: this.indicatorMessages.starting }); + this.setState({ + indicatorMessage: this.indicatorMessages.starting, + stopMessage : this.indicatorMessages.stopped, + }); globalObserver.register('contract.status', contractStatus => { this.animateStage(contractStatus); });