Bug Fixed ViewPort not loading
This commit is contained in:
1 parent
432b5c9dcd
commit
d331b84c26
3 files changed
+5
-219
No files matched your search
+1
-9
@@ -2,16 +2,7 @@ let canvas
|
||||
let markets
|
||||
let ecosystem = newEcosystem()
|
||||
let systemEventHandler
|
||||
|
||||
let viewPort
|
||||
try {
|
||||
viewPort = newViewPort()
|
||||
} catch (e) {
|
||||
setTimeout(() => {
|
||||
console.log('Loading deferred.')
|
||||
viewPort = newViewPort()
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
function newDashboard () {
|
||||
const MODULE_NAME = 'Dashboard'
|
||||
@@ -34,6 +25,7 @@ function newDashboard () {
|
||||
function start () {
|
||||
try {
|
||||
setBrowserEvents()
|
||||
viewPort = newViewPort()
|
||||
|
||||
systemEventHandler = newSystemEventHandler()
|
||||
systemEventHandler.initialize(startCanvas)
|
||||
|
||||
+4
-23
@@ -3,14 +3,11 @@ function newTopSpace () {
|
||||
let thisObject = {
|
||||
container: undefined,
|
||||
draw: draw,
|
||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||
endUser: undefined,
|
||||
currentEvent: undefined,
|
||||
login: undefined,
|
||||
getContainer: getContainer,
|
||||
initialize: initialize
|
||||
}
|
||||
|
||||
var container = newContainer()
|
||||
let container = newContainer()
|
||||
container.initialize()
|
||||
thisObject.container = container
|
||||
|
||||
@@ -20,19 +17,7 @@ function newTopSpace () {
|
||||
|
||||
return thisObject
|
||||
|
||||
async function initialize () {
|
||||
let sharedStatus = {
|
||||
currentDevTeamIndex: 0,
|
||||
currentEventIndex: 0,
|
||||
currentUserBotIndex: 0,
|
||||
currentProcessIndex: 0,
|
||||
currentBotType: '',
|
||||
eventHandler: newEventHandler()
|
||||
}
|
||||
|
||||
thisObject.login = newLogin()
|
||||
await thisObject.login.initialize(sharedStatus)
|
||||
|
||||
function initialize () {
|
||||
window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize)
|
||||
}
|
||||
|
||||
@@ -43,7 +28,7 @@ function newTopSpace () {
|
||||
container.frame.position.x = 0
|
||||
try {
|
||||
container.frame.position.y = viewPort.visibleArea.bottomLeft.y
|
||||
} catch(e) { }
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
function getContainer (point) {
|
||||
@@ -66,10 +51,6 @@ function newTopSpace () {
|
||||
|
||||
drawBackground()
|
||||
return
|
||||
|
||||
thisObject.endUser.draw()
|
||||
thisObject.currentEvent.draw()
|
||||
thisObject.login.draw()
|
||||
}
|
||||
|
||||
function drawBackground () {
|
||||
|
||||
@@ -1,187 +0,0 @@
|
||||
|
||||
function newLogin () {
|
||||
const MODULE_NAME = 'Login'
|
||||
const ERROR_LOG = true
|
||||
const logger = newWebDebugLog()
|
||||
logger.fileName = MODULE_NAME
|
||||
|
||||
let thisObject = {
|
||||
container: undefined,
|
||||
draw: draw,
|
||||
getContainer: getContainer,
|
||||
initialize: initialize
|
||||
}
|
||||
|
||||
let container = newContainer()
|
||||
container.initialize()
|
||||
thisObject.container = container
|
||||
|
||||
thisObject.container.frame.width = 200
|
||||
thisObject.container.frame.height = COCKPIT_SPACE_HEIGHT
|
||||
|
||||
container.frame.position.x = viewPort.visibleArea.topRight.x - thisObject.container.frame.width * 1
|
||||
container.frame.position.y = viewPort.visibleArea.bottomLeft.y + BREAKPOINT_HEIGHT
|
||||
|
||||
container.isDraggeable = false
|
||||
container.isClickeable = true
|
||||
|
||||
return thisObject
|
||||
|
||||
async function initialize (sharedStatus) {
|
||||
try {
|
||||
if (window.canvasApp.executingAt === 'Local') { return }
|
||||
|
||||
const accessToken = window.localStorage.getItem('access_token')
|
||||
|
||||
if (accessToken) {
|
||||
await getEvents(accessToken, sharedStatus)
|
||||
// await getClones(accessToken)
|
||||
}
|
||||
|
||||
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) {
|
||||
var d = new Date()
|
||||
var nowSeconds = Math.round(d.getTime() / 1000)
|
||||
var twoWeeksAgoSeconds = nowSeconds - 1209600
|
||||
|
||||
let response = await axios({
|
||||
url: window.canvasApp.graphQL.masterAppApiUrl,
|
||||
method: 'post',
|
||||
data: {
|
||||
query:
|
||||
`query events($maxStartDate: Int, $minEndDate: Int){
|
||||
events_Events(maxStartDate: $maxStartDate, minEndDate: $minEndDate){
|
||||
id
|
||||
title
|
||||
startDatetime
|
||||
endDatetime
|
||||
participants{
|
||||
clone{
|
||||
id
|
||||
team{
|
||||
slug
|
||||
}
|
||||
bot{
|
||||
slug
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`
|
||||
},
|
||||
variables: {
|
||||
variables: { maxStartDate: nowSeconds, minEndDate: twoWeeksAgoSeconds }
|
||||
},
|
||||
headers: {
|
||||
authorization: 'Bearer ' + accessToken
|
||||
}
|
||||
})
|
||||
|
||||
if (response.data.errors) {
|
||||
console.log('Error getting events: ' + JSON.stringify(response.data.errors))
|
||||
throw 'Error getting events: ' + JSON.stringify(response.data.errors)
|
||||
} else {
|
||||
window.localStorage.setItem('currentEvents', JSON.stringify(response.data.data.events_Events))
|
||||
currentEvent = window.localStorage.getItem('currentEventObject')
|
||||
if (currentEvent === null || currentEvent === '[]' || currentEvent === '') {
|
||||
sharedStatus.currentEventIndex = -1
|
||||
} else {
|
||||
currentEvent = JSON.parse(currentEvent)
|
||||
sharedStatus.currentEventIndex = response.data.data.events_Events.findIndex(function (element) {
|
||||
return element.id == currentEvent.id
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function getClones (accessToken) {
|
||||
let response = await axios({
|
||||
url: window.canvasApp.graphQL.masterAppApiUrl,
|
||||
method: 'post',
|
||||
data: {
|
||||
query:
|
||||
`query Operations_Clones{
|
||||
operations_Clones {
|
||||
id
|
||||
authId
|
||||
teamId
|
||||
botId
|
||||
mode
|
||||
resumeExecution
|
||||
beginDatetime
|
||||
endDatetime
|
||||
waitTime
|
||||
state
|
||||
stateDatetime
|
||||
createDatetime
|
||||
lastLogs
|
||||
summaryDate
|
||||
buyAverage
|
||||
sellAverage
|
||||
marketRate
|
||||
combinedProfitsA
|
||||
combinedProfitsB
|
||||
assetA
|
||||
assetB
|
||||
botType
|
||||
teamName
|
||||
botName
|
||||
botAvatar
|
||||
teamAvatar
|
||||
processName
|
||||
keyId
|
||||
botSlug
|
||||
}
|
||||
}
|
||||
`
|
||||
},
|
||||
headers: {
|
||||
authorization: 'Bearer ' + accessToken
|
||||
}
|
||||
})
|
||||
|
||||
if (response.data.errors) {
|
||||
console.log('Error getting clones: ' + JSON.stringify(response.data.errors))
|
||||
throw 'Error getting clones: ' + JSON.stringify(response.data.errors)
|
||||
} else {
|
||||
window.localStorage.setItem('userClones', JSON.stringify(response.data.data.operations_Clones))
|
||||
let clones = response.data.data.operations_Clones
|
||||
for (let i = 0; i < clones.length; i++) {
|
||||
let clone = clones[i]
|
||||
if (clone.botType === 'Trading') {
|
||||
let teamSlug = clone.teamName.toLowerCase()
|
||||
teamSlug = teamSlug.replace(' ', '-')
|
||||
let devTeam = ecosystem.getTeam(teamSlug)
|
||||
let bot = ecosystem.getBot(devTeam, clone.botSlug)
|
||||
if (bot !== undefined) {
|
||||
bot.cloneId = clone.id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onClick () {
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
} else {
|
||||
/* This point does not belong to this space. */
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
function draw () {
|
||||
return // nothing to show.
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user