From 90c8133ffe447200564a90d72ec4f4abd264c5be Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 30 May 2018 21:40:14 +0200 Subject: [PATCH] Top Space introduced with several child objects --- CloudVM/CloudVM.js | 4 +-- Dashboard.js | 2 +- Project.njsproj | 16 +++++++++ Scripts/AppLoader.js | 6 ++++ Spaces/TopSpace.js | 28 ++++++++++++++- TopSpace/CurrentBot.js | 70 ++++++++++++++++++++++++++++++++++++ TopSpace/CurrentProcess.js | 70 ++++++++++++++++++++++++++++++++++++ TopSpace/CurrentStartMode.js | 70 ++++++++++++++++++++++++++++++++++++ TopSpace/DevTeam.js | 70 ++++++++++++++++++++++++++++++++++++ TopSpace/EndUser.js | 70 ++++++++++++++++++++++++++++++++++++ server.js | 9 +++++ 11 files changed, 410 insertions(+), 5 deletions(-) create mode 100644 TopSpace/CurrentBot.js create mode 100644 TopSpace/CurrentProcess.js create mode 100644 TopSpace/CurrentStartMode.js create mode 100644 TopSpace/DevTeam.js create mode 100644 TopSpace/EndUser.js diff --git a/CloudVM/CloudVM.js b/CloudVM/CloudVM.js index 7abc92c27..cd6f0d07a 100644 --- a/CloudVM/CloudVM.js +++ b/CloudVM/CloudVM.js @@ -29,9 +29,7 @@ function newCloudVM() { window.CURRENT_ENVIRONMENT = "Develop"; window.CURRENT_EXECUTION_AT = "Browser"; window.STORAGE_PERMISSIONS = ecosystem.getStoragePermissions(); - window.EXCHANGE_KEYS = ecosystem.getExchangeKeys(); - window.USER_LOGGED_IN = window.localStorage.getItem("userName"); - window.DEV_TEAM = window.localStorage.getItem("devTeam"); + window.EXCHANGE_KEYS = ecosystem.getExchangeKeys(); root.initialize(pUI_COMMANDS, onInitialized); diff --git a/Dashboard.js b/Dashboard.js index ae81ab75d..0c682885b 100644 --- a/Dashboard.js +++ b/Dashboard.js @@ -132,7 +132,7 @@ const CHART_ASPECT_RATIO = 1 / 10; let INITIAL_ZOOM_LEVEL = -26; // This is the zoom level at the view port in which the APP starts. let INITIAL_TIME_PERIOD = recalculatePeriod(INITIAL_ZOOM_LEVEL); // This value will be overwritten at the viewPort.initialize if the user had a prevous session with this same browser. -const TOP_SPACE_HEIGHT = 100; +const TOP_SPACE_HEIGHT = 50; var viewPort = newViewPort(); diff --git a/Project.njsproj b/Project.njsproj index 5a3221d8b..7238b1f57 100644 --- a/Project.njsproj +++ b/Project.njsproj @@ -82,6 +82,21 @@ Code + + Code + + + Code + + + Code + + + Code + + + Code + Code @@ -173,6 +188,7 @@ + diff --git a/Scripts/AppLoader.js b/Scripts/AppLoader.js index bc852fec3..f7da204c7 100644 --- a/Scripts/AppLoader.js +++ b/Scripts/AppLoader.js @@ -21,6 +21,12 @@ /* PlotterPanels */ + "TopSpace/CurrentStartMode.js", + "TopSpace/CurrentProcess.js", + "TopSpace/CurrentBot.js", + "TopSpace/DevTeam.js", + "TopSpace/EndUser.js", + "Panels/TimeControlPanel.js", "Panels/ProductsPanel.js", diff --git a/Spaces/TopSpace.js b/Spaces/TopSpace.js index 4a39eaca1..9af654f36 100644 --- a/Spaces/TopSpace.js +++ b/Spaces/TopSpace.js @@ -23,11 +23,31 @@ function newTopSpace() { container.isDraggeable = false; + let endUser; + let devTeam; + let currentBot; + let currentProcess; + let currentStartMode; + return thisObject; function initialize() { - + endUser = newEndUser(); + endUser.initialize(); + + devTeam = newDevTeam(); + devTeam.initialize(); + + currentBot = newCurrentBot(); + currentBot.initialize(); + + currentProcess = newCurrentProcess(); + currentProcess.initialize(); + + currentStartMode = newCurrentStartMode(); + currentStartMode.initialize(); + } function getContainer(point) { @@ -57,6 +77,12 @@ function newTopSpace() { thisObject.container.frame.draw(false, false); drawBackground(); + endUser.draw(); + devTeam.draw(); + currentBot.draw(); + currentProcess.draw(); + currentStartMode.draw(); + } function drawBackground() { diff --git a/TopSpace/CurrentBot.js b/TopSpace/CurrentBot.js new file mode 100644 index 000000000..0ddd13cbb --- /dev/null +++ b/TopSpace/CurrentBot.js @@ -0,0 +1,70 @@ + +function newCurrentBot() { + + var thisObject = { + container: undefined, + draw: draw, + getContainer: getContainer, // returns the inner most container that holds the point received by parameter. + initialize: initialize + }; + + var container = newContainer(); + container.initialize(); + thisObject.container = container; + + thisObject.container.frame.width = 200; + thisObject.container.frame.height = TOP_SPACE_HEIGHT; + + container.frame.position.x = viewPort.visibleArea.topRight.x - thisObject.container.frame.width * 3; + container.frame.position.y = 0; + + container.isDraggeable = false; + + return thisObject; + + function initialize() { + + window.CURRENT_BOT = window.localStorage.getItem("currentBot"); + } + + function getContainer(point) { + + let container; + + for (let i = 0; i < thisObject.panels.length; i++) { + + container = thisObject.panels[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; + + } + + function draw() { + + thisObject.container.frame.draw(false, false); + + let fontSize = 12; + let label = window.CURRENT_BOT; + + let point = { + x: thisObject.container.frame.width * 1 / 3, + y: (thisObject.container.frame.height / 2) + 4 + }; + + point = thisObject.container.frame.frameThisPoint(point); + + browserCanvasContext.font = fontSize + 'px Courier New'; + browserCanvasContext.fillStyle = 'rgba(255, 255, 255, 1)'; + browserCanvasContext.fillText(label, point.x, point.y); + } +} \ No newline at end of file diff --git a/TopSpace/CurrentProcess.js b/TopSpace/CurrentProcess.js new file mode 100644 index 000000000..3f1c46b2d --- /dev/null +++ b/TopSpace/CurrentProcess.js @@ -0,0 +1,70 @@ + +function newCurrentProcess() { + + var thisObject = { + container: undefined, + draw: draw, + getContainer: getContainer, // returns the inner most container that holds the point received by parameter. + initialize: initialize + }; + + var container = newContainer(); + container.initialize(); + thisObject.container = container; + + thisObject.container.frame.width = 200; + thisObject.container.frame.height = TOP_SPACE_HEIGHT; + + container.frame.position.x = viewPort.visibleArea.topRight.x - thisObject.container.frame.width * 2; + container.frame.position.y = 0; + + container.isDraggeable = false; + + return thisObject; + + function initialize() { + + window.CURRENT_PROCESS = window.localStorage.getItem("currentProcess"); + } + + function getContainer(point) { + + let container; + + for (let i = 0; i < thisObject.panels.length; i++) { + + container = thisObject.panels[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; + + } + + function draw() { + + thisObject.container.frame.draw(false, false); + + let fontSize = 12; + let label = window.CURRENT_PROCESS; + + let point = { + x: thisObject.container.frame.width * 1 / 3, + y: (thisObject.container.frame.height / 2) + 4 + }; + + point = thisObject.container.frame.frameThisPoint(point); + + browserCanvasContext.font = fontSize + 'px Courier New'; + browserCanvasContext.fillStyle = 'rgba(255, 255, 255, 1)'; + browserCanvasContext.fillText(label, point.x, point.y); + } +} \ No newline at end of file diff --git a/TopSpace/CurrentStartMode.js b/TopSpace/CurrentStartMode.js new file mode 100644 index 000000000..6970a0964 --- /dev/null +++ b/TopSpace/CurrentStartMode.js @@ -0,0 +1,70 @@ + +function newCurrentStartMode() { + + var thisObject = { + container: undefined, + draw: draw, + getContainer: getContainer, // returns the inner most container that holds the point received by parameter. + initialize: initialize + }; + + var container = newContainer(); + container.initialize(); + thisObject.container = container; + + thisObject.container.frame.width = 200; + thisObject.container.frame.height = TOP_SPACE_HEIGHT; + + container.frame.position.x = viewPort.visibleArea.topRight.x - thisObject.container.frame.width * 1; + container.frame.position.y = 0; + + container.isDraggeable = false; + + return thisObject; + + function initialize() { + + window.CURRENT_START_MODE = window.localStorage.getItem("currentStartMode"); + } + + function getContainer(point) { + + let container; + + for (let i = 0; i < thisObject.panels.length; i++) { + + container = thisObject.panels[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; + + } + + function draw() { + + thisObject.container.frame.draw(false, false); + + let fontSize = 12; + let label = window.CURRENT_START_MODE; + + let point = { + x: thisObject.container.frame.width * 1 / 3, + y: (thisObject.container.frame.height / 2) + 4 + }; + + point = thisObject.container.frame.frameThisPoint(point); + + browserCanvasContext.font = fontSize + 'px Courier New'; + browserCanvasContext.fillStyle = 'rgba(255, 255, 255, 1)'; + browserCanvasContext.fillText(label, point.x, point.y); + } +} \ No newline at end of file diff --git a/TopSpace/DevTeam.js b/TopSpace/DevTeam.js new file mode 100644 index 000000000..478625e3f --- /dev/null +++ b/TopSpace/DevTeam.js @@ -0,0 +1,70 @@ + +function newDevTeam() { + + var thisObject = { + container: undefined, + draw: draw, + getContainer: getContainer, // returns the inner most container that holds the point received by parameter. + initialize: initialize + }; + + var container = newContainer(); + container.initialize(); + thisObject.container = container; + + thisObject.container.frame.width = 200; + thisObject.container.frame.height = TOP_SPACE_HEIGHT; + + container.frame.position.x = viewPort.visibleArea.topRight.x - thisObject.container.frame.width * 4; + container.frame.position.y = 0; + + container.isDraggeable = false; + + return thisObject; + + function initialize() { + + window.DEV_TEAM = window.localStorage.getItem("devTeam"); + } + + function getContainer(point) { + + let container; + + for (let i = 0; i < thisObject.panels.length; i++) { + + container = thisObject.panels[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; + + } + + function draw() { + + thisObject.container.frame.draw(false, false); + + let fontSize = 12; + let label = window.DEV_TEAM; + + let point = { + x: thisObject.container.frame.width * 1 / 3, + y: (thisObject.container.frame.height / 2) + 4 + }; + + point = thisObject.container.frame.frameThisPoint(point); + + browserCanvasContext.font = fontSize + 'px Courier New'; + browserCanvasContext.fillStyle = 'rgba(255, 255, 255, 1)'; + browserCanvasContext.fillText(label, point.x, point.y); + } +} \ No newline at end of file diff --git a/TopSpace/EndUser.js b/TopSpace/EndUser.js new file mode 100644 index 000000000..2154c3b63 --- /dev/null +++ b/TopSpace/EndUser.js @@ -0,0 +1,70 @@ + +function newEndUser() { + + var thisObject = { + container: undefined, + draw: draw, + getContainer: getContainer, // returns the inner most container that holds the point received by parameter. + initialize: initialize + }; + + var container = newContainer(); + container.initialize(); + thisObject.container = container; + + thisObject.container.frame.width = 200; + thisObject.container.frame.height = TOP_SPACE_HEIGHT; + + container.frame.position.x = viewPort.visibleArea.topRight.x - thisObject.container.frame.width * 5; + container.frame.position.y = 0; + + container.isDraggeable = false; + + return thisObject; + + function initialize() { + + window.USER_LOGGED_IN = window.localStorage.getItem("userName"); + } + + function getContainer(point) { + + let container; + + for (let i = 0; i < thisObject.panels.length; i++) { + + container = thisObject.panels[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; + + } + + function draw() { + + thisObject.container.frame.draw(false, false); + + let fontSize = 12; + let label = window.USER_LOGGED_IN; + + let point = { + x: thisObject.container.frame.width * 1 / 3, + y: (thisObject.container.frame.height / 2) + 4 + }; + + point = thisObject.container.frame.frameThisPoint(point); + + browserCanvasContext.font = fontSize + 'px Courier New'; + browserCanvasContext.fillStyle = 'rgba(255, 255, 255, 1)'; + browserCanvasContext.fillText(label, point.x, point.y); + } +} \ No newline at end of file diff --git a/server.js b/server.js index 3df28d16f..5bf32fcb8 100644 --- a/server.js +++ b/server.js @@ -383,6 +383,15 @@ function onBrowserRequest(request, response) { } break; + + case "TopSpace": // This means the TopSpace folder. + { + + respondWithFile('./TopSpace/' + requestParameters[2], response); + + } + break; + case "AABrowserAPI": // This means the Scripts folder. { const AABROSER_API_MODULE = require('./AABrowserAPI/' + 'API');