Strategizer Cleaned Out
This commit is contained in:
1 parent
04b428f515
commit
5e281323e8
3 files changed
+2
-111
No files matched your search
@@ -1,95 +0,0 @@
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,7 +67,7 @@ function newWorkspace () {
|
||||
thisObject.workspaceNode = undefined
|
||||
}
|
||||
|
||||
async function initialize () {
|
||||
function initialize () {
|
||||
try {
|
||||
let savedWorkspace = window.localStorage.getItem(CANVAS_APP_NAME + '.' + 'Workspace')
|
||||
|
||||
@@ -84,17 +84,6 @@ function newWorkspace () {
|
||||
}
|
||||
}
|
||||
|
||||
async function initializeLoadingFromStrategizer () {
|
||||
let result = await canvas.designerSpace.strategizerGateway.loadFromStrategyzer()
|
||||
if (result === true) {
|
||||
thisObject.definition = canvas.designerSpace.strategizerGateway.strategizerData
|
||||
thisObject.workspaceNode.rootNodes.push(thisObject.definition)
|
||||
functionLibraryUiObjectsFromNodes.createUiObjectFromNode(thisObject.definition, undefined, undefined)
|
||||
|
||||
thisObject.enabled = true
|
||||
}
|
||||
}
|
||||
|
||||
function chainDetachNode (node) {
|
||||
functionLibraryChainAttachDetach.chainDetachNode(node, thisObject.workspaceNode.rootNodes)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ function newDesignerSpace () {
|
||||
const MODULE_NAME = 'Strategy Space'
|
||||
let thisObject = {
|
||||
sidePanel: undefined,
|
||||
strategizerGateway: undefined,
|
||||
container: undefined,
|
||||
iconCollection: undefined,
|
||||
iconByUiObjectType: undefined,
|
||||
@@ -27,12 +26,10 @@ function newDesignerSpace () {
|
||||
|
||||
return thisObject
|
||||
|
||||
async function initialize () {
|
||||
function initialize () {
|
||||
loadIconCollection()
|
||||
buildIconByUiObjectTypeMap()
|
||||
|
||||
thisObject.strategizerGateway = newStrategizerGateway()
|
||||
|
||||
thisObject.workspace = newWorkspace()
|
||||
thisObject.workspace.initialize()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user