From d331b84c26c746cfdbf57f9fb4b6faa5e1b24785 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 23 Sep 2019 15:40:23 +0200 Subject: [PATCH] Bug Fixed ViewPort not loading --- Dashboard.js | 10 +-- Spaces/TopSpace.js | 27 +------ TopSpace/Login.js | 187 --------------------------------------------- 3 files changed, 5 insertions(+), 219 deletions(-) delete mode 100644 TopSpace/Login.js diff --git a/Dashboard.js b/Dashboard.js index d4cf9d407..f2de0d950 100644 --- a/Dashboard.js +++ b/Dashboard.js @@ -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) diff --git a/Spaces/TopSpace.js b/Spaces/TopSpace.js index c67effb91..ed96650ac 100644 --- a/Spaces/TopSpace.js +++ b/Spaces/TopSpace.js @@ -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 () { diff --git a/TopSpace/Login.js b/TopSpace/Login.js deleted file mode 100644 index 79b09d25a..000000000 --- a/TopSpace/Login.js +++ /dev/null @@ -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. - } -}