diff --git a/.eslintrc b/.eslintrc index b4346a8137..582942b284 100644 --- a/.eslintrc +++ b/.eslintrc @@ -19,7 +19,6 @@ "globals": { "Blockly": false, "trackJs": false, - "amplitude": false, "jest": false }, "plugins": [ diff --git a/package-lock.json b/package-lock.json index 159c491185..0c4927a503 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5268,7 +5268,8 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -5292,13 +5293,15 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -5315,19 +5318,22 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -5458,7 +5464,8 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -5472,6 +5479,7 @@ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -5488,6 +5496,7 @@ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -5496,13 +5505,15 @@ "version": "0.0.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -5523,6 +5534,7 @@ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -5611,7 +5623,8 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -5625,6 +5638,7 @@ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -5720,7 +5734,8 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -5762,6 +5777,7 @@ "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -5783,6 +5799,7 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -5831,13 +5848,15 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", - "dev": true + "dev": true, + "optional": true } } }, @@ -8605,7 +8624,7 @@ "dev": true, "requires": { "acorn": "^4.0.11", - "clone": "github:aminmarashi/clone#d97b4f0ff3d3afebcaaf4a2ecc9c50fbce914900" + "clone": "github:aminmarashi/clone#d97b4f" }, "dependencies": { "acorn": { diff --git a/src/botPage/bot/cli.js b/src/botPage/bot/cli.js index 7ddfeffe4c..3e6f77b456 100644 --- a/src/botPage/bot/cli.js +++ b/src/botPage/bot/cli.js @@ -3,7 +3,6 @@ import fs from 'fs'; import readline from 'readline'; import program from 'commander'; import { observer as globalObserver } from '../../common/utils/observer'; -import { version } from '../../../package.json'; import { createInterpreter } from './CliTools'; const log = (...args) => console.log(`${new Date().toLocaleTimeString()}:`, ...args); // eslint-disable-line no-console @@ -15,7 +14,6 @@ setInterval(() => {}, 2147483647); // Keep node alive let filename; program - .version(version) .usage('[filename]') .arguments('[filename]') .action(fn => { diff --git a/src/botPage/view/blockly/blocks/trade/components.js b/src/botPage/view/blockly/blocks/trade/components.js index 8252e32ac1..ad5a139c21 100644 --- a/src/botPage/view/blockly/blocks/trade/components.js +++ b/src/botPage/view/blockly/blocks/trade/components.js @@ -78,10 +78,14 @@ export const barrierOffset = block => { .appendField(new Blockly.FieldDropdown(config.barrierTypes), 'BARRIEROFFSETTYPE_LIST'); } else { const barrierOffsetList = block.getField('BARRIEROFFSETTYPE_LIST'); - if (!block.workspace.getBlockById('BARRIERVALUE')) { + + if ( + !block.workspace.getBlockById('BARRIERVALUE') && + !block.getInput('BARRIEROFFSET').connection.isConnected() + ) { const barrierValue = block.workspace.newBlock('math_number', 'BARRIERVALUE'); barrierOffsetList.setValue('+'); - barrierValue.setFieldValue('0.274', 'NUM'); + barrierValue.setFieldValue('0.27', 'NUM'); barrierValue.setShadow(true); barrierValue.outputConnection.connect(block.getInput('BARRIEROFFSET').connection); barrierValue.initSvg(); @@ -99,10 +103,14 @@ export const secondBarrierOffset = block => { .appendField(new Blockly.FieldDropdown(config.barrierTypes), 'SECONDBARRIEROFFSETTYPE_LIST'); } else { const barrierOffsetList = block.getField('SECONDBARRIEROFFSETTYPE_LIST'); - if (!block.workspace.getBlockById('SECONDBARRIERVALUE')) { + + if ( + !block.workspace.getBlockById('SECONDBARRIERVALUE') && + !block.getInput('SECONDBARRIEROFFSET').connection.isConnected() + ) { const secondBarrierValue = block.workspace.newBlock('math_number', 'SECONDBARRIERVALUE'); barrierOffsetList.setValue('-'); - secondBarrierValue.setFieldValue('0.274', 'NUM'); + secondBarrierValue.setFieldValue('0.27', 'NUM'); secondBarrierValue.setShadow(true); secondBarrierValue.outputConnection.connect(block.getInput('SECONDBARRIEROFFSET').connection); secondBarrierValue.initSvg(); diff --git a/src/botPage/view/blockly/customBlockly.js b/src/botPage/view/blockly/customBlockly.js index 966af9270b..11712f5ea2 100644 --- a/src/botPage/view/blockly/customBlockly.js +++ b/src/botPage/view/blockly/customBlockly.js @@ -261,3 +261,30 @@ Blockly.FieldLabel.prototype.init = function() { // Force a render. this.render_(); }; +// Override inline editor blockly +Blockly.FieldTextInput.prototype.showInlineEditor_ = function(quietInput) { + Blockly.WidgetDiv.show(this, this.sourceBlock_.RTL, this.widgetDispose_()); + var div = Blockly.WidgetDiv.DIV; + // Create the input. + var htmlInput = document.createElement('input'); + htmlInput.className = 'blocklyHtmlInput'; + htmlInput.setAttribute('spellcheck', this.spellcheck_); + htmlInput.setAttribute('data-lpignore', 'true'); + var fontSize = Blockly.FieldTextInput.FONTSIZE * this.workspace_.scale + 'pt'; + div.style.fontSize = fontSize; + htmlInput.style.fontSize = fontSize; + + Blockly.FieldTextInput.htmlInput_ = htmlInput; + div.appendChild(htmlInput); + + htmlInput.value = htmlInput.defaultValue = this.text_; + htmlInput.oldValue_ = null; + this.validate_(); + this.resizeEditor_(); + if (!quietInput) { + htmlInput.focus(); + htmlInput.select(); + } + + this.bindEvents_(htmlInput); +}; diff --git a/src/botPage/view/blockly/index.js b/src/botPage/view/blockly/index.js index 47ec73cead..1ea3de507a 100644 --- a/src/botPage/view/blockly/index.js +++ b/src/botPage/view/blockly/index.js @@ -72,6 +72,9 @@ const marketsWereRemoved = xml => { }, ], }); + if (window.trackJs) { + trackJs.track('Invalid financial market'); + } $('#unavailableMarkets').dialog('open'); return true; } diff --git a/src/botPage/view/blockly/utils.js b/src/botPage/view/blockly/utils.js index cf8879e3f8..ece0b55396 100644 --- a/src/botPage/view/blockly/utils.js +++ b/src/botPage/view/blockly/utils.js @@ -97,7 +97,12 @@ export const strategyHasValidTradeTypeCategory = xml => { return false; }); if (!validTradeTypeCategory) { - globalObserver.emit('ui.log.error', translate('The strategy you tried to import is invalid.')); + const errorMessage = translate('The strategy you tried to import is invalid.'); + globalObserver.emit('ui.log.error', errorMessage); + + if (window.trackJs) { + trackJs.track(errorMessage); + } } return validTradeTypeCategory; }; diff --git a/src/botPage/view/index.js b/src/botPage/view/index.js index 4a64f7c549..2dbf151553 100644 --- a/src/botPage/view/index.js +++ b/src/botPage/view/index.js @@ -5,7 +5,6 @@ import 'notifyjs-browser'; import '../../common/binary-ui/dropdown'; import Elevio from '../../common/elevio'; import View from './View'; -import { version } from '../../../package.json'; $.ajaxSetup({ cache: false, @@ -31,7 +30,6 @@ view.initPromise.then(() => { $('.barspinner').hide(); window.dispatchEvent(new Event('resize')); Elevio.init(); - trackJs.addMetadata('version', version); trackJs.configure({ userId: $('.account-id') .first() diff --git a/src/botPage/view/logger.js b/src/botPage/view/logger.js index 5111d8d7f3..2f419bf3f2 100644 --- a/src/botPage/view/logger.js +++ b/src/botPage/view/logger.js @@ -1,7 +1,6 @@ import { observer as globalObserver } from '../../common/utils/observer'; import { getToken } from '../../common/utils/storageManager'; import { translate } from '../../common/i18n'; -import { isVirtual } from '../common/tools'; const log = (type, ...args) => { if (type === 'warn') { @@ -91,8 +90,6 @@ const waitForNotifications = () => { 'log.trade.finish', ]; - const amplitudeList = ['log.bot.login', 'log.trade.finish']; - logList.forEach(event => globalObserver.register(event, d => log('info', event, d))); globalObserver.register('Notify', notify); @@ -102,21 +99,6 @@ const waitForNotifications = () => { notifList.forEach(className => globalObserver.register(`ui.log.${className}`, message => notify({ className, message, position: 'right' })) ); - - amplitudeList.forEach(event => globalObserver.register(event, d => amplitude.getInstance().logEvent(event, d))); - - globalObserver.register('log.revenue', data => { - const { user, profit, contract } = data; - - if (typeof amplitude !== 'undefined' && !isVirtual(user)) { - const revenue = new amplitude.Revenue() - .setProductId(`${contract.underlying}.${contract.contract_type}`) - .setPrice(-profit) - .setRevenueType(profit < 0 ? 'loss' : 'win'); - - amplitude.getInstance().logRevenueV2(revenue, { contract }); - } - }); }; const logHandler = () => { @@ -125,10 +107,6 @@ const logHandler = () => { .attr('value'); const userId = getToken(token).accountName; - if (amplitude) { - amplitude.getInstance().setUserId(userId); - } - if (trackJs) { trackJs.configure({ userId }); } diff --git a/src/common/elevio.js b/src/common/elevio.js index 726eaeb596..5e5c8e2db2 100644 --- a/src/common/elevio.js +++ b/src/common/elevio.js @@ -2,19 +2,26 @@ import { generateLiveApiInstance } from './appId'; // import { getLanguage } from '../common/lang'; import { getTokenList } from './utils/storageManager'; import { translate } from '../common/i18n'; +import { getLanguage } from './lang'; const Elevio = (() => { const init = () => { if (!window._elev) return; // eslint-disable-line no-underscore-dangle + + // eslint-disable-next-line no-underscore-dangle + window._elev.on('widget:opened', () => window._elev.openArticle('43')); + // eslint-disable-next-line no-underscore-dangle window._elev.on('load', elev => { - // const availableElevLanguages = ['es', 'id', 'pt', 'ru']; - // const currentLanguage = getLanguage().toLowerCase(); - // if (availableElevLanguages.indexOf(currentLanguage) !== -1) { - // window._elev.setLanguage(currentLanguage); // eslint-disable-line no-underscore-dangle - // } - // eslint-disable-next-line no-underscore-dangle - window._elev.setSettings({ + const availableLanguages = ['en', 'es', 'id', 'pt', 'ru']; + const currentLanguage = getLanguage(); + if (availableLanguages.includes(currentLanguage)) { + elev.setLanguage(currentLanguage); + } else { + elev.setLanguage('en'); + } + + elev.setSettings({ page_url: `${document.location.protocol}//${document.location.hostname}${document.location.pathname}`, }); setUserInfo(elev); diff --git a/static/css/_footer.scss b/static/css/_footer.scss index 788f3d4332..951e38abfb 100644 --- a/static/css/_footer.scss +++ b/static/css/_footer.scss @@ -135,7 +135,7 @@ font-size: $FONT_SIZE_XS; position: fixed; bottom: 0; - z-index: 10000; + z-index: 100 !important; width: 100%; } #status_notification { diff --git a/static/css/bot.scss b/static/css/bot.scss index b50babb388..b565a92e0a 100644 --- a/static/css/bot.scss +++ b/static/css/bot.scss @@ -208,4 +208,12 @@ label { .ui-icon { background-image: none !important; +} + +#_elev_io ._1g6cj { + z-index: 10000 !important; +} + +.notifyjs-corner { + z-index: 10001 !important; } \ No newline at end of file diff --git a/templates/bot.mustache b/templates/bot.mustache index 1e5cf21f9e..35cf95867a 100644 --- a/templates/bot.mustache +++ b/templates/bot.mustache @@ -190,6 +190,8 @@ {{> bundle}} {{> bot}} {{> elevio_script }} +
+