diff --git a/.vs/AAWebPlatform/v15/.suo b/.vs/AAWebPlatform/v15/.suo index 3fa100778..3c88494f1 100644 Binary files a/.vs/AAWebPlatform/v15/.suo and b/.vs/AAWebPlatform/v15/.suo differ diff --git a/Panels/ProductsPanel.js b/Panels/ProductsPanel.js index 8da0683ed..720da8957 100644 --- a/Panels/ProductsPanel.js +++ b/Panels/ProductsPanel.js @@ -1,7 +1,4 @@ - - - -function newProductsPanel() { +function newProductsPanel() { var thisObject = { container: undefined, @@ -31,7 +28,7 @@ function newProductsPanel() { function initialize() { - thisObject.container.frame.width = 300; + thisObject.container.frame.width = 400; thisObject.container.frame.height = viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topLeft.y + 15; var position = { diff --git a/ProductCard.js b/ProductCard.js index 3e35d49fb..57b3ebb8f 100644 --- a/ProductCard.js +++ b/ProductCard.js @@ -79,8 +79,8 @@ }; this.container.frame.position = position; - this.container.frame.width = 280; - this.container.frame.height = 60; + this.container.frame.width = 380; + this.container.frame.height = 80; /* We retrieve the locally stored status of the Product */ @@ -290,32 +290,31 @@ */ + const devTeamImageSize = 45; + const botImageSize = 45; + let teamImagePoint = { x: 10, - y: 5 + y: thisObject.container.frame.height / 2 - devTeamImageSize / 2 }; teamImagePoint = thisObject.container.frame.frameThisPoint(teamImagePoint); - let teamImage = document.getElementById("AAMasters"); - browserCanvasContext.drawImage(teamImage, teamImagePoint.x, teamImagePoint.y, 45, 45); + let teamImage = document.getElementById(thisObject.bot.devTeam + ".png"); + browserCanvasContext.drawImage(teamImage, teamImagePoint.x, teamImagePoint.y, devTeamImageSize, devTeamImageSize); - centerPoint = { - x: thisObject.container.frame.width - 10, - y: thisObject.container.frame.height / 2 - }; - - if (thisObject.bot.codeName === "AAOlivia") { + if (thisObject.bot.profilePicture !== undefined) { let botImagePoint = { x: thisObject.container.frame.width - 10 - 50, - y: 5 + y: thisObject.container.frame.height / 2 - botImageSize / 2 }; botImagePoint = thisObject.container.frame.frameThisPoint(botImagePoint); - let botImage = document.getElementById("AAOlivia"); - browserCanvasContext.drawImage(botImage, botImagePoint.x, botImagePoint.y, 45, 45); + let imageId = thisObject.bot.devTeam + "." + thisObject.bot.profilePicture; + let botImage = document.getElementById(imageId); + browserCanvasContext.drawImage(botImage, botImagePoint.x, botImagePoint.y, botImageSize, botImageSize); } @@ -379,7 +378,7 @@ labelPoint = { x: 65, - y: thisObject.container.frame.height - 45 + y: thisObject.container.frame.height / 2 - 15 }; labelPoint = thisObject.container.frame.frameThisPoint(labelPoint); @@ -393,7 +392,7 @@ labelPoint = { x: 65, - y: thisObject.container.frame.height - 30 + y: thisObject.container.frame.height / 2 - 0 }; labelPoint = thisObject.container.frame.frameThisPoint(labelPoint); @@ -407,7 +406,7 @@ labelPoint = { x: 65, - y: thisObject.container.frame.height - 15 + y: thisObject.container.frame.height / 2 + 15 }; labelPoint = thisObject.container.frame.frameThisPoint(labelPoint); diff --git a/index.html b/index.html index f92007933..60aabe174 100644 --- a/index.html +++ b/index.html @@ -75,6 +75,8 @@ - + + + \ No newline at end of file diff --git a/server.js b/server.js index 6fb2d9dee..688473d01 100644 --- a/server.js +++ b/server.js @@ -121,6 +121,8 @@ function initialize() { let host = ecosystemObject.hosts[i]; + /* In this first section we will load the competitions configurations. */ + for (let j = 0; j < host.competitions.length; j++) { let competition = host.competitions[j]; @@ -153,7 +155,7 @@ function initialize() { if (requestsSent === responsesReceived) { - readBotsConfig(); + readBotsAndPlottersConfig(); } } @@ -197,7 +199,97 @@ function initialize() { if (requestsSent === responsesReceived) { - readBotsConfig(); + readBotsAndPlottersConfig(); + + } + + } + catch (err) { + console.log("readCompetitionsConfig -> onDataArrived -> Error = " + err); + } + } + } + } + + /* In this second section we will load the plotters configurations. */ + + for (let j = 0; j < host.plotters.length; j++) { + + let plotter = host.plotters[j]; + + requestsSent++; + + if (DEBUG_MODE === true) { + + let fs = require('fs'); + try { + let fileName = '../Plotters/' + host.codeName + '/' + plotter.repo + '/' + plotter.configFile; + fs.readFile(fileName, onFileRead); + + function onFileRead(err, pData) { + + try { + responsesReceived++; + + pData = pData.toString(); + pData = pData.trim(); // remove first byte with some encoding. + + let configObj = JSON.parse(pData); + + /* Since we are going to replace the full bot object and we dont want to lose these two properties, we do this: */ + + configObj.repo = plotter.repo; + configObj.configFile = plotter.configFile; + + host.plotters[j] = configObj; + + if (requestsSent === responsesReceived) { + + readBotsAndPlottersConfig(); + + } + } + catch (err) { + console.log("readCompetitionsConfig -> onFileRead -> File = " + fileName + " Error = " + err); + } + + } + } + catch (err) { + console.log(err); + } + + } else { + + getGithubData(host.codeName, plotter.repo, plotter.configFile, onDataArrived) + + function onDataArrived(pData) { + + try { + + if (CONSOLE_LOG === true) { + + console.log("readCompetitionsConfig -> onDataArrived -> pData = " + pData); + + } + + responsesReceived++; + + pData = pData.toString(); + pData = pData.trim(); // remove first byte with some encoding. + + let configObj = JSON.parse(pData); + + /* Since we are going to replace the full bot object and we dont want to lose these two properties, we do this: */ + + configObj.repo = plotter.repo; + configObj.configFile = plotter.configFile; + + host.plotters[j] = configObj; + + if (requestsSent === responsesReceived) { + + readBotsAndPlottersConfig(); } @@ -211,18 +303,20 @@ function initialize() { } } - function readBotsConfig() { + function readBotsAndPlottersConfig() { if (CONSOLE_LOG === true) { - console.log("I am entering the readBotsConfig function."); + console.log("I am entering the readBotsAndPlottersConfig function."); } /* Each bot has its configuration at its own repo since each team must be able to change it at will. So what we do here is to use the master config at the AAPlatform repo that we already have on - memory and inject into it the config of each bot. + memory and inject into it the config of each bot. + + Inmediatelly after that, we also load the Plotters configs using the same technique. */ @@ -233,6 +327,8 @@ function initialize() { let devTeam = ecosystemObject.devTeams[i]; + /* In the next section we are loading the bots configurations. */ + for (let j = 0; j < devTeam.bots.length; j++) { let bot = devTeam.bots[j]; @@ -270,7 +366,7 @@ function initialize() { } } catch (err) { - console.log("readBotsConfig -> onFileRead -> File = " + fileName + " Error = " + err); + console.log("readBotsAndPlottersConfig -> onFileRead -> File = " + fileName + " Error = " + err); } } @@ -289,7 +385,7 @@ function initialize() { if (CONSOLE_LOG === true) { - console.log("readBotsConfig -> onDataArrived -> pData = " + pData); + console.log("readBotsAndPlottersConfig -> onDataArrived -> pData = " + pData); } @@ -315,7 +411,97 @@ function initialize() { } catch (err) { - console.log("readBotsConfig -> onDataArrived -> Error = " + err); + console.log("readBotsAndPlottersConfig -> onDataArrived -> Error = " + err); + } + } + } + } + + /* In the next section we are loading the plotters configurations. */ + + for (let j = 0; j < devTeam.plotters.length; j++) { + + let plotter = devTeam.plotters[j]; + + requestsSent++; + + if (DEBUG_MODE === true) { + + let fs = require('fs'); + try { + let fileName = '../Plotters/' + devTeam.codeName + '/' + plotter.repo + '/' + plotter.configFile; + fs.readFile(fileName, onFileRead); + + function onFileRead(err, pData) { + + try { + responsesReceived++; + + pData = pData.toString(); + pData = pData.trim(); // remove first byte with some encoding. + + let configObj = JSON.parse(pData); + + /* Since we are going to replace the full plotter object and we dont want to lose these two properties, we do this: */ + + configObj.repo = plotter.repo; + configObj.configFile = plotter.configFile; + + devTeam.plotters[j] = configObj; + + if (requestsSent === responsesReceived) { + + startHtttpServer(); + + } + } + catch (err) { + console.log("readPlottersConfig -> onFileRead -> File = " + fileName + " Error = " + err); + } + + } + } + catch (err) { + console.log(err); + } + + } else { + + getGithubData(devTeam.codeName, plotter.repo, plotter.configFile, onDataArrived) + + function onDataArrived(pData) { + + try { + + if (CONSOLE_LOG === true) { + + console.log("readBotsAndPlottersConfig -> onDataArrived -> pData = " + pData); + + } + + responsesReceived++; + + pData = pData.toString(); + pData = pData.trim(); // remove first byte with some encoding. + + let configObj = JSON.parse(pData); + + /* Since we are going to replace the full plotter object and we dont want to lose these two properties, we do this: */ + + configObj.repo = plotter.repo; + configObj.configFile = plotter.configFile; + + devTeam.plotters[j] = configObj; + + if (requestsSent === responsesReceived) { + + startHtttpServer(); + + } + + } + catch (err) { + console.log("readBotsAndPlottersConfig -> onDataArrived -> Error = " + err); } } } @@ -402,20 +588,24 @@ function onBrowserRequest(request, response) { let plotter = devTeam.plotters[j]; - let caseStringCopy = caseString; + for (let k = 0; k < plotter.modules.length; k++) { - let newFunctionName = devTeam.codeName + plotter.repo + plotter.moduleName; - newFunctionName = newFunctionName.replace(/-/g, ""); + let module = plotter.modules[k]; - let stringToInsert; - stringToInsert = caseStringCopy.replace('@newFunctionName@', newFunctionName); - stringToInsert = stringToInsert.replace('newPlotterName', 'new' + newFunctionName); + let caseStringCopy = caseString; - let firstPart = fileContent.substring(0, fileContent.indexOf('// Cases')); - let secondPart = fileContent.substring(fileContent.indexOf('// Cases')); + let newFunctionName = devTeam.codeName + plotter.repo + module.codeName; + newFunctionName = newFunctionName.replace(/-/g, ""); - fileContent = firstPart + stringToInsert + secondPart; + let stringToInsert; + stringToInsert = caseStringCopy.replace('@newFunctionName@', newFunctionName); + stringToInsert = stringToInsert.replace('newPlotterName', 'new' + newFunctionName); + let firstPart = fileContent.substring(0, fileContent.indexOf('// Cases')); + let secondPart = fileContent.substring(fileContent.indexOf('// Cases')); + + fileContent = firstPart + stringToInsert + secondPart; + } } } } @@ -529,44 +719,105 @@ function onBrowserRequest(request, response) { let fileContent = file.toString(); - /* This is the string we will use to insert into the Plotters.js script. */ + addPlotters(); + addImages(); - let htmlLine = '' + '\n' + - ' ' + function addPlotters() { - let devTeams = ecosystemObject.devTeams; - let hosts = ecosystemObject.hosts; + let htmlLine = '' + '\n' + + ' ' - addScript(devTeams); - addScript(hosts); + let devTeams = ecosystemObject.devTeams; + let hosts = ecosystemObject.hosts; - function addScript(pDevTeamsOrHosts) { + addScript(devTeams); + addScript(hosts); - for (let i = 0; i < pDevTeamsOrHosts.length; i++) { + function addScript(pDevTeamsOrHosts) { - let devTeam = pDevTeamsOrHosts[i]; + for (let i = 0; i < pDevTeamsOrHosts.length; i++) { - for (let j = 0; j < devTeam.plotters.length; j++) { + let devTeam = pDevTeamsOrHosts[i]; - let plotter = devTeam.plotters[j]; + for (let j = 0; j < devTeam.plotters.length; j++) { - /* Now each of these layers has a plotter that we need to define on the Plotter.js file. */ + let plotter = devTeam.plotters[j]; + + for (let k = 0; k < plotter.modules.length; k++) { + + let module = plotter.modules[k]; + + let htmlLineCopy = htmlLine; + + let stringToInsert; + stringToInsert = htmlLineCopy.replace('@devTeam@', devTeam.codeName); + stringToInsert = stringToInsert.replace('@repo@', plotter.repo); + stringToInsert = stringToInsert.replace('@module@', module.moduleName); + + let firstPart = fileContent.substring(0, fileContent.indexOf('') + 15); + let secondPart = fileContent.substring(fileContent.indexOf('') + 15); + + fileContent = firstPart + stringToInsert + secondPart; + + } + } + } + } + } + + function addImages() { + + const htmlLine = '' + '\n' + + ' ' + + let devTeams = ecosystemObject.devTeams; + + addScript(devTeams); + + function addScript(pDevTeams) { + + for (let i = 0; i < pDevTeams.length; i++) { + + let devTeam = pDevTeams[i]; let htmlLineCopy = htmlLine; let stringToInsert; stringToInsert = htmlLineCopy.replace('@devTeam@', devTeam.codeName); - stringToInsert = stringToInsert.replace('@repo@', plotter.repo); - stringToInsert = stringToInsert.replace('@module@', plotter.moduleName); + stringToInsert = stringToInsert.replace('@repo@', devTeam.codeName + "-Dev-Team"); + stringToInsert = stringToInsert.replace('@image@', devTeam.codeName + ".png"); + stringToInsert = stringToInsert.replace('@id@', devTeam.codeName + ".png"); - let firstPart = fileContent.substring(0, fileContent.indexOf('') + 15); - let secondPart = fileContent.substring(fileContent.indexOf('') + 15); + let firstPart = fileContent.substring(0, fileContent.indexOf('') + 15); + let secondPart = fileContent.substring(fileContent.indexOf('') + 15); fileContent = firstPart + stringToInsert + secondPart; + for (let j = 0; j < devTeam.bots.length; j++) { + + let bot = devTeam.bots[j]; + + if (bot.profilePicture !== undefined) { + + let htmlLineCopy = htmlLine; + + let stringToInsert; + stringToInsert = htmlLineCopy.replace('@devTeam@', devTeam.codeName); + stringToInsert = stringToInsert.replace('@repo@', bot.repo); + stringToInsert = stringToInsert.replace('@image@', bot.profilePicture); + stringToInsert = stringToInsert.replace('@id@', devTeam.codeName + "." + bot.profilePicture); + + let firstPart = fileContent.substring(0, fileContent.indexOf('') + 15); + let secondPart = fileContent.substring(fileContent.indexOf('') + 15); + + fileContent = firstPart + stringToInsert + secondPart; + + } + } } } } + respondWithContent(fileContent, response);