Adding Workspace as part
This commit is contained in:
1 parent
06fe11d01f
commit
62e4424028
3 files changed
+71
-2
No files matched your search
@@ -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
|
||||
|
||||
@@ -235,6 +235,11 @@ function newPartsFromNodes () {
|
||||
}
|
||||
return
|
||||
}
|
||||
case 'Workspace': {
|
||||
let workspace = node
|
||||
createPart('Workspace', workspace.name, workspace, parentNode, chainParent, 'Workspace')
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user