From 87d6fc258188c7f304924cd960b1810e7d849d93 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 16 Oct 2021 17:59:57 +0200 Subject: [PATCH] Feature: Loading a Workspace specified at the Command Line. --- Platform/Client/httpInterface.js | 36 ++++++++------- Platform/PlatformApp.js | 5 +-- PlatformRoot.js | 30 +++++++++++-- .../UI/Spaces/Design-Space/Workspace.js | 35 ++++++++++++--- .../Plugins/Positions/Superalgos.json | 2 +- Tested-Exchanges | 44 +++++++++++++++++++ 6 files changed, 123 insertions(+), 29 deletions(-) create mode 100644 Tested-Exchanges diff --git a/Platform/Client/httpInterface.js b/Platform/Client/httpInterface.js index cddb0a04c..ea5c2a057 100644 --- a/Platform/Client/httpInterface.js +++ b/Platform/Client/httpInterface.js @@ -20,7 +20,7 @@ exports.newHttpInterface = function newHttpInterface() { webhook = undefined } - function initialize() { + function initialize(initialWorkspace) { /* We will create an HTTP Server and leave it running forever. */ @@ -29,7 +29,11 @@ exports.newHttpInterface = function newHttpInterface() { if (process.argv.includes("noBrowser")) { //Running Client only with no UI. } else { - SA.nodeModules.open('http://localhost:' + global.env.CLIENT_HTTP_INTERFACE_PORT) + let queryString = '' + if (initialWorkspace.name !== undefined) { + queryString = '/?initialWorkspaceName=' + initialWorkspace.name + '&initialWorkspaceProject=' + initialWorkspace.project + '&initialWorkspaceType=' + initialWorkspace.type + } + SA.nodeModules.open('http://localhost:' + global.env.CLIENT_HTTP_INTERFACE_PORT + queryString) } } @@ -637,7 +641,7 @@ exports.newHttpInterface = function newHttpInterface() { break } switch (requestPath[2]) { // switch by command - + case 'Contribute': { try { let commitMessage = unescape(requestPath[3]) @@ -655,7 +659,7 @@ exports.newHttpInterface = function newHttpInterface() { contribute() - async function contribute() { + async function contribute() { const { lookpath } = SA.nodeModules.lookpath const gitpath = await lookpath('git') if (gitpath === undefined) { @@ -898,11 +902,11 @@ exports.newHttpInterface = function newHttpInterface() { const git = simpleGit(options) try { await git.checkout(currentBranch) - + // Check to see it main repo has been set as upstream let remotes = await git.getRemotes(); let isUpstreamSet - for(let remote in remotes) { + for (let remote in remotes) { if (remotes[remote].name === 'upstream') { isUpstreamSet = true } else { @@ -910,7 +914,7 @@ exports.newHttpInterface = function newHttpInterface() { } } // If upstream has not been set. Set it now - if (isUpstreamSet === false){ + if (isUpstreamSet === false) { await git.addRemote('upstream', 'https://github.com/Superalgos/Superalgos'); } // Pull branch from main repo @@ -918,7 +922,7 @@ exports.newHttpInterface = function newHttpInterface() { // Reset branch to match main repo let upstreamLocation = `upstream/${currentBranch}` await git.reset('hard', [upstreamLocation]) - + } catch (err) { console.log('[ERROR] Error changing current branch to ' + currentBranch) console.log(err.stack) @@ -926,19 +930,19 @@ exports.newHttpInterface = function newHttpInterface() { } } - async function runNodeSetup () { - console.log( "Running Node setup to adjust for new Branch" ) + async function runNodeSetup() { + console.log("Running Node setup to adjust for new Branch") const process = SA.nodeModules.process const childProcess = SA.nodeModules.childProcess let dir = process.cwd() let command = "node setup noShortcuts"; - let stdout = childProcess.execSync( command, - { - cwd: dir - }).toString(); - - console.log("Node Setup has completed with the following result:", stdout) + let stdout = childProcess.execSync(command, + { + cwd: dir + }).toString(); + + console.log("Node Setup has completed with the following result:", stdout) } } catch (err) { diff --git a/Platform/PlatformApp.js b/Platform/PlatformApp.js index 49431f932..7ef1f87b1 100644 --- a/Platform/PlatformApp.js +++ b/Platform/PlatformApp.js @@ -6,7 +6,7 @@ exports.newPlatformApp = function newPlatformApp() { return thisObject - async function run() { + async function run(initialWorkspace) { process.on('uncaughtException', function (err) { if (err.message && err.message.indexOf("EADDRINUSE") > 0) { @@ -133,13 +133,12 @@ exports.newPlatformApp = function newPlatformApp() { console.log('') console.log('SUPERALGOS PLATFORM CLIENT INTERFACES:') console.log('') - WEB_SOCKETS_INTERFACE = WEB_SOCKETS_INTERFACE.newWebSocketsInterface() WEB_SOCKETS_INTERFACE.initialize() console.log('Web Sockets Interface ....................................... Listening at port ' + global.env.CLIENT_WEB_SOCKETS_INTERFACE_PORT) HTTP_INTERFACE = HTTP_INTERFACE.newHttpInterface() - HTTP_INTERFACE.initialize() + HTTP_INTERFACE.initialize(initialWorkspace) console.log('Http Interface .............................................. Listening at port ' + global.env.CLIENT_HTTP_INTERFACE_PORT) console.log('') diff --git a/PlatformRoot.js b/PlatformRoot.js index 924c9e1e5..556e2323e 100644 --- a/PlatformRoot.js +++ b/PlatformRoot.js @@ -52,11 +52,35 @@ SA.nodeModules = { process: require('process'), childProcess: require('child_process') } +/* +Check if we are starting from a particular workspace. +*/ +let initialWorkspace = {} -run() +for (let i = 0; i < process.argv.length; i++) { + let arg = process.argv[i] -async function run() { + if (arg === 'noBrowser') { continue } + if (arg === 'minMemo') { continue } + if (arg.indexOf(':') >= 0) { continue } + + if (initialWorkspace.project === undefined) { + if (arg !== 'My-Workspaces') { + initialWorkspace.type = 'Plugin' + initialWorkspace.project = arg + } else { + initialWorkspace.type = 'My-Workspaces' + initialWorkspace.project = '' + } + } else { + initialWorkspace.name = arg + } +} + +run(initialWorkspace) + +async function run(initialWorkspace) { PL.app = require('./Platform/PlatformApp.js').newPlatformApp() - await PL.app.run() + await PL.app.run(initialWorkspace) console.log('Superalgos Platform App is Running!') } diff --git a/Projects/Foundations/UI/Spaces/Design-Space/Workspace.js b/Projects/Foundations/UI/Spaces/Design-Space/Workspace.js index 2501fd48e..02281b4e2 100644 --- a/Projects/Foundations/UI/Spaces/Design-Space/Workspace.js +++ b/Projects/Foundations/UI/Spaces/Design-Space/Workspace.js @@ -76,17 +76,40 @@ function newWorkspace() { } } - /* Check which was the last workspace. */ + const browserURL = new URLSearchParams(window.location.search); + const queryString = Object.fromEntries(browserURL.entries()); + /* + By default, we will laod the last used workspace. + */ let lastUsedWorkspace = window.localStorage.getItem('Last Used Workspace') - if (lastUsedWorkspace !== 'undefined' && lastUsedWorkspace !== null && lastUsedWorkspace !== undefined) { + if ( + (lastUsedWorkspace !== 'undefined' && lastUsedWorkspace !== null && lastUsedWorkspace !== undefined) || + (queryString.initialWorkspaceName !== undefined) + ) { + let webCommand + if (queryString.initialWorkspaceType !== undefined) { + /* + We get here when the workspace to lead comes at the URL + */ + UI.projects.foundations.utilities.statusBar.changeStatus("Loading Workspace " + queryString.initialWorkspaceName + "...") + if (queryString.initialWorkspaceType !== 'My-Workspaces') { + webCommand = 'LoadPlugin' + '/' + queryString.initialWorkspaceProject + '/' + 'Workspaces' + '/' + queryString.initialWorkspaceName + '.json' + } else { + webCommand = 'LoadMyWorkspace' + '/' + queryString.initialWorkspaceName + } + } else { + /* + We get here when the workspace to lead is the last saved workspace. + */ + UI.projects.foundations.utilities.statusBar.changeStatus("Loading Workspace " + lastUsedWorkspace + "...") + webCommand = 'LoadMyWorkspace' + '/' + lastUsedWorkspace + } - UI.projects.foundations.utilities.statusBar.changeStatus("Loading Workspace " + lastUsedWorkspace + "...") - - httpRequest(undefined, 'LoadMyWorkspace' + '/' + lastUsedWorkspace, onFileReceived) + httpRequest(undefined, webCommand, onFileReceived) function onFileReceived(err, text, response) { if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) { - UI.projects.foundations.spaces.cockpitSpace.setStatus('Could not load the last Workspace used, called "' + lastUsedWorkspace + '". Will switch to the default Workspace instead.', 500, UI.projects.foundations.spaces.cockpitSpace.statusTypes.WARNING) + UI.projects.foundations.spaces.cockpitSpace.setStatus('Could not load the Workspace called "' + lastUsedWorkspace + '". Will switch to the default Workspace instead.', 500, UI.projects.foundations.spaces.cockpitSpace.statusTypes.WARNING) thisObject.workspaceNode = getWorkspace() // This is the default workspace that comes with the system. thisObject.workspaceNode.project = 'Foundations' recreateWorkspace() diff --git a/Projects/Governance/Plugins/Positions/Superalgos.json b/Projects/Governance/Plugins/Positions/Superalgos.json index 44d873726..37ba00585 100644 --- a/Projects/Governance/Plugins/Positions/Superalgos.json +++ b/Projects/Governance/Plugins/Positions/Superalgos.json @@ -4415,7 +4415,7 @@ "floatingObject": { "isPinned": false, "isFrozen": false, - "isCollapsed": false, + "isCollapsed": true, "angleToParent": 1, "distanceToParent": 3, "arrangementStyle": 0 diff --git a/Tested-Exchanges b/Tested-Exchanges new file mode 100644 index 000000000..6452db949 --- /dev/null +++ b/Tested-Exchanges @@ -0,0 +1,44 @@ + +Total RAM istalled in this system is ........................ 15.85 GB +Total RAM available for Superalgos is ....................... 13.47 GB + +If you would like to enable less RAM than that, use the minMemo flag. Note: RAM will be allocated only if needed. + +OPTIONS ACCEPTED: + +none ........................................................ Running without any command line options. + + +SUPERALGOS PLATFORM CLIENT SERVERS: + +Web Server .................................................. Started +UI File Server .............................................. Started +Project File Server ......................................... Started +Plugin Server ............................................... Started +Data File Server ............................................ Started +Events Server ............................................... Started +Task Manager Server ......................................... Started +CCXT Server ................................................. Started +WEB3 Server ................................................. Started +Github Server ............................................... Started + +SUPERALGOS PLATFORM CLIENT INTERFACES: + +Web Sockets Interface ....................................... Listening at port 18041 +Http Interface .............................................. Listening at port 34248 + +You are running Superalgos Beta 12 + +What's new? These are the main new features in this version: + +Governance System ........................................... Automates the distribution of SA Tokens and allow users to vote on the direction of the project. +TensorFlow Integration ...................................... Allows creating and training ML models and use them in trading strategies. + +What's next? This is the current development pipeline: + +Superalgos P2P Network ...................................... Will allow algo-traders to share trading signals with Superalgos users consuming these signals via a mobile app. +Real-time Trading Signals ................................... Will allow users to emit trading signals and be rewarded with SA Tokens. +Superalgos Mobile ........................................... Will allow users to consume trading signals for free and autonomously execute trades from their mobile phones. +Ethereum Integration ........................................ Will allow mining data from an Ethereum network node, and bring it into the Superalgos workflow. [Looking for an Ethereum dev that would like to continue this line of development.] + +Superalgos Platform App is Running!