From ed97e9ad461a60876aea6ed79f98ce3171ed06e8 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 29 Jul 2019 10:42:00 +0200 Subject: [PATCH] Changes to make it work locally --- Project.njsproj | 1 + Scripts/AppLoader.js | 40 ++++++++++++++++++++------------ ecosystem.json | 55 +------------------------------------------- index.html | 8 +++---- server.js | 12 +++++----- 5 files changed, 37 insertions(+), 79 deletions(-) diff --git a/Project.njsproj b/Project.njsproj index 371261648..5291291ee 100644 --- a/Project.njsproj +++ b/Project.njsproj @@ -43,6 +43,7 @@ + diff --git a/Scripts/AppLoader.js b/Scripts/AppLoader.js index f69ba2157..f8c30ee64 100644 --- a/Scripts/AppLoader.js +++ b/Scripts/AppLoader.js @@ -19,21 +19,31 @@ function newAppLoader() { window.localStorage.removeItem('ecosystem') - let plotters, modulesArray - let ecosystem = await loadEcosystem() - if (ecosystem) { - window.localStorage.setItem('ecosystem', JSON.stringify(ecosystem)) - plotters = getPlotters(ecosystem) + let plotters + let modulesArray = [] + + if (window.canvasApp.executingAt !== 'Local') { + let ecosystem = await loadEcosystem() + if (ecosystem) { + window.localStorage.setItem('ecosystem', JSON.stringify(ecosystem)) + plotters = getPlotters(ecosystem) + } else { + plotters = defaultPlotters() + modulesArray = ['UserEcosystem.js'] + } } else { plotters = defaultPlotters() modulesArray = ['UserEcosystem.js'] } + + modulesArray = modulesArray.concat([ 'ChartsSpace/ViewPort.js', 'Globals.js', 'Ecosystem.js', + 'UserEcosystem.js', 'MQService', 'ChartsSpace/ChartUtilities.js', @@ -316,30 +326,30 @@ function newAppLoader() { function defaultPlotters() { return [ 'Plotters/AAMasters/Plotters-Candles-Volumes/Candles.js', - 'PlotterPanels/AAMasters/Plotters-Candles-Volumes/CandlePanel.js', + 'Plotters/AAMasters/Plotters-Candles-Volumes/CandlePanel.js', 'Plotters/AAMasters/Plotters-Candles-Volumes/Volumes.js', - 'PlotterPanels/AAMasters/Plotters-Candles-Volumes/VolumePanel.js', + 'Plotters/AAMasters/Plotters-Candles-Volumes/VolumePanel.js', 'Plotters/AAMasters/Plotters-Stairs-Patterns/CandleStairs.js', 'Plotters/AAMasters/Plotters-Stairs-Patterns/VolumeStairs.js', 'Plotters/AAMasters/Plotters-Trading/Details.js', 'Plotters/AAMasters/Plotters-Trading/History.js', 'Plotters/AAMasters/Plotters-Bollinger-Bands/BollingerBands.js', - 'PlotterPanels/AAMasters/Plotters-Bollinger-Bands/BollingerBandsPanel.js', + 'Plotters/AAMasters/Plotters-Bollinger-Bands/BollingerBandsPanel.js', 'Plotters/AAMasters/Plotters-Bollinger-Bands/PercentageBandwidth.js', 'Plotters/AAMasters/Plotters-Trading-Simulation/TradingSimulation.js', - 'PlotterPanels/AAMasters/Plotters-Trading-Simulation/TradingSimulationPanel.js', + 'Plotters/AAMasters/Plotters-Trading-Simulation/TradingSimulationPanel.js', 'Plotters/AAMasters/Plotters-Trading-Simulation/Conditions.js', 'Plotters/AAMasters/Plotters-Trading-Simulation/Strategies.js', 'Plotters/AAMasters/Plotters-Trading-Simulation/Trades.js', 'Plotters/AAMasters/Plotters-Trading-Simulation/SimulationExecution.js', - 'PlotterPanels/AAMasters/Plotters-Trading-Simulation/SimulationExecutionPanel.js', + 'Plotters/AAMasters/Plotters-Trading-Simulation/SimulationExecutionPanel.js', 'Plotters/AAMasters/Plotters-Bollinger-Channels/BollingerChannels.js', - 'PlotterPanels/AAMasters/Plotters-Bollinger-Channels/ChannelPanel.js', + 'Plotters/AAMasters/Plotters-Bollinger-Channels/ChannelPanel.js', 'Plotters/AAMasters/Plotters-Bollinger-Channels/BollingerSubChannels.js', - 'PlotterPanels/AAMasters/Plotters-Bollinger-Channels/SubChannelPanel.js', - 'Plotters/AAVikings/Plotters-Linear-Regression-Curve/LRC.js', - 'PlotterPanels/AAVikings/Plotters-Linear-Regression-Curve/ChannelPanel.js', - 'Plotters/AAMasters/Plotters-ROI/CombinedProfits.js' + 'Plotters/AAMasters/Plotters-Bollinger-Channels/SubChannelPanel.js', + // 'Plotters/AAVikings/plotters/Plotters-Linear-Regression-Curve/LRC.js', + // 'Plotters/AAVikings/plotters/Plotters-Linear-Regression-Curve/ChannelPanel.js', + 'Plotters/AAArena/Plotters-ROI/CombinedProfits.js' ] } diff --git a/ecosystem.json b/ecosystem.json index 449426410..e521166cb 100644 --- a/ecosystem.json +++ b/ecosystem.json @@ -1200,59 +1200,6 @@ } ], "hosts": [ - { - "codeName": "AAMasters", - "displayName": "AA Arena", - "host": { - "url": "https://demo-api-dev.superalgos.org/", - "storage": "localStorage", - "container": "aamasters", - "accessKey": "09e890b76767ede3e10f0526b5036600a6b8d3faac540336e12b493fdb2aa9ed46f86094c34652f99fb6322e5f09806412f17725807f85e4dc4169bd22dd59f0b23aba5251f5544478a1aabf5a2dea5260e6eb0c29af3a788208af85025a02f94950437d501b91fd55b9d97b3d6ac3af4e1161321f78b73ca0fda524dc3a5d03" - }, - "competitions": [ - { - "codeName": "Weekend-Deathmatch", - "description": "First AA Internal Competition. Bots will be trading during 3 days at the USDT/BTC market of Poloniex to see who can make the gratest return over investment (ROI).", - "displayName": "AA Internal Challenge", - "startDatetime": "2018-01-01T16:00:00.000Z", - "finishDatetime": "2018-01-02T16:00:00.000Z", - "formula": "ROI", - "plotter": { - "devTeam": "AAMasters", - "codeName": "PlottersROI", - "host": { - "url": "https://demo-api-dev.superalgos.org/", - "storage": "localStorage", - "container": "aamasters", - "accessKey": "" - }, - "moduleName": "CombinedProfits", - "repo": "Plotters-ROI" - }, - "rules": [], - "prizes": [], - "participants": [], - "repo": "Weekend-Deathmatch", - "configFile": "this.competition.config.json" - } - ], - "plotters": [ - { - "displayName": "Plotters ROI", - "codeName": "PlottersROI", - "devTeam": "AAMasters", - "modules": [ - { - "codeName": "CombinedProfits", - "moduleName": "CombinedProfits", - "description": "Plots participants of a competition by the ROI each one had over time.", - "panels": [] - } - ], - "repo": "Plotters-ROI", - "configFile": "this.plotter.config.json" - } - ] - } + ] } diff --git a/index.html b/index.html index 50fe33b25..e8685ba2e 100644 --- a/index.html +++ b/index.html @@ -27,11 +27,11 @@ function loadCanvas() { if (window.canvasApp.visible === undefined) { window.canvasApp = { - version: '1.0.0', // This is used to avoid catching problems at the browser level. + version: '', // This is used to avoid catching problems at the browser level. sessionToken: '', - executingAt: 'Master App', + executingAt: 'Local', visible: true, - topMargin: 1, + topMargin: 0, urlPrefix: 'http://localhost:1337/', graphQL: { masterAppApiUrl: 'https://demo-api-dev.superalgos.org/graphql', @@ -56,7 +56,7 @@
diff --git a/server.js b/server.js index 7ba53980e..0556d95b9 100644 --- a/server.js +++ b/server.js @@ -182,7 +182,7 @@ function onBrowserRequest(request, response) { let devTeam = requestParameters[2] let codeName = requestParameters[3] let moduleName = requestParameters[4] - let filePath = './Plotters/' + devTeam + '/plotters/' + codeName + '/' + moduleName + let filePath = process.env.PLOTTERS_PATH + 'Plotters/' + devTeam + '/' + codeName + '/' + moduleName respondWithFile(filePath, response) } break @@ -192,7 +192,7 @@ function onBrowserRequest(request, response) { let devTeam = requestParameters[2] let codeName = requestParameters[3] let moduleName = requestParameters[4] - let filePath = './Plotters/' + devTeam + '/plotters/' + codeName + '/' + moduleName + let filePath = process.env.PLOTTERS_PATH + 'Plotters/' + devTeam + '/' + codeName + '/' + moduleName respondWithFile(filePath, response) } break @@ -266,13 +266,13 @@ function onBrowserRequest(request, response) { } break - case 'ReadUserConfig': + case 'GetDefinition': { - respondWithFile(process.env.CONFIG_PATH + '/userConfig.json', response) + respondWithFile(process.env.CONFIG_PATH + '/definition.json', response) } break - case 'WriteUserConfig': + case 'SaveDefinition': { let fs = require('fs') let body = ''; @@ -286,7 +286,7 @@ function onBrowserRequest(request, response) { request.on('end', function () { try { - let filePath = process.env.CONFIG_PATH + '/userConfig.json' + let filePath = process.env.CONFIG_PATH + '/definition.json' fs.writeFile(filePath, body, onFileWrite) } catch (e) { console.log('[ERROR] Error writing user config.', e)