diff --git a/Spaces/CockpitSpace.js b/Spaces/CockpitSpace.js index 3767afe41..86fc1c821 100644 --- a/Spaces/CockpitSpace.js +++ b/Spaces/CockpitSpace.js @@ -47,20 +47,18 @@ thisObject.container.frame.position.x = 0 let INITIAL_POSITION - const accessToken = window.localStorage.getItem(LOGGED_IN_ACCESS_TOKEN_LOCAL_STORAGE_KEY) - - if (accessToken !== null) { - INITIAL_POSITION = 55 + if (canvas.strategySpace.workspace.enabled === true) { + let localStorage = window.localStorage.getItem(MODULE_NAME) + if (localStorage !== null) { + storage = JSON.parse(localStorage) + thisObject.container.frame.position.y = storage.spacePosition + } else { + INITIAL_POSITION = 55 + thisObject.container.frame.position.y = browserCanvas.height * INITIAL_POSITION / 100 - COCKPIT_SPACE_HEIGHT + } } else { INITIAL_POSITION = 100 - } - - thisObject.container.frame.position.y = browserCanvas.height * INITIAL_POSITION / 100 - COCKPIT_SPACE_HEIGHT - - let localStorage = window.localStorage.getItem(MODULE_NAME) - if (localStorage !== null) { - storage = JSON.parse(localStorage) - thisObject.container.frame.position.y = storage.spacePosition + thisObject.container.frame.position.y = browserCanvas.height * INITIAL_POSITION / 100 - COCKPIT_SPACE_HEIGHT } canvasBrowserResizedEventSubscriptionId = window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize) @@ -101,7 +99,9 @@ } function childrenPhysics () { - thisObject.restartSimulation.physics() + if (canvas.strategySpace.workspace.enabled === true) { + thisObject.restartSimulation.physics() + } thisObject.fullscreen.physics() } function thisObjectPhysics () { @@ -109,8 +109,7 @@ thisObject.status = 'MIDDLE' - let user = window.localStorage.getItem(LOGGED_IN_USER_LOCAL_STORAGE_KEY) - if (user !== null) { // Only if user is logged in + if (canvas.strategySpace.workspace.enabled === true) { thisObject.container.isDraggeable = true } else { thisObject.container.isDraggeable = false @@ -143,8 +142,10 @@ function getContainer (point) { let container - container = thisObject.restartSimulation.getContainer(point) - if (container !== undefined) { return container } + if (canvas.strategySpace.workspace.enabled === true) { + container = thisObject.restartSimulation.getContainer(point) + if (container !== undefined) { return container } + } container = thisObject.fullscreen.getContainer(point) if (container !== undefined) { return container } @@ -162,7 +163,9 @@ drawBackground() thisObject.assetBalances.draw() - thisObject.restartSimulation.draw() + if (canvas.strategySpace.workspace.enabled === true) { + thisObject.restartSimulation.draw() + } thisObject.fullscreen.draw() } @@ -196,8 +199,7 @@ browserCanvasContext.closePath() browserCanvasContext.fill() - let user = window.localStorage.getItem(LOGGED_IN_USER_LOCAL_STORAGE_KEY) - if (user !== null) { // Only if user is logged in + if (canvas.strategySpace.workspace.enabled === true) { arrow() } } diff --git a/StrategySpace/StrategizerGateway.js b/StrategySpace/StrategizerGateway.js index 35ecf134f..fa7b114ee 100644 --- a/StrategySpace/StrategizerGateway.js +++ b/StrategySpace/StrategizerGateway.js @@ -112,7 +112,7 @@ function newStrategizerGateway () { return } - let idAtStrategizer = window.localStorage.getItem(MODULE_NAME) + let idAtStrategizer = window.localStorage.getItem(CANVAS_APP_NAME + '.' + MODULE_NAME + '.' + user.alias) if (idAtStrategizer === undefined || idAtStrategizer === null) { logger.write('[ERROR] saveToStrategyzer -> Can not save when idAtStrategizer is null or undefined.') return diff --git a/StrategySpace/Workspace/Workspace.js b/StrategySpace/Workspace/Workspace.js index ccfaba729..a8b947318 100644 --- a/StrategySpace/Workspace/Workspace.js +++ b/StrategySpace/Workspace/Workspace.js @@ -5,6 +5,7 @@ function newWorkspace () { let thisObject = { tradingSystem: undefined, container: undefined, + enabled: false, onMenuItemClick: onMenuItemClick, getProtocolTradingSystem: getProtocolTradingSystem, physics: physics, @@ -41,7 +42,6 @@ function newWorkspace () { functionLibraryProtocolNode = newProtocolNode() functionLibraryWorkspaceNodes = newStringifyNode() - let isInitialized = false return thisObject function finalize () { @@ -73,7 +73,7 @@ function newWorkspace () { let rootNode = workspaceNode.rootNodes[i] functionLibraryPartsFromNodes.createPartFromNode(rootNode, undefined, undefined) } - isInitialized = true + thisObject.enabled = true } } @@ -84,7 +84,7 @@ function newWorkspace () { workspaceNode.rootNodes.push(thisObject.tradingSystem) functionLibraryPartsFromNodes.createPartFromNode(thisObject.tradingSystem, undefined, undefined) thisObject.tradingSystem.payload.uiObject.setRunningStatus() - isInitialized = true + thisObject.enabled = true } } @@ -101,7 +101,7 @@ function newWorkspace () { } function physics () { - if (isInitialized !== true) { return } + if (thisObject.enabled !== true) { return } /* Here we will save all the workspace related objects into the local storage */ let user = window.localStorage.getItem(LOGGED_IN_USER_LOCAL_STORAGE_KEY) if (user === null) {