From 511a1b237b372a95af1147f99bb170ac445e68e9 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 19 May 2019 10:24:16 +0200 Subject: [PATCH] Saving Strategy Changes while restarting simulation --- CockpitSpace/RestartSimulation.js | 32 +++++++++++++++++++++++-------- Panels/ProductCard.js | 3 ++- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/CockpitSpace/RestartSimulation.js b/CockpitSpace/RestartSimulation.js index 6567ebba5..1aeb12543 100644 --- a/CockpitSpace/RestartSimulation.js +++ b/CockpitSpace/RestartSimulation.js @@ -104,11 +104,18 @@ function newRestartSimulation () { timePeriodMarketArray: timePeriodMarketArray } try { - thisObject.status = 'Restarting' - await graphQlRestartSimulation(simulationParams) - thisObject.status = 'Calculating' - counterTillNextState = 2000 - turnOffProductCards() + thisObject.status = 'Saving' + let result = await canvas.strategySpace.workplace.saveToStrategyzer() + if (result === true) { + thisObject.status = 'Restarting' + await graphQlRestartSimulation(simulationParams) + thisObject.status = 'Calculating' + counterTillNextState = 2000 + turnOffProductCards() + } else { + thisObject.status = 'Error' + counterTillNextState = 500 + } } catch (err) { thisObject.status = 'Error' counterTillNextState = 500 @@ -146,6 +153,9 @@ function newRestartSimulation () { switch (thisObject.status) { case 'Ready': + break + case 'Saving': + break case 'Restarting': @@ -187,6 +197,9 @@ function newRestartSimulation () { } break } + case 'Saving': + params.backgroundColor = UI_COLOR.GREY + break case 'Restarting': params.backgroundColor = UI_COLOR.GREY break @@ -217,16 +230,19 @@ function newRestartSimulation () { switch (thisObject.status) { case 'Ready': - label = 'RESTART TRADING ENGINE' + label = 'RE-CALCULATE' + break + case 'Saving': + label = 'SAVING STRATEGIES CHANGES...' break case 'Restarting': - label = 'RESTARTING...' + label = 'RESTARTING TRADING ENGINE...' break case 'Calculating': label = 'CALCULATING...' break case 'Error': - label = 'NOT POSSIBLE NOW' + label = 'ERROR, RETRY LATER' break } diff --git a/Panels/ProductCard.js b/Panels/ProductCard.js index 3ac66d82d..02bf6aaa9 100644 --- a/Panels/ProductCard.js +++ b/Panels/ProductCard.js @@ -335,7 +335,7 @@ function newProductCard () { } function turnOff () { - if (thisObject.status === PRODUCT_CARD_STATUS.ON) { + if (thisObject.status !== PRODUCT_CARD_STATUS.OFFSS) { resetProgressBars() changeStatusTo(PRODUCT_CARD_STATUS.OFF) } @@ -903,3 +903,4 @@ function newProductCard () { browserCanvasContext.stroke() } } +