From 9863485e910d40b05848cd94f3912aa62080fc34 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 23 Apr 2019 22:25:48 +0200 Subject: [PATCH 01/11] Finalize for Container --- Container.js | 11 +++++++++++ PlottersManager.js | 1 + 2 files changed, 12 insertions(+) diff --git a/Container.js b/Container.js index 8ea75ce14..bbb4d93ed 100644 --- a/Container.js +++ b/Container.js @@ -10,15 +10,25 @@ function newContainer () { isWheelable: false, name: undefined, initialize: initialize, + finalize: finalize, connectToParent: connectToParent, isForThisPurpose: isForThisPurpose } let connectedToParentWidth = false let connectedToParentHeight = false + let isConnectedToParent = false return thisObject + function finalize () { + if (isConnectedToParent === true) { + thisObject.parentContainer.eventHandler.stopListening('Dimmensions Changed', onParentDimmensionsChanged) + thisObject.parentContainer.eventHandler.stopListening('onMouseOver', onMouseOver) + thisObject.parentContainer.eventHandler.stopListening('onMouseNotOver', onMouseNotOver) + } + } + function initialize (pName) { thisObject.name = pName @@ -39,6 +49,7 @@ function newContainer () { function connectToParent (parentContainer, onWidth, onHeight) { connectedToParentWidth = onWidth connectedToParentHeight = onHeight + isConnectedToParent = true thisObject.displacement.parentDisplacement = parentContainer.displacement thisObject.frame.parentFrame = parentContainer.frame diff --git a/PlottersManager.js b/PlottersManager.js index f868af859..99e544dcb 100644 --- a/PlottersManager.js +++ b/PlottersManager.js @@ -619,6 +619,7 @@ function newPlottersManager () { productPlotters[i].storage.finalize() if (productPlotters[i].plotter.finalize !== undefined) { + productPlotters[i].plotter.container.finalize() productPlotters[i].plotter.finalize() } From 10b1a6511f1e1418b135050204a781183ff2b92e Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 24 Apr 2019 08:10:20 +0200 Subject: [PATCH 02/11] removed logs from eventHandler --- EventHandler.js | 24 ------------------------ Panels/ProductsPanel.js | 2 +- 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/EventHandler.js b/EventHandler.js index 89f100d9e..3a17fd9a2 100644 --- a/EventHandler.js +++ b/EventHandler.js @@ -1,7 +1,5 @@  function newEventHandler () { - const CONSOLE_LOG = false - let thisObject = { name: undefined, // This is for debugging purposes only. parentEventHandler: undefined, // Here we store the parent cointainer zoom object. @@ -21,10 +19,6 @@ function newEventHandler () { function listenToEvent (eventType, handler, extraData) { eventHandlers.push([eventType, handler, extraData]) - - if (thisObject.name !== undefined && CONSOLE_LOG === true) { - console.log('Event Handler named ' + thisObject.name + ' received a request to listenToEvent ' + eventType + ' and call ' + (handler.toString()).substring(0, 50)) - } } function stopListening (pEventType, pHandler) { @@ -32,10 +26,6 @@ function newEventHandler () { pHandler = 'Anonymous Function' } - if (thisObject.name !== undefined && CONSOLE_LOG === true) { - console.log('Event Handler named ' + thisObject.name + ' received a request to stop listening to an the event ' + pEventType + ' with this handler: ' + pHandler) - } - for (let i = 0; i < eventHandlers.length; i++) { let record = eventHandlers[i] let eventType = record[0] @@ -45,18 +35,12 @@ function newEventHandler () { if (pEventType === eventType) { eventHandlers.splice(i, 1) - if (thisObject.name !== undefined && CONSOLE_LOG === true) { - console.log('Evethandler found and deleted.') - } return } } else { if (pEventType === eventType && pHandler.toString() === handler.toString()) { eventHandlers.splice(i, 1) - if (thisObject.name !== undefined && CONSOLE_LOG === true) { - console.log('Evethandler found and deleted.') - } return } } @@ -64,10 +48,6 @@ function newEventHandler () { } function raiseEvent (eventType, event) { - if (thisObject.name !== undefined && CONSOLE_LOG === true) { - console.log('Event Handler named ' + thisObject.name + ' received a request to raiseEvent ' + eventType + ' with this data ' + (event.toString()).substring(0, 50)) - } - for (var i = 0; i < eventHandlers.length; i++) { /* We will execute all the functions listening to this event type. */ @@ -75,10 +55,6 @@ function newEventHandler () { var handler = eventHandlers[i][1] var extraData = eventHandlers[i][2] - if (thisObject.name !== undefined && CONSOLE_LOG === true) { - console.log('Event Handler named ' + thisObject.name + ' received a request to raiseEvent ' + eventType + ' and will call this handler: ' + (handler.toString()).substring(0, 50)) - } - handler(event, extraData) } } diff --git a/Panels/ProductsPanel.js b/Panels/ProductsPanel.js index 08822bb7c..fcb1ac068 100644 --- a/Panels/ProductsPanel.js +++ b/Panels/ProductsPanel.js @@ -81,7 +81,7 @@ if (bot.products !== undefined) { for (let k = 0; k < bot.products.length; k++) { let product = bot.products[k] - if (product.shareWith !== 'Public' && devTeam.codeName !== userTeam.slug) { continue } + // if (product.shareWith !== 'Public' && devTeam.codeName !== userTeam.slug) { continue } /* Now we create Product objects */ let productCard = newProductCard() From bca1baf1160a42c3b9617dc24df7481b2d8418c7 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 24 Apr 2019 08:16:23 +0200 Subject: [PATCH 03/11] Event handler cleaning --- Container.js | 1 - EventHandler.js | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Container.js b/Container.js index bbb4d93ed..eb549c09f 100644 --- a/Container.js +++ b/Container.js @@ -38,7 +38,6 @@ function newContainer () { thisObject.frame.container = thisObject thisObject.eventHandler = newEventHandler() - thisObject.eventHandler.initialize() thisObject.eventHandler.name = pName thisObject.displacement = newDisplacement() diff --git a/EventHandler.js b/EventHandler.js index 3a17fd9a2..dcef6df7d 100644 --- a/EventHandler.js +++ b/EventHandler.js @@ -2,14 +2,12 @@ function newEventHandler () { let thisObject = { name: undefined, // This is for debugging purposes only. - parentEventHandler: undefined, // Here we store the parent cointainer zoom object. listenToEvent: listenToEvent, stopListening: stopListening, - raiseEvent: raiseEvent, - initialize: initialize + raiseEvent: raiseEvent } - var eventHandlers = [] // Here we store all the functions we will call when an event is comming. + var eventHandlers = [] // Here we store all the functions we will call when an event is raiseed. return thisObject From 8a2bea0b28528328b882376af63248a0ebb8e78c Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 24 Apr 2019 08:31:09 +0200 Subject: [PATCH 04/11] Event Handler class re done --- EventHandler.js | 37 +++++++++---------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/EventHandler.js b/EventHandler.js index dcef6df7d..ad843afeb 100644 --- a/EventHandler.js +++ b/EventHandler.js @@ -11,36 +11,17 @@ function newEventHandler () { return thisObject - function initialize () { - - } - function listenToEvent (eventType, handler, extraData) { - eventHandlers.push([eventType, handler, extraData]) + let eventSubscriptionId = Math.trunc(Math.random() * 1000000) + eventHandlers.push([eventType, handler, extraData, eventSubscriptionId]) + return eventSubscriptionId } - function stopListening (pEventType, pHandler) { - if (pHandler === undefined) { - pHandler = 'Anonymous Function' - } - + function stopListening (pEventSubscriptionId) { for (let i = 0; i < eventHandlers.length; i++) { - let record = eventHandlers[i] - let eventType = record[0] - let handler = record[1] - - if (pHandler === 'Anonymous Function') { - if (pEventType === eventType) { - eventHandlers.splice(i, 1) - - return - } - } else { - if (pEventType === eventType && pHandler.toString() === handler.toString()) { - eventHandlers.splice(i, 1) - - return - } + if (pEventSubscriptionId === eventHandlers[i][3]) { + eventHandlers.splice(i, 1) + return } } } @@ -50,8 +31,8 @@ function newEventHandler () { /* We will execute all the functions listening to this event type. */ if (eventHandlers[i][0] === eventType) { - var handler = eventHandlers[i][1] - var extraData = eventHandlers[i][2] + let handler = eventHandlers[i][1] + let extraData = eventHandlers[i][2] handler(event, extraData) } From dc04234591d3f142ccb0a369405dc37ffc7ee88e Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 24 Apr 2019 08:33:35 +0200 Subject: [PATCH 05/11] Delete trading History gone --- BottomSpace/DeleteTradingHistory.js | 283 ---------------------------- Spaces/BottomSpace.js | 9 +- 2 files changed, 1 insertion(+), 291 deletions(-) delete mode 100644 BottomSpace/DeleteTradingHistory.js diff --git a/BottomSpace/DeleteTradingHistory.js b/BottomSpace/DeleteTradingHistory.js deleted file mode 100644 index 5b3dda7b5..000000000 --- a/BottomSpace/DeleteTradingHistory.js +++ /dev/null @@ -1,283 +0,0 @@ -  -function newDeleteTradingHistory () { - const MODULE_NAME = 'Delete Trading History' - const INFO_LOG = false - const ERROR_LOG = true - const logger = newWebDebugLog() - logger.fileName = MODULE_NAME - - var thisObject = { - container: undefined, - draw: draw, - getContainer: getContainer, // returns the inner most container that holds the point received by parameter. - initialize: initialize - } - - var container = newContainer() - container.initialize() - thisObject.container = container - - thisObject.container.frame.width = 50 - thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT - - resize() - - container.isDraggeable = false - container.isClickeable = true - - let icon - let canDrawIcon = false - - return thisObject - - function initialize (callBackFunction) { - try { - if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') } - - icon = new Image() - - icon.onload = onImageLoad - - function onImageLoad () { - canDrawIcon = true - } - - icon.src = window.canvasApp.urlPrefix + 'Images/Icons/trash.png' - - thisObject.container.eventHandler.listenToEvent('onMouseClick', onClick) - - window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize) - - if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) } - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err.message = ' + err.message) } - if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) } - } - } - - function resize () { - container.frame.position.x = viewPort.visibleArea.topRight.x - container.frame.position.y = viewPort.visibleArea.bottomLeft.y - } - - function onClick () { - try { - if (INFO_LOG === true) { logger.write('[INFO] onClick -> Entering function.') } - - let sessionToken = window.localStorage.getItem('sessionToken') - - if (sessionToken === null || sessionToken === '') { - /* not logged in */ - return - } - - /* - - To delete the trading history we will follow these steps: - - 1. Get the status report of that bot. - 2. Iterate through all the entries for the startMode received by parameters. - 3. For each entry, get the execution history file belonging to that entry. - 4. Iterate on each entry of each execution history file to get the date of each execution that we will use to locate the - execution context file. - 6. Delete every execution context file found. - 7. Delete the execution history file after finishing the interation. - 8. Delete the Sequence file belonging to the received Start Mode. - 9. Save the Status Report without the records of this Start Mode. - - */ - - let storage = AzureStorage.Blob - - let readOnlyBlobService - let writeOnlyBlobService - let deleteOnlyBlobService - - let readConnectionString = window.USER_PROFILE.storagePermissions.get(window.DEV_TEAM + '.' + 'READ') - - if (readConnectionString !== undefined) { - readOnlyBlobService = storage.createBlobService(readConnectionString) - } - - let writeConnectionString = window.USER_PROFILE.storagePermissions.get(window.DEV_TEAM + '.' + 'WRITE') - - if (writeConnectionString !== undefined) { - writeOnlyBlobService = storage.createBlobService(writeConnectionString) - } - - let deleteConnectionString = window.USER_PROFILE.storagePermissions.get(window.DEV_TEAM + '.' + 'DELETE') - - if (deleteConnectionString !== undefined) { - deleteOnlyBlobService = storage.createBlobService(deleteConnectionString) - } - - let containerName = window.DEV_TEAM.toLowerCase() - - let statusReportFilePath = window.DEV_TEAM + '/' + window.CURRENT_BOT_CODE_NAME + '.1.0' + '/' + 'AACloud.1.1' + '/' + 'Poloniex' + '/' + 'dataSet.V1' + '/' + 'Reports' + '/' + 'Trading-Process' - let statusReportFileName = window.CURRENT_START_MODE + '.' + 'Status.Report.USDT_BTC.json' - - readOnlyBlobService.getBlobToText(containerName, statusReportFilePath + '/' + statusReportFileName, onStatusReport) - - function onStatusReport (err, text, response) { - try { - if (INFO_LOG === true) { logger.write('[INFO] onClick -> onStatusReport -> Entering function.') } - - if (err && err.code === 'BlobNotFound') { - console.log(statusReportFilePath + '/' + statusReportFileName + ' not found. No history detected for this start mode.') - return - } - - let statusReport = JSON.parse(text) - - let toBeDeleted = 0 - let deleted = 0 - - for (let i = 0; i < statusReport.runs.length; i++) { - /* For each record, we will get the execution history file. */ - - let filePath = window.DEV_TEAM + '/' + window.CURRENT_BOT_CODE_NAME + '.1.0' + '/' + 'AACloud.1.1' + '/' + 'Poloniex' + '/' + 'dataSet.V1' + '/' + 'Output' + '/' + 'Trading-Process' - let fileName = 'Execution.History.' + window.CURRENT_START_MODE + '.' + i + '.json' - - readOnlyBlobService.getBlobToText(containerName, filePath + '/' + fileName, onExecutionHistory) - - function onExecutionHistory (err, text, response) { - let executionHistory = JSON.parse(text) - - for (let j = 0; j < executionHistory.length; j++) { - let dateTime = new Date(executionHistory[j][0]) - - let datePath = dateTime.getUTCFullYear() + '/' + pad(dateTime.getUTCMonth() + 1, 2) + '/' + pad(dateTime.getUTCDate(), 2) + '/' + pad(dateTime.getUTCHours(), 2) + '/' + pad(dateTime.getUTCMinutes(), 2) - - let filePath = window.DEV_TEAM + '/' + window.CURRENT_BOT_CODE_NAME + '.1.0' + '/' + 'AACloud.1.1' + '/' + 'Poloniex' + '/' + 'dataSet.V1' + '/' + 'Output' + '/' + 'Trading-Process' + '/' + datePath - let fileName = 'Execution.Context.' + window.CURRENT_START_MODE + '.' + i + '.json' - - deleteOnlyBlobService.deleteBlob(containerName, filePath + '/' + fileName, onDeleted) - - toBeDeleted++ - - function onDeleted (err, text, response) { - if (err) { - - console.log(filePath + '/' + fileName + ' NOT deleted.') - console.log('err.message = ' + err.message) - } else { - - console.log(filePath + '/' + fileName + ' deleted.') - } - - deleted++ - - if (toBeDeleted === deleted) { - - updateStatusReport() - } - } - } - - /* Now we delete the execution history file. */ - - deleteOnlyBlobService.deleteBlob(containerName, filePath + '/' + fileName, onExecutionHistoryDeleted) - - function onExecutionHistoryDeleted (err, text, response) { - console.log(filePath + '/' + fileName + ' deleted.') - } - } - } - - function updateStatusReport () { - try { - if (INFO_LOG === true) { logger.write('[INFO] onClick -> onStatusReport -> updateStatusReport -> Entering function.') } - - statusReport.runs = [] - - /* Here is where we update the current Status Report file with the new version without records for the current Start Mode. */ - - let fileContent = JSON.stringify(statusReport) - - writeOnlyBlobService.createBlockBlobFromText(containerName, statusReportFilePath + '/' + statusReportFileName, fileContent, onStatusReportUpdated) - - function onStatusReportUpdated (err, text, response) { - console.log(statusReportFilePath + '/' + statusReportFileName + ' updated.') - } - - /* Finally we delete the sequence file. */ - - let filePath = window.DEV_TEAM + '/' + window.CURRENT_BOT_CODE_NAME + '.1.0' + '/' + 'AACloud.1.1' + '/' + 'Poloniex' + '/' + 'dataSet.V1' + '/' + 'Output' + '/' + 'Trading-Process' - let fileName = 'Execution.History.' + window.CURRENT_START_MODE + '.' + 'Sequence' + '.json' - - deleteOnlyBlobService.deleteBlob(containerName, filePath + '/' + fileName, onDeleted) - - function onDeleted (err, text, response) { - console.log(filePath + '/' + fileName + ' deleted.') - } - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] onClick -> onStatusReport -> updateStatusReport -> err.message = ' + err.message) } - } - } - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] onClick -> onStatusReport -> err.message = ' + err.message) } - } - } - - function pad (str, max) { - str = str.toString() - return str.length < max ? pad('0' + str, max) : str - } - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] onClick -> err.message = ' + err.message) } - } - } - - function getContainer (point) { - try { - if (INFO_LOG === true) { logger.write('[INFO] getContainer -> Entering function.') } - - let container - - /* 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 - } - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] getContainer -> err.message = ' + err.message) } - } - } - - function draw () { - try { - if (INFO_LOG === true) { logger.write('[INFO] draw -> Entering function.') } - - let sessionToken = window.localStorage.getItem('sessionToken') - - if (sessionToken === null || sessionToken === '') { - /* not logged in */ - return - } - - thisObject.container.frame.draw(false, false) - - if (canDrawIcon === false) { return } - - let breakpointsHeight = 0 - - let imageHeight = 15 - let imageWidth = 15 - - let imagePoint = { - x: 10, - y: thisObject.container.frame.height / 2 - imageHeight / 2 + breakpointsHeight - } - - imagePoint = thisObject.container.frame.frameThisPoint(imagePoint) - - browserCanvasContext.drawImage(icon, imagePoint.x, imagePoint.y, imageWidth, imageHeight) - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] draw -> err.message = ' + err.message) } - } - } -} diff --git a/Spaces/BottomSpace.js b/Spaces/BottomSpace.js index 9121a5356..2757ccbee 100644 --- a/Spaces/BottomSpace.js +++ b/Spaces/BottomSpace.js @@ -1,7 +1,7 @@  function newBottomSpace () { var thisObject = { - deleteTradingHistory: undefined, + container: undefined, draw: draw, getContainer: getContainer, // returns the inner most container that holds the point received by parameter. @@ -19,9 +19,6 @@ function newBottomSpace () { return thisObject function initialize () { - thisObject.deleteTradingHistory = newDeleteTradingHistory() - thisObject.deleteTradingHistory.initialize() - window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize) } @@ -36,9 +33,6 @@ function newBottomSpace () { function getContainer (point) { let container - container = thisObject.deleteTradingHistory.getContainer(point) - if (container !== undefined) { return container } - return thisObject.container } @@ -46,7 +40,6 @@ function newBottomSpace () { thisObject.container.frame.draw(false, false) drawBackground() - thisObject.deleteTradingHistory.draw() } function drawBackground () { From ccdd12f141ba8dc5248daa72b9e0a572d10b4306 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 24 Apr 2019 08:37:09 +0200 Subject: [PATCH 06/11] Breakpoinnt bar deleted --- BreakpointsBar.js | 195 ---------------------------------------------- TimelineChart.js | 12 --- 2 files changed, 207 deletions(-) delete mode 100644 BreakpointsBar.js diff --git a/BreakpointsBar.js b/BreakpointsBar.js deleted file mode 100644 index a13023e08..000000000 --- a/BreakpointsBar.js +++ /dev/null @@ -1,195 +0,0 @@ - -function newBreakpointsBar () { - var thisObject = { - setDatetime: setDatetime, - container: undefined, - draw: draw, - getContainer: getContainer, // returns the inner most container that holds the point received by parameter. - initialize: initialize - } - - var container = newContainer() - container.initialize() - thisObject.container = container - - thisObject.container.frame.width = browserCanvasContext.width - thisObject.container.frame.height = 15 - - container.frame.position.x = 0 - container.frame.position.y = viewPort.visibleArea.bottomRight.y - - container.isDraggeable = false - container.isClickeable = true - - let logo - let canDrawLogo = false - - let datetime - let timePeriod - let timeLineCoordinateSystem - let chartContainer - - let breakpointsByTimePeriod = new Map() - - return thisObject - - function initialize (pChartContainer, pTimeLineCoordinateSystem) { - timeLineCoordinateSystem = pTimeLineCoordinateSystem - chartContainer = pChartContainer - - viewPort.eventHandler.listenToEvent('Zoom Changed', onZoomChanged) - timePeriod = INITIAL_TIME_PERIOD - - thisObject.container.eventHandler.listenToEvent('onMouseClick', onClick) - - for (let i = 0; i < marketFilesPeriods.length; i++) { - let breakpointsMap = new Map() - breakpointsByTimePeriod.set(marketFilesPeriods[i][0], breakpointsMap) - } - - for (let i = 0; i < dailyFilePeriods.length; i++) { - let breakpointsMap = new Map() - breakpointsByTimePeriod.set(dailyFilePeriods[i][0], breakpointsMap) - } - } - - function onClick (pPoint) { - let point = { - x: pPoint.x, - y: pPoint.y - } - - let miliSeconds = getMilisecondsFromPoint(point, chartContainer, timeLineCoordinateSystem) - - miliSeconds = normalizeX(miliSeconds) // We are now exactly at the middle of the "candle" correspondind to the point clicked. - - let breakpointsMap = breakpointsByTimePeriod.get(timePeriod) - let breakpoint = breakpointsMap.get(miliSeconds) - - if (breakpoint === undefined) { - /* The breakpoint didnt exist, then we create one. */ - breakpointsMap.set(miliSeconds, 1) - } else { - /* The breakpoint existed, so we remove it. */ - breakpointsMap.set(miliSeconds, undefined) - } - } - - function normalizeX (pX) { - return Math.trunc(pX / timePeriod) * timePeriod + timePeriod / 2 - } - - function onZoomChanged (event) { - timePeriod = recalculatePeriod(event.newLevel) - } - - function setDatetime (pDatetime) { - datetime = new Date(pDatetime) - } - - function getContainer (point) { - let container - - /* 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 () { - /* - To draw the breakpoints, we will calculate the miliseconds for the first x pixel of the breakpoint bar, and for the last x pixel. Once we have that - we can create an array with all the possible points for breack points. Finally we can see if brealpoints exists at those points. We plot only the ones - that exists. - */ - - let breakpointsMap = breakpointsByTimePeriod.get(timePeriod) - - let beginX = { - x: viewPort.visibleArea.bottomLeft.x, - y: 0 - } - - let endX = { - x: viewPort.visibleArea.bottomRight.x, - y: 0 - } - - let beginMiliseconds = getMilisecondsFromPoint(beginX, chartContainer, timeLineCoordinateSystem) - let endMiliseconds = getMilisecondsFromPoint(endX, chartContainer, timeLineCoordinateSystem) - - beginMiliseconds = normalizeX(beginMiliseconds) - endMiliseconds = normalizeX(endMiliseconds) - - window.AT_BREAKPOINT = false - - for (let miliSeconds = beginMiliseconds; miliSeconds < endMiliseconds; miliSeconds = miliSeconds + timePeriod) { - let breakpoint = breakpointsMap.get(miliSeconds) - - if (breakpoint !== undefined) { - let point1 = { - x: miliSeconds, - y: 0 - } - - point1 = timeLineCoordinateSystem.transformThisPoint(point1) - point1 = transformThisPoint(point1, chartContainer) - - let point2 = { - x: miliSeconds, - y: thisObject.container.frame.height / 2 + 1 - } - - point2 = thisObject.container.frame.frameThisPoint(point2) - - let point = { - x: point1.x, - y: point2.y - } - - let isCurrentRecord = false - - if (datetime !== undefined) { - let dateValue = datetime.valueOf() - if (dateValue >= miliSeconds - timePeriod / 2 && dateValue <= miliSeconds + timePeriod / 2 - 1) { - isCurrentRecord = true - } - } - - let radius = 5 - - let opacity = '0.5' - - browserCanvasContext.lineWidth = 1 - - /* Outer Circle */ - - browserCanvasContext.beginPath() - - browserCanvasContext.strokeStyle = 'rgba(123, 50, 40, ' + opacity + ')' - - if (isCurrentRecord === false) { - browserCanvasContext.fillStyle = 'rgba(223, 70, 60, ' + opacity + ')' - } else { - browserCanvasContext.fillStyle = 'rgba(255, 233, 31, ' + opacity + ')' /* highlight the current record */ - - window.AT_BREAKPOINT = true // We are hitting a breakpoint! - } - - browserCanvasContext.arc(point.x, point.y, radius, 0, Math.PI * 2, true) - browserCanvasContext.closePath() - - if (point.x < viewPort.visibleArea.topLeft.x + 50 || point.x > viewPort.visibleArea.bottomRight.x - 50) { /* we leave this history without fill. */ } else { - browserCanvasContext.fill() - } - - browserCanvasContext.stroke() - } - } - } -} diff --git a/TimelineChart.js b/TimelineChart.js index 34e41ec8c..a5f15f160 100644 --- a/TimelineChart.js +++ b/TimelineChart.js @@ -25,9 +25,6 @@ thisObject.container.initialize(MODULE_NAME) thisObject.container.detectMouseOver = true - // let chartGrid - let breakpointsBar - let initializationReady = false let productsPanel @@ -113,9 +110,6 @@ logoExchange.src = window.canvasApp.urlPrefix + 'Images/' + exchange + '-logo-background.png' logoAA.src = window.canvasApp.urlPrefix + 'Images/sa-logo-background.png' - breakpointsBar = newBreakpointsBar() - breakpointsBar.initialize(thisObject.container, timeLineCoordinateSystem) - // moveToUserPosition(thisObject.container, timeLineCoordinateSystem, undefined, undefined, undefined, true) timePeriod = INITIAL_TIME_PERIOD datetime = NEW_SESSION_INITIAL_DATE @@ -188,7 +182,6 @@ if (thisObject.container.frame.isInViewPort()) { plotterManager.setDatetime(pDatetime) plotterManager.positionAtDatetime(pDatetime) - breakpointsBar.setDatetime(pDatetime) } } @@ -228,8 +221,6 @@ plotterManager.setDatetime(datetime) - breakpointsBar.setDatetime(datetime) - thisObject.container.eventHandler.raiseEvent('Datetime Changed', datetime) } @@ -242,8 +233,6 @@ if (container !== undefined) { return container } - container = breakpointsBar.getContainer(point) - return container } @@ -289,7 +278,6 @@ timePeriodScale.draw() plotterManager.draw() - breakpointsBar.draw() } } From 8e3317e974ed326cfdb2cfa4aa27bdf972a76008 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 24 Apr 2019 08:41:27 +0200 Subject: [PATCH 07/11] Container events fixed --- Container.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Container.js b/Container.js index eb549c09f..cacb0bec1 100644 --- a/Container.js +++ b/Container.js @@ -19,13 +19,17 @@ function newContainer () { let connectedToParentHeight = false let isConnectedToParent = false + let dimensionsChangedEventSubscriptionId + let onMouseOverEventSubscriptionId + let onMouseNotOverEventSubscriptionId + return thisObject function finalize () { if (isConnectedToParent === true) { - thisObject.parentContainer.eventHandler.stopListening('Dimmensions Changed', onParentDimmensionsChanged) - thisObject.parentContainer.eventHandler.stopListening('onMouseOver', onMouseOver) - thisObject.parentContainer.eventHandler.stopListening('onMouseNotOver', onMouseNotOver) + thisObject.parentContainer.eventHandler.stopListening(dimensionsChangedEventSubscriptionId) + thisObject.parentContainer.eventHandler.stopListening(onMouseOverEventSubscriptionId) + thisObject.parentContainer.eventHandler.stopListening(onMouseNotOverEventSubscriptionId) } } @@ -53,9 +57,10 @@ function newContainer () { thisObject.displacement.parentDisplacement = parentContainer.displacement thisObject.frame.parentFrame = parentContainer.frame thisObject.parentContainer = parentContainer - thisObject.parentContainer.eventHandler.listenToEvent('Dimmensions Changed', onParentDimmensionsChanged) - thisObject.parentContainer.eventHandler.listenToEvent('onMouseOver', onMouseOver) - thisObject.parentContainer.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) + + dimensionsChangedEventSubscriptionId = thisObject.parentContainer.eventHandler.listenToEvent('Dimmensions Changed', onParentDimmensionsChanged) + onMouseOverEventSubscriptionId = thisObject.parentContainer.eventHandler.listenToEvent('onMouseOver', onMouseOver) + onMouseNotOverEventSubscriptionId = thisObject.parentContainer.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) if (connectedToParentWidth) { thisObject.frame.width = thisObject.parentContainer.frame.width From bb95fdecba15ff9f470572e0d5fce46dce8dc650 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 24 Apr 2019 08:51:58 +0200 Subject: [PATCH 08/11] Dashboard events fixed --- Dashboard.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Dashboard.js b/Dashboard.js index dcc28e5c4..cb57b4fe3 100644 --- a/Dashboard.js +++ b/Dashboard.js @@ -18,6 +18,9 @@ function newDashboard () { const DEBUG_START_UP_DELAY = 0 // 3000; // This is a waiting time in case there is a need to debug the very first steps of initialization, to be able to hit F12 on time. + let userProfileChangedEventSubscriptionId + let browserResizedEventSubscriptionId + return thisObject function start () { @@ -31,8 +34,8 @@ function newDashboard () { /* 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() - window.canvasApp.eventHandler.listenToEvent('User Profile Changed', userProfileChanged) - window.canvasApp.eventHandler.listenToEvent('Browser Resized', browserResized) + userProfileChangedEventSubscriptionId = window.canvasApp.eventHandler.listenToEvent('User Profile Changed', userProfileChanged) + browserResizedEventSubscriptionId = window.canvasApp.eventHandler.listenToEvent('Browser Resized', browserResized) loadImages(onImagesLoaded) From 4dc08b17e636e81bdad77049233590333b5b1182 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 24 Apr 2019 20:26:40 +0200 Subject: [PATCH 09/11] BUG thisObject without LET solved --- Candle.js | 2 +- Displace.js | 2 +- FloatingSpace/FloatingObject.js | 2 +- FloatingSpace/Note.js | 2 +- Frame.js | 2 +- Panels/PanelTabButton.js | 2 +- Panels/ProductsPanel.js | 2 +- ProductCard.js | 2 +- Spaces/BottomSpace.js | 2 +- Spaces/ChartSpace.js | 2 +- Spaces/PanelsSpace.js | 2 +- Spaces/TopSpace.js | 2 +- SplashScreen.js | 2 +- TimeLineCoordinateSystem.js | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Candle.js b/Candle.js index 19c847b3a..f04ac6ec2 100644 --- a/Candle.js +++ b/Candle.js @@ -1,5 +1,5 @@ function newCandle () { - var candle = { + let candle = { open: undefined, close: undefined, min: 10000000000000, diff --git a/Displace.js b/Displace.js index 328e034c1..b5a3bab8f 100644 --- a/Displace.js +++ b/Displace.js @@ -7,7 +7,7 @@ The displacement is a vector that displaces everything static drawn on on the co */ function newDisplacement () { - var displacement = { + let displacement = { containerName: '', // This is for debugging purposes only. parentDisplacement: undefined, // Here we store the displacement object of the parent cointainer, if exists. container: undefined, diff --git a/FloatingSpace/FloatingObject.js b/FloatingSpace/FloatingObject.js index 0d61a649d..6afa87e03 100644 --- a/FloatingSpace/FloatingObject.js +++ b/FloatingSpace/FloatingObject.js @@ -8,7 +8,7 @@ function newFloatingObject () { const logger = newWebDebugLog() logger.fileName = MODULE_NAME - var thisObject = { + let thisObject = { physicsLoop: physicsLoop, eventHandler: undefined, diff --git a/FloatingSpace/Note.js b/FloatingSpace/Note.js index 87fe4fe15..ed8de1b4e 100644 --- a/FloatingSpace/Note.js +++ b/FloatingSpace/Note.js @@ -1,6 +1,6 @@  function newNote () { - var thisObject = { + let thisObject = { physicsLoop: physicsLoop, onMouseOver: onMouseOver, diff --git a/Frame.js b/Frame.js index a2a541bef..28df28c82 100644 --- a/Frame.js +++ b/Frame.js @@ -3,7 +3,7 @@ function newFrame () { const PANEL_CORNERS_RADIOUS = 5 const TITLE_BAR_HEIGHT = 14 // this must be grater than radius - var frame = { + let frame = { containerName: '', // This is for debugging purposes only. parentFrame: undefined, // Here we store the parent cointainer zoom object. width: browserCanvas.width, diff --git a/Panels/PanelTabButton.js b/Panels/PanelTabButton.js index c4ef7af51..a1d44c195 100644 --- a/Panels/PanelTabButton.js +++ b/Panels/PanelTabButton.js @@ -1,5 +1,5 @@ function newPanelTabButton () { - var thisObject = { + let thisObject = { container: undefined, draw: draw, parentContainer: undefined, diff --git a/Panels/ProductsPanel.js b/Panels/ProductsPanel.js index fcb1ac068..5f9b514a9 100644 --- a/Panels/ProductsPanel.js +++ b/Panels/ProductsPanel.js @@ -1,5 +1,5 @@ function newProductsPanel () { - var thisObject = { + let thisObject = { container: undefined, getLoadingProductCards: getLoadingProductCards, draw: draw, diff --git a/ProductCard.js b/ProductCard.js index 15bdff06a..46512e69c 100644 --- a/ProductCard.js +++ b/ProductCard.js @@ -8,7 +8,7 @@ function newProductCard () { const logger = newWebDebugLog() logger.fileName = MODULE_NAME - var thisObject = { + let thisObject = { container: undefined, draw: draw, status: 'off', diff --git a/Spaces/BottomSpace.js b/Spaces/BottomSpace.js index 2757ccbee..14b7c22a8 100644 --- a/Spaces/BottomSpace.js +++ b/Spaces/BottomSpace.js @@ -1,6 +1,6 @@  function newBottomSpace () { - var thisObject = { + let thisObject = { container: undefined, draw: draw, diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index 80b0c838e..25f51f709 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -13,7 +13,7 @@ function newChartSpace () { const logger = newWebDebugLog() logger.fileName = MODULE_NAME - var thisObject = { + let thisObject = { container: undefined, drawBackground: drawBackground, draw: draw, diff --git a/Spaces/PanelsSpace.js b/Spaces/PanelsSpace.js index ecd4793a2..054510c84 100644 --- a/Spaces/PanelsSpace.js +++ b/Spaces/PanelsSpace.js @@ -5,7 +5,7 @@ The Panel Space y the place wehre all panels live, no matter who create them. */ function newPanelsSpace () { - var thisObject = { + let thisObject = { container: undefined, createNewPanel: createNewPanel, destroyPanel: destroyPanel, diff --git a/Spaces/TopSpace.js b/Spaces/TopSpace.js index 4c19710eb..9bb7e57b8 100644 --- a/Spaces/TopSpace.js +++ b/Spaces/TopSpace.js @@ -1,6 +1,6 @@ function newTopSpace () { - var thisObject = { + let thisObject = { container: undefined, draw: draw, getContainer: getContainer, // returns the inner most container that holds the point received by parameter. diff --git a/SplashScreen.js b/SplashScreen.js index 78ea7d85a..da250bd39 100644 --- a/SplashScreen.js +++ b/SplashScreen.js @@ -5,7 +5,7 @@ The Splash Screen is to show some 'loading...' controls while the app is being l */ function newSplashScreen () { - var thisObject = { + let thisObject = { container: undefined, draw: draw, timeMachines: [], diff --git a/TimeLineCoordinateSystem.js b/TimeLineCoordinateSystem.js index 0fef5e7b6..5cd0abfa5 100644 --- a/TimeLineCoordinateSystem.js +++ b/TimeLineCoordinateSystem.js @@ -8,7 +8,7 @@ The scale on the Y axis depends on the data that wants to be plotted. Usually we */ function newTimeLineCoordinateSystem () { - var thisObject = { + let thisObject = { min: undefined, max: undefined, scale: undefined, From da8f82d57110638e5a388856e72a22a9f9172123 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 24 Apr 2019 21:52:08 +0200 Subject: [PATCH 10/11] Fix #33 --- Panels/ProductsPanel.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Panels/ProductsPanel.js b/Panels/ProductsPanel.js index 5f9b514a9..be880e77f 100644 --- a/Panels/ProductsPanel.js +++ b/Panels/ProductsPanel.js @@ -64,6 +64,7 @@ userTeams = JSON.parse(storedTeams) userTeam = userTeams[0] // Currently we assume a user can be at only one team. } + if (userTeam === undefined) { userTeam = {slug: ''} } /* First thing is to build the productCards array */ From 29d3383c1fb8ad7718f539edc1d8f30dfc346a3f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 24 Apr 2019 21:56:55 +0200 Subject: [PATCH 11/11] Only Public Indicatros allowed --- Panels/ProductsPanel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Panels/ProductsPanel.js b/Panels/ProductsPanel.js index be880e77f..8e7e1a99a 100644 --- a/Panels/ProductsPanel.js +++ b/Panels/ProductsPanel.js @@ -82,7 +82,7 @@ if (bot.products !== undefined) { for (let k = 0; k < bot.products.length; k++) { let product = bot.products[k] - // if (product.shareWith !== 'Public' && devTeam.codeName !== userTeam.slug) { continue } + if (product.shareWith !== 'Public' && devTeam.codeName !== userTeam.slug) { continue } /* Now we create Product objects */ let productCard = newProductCard()