Workspace and StrategizerGateway upgraded
This commit is contained in:
1 parent
398dd56124
commit
66a8e06912
3 files changed
+16
-32
No files matched your search
@@ -32,7 +32,6 @@ function newStrategySpace () {
|
||||
buildIconByPartTypeMap()
|
||||
|
||||
thisObject.strategizerGateway = newStrategizerGateway()
|
||||
thisObject.strategizerGateway.initialize()
|
||||
|
||||
thisObject.workspace = newWorkspace()
|
||||
thisObject.workspace.initialize()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
function newStrategizerGateway () {
|
||||
const MODULE_NAME = 'Strategizer Gateway'
|
||||
const ERROR_LOG = true
|
||||
const logger = newWebDebugLog()
|
||||
logger.fileName = MODULE_NAME
|
||||
|
||||
@@ -10,8 +9,7 @@ function newStrategizerGateway () {
|
||||
strategizerData: undefined,
|
||||
container: undefined,
|
||||
loadFromStrategyzer: loadFromStrategyzer,
|
||||
saveToStrategyzer: saveToStrategyzer,
|
||||
initialize: initialize
|
||||
saveToStrategyzer: saveToStrategyzer
|
||||
}
|
||||
|
||||
let colletionItems = []
|
||||
@@ -29,12 +27,10 @@ function newStrategizerGateway () {
|
||||
thisObject.container.isDraggeable = false
|
||||
thisObject.container.isClickeable = false
|
||||
|
||||
let graphQLServer
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize () {
|
||||
|
||||
}
|
||||
|
||||
async function loadFromStrategyzer () {
|
||||
try {
|
||||
const accessToken = window.localStorage.getItem(LOGGED_IN_ACCESS_TOKEN_LOCAL_STORAGE_KEY)
|
||||
@@ -52,7 +48,7 @@ function newStrategizerGateway () {
|
||||
user = JSON.parse(user)
|
||||
let fbSlug = 'simulator' + '-' + 'bot' + '-' + user.alias.replace('.', '')
|
||||
|
||||
let graphQLServer = await axios({
|
||||
graphQLServer = await axios({
|
||||
url: window.canvasApp.graphQL.masterAppApiUrl,
|
||||
method: 'post',
|
||||
data: {
|
||||
@@ -82,11 +78,12 @@ function newStrategizerGateway () {
|
||||
} 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))
|
||||
window.localStorage.setItem(CANVAS_APP_NAME + '.' + MODULE_NAME + '.' + user.alias, thisObject.idAtStrategizer)
|
||||
return true
|
||||
}
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] loadFromStrategyzer -> err = ' + err.stack) }
|
||||
logger.write('[ERROR] loadFromStrategyzer -> err = ' + err.stack)
|
||||
logger.write('[ERROR] loadFromStrategyzer -> GraphQL Error: ' + JSON.stringify(graphQLServer.data.errors))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +117,7 @@ function newStrategizerGateway () {
|
||||
logger.write('[ERROR] saveToStrategyzer -> Can not save when idAtStrategizer is null or undefined.')
|
||||
return
|
||||
}
|
||||
const graphQLServer = await axios({
|
||||
graphQLServer = await axios({
|
||||
url: window.canvasApp.graphQL.masterAppApiUrl,
|
||||
method: 'post',
|
||||
data: {
|
||||
@@ -152,7 +149,8 @@ function newStrategizerGateway () {
|
||||
|
||||
return true
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] saveToStrategyzer -> err = ' + err.stack) }
|
||||
logger.write('[ERROR] saveToStrategyzer -> err = ' + err.stack)
|
||||
logger.write('[ERROR] loadFromStrategyzer -> GraphQL Error: ' + JSON.stringify(graphQLServer.data.errors))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ function newWorkspace () {
|
||||
spawn: spawn,
|
||||
detachNode: detachNode,
|
||||
attachNode: attachNode,
|
||||
getContainer: getContainer,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
@@ -58,9 +57,10 @@ function newWorkspace () {
|
||||
}
|
||||
user = JSON.parse(user)
|
||||
|
||||
let idAtStrategizer = window.localStorage.getItem(CANVAS_APP_NAME + '.' + user.alias + '.' + 'Strategizer Gateway')
|
||||
let savedWorkspace = window.localStorage.getItem(CANVAS_APP_NAME + '.' + user.alias + '.' + 'Workspace')
|
||||
if (savedWorkspace === null || savedWorkspace === null) {
|
||||
let idAtStrategizer = window.localStorage.getItem(CANVAS_APP_NAME + '.' + 'Strategizer Gateway' + '.' + user.alias)
|
||||
let savedWorkspace = window.localStorage.getItem(CANVAS_APP_NAME + '.' + 'Workspace' + '.' + user.alias)
|
||||
|
||||
if (savedWorkspace === null || idAtStrategizer === null) {
|
||||
workspaceNode.type = 'Workspace'
|
||||
workspaceNode.name = 'My Workspace'
|
||||
functionLibraryPartsFromNodes.createPartFromNode(workspaceNode, undefined, undefined)
|
||||
@@ -84,21 +84,8 @@ function newWorkspace () {
|
||||
workspaceNode.rootNodes.push(thisObject.tradingSystem)
|
||||
functionLibraryPartsFromNodes.createPartFromNode(thisObject.tradingSystem, undefined, undefined)
|
||||
thisObject.tradingSystem.payload.uiObject.setRunningStatus()
|
||||
} else {
|
||||
// First use of the Designer, lets help by creating the first Trading System
|
||||
thisObject.tradingSystem = {
|
||||
type: 'Trading System',
|
||||
strategies: []
|
||||
}
|
||||
workspaceNode.rootNodes.push(thisObject.tradingSystem)
|
||||
functionLibraryPartsFromNodes.createPartFromNode(thisObject.tradingSystem, undefined, undefined)
|
||||
thisObject.tradingSystem.payload.uiObject.setRunningStatus()
|
||||
isInitialized = true
|
||||
}
|
||||
isInitialized = true
|
||||
}
|
||||
|
||||
function getContainer (point) {
|
||||
|
||||
}
|
||||
|
||||
function getProtocolTradingSystem () {
|
||||
@@ -123,7 +110,7 @@ function newWorkspace () {
|
||||
user = JSON.parse(user)
|
||||
|
||||
let textToSave = stringifyWorkspace()
|
||||
window.localStorage.setItem(user.alias + '.' + 'workspace', textToSave)
|
||||
window.localStorage.setItem(CANVAS_APP_NAME + '.' + 'Workspace' + '.' + user.alias, textToSave)
|
||||
}
|
||||
|
||||
function stringifyWorkspace () {
|
||||
|
||||
Reference in new issue
Block a user