diff --git a/.vs/AAWebPlatform/v15/.suo b/.vs/AAWebPlatform/v15/.suo index e795ea1de..75d32ef4d 100644 Binary files a/.vs/AAWebPlatform/v15/.suo and b/.vs/AAWebPlatform/v15/.suo differ diff --git a/AAWebPlatform.njsproj b/AAWebPlatform.njsproj index 53dafe941..b67073d48 100644 --- a/AAWebPlatform.njsproj +++ b/AAWebPlatform.njsproj @@ -36,6 +36,9 @@ + + Code + Code diff --git a/Panels/CompetitionsPanel.js b/Panels/CompetitionsPanel.js new file mode 100644 index 000000000..19e77c83d --- /dev/null +++ b/Panels/CompetitionsPanel.js @@ -0,0 +1,185 @@ + + + +function newCompetitionsPanel() { + + var thisObject = { + container: undefined, + getLoadingCompetitions: getLoadingCompetitions, + draw: draw, + getContainer: getContainer, // returns the inner most container that holds the point received by parameter. + initialize: initialize + }; + + /* Cointainer stuff */ + + var container = newContainer(); + + container.name = "Competitions Product Panel"; + container.initialize(); + + container.isDraggeable = true; + container.isZoomeable = false; + + thisObject.container = container; + thisObject.container.frame.containerName = "Competitions"; + + let isInitialized = false; + let productCards = []; + + return thisObject; + + function initialize() { + + thisObject.container.frame.width = 300; + thisObject.container.frame.height = viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topLeft.y + 15; + + var position = { + x: viewPort.visibleArea.bottomRight.x - thisObject.container.frame.width, + y: 0 + }; + + thisObject.container.frame.position = position; + + /* Needed Variables */ + + var lastY = 5; + + /* First thing is to build the productCards array */ + + let devTeams = ecosystem.getTeams(); + + for (let i = 0; i < devTeams.length; i++) { + + let devTeam = 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]; + + /* Now we create Product objects */ + + let productCard = newProductCard(); + + productCard.devTeam = devTeam; + productCard.bot = bot; + productCard.product = product; + + productCard.code = devTeam.codeName + '-' + bot.codeName + '-' + product.codeName; + + /* Initialize it */ + + productCard.initialize(); + + + /* Container Stuff */ + + productCard.container.displacement.parentDisplacement = thisObject.container.displacement; + productCard.container.zoom.parentZoom = thisObject.container.zoom; + productCard.container.frame.parentFrame = thisObject.container.frame; + productCard.container.parentContainer = thisObject.container; + + /* Positioning within thisObject Panel */ + + let position = { + x: 10, + y: thisObject.container.frame.height - thisObject.container.frame.getBodyHeight() + }; + productCard.container.frame.position.x = position.x; + productCard.container.frame.position.y = position.y + lastY; + + lastY = lastY + productCard.container.frame.height * 1.25; + + /* Add to the Product Array */ + + productCards.push(productCard); + + /* Listen to Status Changes Events */ + + productCard.container.eventHandler.listenToEvent('Status Changed', onProductCardStatusChanged); + + } + } + } + + isInitialized = true; + + } + + function onProductCardStatusChanged(pProductCard) { + + thisObject.container.eventHandler.raiseEvent('Product Card Status Changed', pProductCard); + + } + + function getLoadingCompetitions() { + + /* Returns all productCards which status is ON */ + + let onProducts = []; + + for (let i = 0; i < productCards.length; i++) { + + if (productCards[i].status === PRODUCT_CARD_STATUS.LOADING) { + + onProducts.push(productCards[i]); + } + } + + return onProducts; + } + + function getContainer(point) { + + var container; + + /* First we check if thisObject point is inside thisObject space. */ + + if (thisObject.container.frame.isThisPointHere(point, true) === true) { + + /* Now we see which is the inner most container that has it */ + + + for (var i = 0; i < productCards.length; i++) { + + container = productCards[i].getContainer(point); + + if (container !== undefined) { + + /* We found an inner container which has the point. We return it. */ + + return container; + } + } + + /* The point does not belong to any inner container, so we return the current container. */ + + return thisObject.container; + + } else { + + /* This point does not belong to thisObject space. */ + + return undefined; + } + + } + + + function draw() { + + if (isInitialized === false) { return; } + + thisObject.container.frame.draw(false, false, true); + + for (let i = 0; i < productCards.length; i++) { + productCards[i].draw(); + } + + } + +} \ No newline at end of file diff --git a/Panels/ProductsPanel.js b/Panels/ProductsPanel.js index 89464a8ec..27a05087d 100644 --- a/Panels/ProductsPanel.js +++ b/Panels/ProductsPanel.js @@ -31,15 +31,15 @@ function newProductsPanel() { function initialize() { - this.container.frame.width = 300; - this.container.frame.height = viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topLeft.y + 15; + thisObject.container.frame.width = 300; + thisObject.container.frame.height = viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topLeft.y + 15; var position = { x: viewPort.visibleArea.topLeft.x, y: 0 }; - this.container.frame.position = position; + thisObject.container.frame.position = position; /* Needed Variables */ @@ -78,12 +78,12 @@ function newProductsPanel() { /* Container Stuff */ - productCard.container.displacement.parentDisplacement = this.container.displacement; - productCard.container.zoom.parentZoom = this.container.zoom; - productCard.container.frame.parentFrame = this.container.frame; - productCard.container.parentContainer = this.container; + productCard.container.displacement.parentDisplacement = thisObject.container.displacement; + productCard.container.zoom.parentZoom = thisObject.container.zoom; + productCard.container.frame.parentFrame = thisObject.container.frame; + productCard.container.parentContainer = thisObject.container; - /* Positioning within this Panel */ + /* Positioning within thisObject Panel */ let position = { x: 10, @@ -137,9 +137,9 @@ function newProductsPanel() { var container; - /* First we check if this point is inside this space. */ + /* First we check if thisObject point is inside thisObject space. */ - if (this.container.frame.isThisPointHere(point, true) === true) { + if (thisObject.container.frame.isThisPointHere(point, true) === true) { /* Now we see which is the inner most container that has it */ @@ -158,11 +158,11 @@ function newProductsPanel() { /* The point does not belong to any inner container, so we return the current container. */ - return this.container; + return thisObject.container; } else { - /* This point does not belong to this space. */ + /* This point does not belong to thisObject space. */ return undefined; } diff --git a/index.html b/index.html index 4f5434e25..07c4f451b 100644 --- a/index.html +++ b/index.html @@ -62,7 +62,6 @@ - diff --git a/server.js b/server.js index d227a91ed..840ac4d98 100644 --- a/server.js +++ b/server.js @@ -6,7 +6,7 @@ if (CONSOLE_LOG === true) { } -const DEBUG_MODE = false; // This forces the server to read Plotters from the local drive. +const DEBUG_MODE = true; // This forces the server to read Plotters from the local drive. if (CONSOLE_LOG === true && DEBUG_MODE === true) {