Changes to make it work Locally
This commit is contained in:
1 parent
335fd88d3c
commit
fd4344e793
4 files changed
+106
-77
No files matched your search
@@ -142,6 +142,10 @@ function newPlottersManager () {
|
||||
|
||||
function initializeCompetitionPlotters (callBack) {
|
||||
try {
|
||||
/* Disabling this functionality since it is not currently available */
|
||||
callBack(GLOBAL.DEFAULT_OK_RESPONSE)
|
||||
return
|
||||
|
||||
/* At this current version of the platform, we will support only one competition with only one plotter. */
|
||||
|
||||
const COMPETITION_HOST = 'AAMasters'
|
||||
|
||||
+10
-3
@@ -7,9 +7,9 @@ try {
|
||||
viewPort = newViewPort()
|
||||
} catch (e) {
|
||||
setTimeout(() => {
|
||||
console.log("Loading deferred.")
|
||||
console.log('Loading deferred.')
|
||||
viewPort = newViewPort()
|
||||
}, 1000);
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
function newDashboard () {
|
||||
@@ -36,6 +36,13 @@ function newDashboard () {
|
||||
|
||||
if (canvas !== undefined) { canvas.finalize() }
|
||||
|
||||
/* Here we check where we are executing. In case we are Local we need to create a Local Dummy User and Team. */
|
||||
|
||||
if (window.canvasApp.executingAt === 'Local') {
|
||||
window.localStorage.setItem(LOGGED_IN_ACCESS_TOKEN_LOCAL_STORAGE_KEY, 'Local Access Token') // Dummy Access Token
|
||||
window.localStorage.setItem(LOGGED_IN_USER_LOCAL_STORAGE_KEY, '{"authId":"x|x","alias":"user"}') // Dummy Local User
|
||||
}
|
||||
|
||||
/* Here we will setup the global eventHandler that will enable the Canvas App to react to events happening outside its execution scope. */
|
||||
|
||||
window.canvasApp.eventHandler = newEventHandler()
|
||||
@@ -161,7 +168,7 @@ function newDashboard () {
|
||||
})
|
||||
.then(response => {
|
||||
teams = response.data.teams_Teams
|
||||
//window.localStorage.setItem('Teams', JSON.stringify(response.data.teams_Teams))
|
||||
// window.localStorage.setItem('Teams', JSON.stringify(response.data.teams_Teams))
|
||||
resolve({ teams: response.data.teams_Teams })
|
||||
})
|
||||
.catch(err => {
|
||||
|
||||
@@ -45,41 +45,47 @@ function newStrategizerGateway () {
|
||||
return
|
||||
}
|
||||
|
||||
user = JSON.parse(user)
|
||||
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
|
||||
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'
|
||||
} 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
|
||||
user = JSON.parse(user)
|
||||
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)
|
||||
@@ -100,10 +106,6 @@ function newStrategizerGateway () {
|
||||
return
|
||||
}
|
||||
|
||||
user = JSON.parse(user)
|
||||
|
||||
/* See if we need to update or create a new record at the strategizer */
|
||||
|
||||
let tradingSystem = canvas.strategySpace.workspace.getProtocolTradingSystem()
|
||||
if (tradingSystem === undefined || tradingSystem === null) {
|
||||
logger.write('[ERROR] saveToStrategyzer -> Can not save when tradingSystem is null or undefined.')
|
||||
@@ -115,37 +117,52 @@ function newStrategizerGateway () {
|
||||
logger.write('[ERROR] saveToStrategyzer -> Can not save when idAtStrategizer is null or undefined.')
|
||||
return
|
||||
}
|
||||
graphQLServer = await axios({
|
||||
url: window.canvasApp.graphQL.masterAppApiUrl,
|
||||
method: 'post',
|
||||
data: {
|
||||
query: `
|
||||
mutation strategizer_EditTradingSystem
|
||||
(
|
||||
$id: ID!, $data: strategizer_JSON!
|
||||
)
|
||||
{
|
||||
strategizer_EditTradingSystem(id: $id, tradingSystem: { data: $data })
|
||||
{
|
||||
id
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
id: idAtStrategizer,
|
||||
data: tradingSystem
|
||||
|
||||
if (window.canvasApp.executingAt === 'Local') {
|
||||
callServer(tradingSystem, 'SaveDefinition', onSaved)
|
||||
function onSaved (err) {
|
||||
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
return true
|
||||
} else {
|
||||
logger.write('[ERROR] saveToStrategyzer -> Can not save definition to local server. err = ' + err.messsage)
|
||||
return false
|
||||
}
|
||||
},
|
||||
headers: {
|
||||
authorization: 'Bearer ' + accessToken
|
||||
}
|
||||
})
|
||||
} else {
|
||||
user = JSON.parse(user)
|
||||
|
||||
if (graphQLServer.data.errors) {
|
||||
logger.write('[ERROR] saveToStrategyzer -> GraphsQL Error -> graphQLServer.data.errors = ' + JSON.stringify(graphQLServer.data.errors))
|
||||
graphQLServer = await axios({
|
||||
url: window.canvasApp.graphQL.masterAppApiUrl,
|
||||
method: 'post',
|
||||
data: {
|
||||
query: `
|
||||
mutation strategizer_EditTradingSystem
|
||||
(
|
||||
$id: ID!, $data: strategizer_JSON!
|
||||
)
|
||||
{
|
||||
strategizer_EditTradingSystem(id: $id, tradingSystem: { data: $data })
|
||||
{
|
||||
id
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
id: idAtStrategizer,
|
||||
data: tradingSystem
|
||||
}
|
||||
},
|
||||
headers: {
|
||||
authorization: 'Bearer ' + accessToken
|
||||
}
|
||||
})
|
||||
|
||||
if (graphQLServer.data.errors) {
|
||||
logger.write('[ERROR] saveToStrategyzer -> GraphsQL Error -> graphQLServer.data.errors = ' + JSON.stringify(graphQLServer.data.errors))
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
return true
|
||||
} catch (err) {
|
||||
logger.write('[ERROR] saveToStrategyzer -> err = ' + err.stack)
|
||||
}
|
||||
|
||||
+10
-9
@@ -1,5 +1,5 @@
|
||||
|
||||
function newLogin() {
|
||||
function newLogin () {
|
||||
const MODULE_NAME = 'Login'
|
||||
const ERROR_LOG = true
|
||||
const logger = newWebDebugLog()
|
||||
@@ -27,8 +27,10 @@ function newLogin() {
|
||||
|
||||
return thisObject
|
||||
|
||||
async function initialize(sharedStatus) {
|
||||
async function initialize (sharedStatus) {
|
||||
try {
|
||||
if (window.canvasApp.executingAt === 'Local') { return }
|
||||
|
||||
const accessToken = window.localStorage.getItem('access_token')
|
||||
|
||||
if (accessToken) {
|
||||
@@ -37,14 +39,13 @@ function newLogin() {
|
||||
}
|
||||
|
||||
thisObject.container.eventHandler.listenToEvent('onMouseClick', onClick)
|
||||
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err) }
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err.stack = ' + err.stack) }
|
||||
}
|
||||
}
|
||||
|
||||
async function getEvents(accessToken, sharedStatus) {
|
||||
async function getEvents (accessToken, sharedStatus) {
|
||||
var d = new Date()
|
||||
var nowSeconds = Math.round(d.getTime() / 1000)
|
||||
var twoWeeksAgoSeconds = nowSeconds - 1209600
|
||||
@@ -72,7 +73,7 @@ function newLogin() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}`,
|
||||
}`
|
||||
},
|
||||
variables: {
|
||||
variables: { maxStartDate: nowSeconds, minEndDate: twoWeeksAgoSeconds }
|
||||
@@ -99,7 +100,7 @@ function newLogin() {
|
||||
}
|
||||
}
|
||||
|
||||
async function getClones(accessToken) {
|
||||
async function getClones (accessToken) {
|
||||
let response = await axios({
|
||||
url: window.canvasApp.graphQL.masterAppApiUrl,
|
||||
method: 'post',
|
||||
@@ -166,11 +167,11 @@ function newLogin() {
|
||||
}
|
||||
}
|
||||
|
||||
function onClick() {
|
||||
function onClick () {
|
||||
|
||||
}
|
||||
|
||||
function getContainer(point) {
|
||||
function getContainer (point) {
|
||||
/* First we check if this point is inside this object UI. */
|
||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||
return this.container
|
||||
@@ -180,7 +181,7 @@ function newLogin() {
|
||||
}
|
||||
}
|
||||
|
||||
function draw() {
|
||||
function draw () {
|
||||
return // nothing to show.
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user