Product Pannel at the TimelineChart level
This commit is contained in:
1 parent
b459856f1f
commit
254d93801a
5 files changed
+63
-37
No files matched your search
@@ -95,6 +95,12 @@ function convertTimePeriodToName(pTimePeriod) {
|
||||
window.AT_BREAKPOINT = false;
|
||||
|
||||
const SUPPORTED_EXCHANGES = ["Poloniex", "Coss"];
|
||||
const SUPPORTED_MARKETS = [
|
||||
{
|
||||
assetA: "USDT",
|
||||
assetB: "BTC",
|
||||
}
|
||||
];
|
||||
const DEFAULT_EXCHANGE = "Poloniex";
|
||||
const DEFAULT_MARKET = {
|
||||
assetA: "USDT",
|
||||
|
||||
+10
-4
@@ -11,14 +11,12 @@
|
||||
|
||||
var container = newContainer()
|
||||
|
||||
container.name = 'Indicators and Algobots Product Panel'
|
||||
container.initialize()
|
||||
|
||||
container.isDraggeable = true
|
||||
container.isWheelable = true
|
||||
|
||||
thisObject.container = container
|
||||
thisObject.container.frame.containerName = "Indicators and Algobots's Products"
|
||||
|
||||
let isInitialized = false
|
||||
let productCards = []
|
||||
@@ -31,9 +29,17 @@
|
||||
let lastY = 5
|
||||
let panelTabButton
|
||||
|
||||
let exchange
|
||||
let market
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize () {
|
||||
function initialize (pExchange, pMarket) {
|
||||
exchange = pExchange
|
||||
market = pMarket
|
||||
|
||||
thisObject.container.name = exchange + ' ' + market.assetB + '/' + market.assetA + ' ' + 'Indicators'
|
||||
thisObject.container.frame.containerName = thisObject.container.name
|
||||
thisObject.container.frame.width = UI_PANEL.WIDTH.LARGE
|
||||
thisObject.container.frame.height = viewPort.visibleArea.bottomLeft.y - viewPort.visibleArea.topLeft.y // UI_PANEL.HEIGHT.LARGE;
|
||||
|
||||
@@ -73,7 +79,7 @@
|
||||
productCard.bot = bot
|
||||
productCard.product = product
|
||||
|
||||
productCard.code = devTeam.codeName + '-' + bot.codeName + '-' + product.codeName
|
||||
productCard.code = exchange + '-' + market.assetB + '/' + market.assetA + '-' + devTeam.codeName + '-' + bot.codeName + '-' + product.codeName
|
||||
|
||||
/* Initialize it */
|
||||
|
||||
|
||||
@@ -47,7 +47,6 @@ function newPanelsSpace () {
|
||||
case 'Products Panel':
|
||||
{
|
||||
panel = newProductsPanel()
|
||||
panel.initialize()
|
||||
break
|
||||
}
|
||||
case 'Plotter Panel':
|
||||
|
||||
+39
-26
@@ -33,7 +33,7 @@ function newTimeMachine () {
|
||||
container.frame.containerName = 'Time Machine'
|
||||
|
||||
let controlPanelHandle // We need this to destroy the Panel when this object is itself destroyed or no longer needs it...
|
||||
let productsPanelHandle // ... also to request a reference to the object for the cases we need it.
|
||||
// ... also to request a reference to the object for the cases we need it.
|
||||
|
||||
return thisObject
|
||||
|
||||
@@ -58,13 +58,10 @@ function newTimeMachine () {
|
||||
controlPanelHandle = canvas.panelsSpace.createNewPanel('Time Control Panel')
|
||||
let controlPanel = canvas.panelsSpace.getPanel(controlPanelHandle)
|
||||
|
||||
productsPanelHandle = canvas.panelsSpace.createNewPanel('Products Panel')
|
||||
let productsPanel = canvas.panelsSpace.getPanel(productsPanelHandle)
|
||||
|
||||
let iteration = 0
|
||||
|
||||
/* First, we initialize the market that we are going to show first on screen. Later all the other markets will be initialized on the background. */
|
||||
|
||||
let position = 0 // This defines the position of each chart respect to each other.
|
||||
|
||||
let timelineChart = newTimelineChart()
|
||||
|
||||
timelineChart.container.displacement.parentDisplacement = thisObject.container.displacement
|
||||
@@ -76,17 +73,17 @@ function newTimeMachine () {
|
||||
timelineChart.container.frame.height = thisObject.container.frame.height * 1 * canvas.bottomSpace.chartAspectRatio.aspectRatio.y
|
||||
|
||||
timelineChart.container.frame.position.x = thisObject.container.frame.width / 2 - timelineChart.container.frame.width / 2
|
||||
timelineChart.container.frame.position.y = timelineChart.container.frame.height * 1.5 * iteration
|
||||
timelineChart.container.frame.position.y = timelineChart.container.frame.height * 1.5 * position
|
||||
|
||||
timelineChart.initialize(productsPanel, DEFAULT_EXCHANGE, DEFAULT_MARKET, onDefaultMarketInitialized)
|
||||
position++
|
||||
|
||||
iteration++
|
||||
timelineChart.initialize(DEFAULT_EXCHANGE, DEFAULT_MARKET, onDefaultInitialized)
|
||||
|
||||
function onDefaultMarketInitialized (err) {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onDefaultMarketInitialized -> Entering function.') }
|
||||
function onDefaultInitialized (err) {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onDefaultInitialized -> Entering function.') }
|
||||
|
||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onDefaultMarketInitialized -> Initialization of the only market failed.') }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onDefaultInitialized -> Initialization of the only market failed.') }
|
||||
|
||||
callBackFunction(err)
|
||||
return
|
||||
@@ -98,23 +95,32 @@ function newTimeMachine () {
|
||||
timelineChart.container.eventHandler.listenToEvent('Datetime Changed', controlPanel.setDatetime)
|
||||
|
||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
|
||||
|
||||
// initializeTheRestOfTheMarkets();
|
||||
// initializeTheRest()
|
||||
}
|
||||
|
||||
function initializeTheRestOfTheMarkets () {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] initialize -> initializeTheRestOfTheMarkets -> Entering function.') }
|
||||
function initializeTheRest () {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] initialize -> initializeTheRest -> Entering function.') }
|
||||
|
||||
markets.forEach(initializeTimelineChart)
|
||||
let leftToInitialize = SUPPORTED_EXCHANGES.length * SUPPORTED_MARKETS.length - 1 // The default exchange and market was already initialized.
|
||||
let alreadyInitialized = 0
|
||||
|
||||
function initializeTimelineChart (item, key, mapObj) {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] initialize -> initializeTheRestOfTheMarkets -> initializeTimelineChart -> Entering function.') }
|
||||
for (let i = 0; i < SUPPORTED_EXCHANGES.length; i++) {
|
||||
for (let j = 0; j < SUPPORTED_MARKETS.length; j++) {
|
||||
let exchange = SUPPORTED_EXCHANGES[i]
|
||||
let market = SUPPORTED_MARKETS[j]
|
||||
|
||||
if (key === DEFAULT_MARKET.assetA + '.' + DEFAULT_MARKET.assetB) {
|
||||
// We skip this market since it has already been initialized.
|
||||
if (
|
||||
exchange === DEFAULT_EXCHANGE &&
|
||||
market.assetA === DEFAULT_MARKET.assetA &&
|
||||
market.assetB === DEFAULT_MARKET.assetB
|
||||
) { continue }
|
||||
|
||||
return
|
||||
initializeTimelineChart(exchange, market)
|
||||
}
|
||||
}
|
||||
|
||||
function initializeTimelineChart (exchange, market) {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] initialize -> initializeTheRest -> initializeTimelineChart -> Entering function.') }
|
||||
|
||||
let timelineChart = newTimelineChart()
|
||||
|
||||
@@ -127,19 +133,26 @@ function newTimeMachine () {
|
||||
timelineChart.container.frame.height = thisObject.container.frame.height * 1 * canvas.bottomSpace.chartAspectRatio.aspectRatio.y
|
||||
|
||||
timelineChart.container.frame.position.x = thisObject.container.frame.width / 2 - timelineChart.container.frame.width / 2
|
||||
timelineChart.container.frame.position.y = timelineChart.container.frame.height * 1.5 * iteration
|
||||
timelineChart.container.frame.position.y = timelineChart.container.frame.height * 1.5 * position
|
||||
|
||||
timelineChart.initialize(productsPanel, finalSteps)
|
||||
position++
|
||||
|
||||
iteration++
|
||||
timelineChart.initialize(exchange, market, finalSteps)
|
||||
|
||||
function finalSteps () {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] initialize -> initializeTheRestOfTheMarkets -> initializeTimelineChart -> finalSteps -> Entering function.') }
|
||||
if (INFO_LOG === true) { logger.write('[INFO] initialize -> initializeTheRest -> initializeTimelineChart -> finalSteps -> Entering function.') }
|
||||
|
||||
thisObject.charts.push(timelineChart)
|
||||
|
||||
controlPanel.container.eventHandler.listenToEvent('Datetime Changed', timelineChart.setDatetime, undefined)
|
||||
timelineChart.container.eventHandler.listenToEvent('Datetime Changed', controlPanel.setDatetime)
|
||||
|
||||
alreadyInitialized++
|
||||
console.log('alreadyInitialized ' + alreadyInitialized)
|
||||
console.log('leftToInitialize ' + leftToInitialize)
|
||||
if (alreadyInitialized === leftToInitialize) {
|
||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-6
@@ -48,6 +48,8 @@
|
||||
let exchange
|
||||
let market
|
||||
|
||||
let productsPanelHandle
|
||||
|
||||
return thisObject
|
||||
|
||||
function finalize () {
|
||||
@@ -60,7 +62,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
function initialize (pProductsPanel, pExchange, pMarket, callBackFunction) {
|
||||
function initialize (pExchange, pMarket, callBackFunction) {
|
||||
try {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
|
||||
|
||||
@@ -68,6 +70,10 @@
|
||||
exchange = pExchange
|
||||
market = pMarket
|
||||
|
||||
productsPanelHandle = canvas.panelsSpace.createNewPanel('Products Panel')
|
||||
let productsPanel = canvas.panelsSpace.getPanel(productsPanelHandle)
|
||||
productsPanel.initialize(exchange, market)
|
||||
|
||||
logoA = new Image()
|
||||
logoB = new Image()
|
||||
logoExchange = new Image()
|
||||
@@ -102,10 +108,6 @@
|
||||
logoExchange.src = window.canvasApp.urlPrefix + 'Images/poloniex-logo-background.png'
|
||||
logoAA.src = window.canvasApp.urlPrefix + 'Images/sa-logo-background.png'
|
||||
|
||||
/* Remember the Products Panel */
|
||||
|
||||
productsPanel = pProductsPanel
|
||||
|
||||
chartGrid = newChartGrid()
|
||||
chartGrid.initialize()
|
||||
|
||||
@@ -139,7 +141,7 @@
|
||||
plotterManager.container.frame.position.x = thisObject.container.frame.position.x
|
||||
plotterManager.container.frame.position.y = thisObject.container.frame.position.y
|
||||
|
||||
plotterManager.initialize(pProductsPanel, pExchange, pMarket, onPlotterManagerReady)
|
||||
plotterManager.initialize(productsPanel, pExchange, pMarket, onPlotterManagerReady)
|
||||
|
||||
function onPlotterManagerReady (err) {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onPlotterManagerReady -> Entering function.') }
|
||||
|
||||
Reference in new issue
Block a user