From 216dbbc7d2f7af3831e662401d8b456e890b7a4c Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 25 Oct 2021 12:55:50 +0200 Subject: [PATCH] Environment reaching the UI at the Platform --- Environment.js | 1 + Platform/Client/httpInterface.js | 6 +++++- Platform/UI/AppPostLoader.js | 15 ++++++++++++--- Platform/UI/Globals.js | 3 ++- platform.js | 10 ++++++++-- 5 files changed, 28 insertions(+), 7 deletions(-) diff --git a/Environment.js b/Environment.js index efd66849b..47627f378 100644 --- a/Environment.js +++ b/Environment.js @@ -8,6 +8,7 @@ if (process.env.PACKAGED_PATH) { exports.newEnvironment = function () { let thisObject = { + DEMO_MODE: false, BASE_PATH: basePath, WEB_SERVER_URL: 'localhost', PLATFORM_WEB_SOCKETS_INTERFACE_PORT: 18041, diff --git a/Platform/Client/httpInterface.js b/Platform/Client/httpInterface.js index 08e617350..0d2f8a2a3 100644 --- a/Platform/Client/httpInterface.js +++ b/Platform/Client/httpInterface.js @@ -44,7 +44,11 @@ exports.newHttpInterface = function newHttpInterface() { let endpointOrFile = requestPath[1] switch (endpointOrFile) { - + case 'Environment': + { + SA.projects.foundations.utilities.httpResponses.respondWithContent(JSON.stringify(global.env), httpResponse) + } + break case 'WEB3': { SA.projects.foundations.utilities.httpRequests.getRequestBody(httpRequest, httpResponse, processRequest) diff --git a/Platform/UI/AppPostLoader.js b/Platform/UI/AppPostLoader.js index b73803e3c..9d5cccd81 100644 --- a/Platform/UI/AppPostLoader.js +++ b/Platform/UI/AppPostLoader.js @@ -4,7 +4,7 @@ function newAppPostLoader() { const MODULE_NAME = 'Post Loader' const ERROR_LOG = true const logger = newWebDebugLog() - + let thisObject = { start: start @@ -14,9 +14,18 @@ function newAppPostLoader() { function start() { try { - + // autoSaveWhenClosingTheBrowser() - setupProjectsSchema() + setupEnvironment() + + function setupEnvironment() { + httpRequest(undefined, 'Environment', onResponse) + + function onResponse(err, file) { + UI.environment = JSON.parse(file) + setupProjectsSchema() + } + } function setupProjectsSchema() { httpRequest(undefined, 'ProjectsSchema', onResponse) diff --git a/Platform/UI/Globals.js b/Platform/UI/Globals.js index b3588616d..83bf7c5de 100644 --- a/Platform/UI/Globals.js +++ b/Platform/UI/Globals.js @@ -5,7 +5,8 @@ let PROJECTS_SCHEMA let SCHEMAS_BY_PROJECT = new Map() /* New Root object*/ let UI = { - projects: {} + projects: {}, + environment: {} } /* User Interface Colors */ diff --git a/platform.js b/platform.js index 5058dba87..28b0de345 100644 --- a/platform.js +++ b/platform.js @@ -26,13 +26,14 @@ if ( console.log('') console.log('TELEGRAM COMMUNITY: https://t.me/superalgoscommunity') console.log('') - console.log('USAGE: node platform [help] [noBrowser] [minMemo]') + console.log('USAGE: node platform [help] [noBrowser] [minMemo] [demoMode]') console.log('') console.log('OPTIONS:') console.log('') console.log(' help: Optional. Use it to see this helping information.') console.log(' noBrowser: Optional. Use it to launch Superalgos Platform Client only. The Superalgos Platform UI will not be loaded.') console.log(' minMemo: Optional. Use it when your hardware has less than 8 Gb or memory.') + console.log(' demoMode: Optional. Use it to launch Superalgos in Demo Mode. Users will be able to use the UI but not run Tasks.') console.log('') console.log('If you are having an error while trying to run the Superalgos Platform Client, consider this:') @@ -68,7 +69,6 @@ console.log('OPTIONS ACCEPTED:') console.log('') let optionsAccepted = 0 - if (process.argv.includes("minMemo")) { optionsAccepted++ console.log('minMemo ..................................................... Running with Minimun Required Memory.') @@ -79,9 +79,15 @@ if (process.argv.includes("noBrowser")) { console.log('noBrowser ................................................... Running without User Interface.') } +if (process.argv.includes("demoMode")) { + optionsAccepted++ + console.log('demoMode .................................................... Running without User Interface.') +} + if (optionsAccepted === 0) { console.log('none ........................................................ Running without any command line options.') } + console.log('') console.log('')