Recalculate Buttom Turn Off and On layers related to the simulation so that no user action is needed
This commit is contained in:
1 parent
17d425d5c7
commit
0881b32a35
3 files changed
+43
-16
No files matched your search
@@ -28,6 +28,7 @@ function newRestartSimulation () {
|
||||
let isMouseOver = false
|
||||
let counterTillNextState = 0
|
||||
|
||||
let productCardsToTurnOn = []
|
||||
return thisObject
|
||||
|
||||
function finalize () {
|
||||
@@ -106,13 +107,37 @@ function newRestartSimulation () {
|
||||
thisObject.status = 'Restarting'
|
||||
await graphQlRestartSimulation(simulationParams)
|
||||
thisObject.status = 'Calculating'
|
||||
counterTillNextState = 1000
|
||||
counterTillNextState = 1500
|
||||
turnOffProductCards()
|
||||
} catch (err) {
|
||||
thisObject.status = 'Error'
|
||||
counterTillNextState = 500
|
||||
}
|
||||
}
|
||||
|
||||
function turnOffProductCards () {
|
||||
for (let i = 0; i < canvas.panelsSpace.panels.length; i++) {
|
||||
let panel = canvas.panelsSpace.panels[i]
|
||||
if (panel.name === 'Products Panel') {
|
||||
for (j = 0; j < panel.productCards.length; j++) {
|
||||
let productCard = panel.productCards[j]
|
||||
if (productCard.product.relatedToTradingEngine === true && productCard.status !== PRODUCT_CARD_STATUS.OFF) {
|
||||
productCard.turnOff()
|
||||
productCardsToTurnOn.push(productCard)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function turnOnProductCards () {
|
||||
for (let i = 0; i < productCardsToTurnOn.length; i++) {
|
||||
let productCard = productCardsToTurnOn[i]
|
||||
productCard.turnOn()
|
||||
}
|
||||
productCardsToTurnOn = []
|
||||
}
|
||||
|
||||
function physics () {
|
||||
if (counterTillNextState > 0) {
|
||||
counterTillNextState--
|
||||
@@ -127,6 +152,7 @@ function newRestartSimulation () {
|
||||
break
|
||||
case 'Calculating':
|
||||
thisObject.status = 'Ready'
|
||||
turnOnProductCards()
|
||||
break
|
||||
case 'Error':
|
||||
thisObject.status = 'Ready'
|
||||
|
||||
@@ -7,7 +7,7 @@ function newProductCard () {
|
||||
let thisObject = {
|
||||
container: undefined,
|
||||
draw: draw,
|
||||
status: 'off',
|
||||
status: PRODUCT_CARD_STATUS.OFF,
|
||||
devTeam: undefined,
|
||||
bot: undefined,
|
||||
product: undefined,
|
||||
|
||||
+15
-14
@@ -1,7 +1,9 @@
|
||||
function newProductsPanel () {
|
||||
let thisObject = {
|
||||
name: 'Products Panel',
|
||||
fitFunction: undefined,
|
||||
container: undefined,
|
||||
productCards: [],
|
||||
getLoadingProductCards: getLoadingProductCards,
|
||||
draw: draw,
|
||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||
@@ -20,7 +22,6 @@ function newProductsPanel () {
|
||||
thisObject.container = container
|
||||
|
||||
let isInitialized = false
|
||||
let productCards = []
|
||||
|
||||
let visibleProductCards = []
|
||||
let firstVisibleCard = 1
|
||||
@@ -65,7 +66,7 @@ function newProductsPanel () {
|
||||
userTeams = JSON.parse(storedTeams)
|
||||
}
|
||||
|
||||
/* First thing is to build the productCards array */
|
||||
/* First thing is to build the thisObject.productCards array */
|
||||
|
||||
let devTeams = ecosystem.getTeams()
|
||||
|
||||
@@ -119,7 +120,7 @@ function newProductsPanel () {
|
||||
|
||||
/* Add to the Product Array */
|
||||
|
||||
productCards.push(productCard)
|
||||
thisObject.productCards.push(productCard)
|
||||
|
||||
/* Add to Visible Product Array */
|
||||
|
||||
@@ -153,14 +154,14 @@ function newProductsPanel () {
|
||||
let availableSlots = visibleProductCards.length
|
||||
|
||||
if (firstVisibleCard < 1) { firstVisibleCard = 1 }
|
||||
if (firstVisibleCard > (productCards.length - availableSlots + 1)) { firstVisibleCard = productCards.length - availableSlots + 1 }
|
||||
if (firstVisibleCard > (thisObject.productCards.length - availableSlots + 1)) { firstVisibleCard = thisObject.productCards.length - availableSlots + 1 }
|
||||
|
||||
visibleProductCards = []
|
||||
let lastY = 5
|
||||
|
||||
for (let i = 0; i < productCards.length; i++) {
|
||||
for (let i = 0; i < thisObject.productCards.length; i++) {
|
||||
if (i + 1 >= firstVisibleCard && i + 1 < firstVisibleCard + availableSlots) {
|
||||
let productCard = productCards[i]
|
||||
let productCard = thisObject.productCards[i]
|
||||
|
||||
/* Positioning within thisObject Panel */
|
||||
|
||||
@@ -185,13 +186,13 @@ function newProductsPanel () {
|
||||
}
|
||||
|
||||
function getLoadingProductCards () {
|
||||
/* Returns all productCards which status is LOADING */
|
||||
/* Returns all thisObject.productCards which status is LOADING */
|
||||
|
||||
let onProducts = []
|
||||
|
||||
for (let i = 0; i < productCards.length; i++) {
|
||||
if (productCards[i].status === PRODUCT_CARD_STATUS.LOADING) {
|
||||
onProducts.push(productCards[i])
|
||||
for (let i = 0; i < thisObject.productCards.length; i++) {
|
||||
if (thisObject.productCards[i].status === PRODUCT_CARD_STATUS.LOADING) {
|
||||
onProducts.push(thisObject.productCards[i])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,16 +254,16 @@ function newProductsPanel () {
|
||||
panelTabButton.draw()
|
||||
}
|
||||
|
||||
function isUserTeam(team, userTeams){
|
||||
if(userTeams === undefined)
|
||||
function isUserTeam (team, userTeams) {
|
||||
if (userTeams === undefined) {
|
||||
return false
|
||||
}
|
||||
|
||||
for (let index = 0; index < userTeams.length; index++) {
|
||||
if(team === userTeams[index].slug){
|
||||
if (team === userTeams[index].slug) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user