diff --git a/FloatingSpace/StrategyPartConstructor.js b/FloatingSpace/StrategyPartConstructor.js index 91f43dc5a..cb7cc0b95 100644 --- a/FloatingSpace/StrategyPartConstructor.js +++ b/FloatingSpace/StrategyPartConstructor.js @@ -79,6 +79,52 @@ function newStrategyPartConstructor () { function getMenuItemsInitialValues (strategyPart, floatingObject, payload) { let menuItemsInitialValues = [] switch (payload.node.type) { + case 'Workspace': { + floatingObject.isPinned = true + floatingObject.positionLocked = true + menuItemsInitialValues = [ + { + action: 'Pin / Unpin', + actionFunction: floatingObject.pinToggle, + actionStatus: floatingObject.getPinStatus, + currentStatus: true, + label: undefined, + visible: false, + iconPathOn: 'target', + iconPathOff: 'security', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -135 + }, + { + action: 'Freeze / Unfreeze', + actionFunction: floatingObject.freezeToggle, + actionStatus: floatingObject.getFreezeStatus, + currentStatus: true, + label: undefined, + visible: false, + iconPathOn: 'broken-link', + iconPathOff: 'targeting', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 135 + }, + { + action: 'Download', + actionFunction: payload.onMenuItemClick, + label: 'Download', + visible: false, + iconPathOn: 'upload', + iconPathOff: 'upload', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 0 + }] + break + } case 'Trading System': { floatingObject.isPinned = true floatingObject.positionLocked = true @@ -1600,6 +1646,10 @@ function newStrategyPartConstructor () { const INITIAL_FRICTION = 0.99 switch (payload.node.type) { + case 'Workspace': { + level_0() + break + } case 'Trading System': { level_0() break diff --git a/StrategySpace/Workspace/FunctionLibraries/PartsFromNodes.js b/StrategySpace/Workspace/FunctionLibraries/PartsFromNodes.js index 480f0ece0..ed942efda 100644 --- a/StrategySpace/Workspace/FunctionLibraries/PartsFromNodes.js +++ b/StrategySpace/Workspace/FunctionLibraries/PartsFromNodes.js @@ -235,6 +235,11 @@ function newPartsFromNodes () { } return } + case 'Workspace': { + let workspace = node + createPart('Workspace', workspace.name, workspace, parentNode, chainParent, 'Workspace') + return + } } } diff --git a/StrategySpace/Workspace/Workspace.js b/StrategySpace/Workspace/Workspace.js index 06d36886a..aca823a0e 100644 --- a/StrategySpace/Workspace/Workspace.js +++ b/StrategySpace/Workspace/Workspace.js @@ -51,14 +51,22 @@ function newWorkspace () { } async function initialize () { + let user = window.localStorage.getItem(LOGGED_IN_USER_LOCAL_STORAGE_KEY) + if (user === null) { + return + } + user = JSON.parse(user) + functionLibraryAttachDetach = newAttachDetach() functionLibraryNodeDeleter = newNodeDeleter() functionLibraryPartsFromNodes = newPartsFromNodes() functionLibraryProtocolNode = newProtocolNode() functionLibraryWorkspaceNodes = newWorkspaceNode() - let savedWorkspace = window.localStorage.getItem('workspace') + let savedWorkspace = window.localStorage.getItem(user.alias + '.' + 'workspace') if (savedWorkspace === null) { + let workspaceNode + functionLibraryPartsFromNodes.createPartFromNode(thisObject.tradingSystem, undefined, undefined) initializeLoadingFromStrategizer() } else { workspace = JSON.parse(savedWorkspace) @@ -111,6 +119,12 @@ function newWorkspace () { function physics () { if (isInitialized !== 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) { + return + } + user = JSON.parse(user) + let stringifyReadyNodes = [] for (let i = 0; i < rootNodes.length; i++) { let rootNode = rootNodes[i] @@ -121,7 +135,7 @@ function newWorkspace () { rootNodes: stringifyReadyNodes } let textToSave = JSON.stringify(workspace) - window.localStorage.setItem('workspace', textToSave) + window.localStorage.setItem(user.alias + '.' + 'workspace', textToSave) } function spawn (nodeText, point) {