Designer Space Refactoring
This commit is contained in:
1 parent
d078d17881
commit
f13700287e
19 files changed
+128
-128
No files matched your search
@@ -37,7 +37,7 @@ function newCanvas () {
|
||||
panelsSpace: undefined,
|
||||
cockpitSpace: undefined,
|
||||
bottomSpace: undefined,
|
||||
strategySpace: undefined,
|
||||
designerSpace: undefined,
|
||||
animation: undefined,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
@@ -90,8 +90,8 @@ function newCanvas () {
|
||||
thisObject.topSpace = newTopSpace()
|
||||
await thisObject.topSpace.initialize()
|
||||
|
||||
thisObject.strategySpace = newStrategySpace()
|
||||
await thisObject.strategySpace.initialize()
|
||||
thisObject.designerSpace = newDesignerSpace()
|
||||
await thisObject.designerSpace.initialize()
|
||||
|
||||
thisObject.cockpitSpace = newCockpitSpace()
|
||||
thisObject.cockpitSpace.initialize()
|
||||
@@ -125,7 +125,7 @@ function newCanvas () {
|
||||
animation.addCallBackFunction('Floating Space Physics', thisObject.floatingSpace.physics)
|
||||
animation.addCallBackFunction('Chart Space Physics', thisObject.chartSpace.physics)
|
||||
animation.addCallBackFunction('CockpitSpace Physics', thisObject.cockpitSpace.physics)
|
||||
animation.addCallBackFunction('Strategy Space Physics', thisObject.strategySpace.physics)
|
||||
animation.addCallBackFunction('Strategy Space Physics', thisObject.designerSpace.physics)
|
||||
animation.addCallBackFunction('Panels Space Physics', thisObject.panelsSpace.physics)
|
||||
|
||||
/* Spcaces Drawing */
|
||||
@@ -136,7 +136,7 @@ function newCanvas () {
|
||||
animation.addCallBackFunction('ViewPort Animate', viewPort.animate)
|
||||
animation.addCallBackFunction('CockpitSpace Draw', thisObject.cockpitSpace.draw)
|
||||
animation.addCallBackFunction('Top Space Draw', thisObject.topSpace.draw)
|
||||
animation.addCallBackFunction('Strategy Space Draw', thisObject.strategySpace.draw)
|
||||
animation.addCallBackFunction('Strategy Space Draw', thisObject.designerSpace.draw)
|
||||
animation.addCallBackFunction('Splash Screen Draw', splashScreen.draw)
|
||||
animation.start()
|
||||
} catch (err) {
|
||||
@@ -190,7 +190,7 @@ function newCanvas () {
|
||||
}
|
||||
|
||||
function onKeyDown (event) {
|
||||
let nodeOnFocus = canvas.strategySpace.workspace.getNodeThatIsOnFocus()
|
||||
let nodeOnFocus = canvas.designerSpace.workspace.getNodeThatIsOnFocus()
|
||||
if (nodeOnFocus !== undefined) {
|
||||
if (nodeOnFocus.payload.uiObject.codeEditor !== undefined) {
|
||||
if (nodeOnFocus.payload.uiObject.codeEditor.visible === true) {
|
||||
@@ -266,7 +266,7 @@ function newCanvas () {
|
||||
/* From here we prevent the default behaviour */
|
||||
event.preventDefault()
|
||||
|
||||
let nodeUsingThisKey = canvas.strategySpace.workspace.getNodeByShortcutKey(event.key)
|
||||
let nodeUsingThisKey = canvas.designerSpace.workspace.getNodeByShortcutKey(event.key)
|
||||
|
||||
if (nodeOnFocus === undefined && nodeUsingThisKey !== undefined) {
|
||||
/* Then we displace the whole workspace to center it at the node using this key */
|
||||
@@ -349,7 +349,7 @@ function newCanvas () {
|
||||
x: event.x,
|
||||
y: event.y
|
||||
}
|
||||
thisObject.strategySpace.workspace.spawn(reader.result, mousePosition)
|
||||
thisObject.designerSpace.workspace.spawn(reader.result, mousePosition)
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
@@ -372,7 +372,7 @@ function newCanvas () {
|
||||
|
||||
/* We check if the mouse is over an element of the Strategy Space / */
|
||||
|
||||
container = thisObject.strategySpace.getContainer(point)
|
||||
container = thisObject.designerSpace.getContainer(point)
|
||||
|
||||
if (container !== undefined && container.isDraggeable === true) {
|
||||
containerBeingDragged = container
|
||||
@@ -478,7 +478,7 @@ function newCanvas () {
|
||||
|
||||
/* We check if the mouse is over an element of the Strategy Space / */
|
||||
|
||||
container = thisObject.strategySpace.getContainer(point)
|
||||
container = thisObject.designerSpace.getContainer(point)
|
||||
|
||||
if (container !== undefined && container.isClickeable === true) {
|
||||
container.eventHandler.raiseEvent('onMouseClick', point)
|
||||
@@ -607,8 +607,8 @@ function newCanvas () {
|
||||
|
||||
/* We check if the mouse is over an element of the Strategy Space / */
|
||||
|
||||
if (thisObject.strategySpace !== undefined) {
|
||||
container = thisObject.strategySpace.getContainer(point)
|
||||
if (thisObject.designerSpace !== undefined) {
|
||||
container = thisObject.designerSpace.getContainer(point)
|
||||
|
||||
if (container !== undefined && container.detectMouseOver === true) {
|
||||
containerFound()
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ function newDashboard () {
|
||||
function setBrowserEvents () {
|
||||
window.onbeforeunload = onBrowserClosed
|
||||
function onBrowserClosed () {
|
||||
canvas.strategySpace.workspace.stopAllRunningTasks()
|
||||
canvas.designerSpace.workspace.stopAllRunningTasks()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,95 +1,95 @@
|
||||
|
||||
function newStrategizerGateway () {
|
||||
const MODULE_NAME = 'Strategizer Gateway'
|
||||
const logger = newWebDebugLog()
|
||||
logger.fileName = MODULE_NAME
|
||||
|
||||
let thisObject = {
|
||||
idAtStrategizer: undefined,
|
||||
strategizerData: undefined,
|
||||
container: undefined,
|
||||
loadFromStrategyzer: loadFromStrategyzer
|
||||
}
|
||||
|
||||
let colletionItems = []
|
||||
|
||||
thisObject.container = newContainer()
|
||||
thisObject.container.name = MODULE_NAME
|
||||
thisObject.container.initialize()
|
||||
|
||||
thisObject.container.frame.width = 0
|
||||
thisObject.container.frame.height = 0
|
||||
|
||||
thisObject.container.frame.position.x = 0
|
||||
thisObject.container.frame.position.y = 0
|
||||
|
||||
thisObject.container.isDraggeable = false
|
||||
thisObject.container.isClickeable = false
|
||||
|
||||
let graphQLServer
|
||||
|
||||
return thisObject
|
||||
|
||||
async function loadFromStrategyzer () {
|
||||
try {
|
||||
const accessToken = window.localStorage.getItem(LOGGED_IN_ACCESS_TOKEN_LOCAL_STORAGE_KEY)
|
||||
if (accessToken === null) {
|
||||
logger.write('[ERROR] loadFromStrategyzer -> Can load from strategizer because the accessToken is missing.')
|
||||
return
|
||||
}
|
||||
|
||||
let user = window.localStorage.getItem(LOGGED_IN_USER_LOCAL_STORAGE_KEY)
|
||||
if (user === null) {
|
||||
logger.write('[ERROR] saveToStrategyzer -> Can not load from strategizer because user is not logged in. ')
|
||||
return
|
||||
}
|
||||
|
||||
user = JSON.parse(user)
|
||||
|
||||
if (window.canvasApp.executingAt === 'Local') {
|
||||
window.localStorage.setItem(CANVAS_APP_NAME + '.' + MODULE_NAME + '.' + user.alias, 'Local File')
|
||||
thisObject.strategizerData = JSON.parse('{"type":"Definition"}')
|
||||
thisObject.idAtStrategizer = 'Local File'
|
||||
return true
|
||||
} else {
|
||||
let fbSlug = 'simulator-bot-' + user.alias.replace('.', '')
|
||||
|
||||
graphQLServer = await axios({
|
||||
url: window.canvasApp.graphQL.masterAppApiUrl,
|
||||
method: 'post',
|
||||
data: {
|
||||
query:
|
||||
`
|
||||
query($fbSlug: String!){
|
||||
strategizer_TradingSystemByFb(fbSlug: $fbSlug){
|
||||
id
|
||||
fbSlug
|
||||
data
|
||||
}
|
||||
}
|
||||
`,
|
||||
|
||||
variables: {
|
||||
fbSlug: fbSlug
|
||||
}
|
||||
},
|
||||
headers: {
|
||||
authorization: 'Bearer ' + accessToken
|
||||
}
|
||||
})
|
||||
|
||||
if (graphQLServer.data.errors) {
|
||||
logger.write('[ERROR] loadFromStrategyzer -> GraphQL Error: ' + JSON.stringify(graphQLServer.data.errors))
|
||||
return false
|
||||
} else {
|
||||
thisObject.strategizerData = JSON.parse(JSON.stringify(graphQLServer.data.data.strategizer_TradingSystemByFb.data))
|
||||
thisObject.idAtStrategizer = graphQLServer.data.data.strategizer_TradingSystemByFb.id
|
||||
window.localStorage.setItem(CANVAS_APP_NAME + '.' + MODULE_NAME + '.' + user.alias, thisObject.idAtStrategizer)
|
||||
return true
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
logger.write('[ERROR] loadFromStrategyzer -> err = ' + err.stack)
|
||||
}
|
||||
|
||||
function newStrategizerGateway () {
|
||||
const MODULE_NAME = 'Strategizer Gateway'
|
||||
const logger = newWebDebugLog()
|
||||
logger.fileName = MODULE_NAME
|
||||
|
||||
let thisObject = {
|
||||
idAtStrategizer: undefined,
|
||||
strategizerData: undefined,
|
||||
container: undefined,
|
||||
loadFromStrategyzer: loadFromStrategyzer
|
||||
}
|
||||
}
|
||||
|
||||
let colletionItems = []
|
||||
|
||||
thisObject.container = newContainer()
|
||||
thisObject.container.name = MODULE_NAME
|
||||
thisObject.container.initialize()
|
||||
|
||||
thisObject.container.frame.width = 0
|
||||
thisObject.container.frame.height = 0
|
||||
|
||||
thisObject.container.frame.position.x = 0
|
||||
thisObject.container.frame.position.y = 0
|
||||
|
||||
thisObject.container.isDraggeable = false
|
||||
thisObject.container.isClickeable = false
|
||||
|
||||
let graphQLServer
|
||||
|
||||
return thisObject
|
||||
|
||||
async function loadFromStrategyzer () {
|
||||
try {
|
||||
const accessToken = window.localStorage.getItem(LOGGED_IN_ACCESS_TOKEN_LOCAL_STORAGE_KEY)
|
||||
if (accessToken === null) {
|
||||
logger.write('[ERROR] loadFromStrategyzer -> Can load from strategizer because the accessToken is missing.')
|
||||
return
|
||||
}
|
||||
|
||||
let user = window.localStorage.getItem(LOGGED_IN_USER_LOCAL_STORAGE_KEY)
|
||||
if (user === null) {
|
||||
logger.write('[ERROR] saveToStrategyzer -> Can not load from strategizer because user is not logged in. ')
|
||||
return
|
||||
}
|
||||
|
||||
user = JSON.parse(user)
|
||||
|
||||
if (window.canvasApp.executingAt === 'Local') {
|
||||
window.localStorage.setItem(CANVAS_APP_NAME + '.' + MODULE_NAME + '.' + user.alias, 'Local File')
|
||||
thisObject.strategizerData = JSON.parse('{"type":"Definition"}')
|
||||
thisObject.idAtStrategizer = 'Local File'
|
||||
return true
|
||||
} else {
|
||||
let fbSlug = 'simulator-bot-' + user.alias.replace('.', '')
|
||||
|
||||
graphQLServer = await axios({
|
||||
url: window.canvasApp.graphQL.masterAppApiUrl,
|
||||
method: 'post',
|
||||
data: {
|
||||
query:
|
||||
`
|
||||
query($fbSlug: String!){
|
||||
strategizer_TradingSystemByFb(fbSlug: $fbSlug){
|
||||
id
|
||||
fbSlug
|
||||
data
|
||||
}
|
||||
}
|
||||
`,
|
||||
|
||||
variables: {
|
||||
fbSlug: fbSlug
|
||||
}
|
||||
},
|
||||
headers: {
|
||||
authorization: 'Bearer ' + accessToken
|
||||
}
|
||||
})
|
||||
|
||||
if (graphQLServer.data.errors) {
|
||||
logger.write('[ERROR] loadFromStrategyzer -> GraphQL Error: ' + JSON.stringify(graphQLServer.data.errors))
|
||||
return false
|
||||
} else {
|
||||
thisObject.strategizerData = JSON.parse(JSON.stringify(graphQLServer.data.data.strategizer_TradingSystemByFb.data))
|
||||
thisObject.idAtStrategizer = graphQLServer.data.data.strategizer_TradingSystemByFb.id
|
||||
window.localStorage.setItem(CANVAS_APP_NAME + '.' + MODULE_NAME + '.' + user.alias, thisObject.idAtStrategizer)
|
||||
return true
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
logger.write('[ERROR] loadFromStrategyzer -> err = ' + err.stack)
|
||||
}
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -1291,7 +1291,7 @@ function newUiObjectsFromNodes () {
|
||||
payload.node = node
|
||||
payload.parentNode = parentNode
|
||||
payload.chainParent = chainParent
|
||||
payload.onMenuItemClick = canvas.strategySpace.workspace.onMenuItemClick
|
||||
payload.onMenuItemClick = canvas.designerSpace.workspace.onMenuItemClick
|
||||
|
||||
if (node.id === undefined) {
|
||||
node.id = newUniqueId()
|
||||
@@ -96,9 +96,9 @@ function newWorkspace () {
|
||||
}
|
||||
|
||||
async function initializeLoadingFromStrategizer () {
|
||||
let result = await canvas.strategySpace.strategizerGateway.loadFromStrategyzer()
|
||||
let result = await canvas.designerSpace.strategizerGateway.loadFromStrategyzer()
|
||||
if (result === true) {
|
||||
thisObject.definition = canvas.strategySpace.strategizerGateway.strategizerData
|
||||
thisObject.definition = canvas.designerSpace.strategizerGateway.strategizerData
|
||||
thisObject.workspaceNode.rootNodes.push(thisObject.definition)
|
||||
functionLibraryUiObjectsFromNodes.createPartFromNode(thisObject.definition, undefined, undefined)
|
||||
|
||||
@@ -167,15 +167,15 @@ function newCircularMenuItem () {
|
||||
temporaryStatus === STATUS_SECONDARY_WORK_FAILED
|
||||
) && thisObject.secondaryAction !== undefined
|
||||
) {
|
||||
thisObject.iconOn = canvas.strategySpace.iconCollection.get(thisObject.secondaryIcon)
|
||||
thisObject.iconOff = canvas.strategySpace.iconCollection.get(thisObject.secondaryIcon)
|
||||
thisObject.iconOn = canvas.designerSpace.iconCollection.get(thisObject.secondaryIcon)
|
||||
thisObject.iconOff = canvas.designerSpace.iconCollection.get(thisObject.secondaryIcon)
|
||||
} else {
|
||||
if (thisObject.relatedUiObject !== undefined) {
|
||||
thisObject.iconOn = canvas.strategySpace.iconByPartType.get(thisObject.relatedUiObject)
|
||||
thisObject.iconOff = canvas.strategySpace.iconByPartType.get(thisObject.relatedUiObject)
|
||||
thisObject.iconOn = canvas.designerSpace.iconByPartType.get(thisObject.relatedUiObject)
|
||||
thisObject.iconOff = canvas.designerSpace.iconByPartType.get(thisObject.relatedUiObject)
|
||||
} else {
|
||||
thisObject.iconOn = canvas.strategySpace.iconCollection.get(thisObject.iconPathOn)
|
||||
thisObject.iconOff = canvas.strategySpace.iconCollection.get(thisObject.iconPathOff)
|
||||
thisObject.iconOn = canvas.designerSpace.iconCollection.get(thisObject.iconPathOn)
|
||||
thisObject.iconOff = canvas.designerSpace.iconCollection.get(thisObject.iconPathOff)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -208,7 +208,7 @@ function newFloatingObject () {
|
||||
let parent = thisObject.payload.chainParent
|
||||
if (parent !== undefined) {
|
||||
let distanceToChainParent = Math.sqrt(Math.pow(parent.payload.position.x - thisObject.container.frame.position.x, 2) + Math.pow(parent.payload.position.y - thisObject.container.frame.position.y, 2)) // ... we calculate the distance ...
|
||||
let parentChildren = canvas.strategySpace.workspace.nodeChildren.childrenCount(parent, thisObject.payload.node)
|
||||
let parentChildren = canvas.designerSpace.workspace.nodeChildren.childrenCount(parent, thisObject.payload.node)
|
||||
let axisCount = parentChildren.childrenCount
|
||||
let axisIndex = parentChildren.childIndex
|
||||
let baseAngle = 0
|
||||
|
||||
@@ -549,7 +549,7 @@ function newUiObject () {
|
||||
|
||||
if (previousDistance !== undefined) {
|
||||
if (ratio > THRESHOLD) {
|
||||
canvas.strategySpace.workspace.detachNode(thisObject.payload.node)
|
||||
canvas.designerSpace.workspace.detachNode(thisObject.payload.node)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -658,8 +658,8 @@ function newUiObject () {
|
||||
}
|
||||
|
||||
function iconPhysics () {
|
||||
icon = canvas.strategySpace.iconByPartType.get(thisObject.payload.node.type)
|
||||
executingIcon = canvas.strategySpace.iconCollection.get('attractive')
|
||||
icon = canvas.designerSpace.iconByPartType.get(thisObject.payload.node.type)
|
||||
executingIcon = canvas.designerSpace.iconCollection.get('attractive')
|
||||
}
|
||||
|
||||
function onFocus () {
|
||||
@@ -692,7 +692,7 @@ function newUiObject () {
|
||||
|
||||
function onDragFinished (event) {
|
||||
if (isAttaching === true) {
|
||||
canvas.strategySpace.workspace.attachNode(thisObject.payload.node, attachToNode)
|
||||
canvas.designerSpace.workspace.attachNode(thisObject.payload.node, attachToNode)
|
||||
attachToNode = undefined
|
||||
isAttaching = false
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ function newProductsPanel () {
|
||||
}
|
||||
|
||||
/* Then we get an Array of all instances of this bot placed at Definitions on the Workspace. */
|
||||
let tradingBotInstances = canvas.strategySpace.workspace.getAllTradingBotInstances()
|
||||
let tradingBotInstances = canvas.designerSpace.workspace.getAllTradingBotInstances()
|
||||
|
||||
/* Here we will go through all the instances of trading engines and see their layers, to see
|
||||
if we can find a matching layer. */
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
thisObject.container.frame.position.x = 0
|
||||
|
||||
let INITIAL_POSITION
|
||||
if (canvas.strategySpace.workspace.enabled === true) {
|
||||
if (canvas.designerSpace.workspace.enabled === true) {
|
||||
let localStorage = window.localStorage.getItem(MODULE_NAME)
|
||||
if (localStorage !== null) {
|
||||
storage = JSON.parse(localStorage)
|
||||
@@ -100,7 +100,7 @@
|
||||
|
||||
thisObject.status = 'MIDDLE'
|
||||
|
||||
if (canvas.strategySpace.workspace.enabled === true) {
|
||||
if (canvas.designerSpace.workspace.enabled === true) {
|
||||
thisObject.container.isDraggeable = true
|
||||
} else {
|
||||
thisObject.container.isDraggeable = false
|
||||
@@ -109,10 +109,10 @@
|
||||
if (thisObject.container.frame.position.y > browserCanvas.height * 99.5 / 100 - COCKPIT_SPACE_HEIGHT) {
|
||||
thisObject.container.frame.position.y = browserCanvas.height - COCKPIT_SPACE_HEIGHT
|
||||
thisObject.status = 'BOTTOM'
|
||||
canvas.strategySpace.makeInvisible()
|
||||
canvas.designerSpace.makeInvisible()
|
||||
canvas.floatingSpace.makeInvisible()
|
||||
} else {
|
||||
canvas.strategySpace.makeVisible()
|
||||
canvas.designerSpace.makeVisible()
|
||||
canvas.floatingSpace.makeVisible()
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@
|
||||
browserCanvasContext.closePath()
|
||||
browserCanvasContext.fill()
|
||||
|
||||
if (canvas.strategySpace.workspace.enabled === true) {
|
||||
if (canvas.designerSpace.workspace.enabled === true) {
|
||||
arrow()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
function newStrategySpace () {
|
||||
function newDesignerSpace () {
|
||||
const MODULE_NAME = 'Strategy Space'
|
||||
let thisObject = {
|
||||
sidePanel: undefined,
|
||||
Reference in new issue
Block a user