From 770561a7484392db32f92c9788729818b6513d5e Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 5 Mar 2018 13:29:57 +0100 Subject: [PATCH] Refactoring --- .vs/AAWebPlatform/v15/.suo | Bin 71680 -> 75264 bytes AAWebPlatform.njsproj | 3 + Panels/CompetitionsPanel.js | 185 ++++++++++++++++++++++++++++++++++++ Panels/ProductsPanel.js | 24 ++--- index.html | 1 - server.js | 2 +- 6 files changed, 201 insertions(+), 14 deletions(-) create mode 100644 Panels/CompetitionsPanel.js diff --git a/.vs/AAWebPlatform/v15/.suo b/.vs/AAWebPlatform/v15/.suo index e795ea1de103f7d04b75d257031b35c49eeedbef..75d32ef4d0ac97b662c49a944b4be801c67a4993 100644 GIT binary patch delta 3014 zcmd6peN0nV6u{qoeFcgI`T@c~qyH;Z1(I z=bn4+Iq#l#-hJ0~nsZ&`dQ5tjk(!EO=A$S>?)&|Is-?1iuqug-K7Fk4_}()=kaE?#CZ_D<`+fn^1Ov}5{RxO7cClHApgDw;1Id#E2|m82EsTQY4_f0P(|Mgtj~!B^~lCvK+}n zN)ZmJMbt4lw)S zS&gwM(X6jSvXNy7HKQ$<_192Gv!063td}97S*NxOQAe}hj0E2T%{tA#5)N=FhG34L zN399TM|cFQC=gL6^{e4Bm#YtxM$|XWcT&hW7v)OO*JvSMo-Ka`M;X0U+Oj&ygeJNX z*^V?IJCPkoXl`3@+=@{5_1Fh;`jvdOJFmXq)31AFU}_iUOntC=Ha}|1kU2>2wEpW z6S!4u;b>-|t1lazCEdaT4hk$WVod5^;cm^YKy=MoqNEFgg)tM{W)xGiZ^$9fq7}7E zVu>p0!?gaA{fDmhfA&#pff#cain6{Fc-EskPn0up1uHq054kL_sFImP4rQDom za7(WOt|l|CTQaBXY3sr9ebJov4FOkis+d}FgShiD)zs^Zf#3f=%Dtk#=362(vCx&K zg*(5eiUq5`R|~6Hp_UUGSfQSE7mkTzON^`r62zr#mx%BdD;x~0?a{HKt`5EJ3lsLUaI(8o?C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xcw*;RR@al=;< z3yE-1mf?m!ME=Nz=abD1kBnVJHaGkUf=lrW3pX5htB&Y!cW+>q8eg!CrX7TdC?J*- z^ND%H!-Rq0u5yV~l5>enBHYy_sMp^=V?!u{qqwyd1b22L!9I?DytUN6nA`eP$jK8= zN9d16=sdTL>;|Hdzzce3AZCyDO-wel)~yMc8ek?ins&kryk=Two-D#g;C0+s$kH0k zi4cwtT77^%dru(FhrZkeVpP?da*M!p`}@GLcz;CV`;52eoOVu+zSth=64D`pd7prZ zEAmGgu8dhl_ zJf2=Uk}bHAlJO5rf59KgOj%^SO7I9&oiYQL;dc@)r;SxP0UgO%CjN`Kz2O;bNG`+A zgcHY-OH?OK;I6lv*pRYEE>Zt(^QPA+ZZE+@dWBpdY})+#evoxSHV9cG8Zhx|J8Z*&m82AO7r3uSn^!-mWESylF+XL&8wez+b39WHqo z@R?yd4t1zn+6R^JUzTcmdDJM62|Rx>5l?-tIXVSp4~$~*X4|5oF+&Gp+i*So6a$N!ftVfkP+)(u#(<&s775BMQ?!4K%| zvEhk6GtTJC#-A=(U~=~qI#(5nPtsAm*gM!Os+%#kH#Zcy3Qt_j!B+Re5`>TX<%)mK+o`{m; z1{}WZ(|o`70M?ZlJ~F^r=&m$@OFar--O|MSEmok15d^-N8HZS(+TEJ~U&5pxE5{Qs sWm8i3aT|DbZK==_8RXF&OagH*6+~MGw6tGMg7WSW2iz3xKc++H?+OdhR{#J2 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) {