Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
30abbf6
Restore original code from before singapore-fix to allow for correctl…
Jan 8, 2019
ddb6f79
Pass each block through removeUnavailableMarkets() and re-order imports
Jan 8, 2019
3408742
add removeUnavailableMarkets() function
Jan 8, 2019
5775ab7
Fix linting errors
Jan 8, 2019
50ee0e0
Refactor and add separator logic to applyToolboxPermissions
Jan 9, 2019
5d37d8b
Remove stroke so lines don't overlap with top toolbar
Jan 9, 2019
ddf50fe
Add rules for toolbox-separator
Jan 9, 2019
ee1f96e
Move toolbox to top
Jan 9, 2019
1a38b83
Attach 'Bot controls' tour-step to button for correct positioning
Jan 9, 2019
c6bca5f
Show dialog when user imports strategy with unavailable financial market
Jan 9, 2019
69dbcac
Refactor removeUnavailableMarkets(), also return boolean
Jan 9, 2019
276369a
Add dialog for users trying to load xml with unavailable financial ma…
Jan 9, 2019
9d89f96
Add scroll function in callback to fix Safari bug
Jan 10, 2019
c039fa1
Remove fixed positioning
Jan 10, 2019
0b1b859
Set z-index to 0 for proper rendering
Jan 10, 2019
3c2af20
Add z-index for proper rendering
Jan 10, 2019
df5eedd
Change overflow to auto to support scrolling for tour, add z-index fo…
Jan 10, 2019
6949a82
Fix div
Jan 10, 2019
aed21b8
Block strategy from being loaded if user does not have access to fina…
Jan 10, 2019
9acffbb
Update message shown to users trying to import strategies with financ…
Jan 10, 2019
0b25c5d
Merge pull request #1095 from aaron-binary/move-toolbox-to-top
ashkanx Jan 10, 2019
38ac9fe
Fix linting rules, disable prefer-destructuring
Jan 11, 2019
4d959cb
Remove comment
Jan 11, 2019
1021b30
Merge pull request #1091 from aaron-binary/prediction-import-fix
ashkanx Jan 11, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions src/botPage/view/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ api.send({ time: '1' }).then(response => {
});

api.events.on('balance', response => {
const { balance: { balance: b, currency } } = response;
const {
balance: { balance: b, currency },
} = response;

const balance = (+roundBalance({ currency, balance: b })).toLocaleString(getLanguage().replace('_', '-'));
$('.topMenuBalance').text(`${balance} ${currency}`);
Expand Down Expand Up @@ -215,15 +217,11 @@ const updateTokenList = () => {
};

const applyToolboxPermissions = () => {
if (getTokenList().length) {
$('#runButton').show();
$('#showSummary').show();
$('#logButton').show();
} else {
$('#runButton').hide();
$('#showSummary').hide();
$('#logButton').hide();
}
const fn = getTokenList().length ? 'show' : 'hide';
$('#runButton, #showSummary, #logButton')
[fn]()
.prevAll('.toolbox-separator:first')
[fn]();
};

const showPopup = selector =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ export default () => {
init: function init() {
duration(this);
payout(this);
prediction(this);
barrierOffset(this);
secondBarrierOffset(this);
this.setInputsInline(false);
this.setPreviousStatement(true, 'Condition');
},
Expand Down
45 changes: 38 additions & 7 deletions src/botPage/view/blockly/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { observer as globalObserver } from '../../../common/utils/observer';
import { translate, xml as translateXml } from '../../../common/i18n';
import createError from '../../common/error';
import './customBlockly';
import blocks from './blocks';
import {
isMainBlock,
save,
Expand All @@ -12,11 +11,13 @@ import {
backwardCompatibility,
fixCollapsedBlocks,
fixArgumentAttribute,
removeUnavailableMarkets,
} from './utils';
import blocks from './blocks';
import Interpreter from '../../bot/Interpreter';
import createError from '../../common/error';
import { translate, xml as translateXml } from '../../../common/i18n';
import { getLanguage } from '../../../common/lang';
import './customBlockly';
import { observer as globalObserver } from '../../../common/utils/observer';

const setBeforeUnload = off => {
if (off) {
Expand Down Expand Up @@ -49,16 +50,46 @@ const disposeBlocksWithLoaders = () => {
});
};
const loadWorkspace = xml => {
const marketsWereRemoved = !Array.from(xml.children).every(block => !removeUnavailableMarkets(block));
if (marketsWereRemoved) {
$('#unavailableMarkets').dialog({
height: 'auto',
width : 600,
modal : true,
open() {
$(this)
.parent()
.find('.ui-dialog-buttonset > button')
.removeClass('ui-button ui-corner-all ui-widget');
},
buttons: [
{
text : translate('OK'),
class: 'button-primary',
click() {
$(this).dialog('close');
},
},
],
});
$('#unavailableMarkets').dialog('open');
return;
}

Blockly.Events.setGroup('load');
Blockly.mainWorkspace.clear();
Array.from(xml.children).forEach(block => backwardCompatibility(block));

Array.from(xml.children).forEach(block => {
backwardCompatibility(block);
});

fixArgumentAttribute(xml);
Blockly.Xml.domToWorkspace(xml, Blockly.mainWorkspace);
addLoadersFirst(xml).then(
() => {
fixCollapsedBlocks();
globalObserver.emit('ui.log.success', translate('Blocks are loaded successfully'));
Blockly.Events.setGroup(false);
globalObserver.emit('ui.log.success', translate('Blocks are loaded successfully'));
},
e => {
Blockly.Events.setGroup(false);
Expand Down
25 changes: 23 additions & 2 deletions src/botPage/view/blockly/utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { observer as globalObserver } from '../../../common/utils/observer';
import { fieldGeneratorMapping } from './blocks/shared';
import { saveAs } from '../shared';
import config from '../../common/const';
import { translate } from '../../../common/i18n';
import { saveAs } from '../shared';
import { observer as globalObserver } from '../../../common/utils/observer';

export const isMainBlock = blockType => config.mainBlocks.indexOf(blockType) >= 0;

Expand All @@ -25,6 +26,26 @@ export const backwardCompatibility = block => {
}
};

export const removeUnavailableMarkets = block => {
const containsUnavailableMarket = Array.from(block.getElementsByTagName('field')).some(
field =>
field.getAttribute('name') === 'MARKET_LIST' &&
!fieldGeneratorMapping
.MARKET_LIST()
.map(markets => markets[1])
.includes(field.innerText)
);
if (containsUnavailableMarket) {
const nodesToRemove = ['MARKET_LIST', 'SUBMARKET_LIST', 'SYMBOL_LIST', 'TRADETYPECAT_LIST', 'TRADETYPE_LIST'];
Array.from(block.getElementsByTagName('field')).forEach(field => {
if (nodesToRemove.includes(field.getAttribute('name'))) {
block.removeChild(field);
}
});
}
return containsUnavailableMarket;
};

const getCollapsedProcedures = () =>
Blockly.mainWorkspace
.getTopBlocks()
Expand Down
13 changes: 13 additions & 0 deletions src/botPage/view/tour/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ class Tour extends PureComponent {
}
render() {
const callback = data => {
// Scroll to highlighted element (req for Safari)
if (data.step && data.step.selector) {
let element;
const selector = data.step.selector; // eslint-disable-line prefer-destructuring
if (/^\./.test(selector)) {
element = document.getElementsByClassName(selector.substring(1))[0]; // eslint-disable-line prefer-destructuring
} else {
element = document.getElementById(selector.substring(1));
}
if (element) {
element.scrollIntoView();
}
}
if (data.index === 0 && data.type === 'step:after') {
setDoneCheck();
}
Expand Down
2 changes: 1 addition & 1 deletion src/botPage/view/tour/welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const steps = [
text : `<p>
${translate('Control your blocks. Hold the cursor on each button for more info.')}
</p>`,
selector: '#toolbox',
selector: '#zoomIn',
position: 'left',
},
{
Expand Down
5 changes: 4 additions & 1 deletion static/css/_blockly-toolbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
}

.blocklyToolboxDiv {
position: fixed !important;
z-index: 99 !important;
left: -100%;
overflow-x: hidden !important;
Expand All @@ -92,3 +91,7 @@
.blocklySvg {
position: absolute;
}

.blocklyMainBackground {
stroke: none;
}
25 changes: 15 additions & 10 deletions static/css/_toolbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,25 @@
}

@mixin toolbox-runButton-disabled {
background-color: #f2f2f2;
color: #dedede;
background-color: $brand-gray;
color: $brand-dark-gray;
}

@mixin toolbox-runButton-hover {
background-color: $toolbox-btn-active;
}

#toolbox {
position: absolute;
z-index: 99;
right: 0;
width: 4em;
text-align: center;
padding: 2px 10px;
background-color: $brand-gray;
border-bottom: 1px solid $brand-dark-gray;
padding: 2px 3px;
z-index: 0;

#runButton[disabled], #runButton[disabled]:hover {
@include toolbox-runButton-disabled;
}

.toolbox-button {
float: right;
margin-bottom: 0.313em;
@include toolbox-button-base;
}

Expand All @@ -49,4 +45,13 @@
.box.is-dragover {
background-color: grey;
}

.toolbox-separator {
background-color: $brand-dark-gray;
display: inline-block;
height: 15px;
margin: 0 5px;
user-select: none;
width: 2px;
}
}
1 change: 1 addition & 0 deletions static/css/_tour.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ $joyride-tooltip-width: (15em, 20em, 20em);
display: inline;
bottom: 1em;
right: 1em;
z-index: 999 !important;
}

.tour-first-pop-up {
Expand Down
4 changes: 2 additions & 2 deletions static/css/bot.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ body {
margin: 0em;
max-width: 100%;
max-height: 100%;
overflow-x: hidden;
overflow-y: hidden;
overflow: auto;
font-size: 1em;
}

Expand Down Expand Up @@ -97,6 +96,7 @@ body {
border-bottom: 4px solid $brand-orange;
font-size: 18px;
padding: 0 20px;
z-index: 0;
}

#topbar {
Expand Down
27 changes: 19 additions & 8 deletions templates/bot.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
<p style="margin:0.7em" data-i18n-text="Binary Bot will not place any new trades. Current unexpired trades will be completed by our system. All unsaved changes will be lost."></p>
<p style="margin:0.7em" data-i18n-text="Note: Please see the Binary.com statement page for details of all confirmed transactions."></p>
</span>
<span id="unavailableMarkets" class="draggable-dialog" title="Warning">
<p style="margin:0.7em" data-i18n-text="This strategy is not available in your country."></p>
</span>
<div>
<div class="blocker"></div>
<div class="reality-check" style="display: none">
Expand Down Expand Up @@ -116,28 +119,36 @@
</div>
</div>
</div>
<div id="blocklyArea"><div>
<div id="blocklyDiv" style="position: absolute;"></div>

<form id="fileUploadForm" style="display: none;">
<input title="Open an already saved XML file and retrieve its blocks" type="file" id="files" accept=".xml" multiple/>
</form>
<div id="toolbox" class="actions_menu show-on-load" style="position:absolute; top: 105px;">
<div id="toolbox" class="actions_menu show-on-load">
<button title="Reset the blocks to their initial state" id="resetButton" class="toolbox-button icon-reset"></button>
<button title="Load new blocks (xml file)" id="loadXml" class="toolbox-button icon-browse"></button>
<button title="Save the existing blocks (xml file)" id="save-xml" class="toolbox-button icon-save"></button>

<span class="toolbox-separator"></span>
<button title="Undo the changes (Ctrl+Z)" id="undo" class="toolbox-button icon-undo"></button>
<button title="Redo the changes (Ctrl+Shift+Z)" id="redo" class="toolbox-button icon-redo"></button>

<span class="toolbox-separator"></span>
<button title="Zoom In (Ctrl + +)" id="zoomIn" class="toolbox-button icon-zoom-in"></button>
<button title="Zoom Out (Ctrl + -)" id="zoomOut" class="toolbox-button icon-zoom-out"></button>
<button title="Rearrange Vertically" id="rearrange" class="toolbox-button icon-sort"></button>

<span class="toolbox-separator"></span>
<button title="Show/hide the summary pop-up" id="showSummary" class="toolbox-button icon-summary"></button>
<button title="Run the bot" id="runButton" class="toolbox-button icon-run"></button>
<button title="Stop the bot" id="stopButton" class="toolbox-button icon-stop"></button>
<button title="Show log" id="logButton" class="toolbox-button icon-info"></button>

<span class="toolbox-separator"></span>
<button title="Show chart" id="chartButton" class="toolbox-button icon-chart-line"></button>
<button title="Show Trading View" id="tradingViewButton" class="toolbox-button icon-trading-view"></button>
<button title="Reset the blocks to their initial state" id="resetButton" class="toolbox-button icon-reset"></button>
</div>
<div id="blocklyArea"></div>
<div id="blocklyDiv" style="position: absolute;"></div>

<form id="fileUploadForm" style="display: none;">
<input title="Open an already saved XML file and retrieve its blocks" type="file" id="files" accept=".xml" multiple/>
</form>
<div id="footer"></div>
<audio id="announcement" src="sound/announcement.ogg" autostart="false" ></audio>
<audio id="earned-money" src="sound/coins.ogg" autostart="false" ></audio>
Expand Down