Product Panel Implemented

This commit is contained in:
Luis Fernando Molina committed 2018-03-01 16:24:20 +01:00
1 parent 8c764ae445
commit 2716ddbef1
16 files changed
+82 -147

No files matched your search

Binary file not shown.
+2 -2
View File
@@ -58,8 +58,8 @@ function newAccumulatedVolumeChartLayer() {
viewPort.eventHandler.listenToEvent("Zoom Changed", onZoomChanged);
canvas.eventHandler.listenToEvent("Drag Finished", onDragFinished);
layerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.BUY_SELL_BALANCE);
parentLayerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.VOLUME);
layerStatus = botsPanel.getProductStatus(botsPanel.layerNames.BUY_SELL_BALANCE);
parentLayerStatus = botsPanel.getProductStatus(botsPanel.layerNames.VOLUME);
}
+1 -1
View File
@@ -74,7 +74,7 @@ function newAllTimeChartLayer() {
}
layerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.ATH);
layerStatus = botsPanel.getProductStatus(botsPanel.layerNames.ATH);
}
+1 -1
View File
@@ -61,7 +61,7 @@ function newCandleStickChartLayer() {
viewPort.eventHandler.listenToEvent("Zoom Changed", onZoomChanged);
canvas.eventHandler.listenToEvent("Drag Finished", onDragFinished);
layerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.CANDLESTICKS);
layerStatus = botsPanel.getProductStatus(botsPanel.layerNames.CANDLESTICKS);
}
@@ -51,8 +51,8 @@ function newCandleTechnicalAnalisysChartLayer() {
recalculateScale();
layerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.CANDLE_STAIRS);
parentLayerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.CANDLESTICKS);
layerStatus = botsPanel.getProductStatus(botsPanel.layerNames.CANDLE_STAIRS);
parentLayerStatus = botsPanel.getProductStatus(botsPanel.layerNames.CANDLESTICKS);
}
+2 -2
View File
@@ -54,8 +54,8 @@ function newForecastChartLayer() {
viewPort.eventHandler.listenToEvent("Zoom Changed", onZoomChanged);
canvas.eventHandler.listenToEvent("Drag Finished", onDragFinished);
layerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.FORECAST);
parentLayerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.CANDLESTICKS);
layerStatus = botsPanel.getProductStatus(botsPanel.layerNames.FORECAST);
parentLayerStatus = botsPanel.getProductStatus(botsPanel.layerNames.CANDLESTICKS);
}
+2 -2
View File
@@ -51,8 +51,8 @@ function newHighLowChartLayer() {
recalculateScale();
layerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.HIGH_LOWS);
parentLayerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.CANDLESTICKS);
layerStatus = botsPanel.getProductStatus(botsPanel.layerNames.HIGH_LOWS);
parentLayerStatus = botsPanel.getProductStatus(botsPanel.layerNames.CANDLESTICKS);
}
+1 -1
View File
@@ -49,7 +49,7 @@ function newLinearRegressionCurve() {
recalculateScale();
layerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.LINEAR_REGRESION_CURVE);
layerStatus = botsPanel.getProductStatus(botsPanel.layerNames.LINEAR_REGRESION_CURVE);
}
function getContainer(point) {
+1 -1
View File
@@ -68,7 +68,7 @@ function newOrderBooksChartLayer() {
canvas.eventHandler.listenToEvent("Drag Finished", onDragFinished);
canvas.eventHandler.listenToEvent("Dragging", onDragging);
layerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.ORDER_BOOKS);
layerStatus = botsPanel.getProductStatus(botsPanel.layerNames.ORDER_BOOKS);
}
+1 -1
View File
@@ -47,7 +47,7 @@ function newSupportResistanceChartLayer() {
recalculateScale();
layerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.CANDLESTICKS); // TODO : Put the right layer name here when it exists.
layerStatus = botsPanel.getProductStatus(botsPanel.layerNames.CANDLESTICKS); // TODO : Put the right layer name here when it exists.
}
+1 -1
View File
@@ -56,7 +56,7 @@ function newVolumeChartLayer() {
viewPort.eventHandler.listenToEvent("Zoom Changed", onZoomChanged);
canvas.eventHandler.listenToEvent("Drag Finished", onDragFinished);
layerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.VOLUME);
layerStatus = botsPanel.getProductStatus(botsPanel.layerNames.VOLUME);
}
@@ -50,8 +50,8 @@ function newVolumeTechnicalAnalisysChartLayer() {
marketIndex = index;
dailyFilesCursor = dailyFiles;
layerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.VOLUME_STAIRS);
parentLayerStatus = botsPanel.getLayerStatus(botsPanel.layerNames.VOLUME);
layerStatus = botsPanel.getProductStatus(botsPanel.layerNames.VOLUME_STAIRS);
parentLayerStatus = botsPanel.getProductStatus(botsPanel.layerNames.VOLUME);
}
-42
View File
@@ -6,8 +6,6 @@ function newEcosystem() {
getTeams: getTeams,
getBot: getBot,
getProduct: getProduct,
getLayer: getLayer,
getLayers: getLayers,
getExchange: getExchange,
initialize: initialize
}
@@ -62,17 +60,6 @@ function newEcosystem() {
}
}
function getLayer(pProduct, pLayerCodeName) {
for (let i = 0; i < pProduct.layers.length; i++) {
if (pProduct.layers[i].codeName === pLayerCodeName) {
return pProduct.layers[i];
}
}
}
function getExchange(pProduct, pName) {
for (let i = 0; i < pProduct.exchangeList.exchange.length; i++) {
@@ -83,34 +70,5 @@ function newEcosystem() {
}
}
}
function getLayers() {
let allLayers = [];
for (let i = 0; i < ECOSYSTEM.devTeams.length; i++) {
let devTeam = ecosystem.devTeams[i];
for (let j = 0; j < devTeam.bots.length; j++) {
let bot = devTeam.bots[j];
for (let k = 0; k < bot.products.length; k++) {
let product = bot.products[k];
for (let l = 0; l < product.layers.length; l++) {
let layer = product.layers[l];
allLayers.push(layer);
}
}
}
}
return allLayers;
}
}
+63 -83
View File
@@ -10,8 +10,8 @@ function newProductsPanel() {
var thisObject = {
container: undefined,
gerOnProducts: gerOnProducts,
getLayerStatus: getLayerStatus,
getOnProducts: getOnProducts,
getProductStatus: getProductStatus,
draw: draw,
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
initialize: initialize
@@ -27,8 +27,6 @@ function newProductsPanel() {
let isInitialized = false;
let products;
let layers = [];
return thisObject;
function initialize() {
@@ -43,7 +41,11 @@ function newProductsPanel() {
this.container.frame.position = position;
/* First thing is to build the layers array */
/* Needed Variables */
var lastY = 5;
/* First thing is to build the products array */
let devTeams = ecosystem.getTeams();
@@ -59,89 +61,69 @@ function newProductsPanel() {
let product = bot.products[k];
for (let l = 0; l < product.layers.length; l++) {
/* Now we create Product objects */
let layer = product.layers[l];
var product = newProduct();
let panelLayer = {
devTeam: devTeam,
bot: bot,
product: product,
layer: layer
};
product.devTeam = devTeam;
product.bot = bot;
product.product = product;
product.code = devTeam.codeName + '-' + bot.codeName + '-' + product.codeName;
/* Container Stuff */
product.container.displacement.parentDisplacement = this.container.displacement;
product.container.zoom.parentZoom = this.container.zoom;
product.container.frame.parentFrame = this.container.frame;
product.container.parentContainer = this.container;
/* Initialize it */
product.initialize();
/* Positioning within this Panel */
let position = {
x: 10,
y: thisObject.container.frame.height - thisObject.container.frame.getBodyHeight()
};
product.container.frame.position.x = position.x;
product.container.frame.position.y = position.y + lastY;
lastY = lastY + product.container.frame.height;
/* We start listening to the products click event, so as to know when one was pressed. */
product.container.eventHandler.listenToEvent('onMouseClick', buttonPressed, i);
/* We retrieve the locally stored status of the Product */
let storedValue = window.localStorage.getItem(product.code);
if (storedValue !== null) {
product.status = storedValue;
} else {
product.status = PRODUCT_STATUS.ON;
layers.push(panelLayer);
}
/* Add to the Product Array */
products.push(product);
}
}
}
var cardPosition;
var lastY = 5;
products = [];
for (var i = 0; i < layers.length; i++) {
let fullCodeName = layers[i].devTeam.codeName + '-' + layers[i].bot.codeName + '-' + layers[i].product.codeName + '-' + layers[i].layer.codeName;
/* Products are going to be one at the right of the other. */
var card = newProduct();
card.devTeam = layers[i].devTeam.displayName;
card.bot = layers[i].bot.displayName;
card.product = layers[i].product.displayName;
card.layer = layers[i].layer.displayName;
card.code = fullCodeName;
card.container.displacement.parentDisplacement = this.container.displacement;
card.container.zoom.parentZoom = this.container.zoom;
card.container.frame.parentFrame = this.container.frame;
card.container.parentContainer = this.container;
card.initialize();
cardPosition = { // The first card
x: 10,
y: thisObject.container.frame.height - thisObject.container.frame.getBodyHeight()
};
card.container.frame.position.x = cardPosition.x;
card.container.frame.position.y = cardPosition.y + lastY;
lastY = lastY + card.container.frame.height;
/* We start listening to the products click event, so as to know when one was pressed. */
card.container.eventHandler.listenToEvent('onMouseClick', buttonPressed, i);
let storedValue = window.localStorage.getItem(card.code);
if (storedValue !== null) {
card.status = storedValue;
} else {
card.status = PRODUCT_STATUS.ON;
}
products.push(card);
let eventData = {
layer: card.code,
status: card.status
}
thisObject.container.eventHandler.raiseEvent('Layer Status Changed', eventData);
}
isInitialized = true;
}
function gerOnProducts() {
function getOnProducts() {
/* Returns all products which status is ON */
@@ -158,14 +140,13 @@ function newProductsPanel() {
return onProducts;
}
function getLayerStatus(layerName) {
function getProductStatus(pProductCode) {
for (let i = 0; i < products.length; i++) {
let button = products[i];
if (button.code === layerName) {
if (button.code === pProductCode) {
return button.status;
@@ -226,13 +207,12 @@ function newProductsPanel() {
}
let eventData = {
layer: products[index].code,
productCode: products[index].code,
status: products[index].status
}
thisObject.container.eventHandler.raiseEvent('Layer Status Changed', eventData);
thisObject.container.eventHandler.raiseEvent('Product Status Changed', eventData);
window.localStorage.setItem(products[index].code, products[index].status);
@@ -244,7 +224,7 @@ function newProductsPanel() {
thisObject.container.frame.draw(false, false, true);
for (var i = 0; i < products.length; i++) {
for (let i = 0; i < products.length; i++) {
products[i].draw();
}
-3
View File
@@ -35,9 +35,6 @@
this.container.frame.width = 280;
this.container.frame.height = 28;
/* Now we start listening to the onClick event from the mouse, so that we can allow users operate this thisObject. */
}
function getContainer(point) {
+3 -3
View File
@@ -100,13 +100,13 @@ function newTimelineChart() {
/* Lets get all the cards that are turned on. */
let onCards = botsPanel.gerOnCards();
let onProducts = botsPanel.getOnProducts();
for (let i = 0; i < onCards.length; i++) {
for (let i = 0; i < onProducts.length; i++) {
/* For each one, we will initialize the associated plotter. */
let onCard = onCards[i];
let onCard = onProducts[i];
let plotter = getNewPlotter(onCard.plotter.devTeam, onCard.plotter.repo, onCard.plotter.moduleName);